Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksoid <aleksoid@users.sourceforge.net>2009-09-03 09:37:28 +0400
committerAleksoid <aleksoid@users.sourceforge.net>2009-09-03 09:37:28 +0400
commit894a9e923223583e303ffd8dc83ebc8c90db6a47 (patch)
treefc948bd9d2622c31792bcea1cd652ce1f7e00966 /src/filters/transform/mpcvideodec/ffmpeg
parent9f1c5503968c644da350d74a6def873a1a34c8dd (diff)
ADD : Support AMR(mobile phone) audio codec;
Change : gccbuild.bat and gccbuild64.bat(include local environment variable 'CC'); git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@1269 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/transform/mpcvideodec/ffmpeg')
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/Makefile16
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/config.h7
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/ffcodecs.h3
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/gccbuild.bat7
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/gccbuild64.bat7
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec.vcproj208
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/allcodecs.c3
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/decoder.c158
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/encoder.c241
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/interf_dec.c882
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/interf_dec.h55
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/interf_enc.c798
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/interf_enc.h58
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/interf_rom.h1802
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/rom_dec.h13310
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/rom_enc.h14473
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/sp_dec.c6122
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/sp_dec.h81
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/sp_enc.c11374
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/sp_enc.h74
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/typedef.h22
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec.h18
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_acelp.c692
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_acelp.h17
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_dtx.c748
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_dtx.h49
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_gain.c963
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_gain.h28
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_if.c970
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_if.h23
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_lpc.c873
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_lpc.h25
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_main.c970
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_main.h58
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_rom.c2112
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_util.c1387
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_util.h33
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/decoder.c146
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc.h18
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_acelp.c2074
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_acelp.h27
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_dtx.c1585
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_dtx.h72
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_gain.c781
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_gain.h33
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_if.c1031
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_if.h19
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_lpc.c1255
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_lpc.h32
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_main.c1416
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_main.h75
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_rom.c2357
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_util.c1316
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_util.h43
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/encoder.c194
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/if_rom.c1022
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/if_rom.h70
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/typedef.h18
-rw-r--r--src/filters/transform/mpcvideodec/ffmpeg/libavcodec/libamr.c446
59 files changed, 72687 insertions, 10 deletions
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/Makefile b/src/filters/transform/mpcvideodec/ffmpeg/Makefile
index 45cbfdc2a..60973b17c 100644
--- a/src/filters/transform/mpcvideodec/ffmpeg/Makefile
+++ b/src/filters/transform/mpcvideodec/ffmpeg/Makefile
@@ -43,6 +43,20 @@ SRCS_C=\
$(LAVC_DIR)/jpegls.c \
$(LAVC_DIR)/jpeglsdec.c \
$(LAVC_DIR)/jrevdct.c \
+ $(LAVC_DIR)/libamr.c \
+ $(LAVC_DIR)/amrnb/interf_dec.c \
+ $(LAVC_DIR)/amrnb/sp_dec.c \
+ $(LAVC_DIR)/amrnb/interf_enc.c\
+ $(LAVC_DIR)/amrnb/sp_enc.c \
+ $(LAVC_DIR)/amrwb/dec_if.c\
+ $(LAVC_DIR)/amrwb/if_rom.c\
+ $(LAVC_DIR)/amrwb/dec_rom.c\
+ $(LAVC_DIR)/amrwb/dec_gain.c\
+ $(LAVC_DIR)/amrwb/dec_main.c\
+ $(LAVC_DIR)/amrwb/dec_dtx.c\
+ $(LAVC_DIR)/amrwb/dec_lpc.c\
+ $(LAVC_DIR)/amrwb/dec_util.c\
+ $(LAVC_DIR)/amrwb/dec_acelp.c\
$(LAVC_DIR)/mdct.c \
$(LAVC_DIR)/mjpeg.c \
$(LAVC_DIR)/mjpegdec.c \
@@ -146,7 +160,7 @@ OPTFLAGS+= -fno-math-errno
.all: $(SLIB)
clean:
- rm -f *.o *.d *~ $(LAVC_DIR)/*.o $(LAVC_DIR)/*.d $(LAVC_DIR)/x86/*.o $(LAVC_DIR)/amr_float/*.o $(LAVF_DIR)/*.o $(LAVF_DIR)/*.d $(LAVU_DIR)/*.o $(LAVU_DIR)/*.d $(SLIB) $(ZLIB_DIR)/*.o $(PNG_DIR)/*.o $(LAVC_DIR)/x86/*.d $(LAVC_DIR)/amr_float/*.d $(ZLIB_DIR)/*.d
+ rm -f *.o *.d *~ $(LAVC_DIR)/*.o $(LAVC_DIR)/*.d $(LAVC_DIR)/x86/*.o $(LAVC_DIR)/amrnb/*.o $(LAVC_DIR)/amrwb/*.o $(LAVF_DIR)/*.o $(LAVF_DIR)/*.d $(LAVU_DIR)/*.o $(LAVU_DIR)/*.d $(SLIB) $(ZLIB_DIR)/*.o $(PNG_DIR)/*.o $(LAVC_DIR)/x86/*.d $(LAVC_DIR)/amr_float/*.d $(ZLIB_DIR)/*.d
#
# include dependency files if they exist
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/config.h b/src/filters/transform/mpcvideodec/ffmpeg/config.h
index 00661827b..da15bb5a7 100644
--- a/src/filters/transform/mpcvideodec/ffmpeg/config.h
+++ b/src/filters/transform/mpcvideodec/ffmpeg/config.h
@@ -60,7 +60,11 @@
#define CONFIG_HARDCODED_TABLES 0
#define CONFIG_GPL 1
#define CONFIG_GRAY 1
+
#define CONFIG_LIBAMR_NB 1
+#define CONFIG_LIBAMR_NB_FIXED 0
+#define CONFIG_LIBAMR_WB 1
+
#define CONFIG_LIBXVID 0
#define CONFIG_MPEGAUDIO_HP 1
#define CONFIG_SMALL 0
@@ -190,7 +194,8 @@
#define CONFIG_ADPCM_XA_DECODER 0
#define CONFIG_ADPCM_YAMAHA_DECODER 0
-#define CONFIG_LIBAMR_NB_DECODER 0
+#define CONFIG_LIBAMR_NB_DECODER 1
+#define CONFIG_LIBAMR_WB_DECODER 1
#define CONFIG_DVVIDEO_ENCODER 0
#define CONFIG_FFV1_ENCODER 0
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/ffcodecs.h b/src/filters/transform/mpcvideodec/ffmpeg/ffcodecs.h
index 867cb4bb2..94d4490c1 100644
--- a/src/filters/transform/mpcvideodec/ffmpeg/ffcodecs.h
+++ b/src/filters/transform/mpcvideodec/ffmpeg/ffcodecs.h
@@ -135,7 +135,8 @@
CODEC_OP(CODEC_ID_WAVPACK ,150,"Wavpack") \
CODEC_OP(CODEC_ID_PCM_ZORK ,151,"PCM Zork") \
CODEC_OP(CODEC_ID_SHORTEN ,152,"Shorten") \
- CODEC_OP(CODEC_ID_TRUEHD ,153,"truehd") \
+ CODEC_OP(CODEC_ID_AMR_WB ,153,"amrwb") \
+ CODEC_OP(CODEC_ID_TRUEHD ,154,"truehd") \
\
/* Raw formats */ \
CODEC_OP(CODEC_ID_RAW ,300,"raw") \
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/gccbuild.bat b/src/filters/transform/mpcvideodec/ffmpeg/gccbuild.bat
index b0caccbe0..bd21d9db9 100644
--- a/src/filters/transform/mpcvideodec/ffmpeg/gccbuild.bat
+++ b/src/filters/transform/mpcvideodec/ffmpeg/gccbuild.bat
@@ -4,11 +4,12 @@ echo "ERROR : please define MINGW32 (and/or MSYS) environment variable(s)"
exit 1005
:Var1Ok
-if NOT "x%CC%" == "x" goto Var2Ok
-echo "ERROR : please define CC environment variable"
-exit 1005
+rem if NOT "x%CC%" == "x" goto Var2Ok
+rem echo "ERROR : please define CC environment variable"
+rem exit 1005
:Var2Ok
+set CC=gcc.exe
set PATH=%MSYS%\bin;%MINGW32%\bin;%YASM%;%PATH%
IF "%1%"=="rebuild" goto DoClean
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/gccbuild64.bat b/src/filters/transform/mpcvideodec/ffmpeg/gccbuild64.bat
index a92023da2..022090970 100644
--- a/src/filters/transform/mpcvideodec/ffmpeg/gccbuild64.bat
+++ b/src/filters/transform/mpcvideodec/ffmpeg/gccbuild64.bat
@@ -4,11 +4,12 @@ echo "ERROR : please define MINGW64 (and/or MSYS) environment variable(s)"
exit 1005
:Var1Ok
-if NOT "x%CC%" == "x" goto Var2Ok
-echo "ERROR : please define CC environment variable"
-exit 1005
+rem if NOT "x%CC%" == "x" goto Var2Ok
+rem echo "ERROR : please define CC environment variable"
+rem exit 1005
:Var2Ok
+set CC=gcc.exe
set PATH=%MSYS%\bin;%YASM%;%MINGW64%\bin;%PATH%
IF EXIST "%MINGW32%\bin\mingw32-make.exe" copy /y "%MINGW32%\bin\mingw32-make.exe" "%MINGW32%\bin\make.exe" >nul
IF EXIST "%MINGW64%\x86_64-w64-mingw32\bin\ar.exe" copy /y "%MINGW64%\x86_64-w64-mingw32\bin\ar.exe" "%MINGW64%\bin\x86_64-w64-mingw32-ar.exe" >nul
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec.vcproj b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec.vcproj
index 7f4480537..e154a6ab1 100644
--- a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec.vcproj
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec.vcproj
@@ -402,6 +402,46 @@
>
</File>
<File
+ RelativePath=".\libavcodec\amrwb\dec_acelp.c"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\dec_dtx.c"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\dec_gain.c"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\dec_if.c"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\dec_lpc.c"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\dec_main.c"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\dec_rom.c"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\dec_util.c"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\decoder.c"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrnb\decoder.c"
+ >
+ </File>
+ <File
RelativePath=".\libavcodec\dsputil.c"
>
</File>
@@ -414,6 +454,46 @@
>
</File>
<File
+ RelativePath=".\libavcodec\amrwb\enc_acelp.c"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\enc_dtx.c"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\enc_gain.c"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\enc_if.c"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\enc_lpc.c"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\enc_main.c"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\enc_rom.c"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\enc_util.c"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\encoder.c"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrnb\encoder.c"
+ >
+ </File>
+ <File
RelativePath=".\libavcodec\error_resilience.c"
>
</File>
@@ -518,10 +598,22 @@
>
</File>
<File
+ RelativePath=".\libavcodec\amrwb\if_rom.c"
+ >
+ </File>
+ <File
RelativePath="libavcodec\imgconvert.c"
>
</File>
<File
+ RelativePath=".\libavcodec\amrnb\interf_dec.c"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrnb\interf_enc.c"
+ >
+ </File>
+ <File
RelativePath=".\libavcodec\intrax8.c"
>
</File>
@@ -542,6 +634,10 @@
>
</File>
<File
+ RelativePath=".\libavcodec\libamr.c"
+ >
+ </File>
+ <File
RelativePath=".\libavcodec\mdct.c"
>
</File>
@@ -614,6 +710,14 @@
>
</File>
<File
+ RelativePath=".\libavcodec\amrnb\sp_dec.c"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrnb\sp_enc.c"
+ >
+ </File>
+ <File
RelativePath=".\libavcodec\svq1.c"
>
</File>
@@ -819,6 +923,38 @@
>
</File>
<File
+ RelativePath=".\libavcodec\amrwb\dec.h"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\dec_acelp.h"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\dec_dtx.h"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\dec_gain.h"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\dec_if.h"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\dec_lpc.h"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\dec_main.h"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\dec_util.h"
+ >
+ </File>
+ <File
RelativePath=".\libavcodec\dsputil.h"
>
</File>
@@ -827,6 +963,38 @@
>
</File>
<File
+ RelativePath=".\libavcodec\amrwb\enc.h"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\enc_acelp.h"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\enc_dtx.h"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\enc_gain.h"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\enc_if.h"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\enc_lpc.h"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\enc_main.h"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrwb\enc_util.h"
+ >
+ </File>
+ <File
RelativePath=".\libavcodec\eval.h"
>
</File>
@@ -887,6 +1055,22 @@
>
</File>
<File
+ RelativePath=".\libavcodec\amrwb\if_rom.h"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrnb\interf_dec.h"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrnb\interf_enc.h"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrnb\interf_rom.h"
+ >
+ </File>
+ <File
RelativePath=".\libavcodec\intrax8.h"
>
</File>
@@ -975,6 +1159,14 @@
>
</File>
<File
+ RelativePath=".\libavcodec\amrnb\rom_dec.h"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrnb\rom_enc.h"
+ >
+ </File>
+ <File
RelativePath=".\libavcodec\simple_idct.h"
>
</File>
@@ -983,6 +1175,14 @@
>
</File>
<File
+ RelativePath=".\libavcodec\amrnb\sp_dec.h"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrnb\sp_enc.h"
+ >
+ </File>
+ <File
RelativePath="libavcodec\svq1.h"
>
</File>
@@ -999,6 +1199,14 @@
>
</File>
<File
+ RelativePath=".\libavcodec\amrwb\typedef.h"
+ >
+ </File>
+ <File
+ RelativePath=".\libavcodec\amrnb\typedef.h"
+ >
+ </File>
+ <File
RelativePath=".\libavcodec\unary.h"
>
</File>
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/allcodecs.c b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/allcodecs.c
index ede034ec8..595fe72ca 100644
--- a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/allcodecs.c
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/allcodecs.c
@@ -169,7 +169,8 @@ void avcodec_register_all(void)
//REGISTER_DECODER (ADPCM_YAMAHA, adpcm_yamaha);
/* external libraries */
- //REGISTER_DECODER (LIBAMR_NB, libamr_nb);
+ REGISTER_DECODER (LIBAMR_NB, libamr_nb);
+ REGISTER_DECODER (LIBAMR_WB, libamr_wb);
/* parsers */
//REGISTER_PARSER (AAC, aac);
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/decoder.c b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/decoder.c
new file mode 100644
index 000000000..7b6a44659
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/decoder.c
@@ -0,0 +1,158 @@
+/*
+ * ===================================================================
+ * TS 26.104
+ * REL-5 V5.4.0 2004-03
+ * REL-6 V6.1.0 2004-03
+ * 3GPP AMR Floating-point Speech Codec
+ * ===================================================================
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <memory.h>
+#include "interf_dec.h"
+#include "sp_dec.h"
+#include "typedef.h"
+
+#ifndef ETSI
+#ifndef IF2
+#include <string.h>
+#define AMR_MAGIC_NUMBER "#!AMR\n"
+#endif
+#endif
+
+void Copyright(void){
+fprintf (stderr,
+"===================================================================\n"
+" TS 26.104 \n"
+" REL-5 V5.4.0 2004-03 \n"
+" REL-6 V6.1.0 2004-03 \n"
+" 3GPP AMR Floating-point Speech Decoder \n"
+"===================================================================\n"
+);
+}
+/*
+ * main
+ *
+ *
+ * Function:
+ * Speech decoder main program
+ *
+ * Usage: decoder bitstream_file synthesis_file
+ *
+ * Format for ETSI bitstream file:
+ * 1 word (2-byte) for the TX frame type
+ * 244 words (2-byte) containing 244 bits.
+ * Bit 0 = 0x0000 and Bit 1 = 0x0001
+ * 1 word (2-byte) for the mode indication
+ * 4 words for future use, currently written as zero
+ *
+ * Format for 3GPP bitstream file:
+ * Holds mode information and bits packed to octets.
+ * Size is from 1 byte to 31 bytes.
+ *
+ * Format for synthesis_file:
+ * Speech is written to a 16 bit 8kHz file.
+ *
+ * ETSI bitstream file format is defined using ETSI as preprocessor
+ * definition
+ * Returns:
+ * 0
+ */
+int main (int argc, char * argv[]){
+
+ FILE * file_speech, *file_analysis;
+
+ short synth[160];
+ int frames = 0;
+ int * destate;
+ int read_size;
+#ifndef ETSI
+ unsigned char analysis[32];
+ enum Mode dec_mode;
+#ifdef IF2
+ short block_size[16]={ 12, 13, 15, 17, 18, 20, 25, 30, 5, 0, 0, 0, 0, 0, 0, 0 };
+#else
+ char magic[8];
+ short block_size[16]={ 12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0 };
+#endif
+#else
+ short analysis[250];
+#endif
+
+ /* Process command line options */
+ if (argc == 3){
+
+ file_speech = fopen(argv[2], "wb");
+ if (file_speech == NULL){
+ fprintf ( stderr, "%s%s%s\n","Use: ",argv[0], " input.file output.file " );
+ return 1;
+ }
+
+ file_analysis = fopen(argv[1], "rb");
+ if (file_analysis == NULL){
+ fprintf ( stderr, "%s%s%s\n","Use: ",argv[0], " input.file output.file " );
+ fclose(file_speech);
+ return 1;
+ }
+
+ }
+ else {
+ fprintf ( stderr, "%s%s%s\n","Use: ",argv[0], " input.file output.file " );
+ return 1;
+ }
+ Copyright();
+ /* init decoder */
+ destate = Decoder_Interface_init();
+
+#ifndef ETSI
+#ifndef IF2
+ /* read and verify magic number */
+ fread( magic, sizeof( char ), strlen( AMR_MAGIC_NUMBER ), file_analysis );
+ if ( strncmp( magic, AMR_MAGIC_NUMBER, strlen( AMR_MAGIC_NUMBER ) ) ) {
+ fprintf( stderr, "%s%s\n", "Invalid magic number: ", magic );
+ fclose( file_speech );
+ fclose( file_analysis );
+ return 1;
+ }
+#endif
+#endif
+
+#ifndef ETSI
+
+ /* find mode, read file */
+ while (fread(analysis, sizeof (unsigned char), 1, file_analysis ) > 0)
+ {
+#ifdef IF2
+ dec_mode = analysis[0] & 0x000F;
+#else
+ dec_mode = (analysis[0] >> 3) & 0x000F;
+#endif
+ read_size = block_size[dec_mode];
+
+ fread(&analysis[1], sizeof (char), read_size, file_analysis );
+#else
+
+ read_size = 250;
+ /* read file */
+ while (fread(analysis, sizeof (short), read_size, file_analysis ) > 0)
+ {
+#endif
+
+ frames ++;
+
+ /* call decoder */
+ Decoder_Interface_Decode(destate, analysis, synth, 0);
+
+ fwrite( synth, sizeof (short), 160, file_speech );
+ }
+
+ Decoder_Interface_exit(destate);
+
+ fclose(file_speech);
+ fclose(file_analysis);
+ fprintf ( stderr, "\n%s%i%s\n","Decoded ", frames, " frames.");
+
+ return 0;
+}
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/encoder.c b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/encoder.c
new file mode 100644
index 000000000..a41ea0603
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/encoder.c
@@ -0,0 +1,241 @@
+/*
+ * ===================================================================
+ * TS 26.104
+ * REL-5 V5.4.0 2004-03
+ * REL-6 V6.1.0 2004-03
+ * 3GPP AMR Floating-point Speech Codec
+ * ===================================================================
+ *
+ */
+
+/*
+ * encoder.c
+ *
+ *
+ * Project:
+ * AMR Floating-Point Codec
+ *
+ * Contains:
+ * Speech encoder main program
+ *
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <memory.h>
+#include <string.h>
+#include "typedef.h"
+#include "interf_enc.h"
+
+#ifndef ETSI
+#ifndef IF2
+#define AMR_MAGIC_NUMBER "#!AMR\n"
+#endif
+#endif
+
+static const short modeConv[]={
+ 475, 515, 59, 67, 74, 795, 102, 122};
+
+static void Usage(char* argv[])
+{
+ fprintf (stderr,
+ "Usage of %s:\n\n"
+ "[-dtx] mode speech_file bitstream_file \n\n"
+ "or \n\n"
+ "[-dtx] -modefile=mode_file speech_file bitstream_file \n\n\n"
+ "mode = MR475, MR515, MR59, MR67, MR74, MR795, MR102, MR122 \n\n\n",
+ argv[0]);
+}
+void Copyright(void){
+fprintf (stderr,
+"===================================================================\n"
+" TS 26.104 \n"
+" REL-5 V5.4.0 2004-03 \n"
+" REL-6 V6.1.0 2004-03 \n"
+" 3GPP AMR Floating-point Speech Encoder \n"
+"===================================================================\n"
+);
+}
+/*
+ * main
+ *
+ *
+ * Function:
+ * Speech encoder main program
+ *
+ * Usage: encoder speech_file bitstream_file mode dtx mode_file
+ *
+ * Format for speech_file:
+ * Speech is read from a binary file of 16 bits data.
+ *
+ * Format for ETSI bitstream file:
+ * 1 word (2-byte) for the TX frame type
+ * 244 words (2-byte) containing 244 bits.
+ * Bit 0 = 0x0000 and Bit 1 = 0x0001
+ * 1 word (2-byte) for the mode indication
+ * 4 words for future use, currently written as zero
+ *
+ * Format for 3GPP bitstream file:
+ * Holds mode information and bits packed to octets.
+ * Size is from 1 byte to 31 bytes.
+ *
+ * ETSI bitstream file format is defined using ETSI as preprocessor
+ * definition
+ *
+ * mode : MR475, MR515, MR59, MR67, MR74, MR795, MR102, MR122
+ * mode_file : reads mode information from a file
+ * Returns:
+ * 0
+ */
+int main (int argc, char * argv[]){
+
+ /* file strucrures */
+ FILE * file_speech = NULL;
+ FILE * file_encoded = NULL;
+ FILE * file_mode = NULL;
+
+ /* input speech vector */
+ short speech[160];
+
+ /* counters */
+ int byte_counter, frames = 0, bytes = 0;
+
+ /* pointer to encoder state structure */
+ int *enstate;
+
+ /* requested mode */
+ enum Mode req_mode = MR122;
+ int dtx = 0;
+
+ /* temporary variables */
+ char mode_string[9];
+ long mode_tmp;
+
+ /* bitstream filetype */
+#ifndef ETSI
+ unsigned char serial_data[32];
+#else
+ short serial_data[250] = {0};
+#endif
+
+ /* Process command line options */
+
+ if ((argc == 5) || (argc == 4)){
+ file_encoded = fopen(argv[argc - 1], "wb");
+ if (file_encoded == NULL){
+ Usage(argv);
+ return 1;
+ }
+ file_speech = fopen(argv[argc - 2], "rb");
+ if (file_speech == NULL){
+ fclose(file_encoded);
+ Usage(argv);
+ return 1;
+ }
+ if (strncmp(argv[argc - 3], "-modefile=", 10) == 0){
+ file_mode = fopen(&argv[argc - 3][10], "rt");
+ if (file_mode == NULL){
+ Usage(argv);
+ fclose(file_speech);
+ fclose(file_encoded);
+ return 1;
+ }
+ }
+ else {
+ mode_tmp = strtol(&argv[argc - 3][2], NULL, 0);
+ for (req_mode = 0; req_mode < 8; req_mode++){
+ if (mode_tmp == modeConv[req_mode])
+ break;
+ }
+ if (req_mode == 8){
+ Usage(argv);
+ fclose(file_speech);
+ fclose(file_encoded);
+ if (file_mode != NULL)
+ fclose(file_mode);
+ return 1;
+ }
+ }
+ if (argc == 5){
+ if ((strcmp(argv[1], "-dtx") != 0)){
+ Usage(argv);
+ fclose(file_speech);
+ fclose(file_encoded);
+ if (file_mode != NULL){
+ fclose(file_mode);
+ }
+ return 1;
+ }
+ else {
+ dtx = 1;
+ }
+ }
+ }
+ else {
+ Usage(argv);
+ return 1;
+ }
+
+
+ enstate = Encoder_Interface_init(dtx);
+
+ Copyright();
+#ifndef VAD2
+ fprintf( stderr, "%s\n", "Code compiled with VAD option: VAD1");
+#else
+ fprintf( stderr, "%s\n", "Code compiled with VAD option: VAD2");
+#endif
+
+#ifndef ETSI
+#ifndef IF2
+ /* write magic number to indicate single channel AMR file storage format */
+ bytes = fwrite(AMR_MAGIC_NUMBER, sizeof(char), strlen(AMR_MAGIC_NUMBER), file_encoded);
+#endif
+#endif
+
+ /* read file */
+ while (fread( speech, sizeof (Word16), 160, file_speech ) > 0)
+ {
+ /* read mode */
+ if (file_mode != NULL){
+ req_mode = 8;
+ if (fscanf(file_mode, "%9s\n", mode_string) != EOF) {
+ mode_tmp = strtol(&mode_string[2], NULL, 0);
+ for (req_mode = 0; req_mode < 8; req_mode++){
+ if (mode_tmp == modeConv[req_mode]){
+ break;
+ }
+ }
+ }
+ if (req_mode == 8){
+ break;
+ }
+ }
+
+ frames ++;
+
+ /* call encoder */
+ byte_counter = Encoder_Interface_Encode(enstate, req_mode, speech, serial_data, 0);
+
+ bytes += byte_counter;
+ fwrite(serial_data, sizeof (UWord8), byte_counter, file_encoded );
+ fflush(file_encoded);
+ }
+ Encoder_Interface_exit(enstate);
+
+#ifndef ETSI
+#ifdef IF2
+ fprintf ( stderr, "\n%s%i%s%i%s\n", "Frame structure AMR IF2: ", frames, " frames, ", bytes, " bytes.");
+#else
+ fprintf ( stderr, "\n%s%i%s%i%s\n", "Frame structure AMR MIME file storage format: ", frames, " frames, ", bytes, " bytes.");
+#endif
+#else
+ fprintf ( stderr, "\n%s%i%s\n", "Frame structure AMR ETSI: ", frames, " frames. ");
+#endif
+
+ fclose(file_speech);
+ fclose(file_encoded);
+ if (file_mode != NULL)
+ fclose(file_mode);
+
+ return 0;
+}
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/interf_dec.c b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/interf_dec.c
new file mode 100644
index 000000000..c179c300c
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/interf_dec.c
@@ -0,0 +1,882 @@
+/*
+ * ===================================================================
+ * TS 26.104
+ * REL-5 V5.4.0 2004-03
+ * REL-6 V6.1.0 2004-03
+ * 3GPP AMR Floating-point Speech Codec
+ * ===================================================================
+ *
+ */
+
+/*
+ * interf_dec.c
+ *
+ *
+ * Project:
+ * AMR Floating-Point Codec
+ *
+ * Contains:
+ * This module provides means to conversion from 3GPP or ETSI
+ * bitstream to AMR parameters
+ */
+
+/*
+ * include files
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <memory.h>
+#include "typedef.h"
+#include "sp_dec.h"
+#include "interf_rom.h"
+#include "rom_dec.h"
+
+/*
+ * definition of constants
+ */
+#define EHF_MASK 0x0008 /* encoder homing frame pattern */
+typedef
+
+struct
+{
+ int reset_flag_old; /* previous was homing frame */
+
+
+ enum RXFrameType prev_ft; /* previous frame type */
+ enum Mode prev_mode; /* previous mode */
+ void *decoder_State; /* Points decoder state */
+
+
+}dec_interface_State;
+
+#ifdef ETSI
+
+
+/*
+ * Bin2Int
+ *
+ *
+ * Parameters:
+ * no_of_bits I: number of bits associated with value
+ * bits O: address where bits are written
+ *
+ * Function:
+ * Read nuber of bits from the array and convert to integer.
+ *
+ * Returns:
+ * value
+ */
+static Word16 Bin2Int( Word16 no_of_bits, Word16 *bitstream )
+{
+ Word32 value, i, bit;
+
+
+ value = 0;
+
+ for ( i = 0; i < no_of_bits; i++ ) {
+ value = value << 1;
+ bit = *bitstream++;
+
+ if ( bit == 0x1 )
+ value = value + 1;
+ }
+ return( Word16 )( value );
+}
+
+
+/*
+ * Bits2Prm
+ *
+ *
+ * Parameters:
+ * mode I: AMR mode
+ * bits I: serial bits
+ * param O: AMR parameters
+ *
+ * Function:
+ * Retrieves the vector of encoder parameters from
+ * the received serial bits in a frame.
+ *
+ * Returns:
+ * void
+ */
+static void Bits2Prm( enum Mode mode, Word16 bits[], Word16 prm[] )
+{
+ Word32 i;
+
+
+ switch ( mode ) {
+ case MR122:
+ for ( i = 0; i < PRMNO_MR122; i++ ) {
+ prm[i] = Bin2Int( bitno_MR122[i], bits );
+ bits += bitno_MR122[i];
+ }
+ break;
+
+ case MR102:
+ for ( i = 0; i < PRMNO_MR102; i++ ) {
+ prm[i] = Bin2Int( bitno_MR102[i], bits );
+ bits += bitno_MR102[i];
+ }
+ break;
+
+ case MR795:
+ for ( i = 0; i < PRMNO_MR795; i++ ) {
+ prm[i] = Bin2Int( bitno_MR795[i], bits );
+ bits += bitno_MR795[i];
+ }
+ break;
+
+ case MR74:
+ for ( i = 0; i < PRMNO_MR74; i++ ) {
+ prm[i] = Bin2Int( bitno_MR74[i], bits );
+ bits += bitno_MR74[i];
+ }
+ break;
+
+ case MR67:
+ for ( i = 0; i < PRMNO_MR67; i++ ) {
+ prm[i] = Bin2Int( bitno_MR67[i], bits );
+ bits += bitno_MR67[i];
+ }
+ break;
+
+ case MR59:
+ for ( i = 0; i < PRMNO_MR59; i++ ) {
+ prm[i] = Bin2Int( bitno_MR59[i], bits );
+ bits += bitno_MR59[i];
+ }
+ break;
+
+ case MR515:
+ for ( i = 0; i < PRMNO_MR515; i++ ) {
+ prm[i] = Bin2Int( bitno_MR515[i], bits );
+ bits += bitno_MR515[i];
+ }
+ break;
+
+ case MR475:
+ for ( i = 0; i < PRMNO_MR475; i++ ) {
+ prm[i] = Bin2Int( bitno_MR475[i], bits );
+ bits += bitno_MR475[i];
+ }
+ break;
+
+ case MRDTX:
+ for ( i = 0; i < PRMNO_MRDTX; i++ ) {
+ prm[i] = Bin2Int( bitno_MRDTX[i], bits );
+ bits += bitno_MRDTX[i];
+ }
+ break;
+ }
+ return;
+}
+
+#else
+
+#ifndef IF2
+
+/*
+ * DecoderMMS
+ *
+ *
+ * Parameters:
+ * param O: AMR parameters
+ * stream I: input bitstream
+ * frame_type O: frame type
+ * speech_mode O: speech mode in DTX
+ *
+ * Function:
+ * AMR file storage format frame to decoder parameters
+ *
+ * Returns:
+ * mode used mode
+ */
+enum Mode DecoderMMS( Word16 *param, UWord8 *stream, enum RXFrameType
+ *frame_type, enum Mode *speech_mode, Word16 *q_bit )
+{
+ enum Mode mode;
+ Word32 j;
+ Word16 *mask;
+
+
+ memset( param, 0, PRMNO_MR122 <<1 );
+ *q_bit = 0x01 & (*stream >> 2);
+ mode = 0x0F & (*stream >> 3);
+ stream++;
+
+ if ( mode == MRDTX ) {
+ mask = order_MRDTX;
+
+ for ( j = 1; j < 36; j++ ) {
+ if ( *stream & 0x80 )
+ param[ * mask] = ( short )( param[ * mask] + *( mask + 1 ) );
+ mask += 2;
+
+ if ( j % 8 )
+ *stream <<= 1;
+ else
+ stream++;
+ }
+
+ /* get SID type bit */
+
+ *frame_type = RX_SID_FIRST;
+ if (*stream & 0x80)
+ *frame_type = RX_SID_UPDATE;
+
+ /* since there is update, use it */
+ /* *frame_type = RX_SID_UPDATE; */
+
+ /* speech mode indicator */
+ *speech_mode = (*stream >> 4) & 0x07;
+ *speech_mode = ((*speech_mode & 0x0001) << 2) | (*speech_mode & 0x0002) | ((*speech_mode & 0x0004) >> 2);
+
+ }
+ else if ( mode == 15 ) {
+ *frame_type = RX_NO_DATA;
+ }
+ else if ( mode == MR475 ) {
+ mask = order_MR475;
+
+ for ( j = 1; j < 96; j++ ) {
+ if ( *stream & 0x80 )
+ param[ * mask] = ( short )( param[ * mask] + *( mask + 1 ) );
+ mask += 2;
+
+ if ( j % 8 )
+ *stream <<= 1;
+ else
+ stream++;
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ }
+ else if ( mode == MR515 ) {
+ mask = order_MR515;
+
+ for ( j = 1; j < 104; j++ ) {
+ if ( *stream & 0x80 )
+ param[ * mask] = ( short )( param[ * mask] + *( mask + 1 ) );
+ mask += 2;
+
+ if ( j % 8 )
+ *stream <<= 1;
+ else
+ stream++;
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ }
+ else if ( mode == MR59 ) {
+ mask = order_MR59;
+
+ for ( j = 1; j < 119; j++ ) {
+ if ( *stream & 0x80 )
+ param[ * mask] = ( short )( param[ * mask] + *( mask + 1 ) );
+ mask += 2;
+
+ if ( j % 8 )
+ *stream <<= 1;
+ else
+ stream++;
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ }
+ else if ( mode == MR67 ) {
+ mask = order_MR67;
+
+ for ( j = 1; j < 135; j++ ) {
+ if ( *stream & 0x80 )
+ param[ * mask] = ( short )( param[ * mask] + *( mask + 1 ) );
+ mask += 2;
+
+ if ( j % 8 )
+ *stream <<= 1;
+ else
+ stream++;
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ }
+ else if ( mode == MR74 ) {
+ mask = order_MR74;
+
+ for ( j = 1; j < 149; j++ ) {
+ if ( *stream & 0x80 )
+ param[ * mask] = ( short )( param[ * mask] + *( mask + 1 ) );
+ mask += 2;
+
+ if ( j % 8 )
+ *stream <<= 1;
+ else
+ stream++;
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ }
+ else if ( mode == MR795 ) {
+ mask = order_MR795;
+
+ for ( j = 1; j < 160; j++ ) {
+ if ( *stream & 0x80 )
+ param[ * mask] = ( short )( param[ * mask] + *( mask + 1 ) );
+ mask += 2;
+
+ if ( j % 8 )
+ *stream <<= 1;
+ else
+ stream++;
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ }
+ else if ( mode == MR102 ) {
+ mask = order_MR102;
+
+ for ( j = 1; j < 205; j++ ) {
+ if ( *stream & 0x80 )
+ param[ * mask] = ( short )( param[ * mask] + *( mask + 1 ) );
+ mask += 2;
+
+ if ( j % 8 )
+ *stream <<= 1;
+ else
+ stream++;
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ }
+ else if ( mode == MR122 ) {
+ mask = order_MR122;
+
+ for ( j = 1; j < 245; j++ ) {
+ if ( *stream & 0x80 )
+ param[ * mask] = ( short )( param[ * mask] + *( mask + 1 ) );
+ mask += 2;
+
+ if ( j % 8 )
+ *stream <<= 1;
+ else
+ stream++;
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ }
+ else
+ *frame_type = RX_SPEECH_BAD;
+ return mode;
+}
+
+#else
+
+/*
+ * Decoder3GPP
+ *
+ *
+ * Parameters:
+ * param O: AMR parameters
+ * stream I: input bitstream
+ * frame_type O: frame type
+ * speech_mode O: speech mode in DTX
+ *
+ * Function:
+ * Resets state memory
+ *
+ * Returns:
+ * mode used mode
+ */
+enum Mode Decoder3GPP( Word16 *param, UWord8 *stream, enum RXFrameType
+ *frame_type, enum Mode *speech_mode )
+{
+ enum Mode mode;
+ Word32 j;
+ Word16 *mask;
+
+
+ memset( param, 0, PRMNO_MR122 <<1 );
+ mode = 0xF & *stream;
+ *stream >>= 4;
+
+ if ( mode == MRDTX ) {
+ mask = order_MRDTX;
+
+ for ( j = 5; j < 40; j++ ) {
+ if ( *stream & 0x1 )
+ param[ * mask] = ( short )( param[ * mask] + *( mask + 1 ) );
+ mask += 2;
+
+ if ( j % 8 )
+ *stream >>= 1;
+ else
+ stream++;
+ }
+
+ /* get SID type bit */
+
+ *frame_type = RX_SID_FIRST;
+ if (*stream)
+ *frame_type = RX_SID_UPDATE;
+
+ /* since there is update, use it */
+ /* *frame_type = RX_SID_UPDATE; */
+ stream++;
+
+ /* speech mode indicator */
+ *speech_mode = *stream;
+ }
+ else if ( mode == 15 ) {
+ *frame_type = RX_NO_DATA;
+ }
+ else if ( mode == MR475 ) {
+ mask = order_MR475;
+
+ for ( j = 5; j < 100; j++ ) {
+ if ( *stream & 0x1 )
+ param[ * mask] = ( short )( param[ * mask] + *( mask + 1 ) );
+ mask += 2;
+
+ if ( j % 8 )
+ *stream >>= 1;
+ else
+ stream++;
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ }
+ else if ( mode == MR515 ) {
+ mask = order_MR515;
+
+ for ( j = 5; j < 108; j++ ) {
+ if ( *stream & 0x1 )
+ param[ * mask] = ( short )( param[ * mask] + *( mask + 1 ) );
+ mask += 2;
+
+ if ( j % 8 )
+ *stream >>= 1;
+ else
+ stream++;
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ }
+ else if ( mode == MR59 ) {
+ mask = order_MR59;
+
+ for ( j = 5; j < 123; j++ ) {
+ if ( *stream & 0x1 )
+ param[ * mask] = ( short )( param[ * mask] + *( mask + 1 ) );
+ mask += 2;
+
+ if ( j % 8 )
+ *stream >>= 1;
+ else
+ stream++;
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ }
+ else if ( mode == MR67 ) {
+ mask = order_MR67;
+
+ for ( j = 5; j < 139; j++ ) {
+ if ( *stream & 0x1 )
+ param[ * mask] = ( short )( param[ * mask] + *( mask + 1 ) );
+ mask += 2;
+
+ if ( j % 8 )
+ *stream >>= 1;
+ else
+ stream++;
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ }
+ else if ( mode == MR74 ) {
+ mask = order_MR74;
+
+ for ( j = 5; j < 153; j++ ) {
+ if ( *stream & 0x1 )
+ param[ * mask] = ( short )( param[ * mask] + *( mask + 1 ) );
+ mask += 2;
+
+ if ( j % 8 )
+ *stream >>= 1;
+ else
+ stream++;
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ }
+ else if ( mode == MR795 ) {
+ mask = order_MR795;
+
+ for ( j = 5; j < 164; j++ ) {
+ if ( *stream & 0x1 )
+ param[ * mask] = ( short )( param[ * mask] + *( mask + 1 ) );
+ mask += 2;
+
+ if ( j % 8 )
+ *stream >>= 1;
+ else
+ stream++;
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ }
+ else if ( mode == MR102 ) {
+ mask = order_MR102;
+
+ for ( j = 5; j < 209; j++ ) {
+ if ( *stream & 0x1 )
+ param[ * mask] = ( short )( param[ * mask] + *( mask + 1 ) );
+ mask += 2;
+
+ if ( j % 8 )
+ *stream >>= 1;
+ else
+ stream++;
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ }
+ else if ( mode == MR122 ) {
+ mask = order_MR122;
+
+ for ( j = 5; j < 249; j++ ) {
+ if ( *stream & 0x1 )
+ param[ * mask] = ( short )( param[ * mask] + *( mask + 1 ) );
+ mask += 2;
+
+ if ( j % 8 )
+ *stream >>= 1;
+ else
+ stream++;
+ }
+ *frame_type = RX_SPEECH_GOOD;
+ }
+ else
+ *frame_type = RX_SPEECH_BAD;
+ return mode;
+}
+#endif
+#endif
+
+/*
+ * Decoder_Interface_reset
+ *
+ *
+ * Parameters:
+ * st O: state struct
+ *
+ * Function:
+ * Reset homing frame counter
+ *
+ * Returns:
+ * void
+ */
+void Decoder_Interface_reset( dec_interface_State *st )
+{
+ st->reset_flag_old = 1;
+ st->prev_ft = RX_SPEECH_GOOD;
+ st->prev_mode = MR475; /* minimum bitrate */
+}
+
+
+/*
+ * Decoder_Interface_init
+ *
+ *
+ * Parameters:
+ * void
+ *
+ * Function:
+ * Allocates state memory and initializes state memory
+ *
+ * Returns:
+ * success : pointer to structure
+ * failure : NULL
+ */
+void * Decoder_Interface_init( void )
+{
+ dec_interface_State * s;
+
+ /* allocate memory */
+ if ( ( s = ( dec_interface_State * ) malloc( sizeof( dec_interface_State ) ) ) ==
+ NULL ) {
+ fprintf( stderr, "Decoder_Interface_init: "
+ "can not malloc state structure\n" );
+ return NULL;
+ }
+ s->decoder_State = Speech_Decode_Frame_init( );
+
+ if ( s->decoder_State == NULL ) {
+ free( s );
+ return NULL;
+ }
+ Decoder_Interface_reset( s );
+ return s;
+}
+
+
+/*
+ * Decoder_Interface_exit
+ *
+ *
+ * Parameters:
+ * state I: state structure
+ *
+ * Function:
+ * The memory used for state memory is freed
+ *
+ * Returns:
+ * Void
+ */
+void Decoder_Interface_exit( void *state )
+{
+ dec_interface_State * s;
+ s = ( dec_interface_State * )state;
+
+ /* free memory */
+ Speech_Decode_Frame_exit(s->decoder_State );
+ free( s );
+ s = NULL;
+ state = NULL;
+}
+
+
+/*
+ * Decoder_Interface_Decode
+ *
+ *
+ * Parameters:
+ * st B: state structure
+ * bits I: bit stream
+ * synth O: synthesized speech
+ * bfi I: bad frame indicator
+ *
+ * Function:
+ * Decode bit stream to synthesized speech
+ *
+ * Returns:
+ * Void
+ */
+void Decoder_Interface_Decode( void *st,
+
+#ifndef ETSI
+ UWord8 *bits,
+
+#else
+ Word16 *bits,
+#endif
+
+ Word16 *synth, int bfi)
+{
+ enum Mode mode; /* AMR mode */
+
+#ifndef ETSI
+ enum Mode speech_mode = MR475; /* speech mode */
+#endif
+
+ Word16 prm[PRMNO_MR122]; /* AMR parameters */
+
+ enum RXFrameType frame_type; /* frame type */
+ dec_interface_State * s; /* pointer to structure */
+
+ const Word16 *homing; /* pointer to homing frame */
+ Word16 homingSize; /* frame size for homing frame */
+ Word32 i; /* counter */
+ Word32 resetFlag = 1; /* homing frame */
+
+#ifndef ETSI
+#ifndef IF2
+ Word16 q_bit;
+#endif
+#endif
+
+ s = ( dec_interface_State * )st;
+
+#ifndef ETSI
+
+ /*
+ * extract mode information and frametype,
+ * octets to parameters
+ */
+#ifdef IF2
+ mode = Decoder3GPP( prm, bits, &frame_type, &speech_mode );
+#else
+ mode = DecoderMMS( prm, bits, &frame_type, &speech_mode, &q_bit );
+ if (!bfi) bfi = 1 - q_bit;
+#endif
+
+ if ( bfi == 1 ) {
+ if ( mode <= MR122 ) {
+ frame_type = RX_SPEECH_BAD;
+ }
+ else if ( frame_type != RX_NO_DATA ) {
+ frame_type = RX_SID_BAD;
+ mode = s->prev_mode;
+ }
+ } else {
+ if ( frame_type == RX_SID_FIRST || frame_type == RX_SID_UPDATE) {
+ mode = speech_mode;
+ }
+ else if ( frame_type == RX_NO_DATA ) {
+ mode = s->prev_mode;
+ }
+ /*
+ * if no mode information
+ * guess one from the previous frame
+ */
+ if ( frame_type == RX_SPEECH_BAD ) {
+ mode = s->prev_mode;
+ if ( s->prev_ft >= RX_SID_FIRST ) {
+ frame_type = RX_SID_BAD;
+ }
+ }
+ }
+#else
+ bfi = 0;
+ frame_type = bits[0];
+
+ switch ( frame_type ) {
+ case 0:
+ frame_type = RX_SPEECH_GOOD;
+ mode = bits[245];
+ Bits2Prm( mode, &bits[1], prm );
+ break;
+
+ case 1:
+ frame_type = RX_SID_FIRST;
+ mode = bits[245];
+ break;
+
+ case 2:
+ frame_type = RX_SID_UPDATE;
+ mode = bits[245];
+ Bits2Prm( MRDTX, &bits[1], prm );
+ break;
+
+ case 3:
+ frame_type = RX_NO_DATA;
+ mode = s->prev_mode;
+ break;
+ }
+#endif
+
+ /* test for homing frame */
+ if ( s->reset_flag_old == 1 ) {
+ switch ( mode ) {
+ case MR122:
+ homing = dhf_MR122;
+ homingSize = 18;
+ break;
+
+ case MR102:
+ homing = dhf_MR102;
+ homingSize = 12;
+ break;
+
+ case MR795:
+ homing = dhf_MR795;
+ homingSize = 8;
+ break;
+
+ case MR74:
+ homing = dhf_MR74;
+ homingSize = 7;
+ break;
+
+ case MR67:
+ homing = dhf_MR67;
+ homingSize = 7;
+ break;
+
+ case MR59:
+ homing = dhf_MR59;
+ homingSize = 7;
+ break;
+
+ case MR515:
+ homing = dhf_MR515;
+ homingSize = 7;
+ break;
+
+ case MR475:
+ homing = dhf_MR475;
+ homingSize = 7;
+ break;
+
+ default:
+ homing = NULL;
+ homingSize = 0;
+ break;
+ }
+
+ for ( i = 0; i < homingSize; i++ ) {
+ resetFlag = prm[i] ^ homing[i];
+
+ if ( resetFlag )
+ break;
+ }
+ }
+
+ if ( ( resetFlag == 0 ) && ( s->reset_flag_old != 0 ) ) {
+ for ( i = 0; i < 160; i++ ) {
+ synth[i] = EHF_MASK;
+ }
+ }
+ else
+ Speech_Decode_Frame( s->decoder_State, mode, prm, frame_type, synth );
+
+ if ( s->reset_flag_old == 0 ) {
+ /* check whole frame */
+ switch ( mode ) {
+ case MR122:
+ homing = dhf_MR122;
+ homingSize = PRMNO_MR122;
+ break;
+
+ case MR102:
+ homing = dhf_MR102;
+ homingSize = PRMNO_MR102;
+ break;
+
+ case MR795:
+ homing = dhf_MR795;
+ homingSize = PRMNO_MR795;
+ break;
+
+ case MR74:
+ homing = dhf_MR74;
+ homingSize = PRMNO_MR74;
+ break;
+
+ case MR67:
+ homing = dhf_MR67;
+ homingSize = PRMNO_MR67;
+ break;
+
+ case MR59:
+ homing = dhf_MR59;
+ homingSize = PRMNO_MR59;
+ break;
+
+ case MR515:
+ homing = dhf_MR515;
+ homingSize = PRMNO_MR515;
+ break;
+
+ case MR475:
+ homing = dhf_MR475;
+ homingSize = PRMNO_MR475;
+ break;
+
+ default:
+ homing = NULL;
+ homingSize = 0;
+ }
+
+ for ( i = 0; i < homingSize; i++ ) {
+ resetFlag = prm[i] ^ homing[i];
+
+ if ( resetFlag )
+ break;
+ }
+ }
+
+ /* reset decoder if current frame is a homing frame */
+ if ( resetFlag == 0 ) {
+ Speech_Decode_Frame_reset( s->decoder_State );
+ }
+ s->reset_flag_old = !resetFlag;
+ s->prev_ft = frame_type;
+ s->prev_mode = mode;
+}
+
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/interf_dec.h b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/interf_dec.h
new file mode 100644
index 000000000..3f4653379
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/interf_dec.h
@@ -0,0 +1,55 @@
+/*
+ * ===================================================================
+ * TS 26.104
+ * REL-5 V5.4.0 2004-03
+ * REL-6 V6.1.0 2004-03
+ * 3GPP AMR Floating-point Speech Codec
+ * ===================================================================
+ *
+ */
+
+/*
+ * interf_dec.h
+ *
+ *
+ * Project:
+ * AMR Floating-Point Codec
+ *
+ * Contains:
+ * Defines interface to AMR decoder
+ *
+ */
+
+#ifndef _interf_dec_h_
+#define _interf_dec_h_
+
+/*
+ * Function prototypes
+ */
+/*
+ * Conversion from packed bitstream to endoded parameters
+ * Decoding parameters to speech
+ */
+void Decoder_Interface_Decode( void *st,
+
+#ifndef ETSI
+ unsigned char *bits,
+
+#else
+ short *bits,
+#endif
+
+ short *synth, int bfi );
+
+/*
+ * Reserve and init. memory
+ */
+void *Decoder_Interface_init( void );
+
+/*
+ * Exit and free memory
+ */
+void Decoder_Interface_exit( void *state );
+
+#endif
+
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/interf_enc.c b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/interf_enc.c
new file mode 100644
index 000000000..817b981a5
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/interf_enc.c
@@ -0,0 +1,798 @@
+/*
+ * ===================================================================
+ * TS 26.104
+ * REL-5 V5.4.0 2004-03
+ * REL-6 V6.1.0 2004-03
+ * 3GPP AMR Floating-point Speech Codec
+ * ===================================================================
+ *
+ */
+
+/*
+ * interf_enc.c
+ *
+ *
+ * Project:
+ * AMR Floating-Point Codec
+ *
+ * Contains:
+ * This module contains all the functions needed encoding 160
+ * 16-bit speech samples to AMR encoder parameters.
+ *
+ */
+
+/*
+ * include files
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <memory.h>
+#include "sp_enc.h"
+#include "interf_rom.h"
+
+/*
+ * Declare structure types
+ */
+/* Declaration transmitted frame types */
+enum TXFrameType { TX_SPEECH_GOOD = 0,
+ TX_SID_FIRST,
+ TX_SID_UPDATE,
+ TX_NO_DATA,
+ TX_SPEECH_DEGRADED,
+ TX_SPEECH_BAD,
+ TX_SID_BAD,
+ TX_ONSET,
+ TX_N_FRAMETYPES /* number of frame types */
+};
+
+/* Declaration of interface structure */
+typedef struct
+{
+ Word16 sid_update_counter; /* Number of frames since last SID */
+ Word16 sid_handover_debt; /* Number of extra SID_UPD frames to schedule */
+ Word32 dtx;
+ enum TXFrameType prev_ft; /* Type of the previous frame */
+ void *encoderState; /* Points encoder state structure */
+} enc_interface_State;
+
+
+#ifdef ETSI
+/*
+ * Prm2Bits
+ *
+ *
+ * Parameters:
+ * value I: value to be converted to binary
+ * no_of_bits I: number of bits associated with value
+ * bitstream O: address where bits are written
+ *
+ * Function:
+ * Convert integer to binary and write the bits to the array.
+ * The most significant bits are written first.
+ * Returns:
+ * void
+ */
+static void Int2Bin( Word16 value, Word16 no_of_bits, Word16 *bitstream )
+{
+ Word32 i, bit;
+ Word16 *pt_bitstream;
+
+ pt_bitstream = &bitstream[no_of_bits];
+
+ for ( i = 0; i < no_of_bits; i++ ) {
+ bit = value & 0x0001;
+
+ if ( bit == 0 ) {
+ * --pt_bitstream = 0;
+ }
+ else {
+ * --pt_bitstream = 1;
+ }
+ value = ( Word16 )( value >> 1 );
+ }
+}
+
+
+/*
+ * Prm2Bits
+ *
+ *
+ * Parameters:
+ * mode I: AMR mode
+ * prm I: analysis parameters
+ * bits O: serial bits
+ *
+ * Function:
+ * converts the encoder parameter vector into a vector of serial bits.
+ * Returns:
+ * void
+ */
+static void Prm2Bits( enum Mode mode, Word16 prm[], Word16 bits[] )
+{
+ Word32 i;
+
+ switch ( mode ) {
+ case MR122:
+ for ( i = 0; i < PRMNO_MR122; i++ ) {
+ Int2Bin( prm[i], bitno_MR122[i], bits );
+ bits += bitno_MR122[i];
+ }
+ break;
+
+ case MR102:
+ for ( i = 0; i < PRMNO_MR102; i++ ) {
+ Int2Bin( prm[i], bitno_MR102[i], bits );
+ bits += bitno_MR102[i];
+ }
+ break;
+
+ case MR795:
+ for ( i = 0; i < PRMNO_MR795; i++ ) {
+ Int2Bin( prm[i], bitno_MR795[i], bits );
+ bits += bitno_MR795[i];
+ }
+ break;
+
+ case MR74:
+ for ( i = 0; i < PRMNO_MR74; i++ ) {
+ Int2Bin( prm[i], bitno_MR74[i], bits );
+ bits += bitno_MR74[i];
+ }
+ break;
+
+ case MR67:
+ for ( i = 0; i < PRMNO_MR67; i++ ) {
+ Int2Bin( prm[i], bitno_MR67[i], bits );
+ bits += bitno_MR67[i];
+ }
+ break;
+
+ case MR59:
+ for ( i = 0; i < PRMNO_MR59; i++ ) {
+ Int2Bin( prm[i], bitno_MR59[i], bits );
+ bits += bitno_MR59[i];
+ }
+ break;
+
+ case MR515:
+ for ( i = 0; i < PRMNO_MR515; i++ ) {
+ Int2Bin( prm[i], bitno_MR515[i], bits );
+ bits += bitno_MR515[i];
+ }
+ break;
+
+ case MR475:
+ for ( i = 0; i < PRMNO_MR475; i++ ) {
+ Int2Bin( prm[i], bitno_MR475[i], bits );
+ bits += bitno_MR475[i];
+ }
+ break;
+
+ case MRDTX:
+ for ( i = 0; i < PRMNO_MRDTX; i++ ) {
+ Int2Bin( prm[i], bitno_MRDTX[i], bits );
+ bits += bitno_MRDTX[i];
+ }
+ break;
+ }
+ return;
+}
+
+#else
+
+#ifndef IF2
+
+/*
+ * EncoderMMS
+ *
+ *
+ * Parameters:
+ * mode I: AMR mode
+ * param I: Encoder output parameters
+ * stream O: packed speech frame
+ * frame_type I: frame type (DTX)
+ * speech_mode I: speech mode (DTX)
+ *
+ * Function:
+ * Pack encoder output parameters to octet structure according
+ * importance table and AMR file storage format according to
+ * RFC 3267.
+ * Returns:
+ * number of octets
+ */
+static int EncoderMMS( enum Mode mode, Word16 *param, UWord8 *stream, enum
+ TXFrameType frame_type, enum Mode speech_mode )
+{
+ Word32 j = 0, k;
+ Word16 *mask;
+
+ memset(stream, 0, block_size[mode]);
+
+ *stream = toc_byte[mode];
+ stream++;
+
+ if ( mode == 15 ) {
+ return 1;
+ }
+ else if ( mode == MRDTX ) {
+ mask = order_MRDTX;
+
+ for ( j = 1; j < 36; j++ ) {
+ if ( param[ * mask] & *( mask + 1 ) )
+ *stream += 0x01;
+ mask += 2;
+
+ if ( j % 8 )
+ *stream <<= 1;
+ else
+ stream++;
+ }
+
+ /* add SID type information */
+ if ( frame_type == TX_SID_UPDATE )
+ *stream += 0x01;
+ *stream <<= 3;
+
+ /* speech mode indication */
+ *stream += ( unsigned char )(((speech_mode & 0x0001) << 2) | (speech_mode & 0x0002) | ((speech_mode & 0x0004) >> 2));
+
+ *stream <<= 1;
+
+ /* don't shift at the end of the function */
+ return 6;
+ }
+ else if ( mode == MR475 ) {
+ mask = order_MR475;
+
+ for ( j = 1; j < 96; j++ ) {
+ if ( param[ * mask] & *( mask + 1 ) )
+ *stream += 0x01;
+ mask += 2;
+
+ if ( j % 8 )
+ *stream <<= 1;
+ else
+ stream++;
+ }
+ }
+ else if ( mode == MR515 ) {
+ mask = order_MR515;
+
+ for ( j = 1; j < 104; j++ ) {
+ if ( param[ * mask] & *( mask + 1 ) )
+ *stream += 0x01;
+ mask += 2;
+
+ if ( j % 8 )
+ *stream <<= 1;
+ else
+ stream++;
+ }
+ }
+ else if ( mode == MR59 ) {
+ mask = order_MR59;
+
+ for ( j = 1; j < 119; j++ ) {
+ if ( param[ * mask] & *( mask + 1 ) )
+ *stream += 0x01;
+ mask += 2;
+
+ if ( j % 8 )
+ *stream <<= 1;
+ else
+ stream++;
+ }
+ }
+ else if ( mode == MR67 ) {
+ mask = order_MR67;
+
+ for ( j = 1; j < 135; j++ ) {
+ if ( param[ * mask] & *( mask + 1 ) )
+ *stream += 0x01;
+ mask += 2;
+
+ if ( j % 8 )
+ *stream <<= 1;
+ else
+ stream++;
+ }
+ }
+ else if ( mode == MR74 ) {
+ mask = order_MR74;
+
+ for ( j = 1; j < 149; j++ ) {
+ if ( param[ * mask] & *( mask + 1 ) )
+ *stream += 0x01;
+ mask += 2;
+
+ if ( j % 8 )
+ *stream <<= 1;
+ else
+ stream++;
+ }
+ }
+ else if ( mode == MR795 ) {
+ mask = order_MR795;
+
+ for ( j = 1; j < 160; j++ ) {
+ if ( param[ * mask] & *( mask + 1 ) )
+ *stream += 0x01;
+ mask += 2;
+
+ if ( j % 8 )
+ *stream <<= 1;
+ else
+ stream++;
+ }
+ }
+ else if ( mode == MR102 ) {
+ mask = order_MR102;
+
+ for ( j = 1; j < 205; j++ ) {
+ if ( param[ * mask] & *( mask + 1 ) )
+ *stream += 0x01;
+ mask += 2;
+
+ if ( j % 8 )
+ *stream <<= 1;
+ else
+ stream++;
+ }
+ }
+ else if ( mode == MR122 ) {
+ mask = order_MR122;
+
+ for ( j = 1; j < 245; j++ ) {
+ if ( param[ * mask] & *( mask + 1 ) )
+ *stream += 0x01;
+ mask += 2;
+
+ if ( j % 8 )
+ *stream <<= 1;
+ else
+ stream++;
+ }
+ }
+
+ /* shift remaining bits */
+ if ( k = j % 8 ) *stream <<= ( 8 - k );
+ return( (int)block_size[mode] );
+}
+
+#else
+
+/*
+ * Encoder3GPP
+ *
+ *
+ * Parameters:
+ * mode I: AMR mode
+ * param I: Encoder output parameters
+ * stream O: packed speech frame
+ * frame_type I: frame type (DTX)
+ * speech_mode I: speech mode (DTX)
+ *
+ * Function:
+ * Pack encoder output parameters to octet structure according
+ * importance table.
+ * Returns:
+ * number of octets
+ */
+static int Encoder3GPP( enum Mode mode, Word16 *param, UWord8 *stream, enum
+ TXFrameType frame_type, enum Mode speech_mode )
+{
+ Word32 j = 0;
+ Word16 *mask;
+
+ memset(stream, 0, block_size[mode]);
+
+ if ( mode == 15 ) {
+ *stream = 0xF;
+ return 1;
+ }
+ else if ( mode == MRDTX ) {
+ mask = order_MRDTX;
+ *stream = 0x40;
+
+ for ( j = 5; j < 40; j++ ) {
+ if ( param[ * mask] & *( mask + 1 ) )
+ *stream += 0x80;
+ mask += 2;
+
+ if ( j % 8 )
+ *stream >>= 1;
+ else
+ stream++;
+ }
+
+ /* add SID type information */
+ if ( frame_type == TX_SID_UPDATE )
+ *stream += 0x80;
+ stream++;
+
+ /* speech mode indication */
+ *stream = ( unsigned char )speech_mode;
+
+ /* don't shift at the end of the function */
+ return 6;
+ }
+ else if ( mode == MR475 ) {
+ mask = order_MR475;
+ *stream = 0;
+
+ for ( j = 5; j < 100; j++ ) {
+ if ( param[ * mask] & *( mask + 1 ) )
+ *stream += 0x80;
+ mask += 2;
+
+ if ( j % 8 )
+ *stream >>= 1;
+ else
+ stream++;
+ }
+ }
+ else if ( mode == MR515 ) {
+ mask = order_MR515;
+ *stream = 0x8;
+
+ for ( j = 5; j < 108; j++ ) {
+ if ( param[ * mask] & *( mask + 1 ) )
+ *stream += 0x80;
+ mask += 2;
+
+ if ( j % 8 )
+ *stream >>= 1;
+ else
+ stream++;
+ }
+ }
+ else if ( mode == MR59 ) {
+ mask = order_MR59;
+ *stream = 0x10;
+
+ for ( j = 5; j < 123; j++ ) {
+ if ( param[ * mask] & *( mask + 1 ) )
+ *stream += 0x80;
+ mask += 2;
+
+ if ( j % 8 )
+ *stream >>= 1;
+ else
+ stream++;
+ }
+ }
+ else if ( mode == MR67 ) {
+ mask = order_MR67;
+ *stream = 0x18;
+
+ for ( j = 5; j < 139; j++ ) {
+ if ( param[ * mask] & *( mask + 1 ) )
+ *stream += 0x80;
+ mask += 2;
+
+ if ( j % 8 )
+ *stream >>= 1;
+ else
+ stream++;
+ }
+ }
+ else if ( mode == MR74 ) {
+ mask = order_MR74;
+ *stream = 0x20;
+
+ for ( j = 5; j < 153; j++ ) {
+ if ( param[ * mask] & *( mask + 1 ) )
+ *stream += 0x80;
+ mask += 2;
+
+ if ( j % 8 )
+ *stream >>= 1;
+ else
+ stream++;
+ }
+ }
+ else if ( mode == MR795 ) {
+ mask = order_MR795;
+ *stream = 0x28;
+
+ for ( j = 5; j < 164; j++ ) {
+ if ( param[ * mask] & *( mask + 1 ) )
+ *stream += 0x80;
+ mask += 2;
+
+ if ( j % 8 )
+ *stream >>= 1;
+ else
+ stream++;
+ }
+ }
+ else if ( mode == MR102 ) {
+ mask = order_MR102;
+ *stream = 0x30;
+
+ for ( j = 5; j < 209; j++ ) {
+ if ( param[ * mask] & *( mask + 1 ) )
+ *stream += 0x80;
+ mask += 2;
+
+ if ( j % 8 )
+ *stream >>= 1;
+ else
+ stream++;
+ }
+ }
+ else if ( mode == MR122 ) {
+ mask = order_MR122;
+ *stream = 0x38;
+
+ for ( j = 5; j < 249; j++ ) {
+ if ( param[ * mask] & *( mask + 1 ) )
+ *stream += 0x80;
+ mask += 2;
+
+ if ( j % 8 )
+ *stream >>= 1;
+ else
+ stream++;
+ }
+ }
+
+ /* shift remaining bits */
+ *stream >>= ( 8 - j % 8 );
+ return( (int)block_size[mode] );
+}
+#endif
+#endif
+
+/*
+ * Sid_Sync_reset
+ *
+ *
+ * Parameters:
+ * st O: state structure
+ *
+ * Function:
+ * Initializes state memory
+ *
+ * Returns:
+ * void
+ */
+static void Sid_Sync_reset( enc_interface_State *st )
+{
+ st->sid_update_counter = 3;
+ st->sid_handover_debt = 0;
+ st->prev_ft = TX_SPEECH_GOOD;
+}
+
+
+/*
+ * Encoder_Interface_Encode
+ *
+ *
+ * Parameters:
+ * st I: pointer to state structure
+ * mode I: Speech Mode
+ * speech I: Input speech
+ * serial O: Output octet structure 3GPP or
+ * ETSI serial stream
+ * force_speech I: Force speech in DTX
+ *
+ * Function:
+ * Encoding and packing one frame of speech
+ *
+ * Returns:
+ * number of octets
+ */
+int Encoder_Interface_Encode( void *st, enum Mode mode, Word16 *speech,
+
+#ifndef ETSI
+ UWord8 *serial,
+
+#else
+ Word16 *serial,
+#endif
+
+ int force_speech )
+{
+ Word16 prm[PRMNO_MR122]; /* speech parameters, max size */
+ const Word16 *homing; /* pointer to homing frame */
+ Word16 homing_size; /* frame size for homing frame */
+
+
+ enc_interface_State * s;
+ enum TXFrameType txFrameType; /* frame type */
+
+ int i, noHoming = 0;
+
+
+ /*
+ * used encoder mode,
+ * if used_mode == -1, force VAD on
+ */
+ enum Mode used_mode = -force_speech;
+
+
+ s = ( enc_interface_State * )st;
+
+ /*
+ * Checks if all samples of the input frame matches the encoder
+ * homing frame pattern, which is 0x0008 for all samples.
+ */
+ for ( i = 0; i < 160; i++ ) {
+ noHoming = speech[i] ^ 0x0008;
+
+ if ( noHoming )
+ break;
+ }
+
+ if (noHoming){
+ Speech_Encode_Frame( s->encoderState, mode, speech, prm, &used_mode );
+ }
+ else {
+ switch ( mode ) {
+ case MR122:
+ homing = dhf_MR122;
+ homing_size = 18;
+ break;
+
+ case MR102:
+ homing = dhf_MR102;
+ homing_size = 12;
+ break;
+
+ case MR795:
+ homing = dhf_MR795;
+ homing_size = 8;
+ break;
+
+ case MR74:
+ homing = dhf_MR74;
+ homing_size = 7;
+ break;
+
+ case MR67:
+ homing = dhf_MR67;
+ homing_size = 7;
+ break;
+
+ case MR59:
+ homing = dhf_MR59;
+ homing_size = 7;
+ break;
+
+ case MR515:
+ homing = dhf_MR515;
+ homing_size = 7;
+ break;
+
+ case MR475:
+ homing = dhf_MR475;
+ homing_size = 7;
+ break;
+
+ default:
+ homing = NULL;
+ homing_size = 0;
+ break;
+ }
+ for( i = 0; i < homing_size; i++){
+ prm[i] = homing[i];
+ }
+ /* rest of the parameters are zero */
+ memset(&prm[homing_size], 0, (PRMNO_MR122 - homing_size) << 1);
+ used_mode = mode;
+ }
+ if ( used_mode == MRDTX ) {
+ s->sid_update_counter--;
+
+ if ( s->prev_ft == TX_SPEECH_GOOD ) {
+ txFrameType = TX_SID_FIRST;
+ s->sid_update_counter = 3;
+ }
+ else {
+ /* TX_SID_UPDATE or TX_NO_DATA */
+ if ( ( s->sid_handover_debt > 0 ) && ( s->sid_update_counter > 2 ) ) {
+ /*
+ * ensure extra updates are properly delayed after
+ * a possible SID_FIRST
+ */
+ txFrameType = TX_SID_UPDATE;
+ s->sid_handover_debt--;
+ }
+ else {
+ if ( s->sid_update_counter == 0 ) {
+ txFrameType = TX_SID_UPDATE;
+ s->sid_update_counter = 8;
+ }
+ else {
+ txFrameType = TX_NO_DATA;
+ used_mode = 15;
+ }
+ }
+ }
+ }
+ else {
+ s->sid_update_counter = 8;
+ txFrameType = TX_SPEECH_GOOD;
+ }
+ s->prev_ft = txFrameType;
+
+ if ( noHoming == 0 ) {
+ Speech_Encode_Frame_reset( s->encoderState, s->dtx );
+ Sid_Sync_reset( s );
+ }
+
+#ifndef ETSI
+#ifdef IF2
+ return Encoder3GPP( used_mode, prm, serial, txFrameType, mode );
+
+#else
+ return EncoderMMS( used_mode, prm, serial, txFrameType, mode );
+
+#endif
+#else
+
+ Prm2Bits( used_mode, prm, &serial[1] );
+ serial[0] = ( Word16 )txFrameType;
+ serial[245] = ( Word16 )mode;
+ return 500;
+#endif
+
+}
+
+
+/*
+ * Encoder_Interface_init
+ *
+ *
+ * Parameters:
+ * dtx I: DTX flag
+ *
+ * Function:
+ * Allocates state memory and initializes state memory
+ *
+ * Returns:
+ * pointer to encoder interface structure
+ */
+void * Encoder_Interface_init( int dtx )
+{
+ enc_interface_State * s;
+
+ /* allocate memory */
+ if ( ( s = ( enc_interface_State * ) malloc( sizeof( enc_interface_State ) ) ) ==
+ NULL ) {
+ fprintf( stderr, "Encoder_Interface_init: "
+ "can not malloc state structure\n" );
+ return NULL;
+ }
+ s->encoderState = Speech_Encode_Frame_init( dtx );
+ Sid_Sync_reset( s );
+ s->dtx = dtx;
+ return s;
+}
+
+
+/*
+ * DecoderInterfaceExit
+ *
+ *
+ * Parameters:
+ * state I: state structure
+ *
+ * Function:
+ * The memory used for state memory is freed
+ *
+ * Returns:
+ * Void
+ */
+void Encoder_Interface_exit( void *state )
+{
+ enc_interface_State * s;
+ s = ( enc_interface_State * )state;
+
+ /* free memory */
+ Speech_Encode_Frame_exit( &s->encoderState );
+ free( s );
+ state = NULL;
+}
+
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/interf_enc.h b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/interf_enc.h
new file mode 100644
index 000000000..6b89f9a8a
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/interf_enc.h
@@ -0,0 +1,58 @@
+/*
+ * ===================================================================
+ * TS 26.104
+ * REL-5 V5.4.0 2004-03
+ * REL-6 V6.1.0 2004-03
+ * 3GPP AMR Floating-point Speech Codec
+ * ===================================================================
+ *
+ */
+
+/*
+ * interf_enc.h
+ *
+ *
+ * Project:
+ * AMR Floating-Point Codec
+ *
+ * Contains:
+ * Defines interface to AMR encoder
+ *
+ */
+
+#ifndef _interf_enc_h_
+#define _interf_enc_h_
+
+/*
+ * include files
+ */
+#include"sp_enc.h"
+
+/*
+ * Function prototypes
+ */
+/*
+ * Encodes one frame of speech
+ * Returns packed octets
+ */
+int Encoder_Interface_Encode( void *st, enum Mode mode, short *speech,
+
+#ifndef ETSI
+ unsigned char *serial, /* max size 31 bytes */
+
+#else
+ short *serial, /* size 500 bytes */
+#endif
+
+ int forceSpeech ); /* use speech mode */
+
+/*
+ * Reserve and init. memory
+ */
+void *Encoder_Interface_init( int dtx );
+
+/*
+ * Exit and free memory
+ */
+void Encoder_Interface_exit( void *state );
+#endif
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/interf_rom.h b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/interf_rom.h
new file mode 100644
index 000000000..349f9d4d0
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/interf_rom.h
@@ -0,0 +1,1802 @@
+/*
+ * ===================================================================
+ * TS 26.104
+ * REL-5 V5.4.0 2004-03
+ * REL-6 V6.1.0 2004-03
+ * 3GPP AMR Floating-point Speech Codec
+ * ===================================================================
+ *
+ */
+
+/*
+ * interf_rom.h
+ *
+ *
+ * Project:
+ * AMR Floating-Point Codec
+ *
+ * Contains:
+ * Tables: Subjective importance
+ * Homing frames
+ *
+ *
+ */
+
+#ifndef _interf_rom_h_
+#define _interf_rom_h_
+
+/*
+ * include files
+ */
+#include"typedef.h"
+
+/*
+ * definition of constants
+ */
+
+/* number of parameters */
+#define PRMNO_MR475 17
+#define PRMNO_MR515 19
+#define PRMNO_MR59 19
+#define PRMNO_MR67 19
+#define PRMNO_MR74 19
+#define PRMNO_MR795 23
+#define PRMNO_MR102 39
+#define PRMNO_MR122 57
+#define PRMNO_MRDTX 5
+
+/*
+ * tables
+ */
+#ifndef IF2
+#ifndef ETSI
+static const UWord8 block_size[16]={ 13, 14, 16, 18, 20, 21, 27, 32,
+ 6 , 0 , 0 , 0 , 0 , 0 , 0 , 1 };
+
+static const UWord8 toc_byte[16]={0x04, 0x0C, 0x14, 0x1C, 0x24, 0x2C, 0x34, 0x3C,
+ 0x44, 0x4C, 0x54, 0x5C, 0x64, 0x6C, 0x74, 0x7C};
+#endif
+#else
+/* One encoded frame (bytes) */
+static const UWord8 block_size[16]={ 13, 14, 16, 18, 19, 21, 26, 31,
+ 5 , 0 , 0 , 0 , 0 , 0 , 0 , 1 };
+#endif
+
+/* Subjective importance of the speech encoded bits */
+static Word16 order_MR475[] =
+{
+ 0, 0x80,
+ 0, 0x40,
+ 0, 0x20,
+ 0, 0x10,
+ 0, 0x8,
+ 0, 0x4,
+ 0, 0x2,
+ 0, 0x1,
+ 1, 0x80,
+ 1, 0x40,
+ 1, 0x20,
+ 1, 0x10,
+ 1, 0x8,
+ 1, 0x4,
+ 1, 0x2,
+ 1, 0x1,
+ 3, 0x80,
+ 3, 0x40,
+ 3, 0x20,
+ 3, 0x10,
+ 3, 0x8,
+ 3, 0x4,
+ 7, 0x8,
+ 7, 0x4,
+ 10, 0x8,
+ 10, 0x4,
+ 14, 0x8,
+ 14, 0x4,
+ 6, 0x1,
+ 6, 0x2,
+ 6, 0x4,
+ 6, 0x8,
+ 13, 0x1,
+ 13, 0x2,
+ 13, 0x4,
+ 13, 0x8,
+ 2, 0x20,
+ 2, 0x10,
+ 2, 0x4,
+ 2, 0x1,
+ 13, 0x10,
+ 13, 0x20,
+ 13, 0x40,
+ 13, 0x80,
+ 3, 0x2,
+ 3, 0x1,
+ 6, 0x10,
+ 6, 0x20,
+ 6, 0x40,
+ 6, 0x80,
+ 5, 0x2,
+ 5, 0x1,
+ 2, 0x40,
+ 2, 0x8,
+ 2, 0x2,
+ 7, 0x2,
+ 7, 0x1,
+ 9, 0x2,
+ 9, 0x1,
+ 10, 0x2,
+ 10, 0x1,
+ 12, 0x2,
+ 12, 0x1,
+ 14, 0x2,
+ 14, 0x1,
+ 16, 0x2,
+ 16, 0x1,
+ 4, 0x20,
+ 4, 0x10,
+ 4, 0x4,
+ 4, 0x2,
+ 8, 0x20,
+ 8, 0x10,
+ 8, 0x4,
+ 8, 0x2,
+ 11, 0x20,
+ 11, 0x10,
+ 11, 0x4,
+ 11, 0x2,
+ 15, 0x20,
+ 15, 0x10,
+ 15, 0x4,
+ 15, 0x2,
+ 4, 0x8,
+ 8, 0x8,
+ 11, 0x8,
+ 15, 0x8,
+ 4, 0x1,
+ 8, 0x1,
+ 11, 0x1,
+ 15, 0x1,
+ 4, 0x40,
+ 8, 0x40,
+ 11, 0x40,
+ 15, 0x40
+};
+static Word16 order_MR515[] =
+{
+ 0, 0x1,
+ 0, 0x2,
+ 0, 0x4,
+ 0, 0x8,
+ 0, 0x10,
+ 0, 0x20,
+ 0, 0x40,
+ 0, 0x80,
+ 1, 0x1,
+ 1, 0x2,
+ 1, 0x4,
+ 1, 0x8,
+ 1, 0x10,
+ 1, 0x20,
+ 1, 0x40,
+ 1, 0x80,
+ 3, 0x80,
+ 3, 0x40,
+ 3, 0x20,
+ 3, 0x10,
+ 3, 0x8,
+ 7, 0x8,
+ 11, 0x8,
+ 15, 0x8,
+ 6, 0x1,
+ 6, 0x2,
+ 6, 0x4,
+ 10, 0x1,
+ 10, 0x2,
+ 10, 0x4,
+ 14, 0x1,
+ 14, 0x2,
+ 14, 0x4,
+ 18, 0x1,
+ 18, 0x2,
+ 18, 0x4,
+ 6, 0x8,
+ 10, 0x8,
+ 14, 0x8,
+ 18, 0x8,
+ 3, 0x4,
+ 7, 0x4,
+ 11, 0x4,
+ 15, 0x4,
+ 2, 0x10,
+ 6, 0x10,
+ 10, 0x10,
+ 14, 0x10,
+ 18, 0x10,
+ 3, 0x2,
+ 7, 0x2,
+ 11, 0x2,
+ 2, 0x20,
+ 2, 0x4,
+ 2, 0x1,
+ 6, 0x20,
+ 10, 0x20,
+ 14, 0x20,
+ 18, 0x20,
+ 2, 0x2,
+ 3, 0x1,
+ 7, 0x1,
+ 11, 0x1,
+ 15, 0x2,
+ 2, 0x8,
+ 2, 0x40,
+ 15, 0x1,
+ 5, 0x1,
+ 5, 0x2,
+ 9, 0x1,
+ 9, 0x2,
+ 13, 0x1,
+ 4, 0x4,
+ 8, 0x4,
+ 12, 0x4,
+ 16, 0x4,
+ 13, 0x2,
+ 17, 0x1,
+ 17, 0x2,
+ 4, 0x2,
+ 8, 0x2,
+ 12, 0x2,
+ 16, 0x2,
+ 4, 0x20,
+ 8, 0x20,
+ 4, 0x10,
+ 8, 0x10,
+ 12, 0x20,
+ 12, 0x10,
+ 16, 0x20,
+ 16, 0x10,
+ 4, 0x40,
+ 8, 0x40,
+ 12, 0x40,
+ 16, 0x40,
+ 4, 0x1,
+ 8, 0x1,
+ 12, 0x1,
+ 16, 0x1,
+ 4, 0x8,
+ 8, 0x8,
+ 12, 0x8,
+ 16, 0x8
+};
+static Word16 order_MR59[] =
+{
+ 0, 0x80,
+ 0, 0x40,
+ 0, 0x8,
+ 0, 0x4,
+ 0, 0x10,
+ 0, 0x2,
+ 0, 0x1,
+ 0, 0x20,
+ 1, 0x8,
+ 1, 0x2,
+ 1, 0x100,
+ 1, 0x80,
+ 1, 0x20,
+ 1, 0x10,
+ 1, 0x4,
+ 1, 0x40,
+ 1, 0x1,
+ 3, 0x20,
+ 11, 0x20,
+ 3, 0x10,
+ 11, 0x10,
+ 3, 0x40,
+ 11, 0x40,
+ 3, 0x80,
+ 11, 0x80,
+ 3, 0x8,
+ 11, 0x8,
+ 7, 0x8,
+ 15, 0x8,
+ 6, 0x1,
+ 10, 0x1,
+ 14, 0x1,
+ 18, 0x1,
+ 3, 0x4,
+ 11, 0x4,
+ 7, 0x4,
+ 15, 0x4,
+ 6, 0x2,
+ 10, 0x2,
+ 14, 0x2,
+ 18, 0x2,
+ 7, 0x2,
+ 15, 0x2,
+ 3, 0x2,
+ 11, 0x2,
+ 3, 0x1,
+ 11, 0x1,
+ 6, 0x4,
+ 10, 0x4,
+ 14, 0x4,
+ 18, 0x4,
+ 6, 0x8,
+ 10, 0x8,
+ 14, 0x8,
+ 18, 0x8,
+ 6, 0x10,
+ 10, 0x10,
+ 14, 0x10,
+ 18, 0x10,
+ 2, 0x40,
+ 2, 0x10,
+ 2, 0x4,
+ 2, 0x8,
+ 2, 0x80,
+ 2, 0x100,
+ 2, 0x20,
+ 2, 0x2,
+ 17, 0x1,
+ 5, 0x2,
+ 13, 0x2,
+ 17, 0x2,
+ 9, 0x2,
+ 9, 0x1,
+ 5, 0x1,
+ 13, 0x1,
+ 2, 0x1,
+ 6, 0x20,
+ 10, 0x20,
+ 14, 0x20,
+ 18, 0x20,
+ 7, 0x1,
+ 15, 0x1,
+ 4, 0x4,
+ 8, 0x4,
+ 12, 0x4,
+ 16, 0x4,
+ 4, 0x8,
+ 8, 0x8,
+ 12, 0x8,
+ 16, 0x8,
+ 4, 0x40,
+ 8, 0x40,
+ 12, 0x40,
+ 16, 0x40,
+ 4, 0x80,
+ 8, 0x80,
+ 12, 0x80,
+ 16, 0x80,
+ 4, 0x100,
+ 8, 0x100,
+ 12, 0x100,
+ 16, 0x100,
+ 4, 0x1,
+ 8, 0x1,
+ 12, 0x1,
+ 16, 0x1,
+ 4, 0x2,
+ 8, 0x2,
+ 12, 0x2,
+ 16, 0x2,
+ 4, 0x10,
+ 8, 0x10,
+ 12, 0x10,
+ 16, 0x10,
+ 4, 0x20,
+ 8, 0x20,
+ 12, 0x20,
+ 16, 0x20
+};
+static Word16 order_MR67[] =
+{
+ 0, 0x80,
+ 0, 0x40,
+ 0, 0x8,
+ 0, 0x10,
+ 0, 0x4,
+ 0, 0x2,
+ 1, 0x8,
+ 0, 0x1,
+ 0, 0x20,
+ 1, 0x100,
+ 1, 0x80,
+ 1, 0x20,
+ 1, 0x2,
+ 1, 0x10,
+ 1, 0x4,
+ 1, 0x40,
+ 3, 0x20,
+ 11, 0x20,
+ 3, 0x10,
+ 11, 0x10,
+ 3, 0x40,
+ 11, 0x40,
+ 3, 0x80,
+ 11, 0x80,
+ 3, 0x8,
+ 11, 0x8,
+ 1, 0x1,
+ 7, 0x8,
+ 15, 0x8,
+ 7, 0x4,
+ 15, 0x4,
+ 3, 0x4,
+ 11, 0x4,
+ 7, 0x2,
+ 15, 0x2,
+ 6, 0x40,
+ 10, 0x40,
+ 14, 0x40,
+ 18, 0x40,
+ 3, 0x2,
+ 11, 0x2,
+ 6, 0x8,
+ 10, 0x8,
+ 14, 0x8,
+ 18, 0x8,
+ 6, 0x4,
+ 10, 0x4,
+ 14, 0x4,
+ 18, 0x4,
+ 7, 0x1,
+ 15, 0x1,
+ 3, 0x1,
+ 11, 0x1,
+ 2, 0x40,
+ 2, 0x4,
+ 6, 0x2,
+ 10, 0x2,
+ 14, 0x2,
+ 18, 0x2,
+ 2, 0x10,
+ 2, 0x8,
+ 2, 0x80,
+ 2, 0x100,
+ 2, 0x20,
+ 2, 0x2,
+ 2, 0x1,
+ 6, 0x10,
+ 10, 0x10,
+ 14, 0x10,
+ 18, 0x10,
+ 5, 0x1,
+ 9, 0x1,
+ 13, 0x1,
+ 17, 0x1,
+ 6, 0x1,
+ 10, 0x1,
+ 14, 0x1,
+ 18, 0x1,
+ 5, 0x2,
+ 9, 0x2,
+ 13, 0x2,
+ 17, 0x2,
+ 18, 0x20,
+ 14, 0x20,
+ 10, 0x20,
+ 6, 0x20,
+ 5, 0x4,
+ 9, 0x4,
+ 13, 0x4,
+ 17, 0x4,
+ 4, 0x4,
+ 8, 0x4,
+ 12, 0x4,
+ 16, 0x4,
+ 4, 0x20,
+ 8, 0x20,
+ 12, 0x20,
+ 16, 0x20,
+ 4, 0x40,
+ 8, 0x40,
+ 12, 0x40,
+ 16, 0x40,
+ 4, 0x200,
+ 8, 0x200,
+ 12, 0x200,
+ 16, 0x200,
+ 4, 0x400,
+ 8, 0x400,
+ 12, 0x400,
+ 16, 0x400,
+ 4, 0x1,
+ 8, 0x1,
+ 12, 0x1,
+ 16, 0x1,
+ 4, 0x2,
+ 8, 0x2,
+ 12, 0x2,
+ 16, 0x2,
+ 4, 0x8,
+ 8, 0x8,
+ 12, 0x8,
+ 16, 0x8,
+ 4, 0x10,
+ 8, 0x10,
+ 12, 0x10,
+ 16, 0x10,
+ 4, 0x80,
+ 8, 0x80,
+ 12, 0x80,
+ 16, 0x80,
+ 4, 0x100,
+ 8, 0x100,
+ 12, 0x100,
+ 16, 0x100
+};
+static Word16 order_MR74[] =
+{
+ 0, 0x80,
+ 0, 0x40,
+ 0, 0x20,
+ 0, 0x10,
+ 0, 0x8,
+ 0, 0x4,
+ 0, 0x2,
+ 0, 0x1,
+ 1, 0x100,
+ 1, 0x80,
+ 1, 0x40,
+ 1, 0x20,
+ 1, 0x10,
+ 1, 0x8,
+ 1, 0x4,
+ 1, 0x2,
+ 1, 0x1,
+ 3, 0x80,
+ 11, 0x80,
+ 3, 0x40,
+ 11, 0x40,
+ 3, 0x20,
+ 11, 0x20,
+ 3, 0x10,
+ 11, 0x10,
+ 3, 0x8,
+ 11, 0x8,
+ 6, 0x40,
+ 10, 0x40,
+ 14, 0x40,
+ 18, 0x40,
+ 6, 0x20,
+ 10, 0x20,
+ 14, 0x20,
+ 18, 0x20,
+ 6, 0x8,
+ 10, 0x8,
+ 14, 0x8,
+ 18, 0x8,
+ 6, 0x4,
+ 10, 0x4,
+ 14, 0x4,
+ 18, 0x4,
+ 7, 0x10,
+ 15, 0x10,
+ 7, 0x8,
+ 15, 0x8,
+ 2, 0x10,
+ 2, 0x8,
+ 2, 0x4,
+ 2, 0x100,
+ 2, 0x80,
+ 2, 0x40,
+ 3, 0x4,
+ 7, 0x4,
+ 11, 0x4,
+ 15, 0x4,
+ 6, 0x2,
+ 10, 0x2,
+ 14, 0x2,
+ 18, 0x2,
+ 2, 0x20,
+ 2, 0x2,
+ 2, 0x1,
+ 5, 0x1,
+ 9, 0x1,
+ 13, 0x1,
+ 17, 0x1,
+ 6, 0x1,
+ 10, 0x1,
+ 14, 0x1,
+ 18, 0x1,
+ 5, 0x2,
+ 9, 0x2,
+ 13, 0x2,
+ 17, 0x2,
+ 5, 0x4,
+ 9, 0x4,
+ 6, 0x10,
+ 10, 0x10,
+ 14, 0x10,
+ 18, 0x10,
+ 13, 0x4,
+ 17, 0x4,
+ 5, 0x8,
+ 9, 0x8,
+ 13, 0x8,
+ 17, 0x8,
+ 3, 0x2,
+ 3, 0x1,
+ 7, 0x2,
+ 7, 0x1,
+ 11, 0x2,
+ 11, 0x1,
+ 15, 0x2,
+ 15, 0x1,
+ 4, 0x20,
+ 4, 0x10,
+ 4, 0x8,
+ 4, 0x4,
+ 4, 0x2,
+ 4, 0x1,
+ 8, 0x20,
+ 8, 0x10,
+ 8, 0x8,
+ 8, 0x4,
+ 8, 0x2,
+ 8, 0x1,
+ 12, 0x20,
+ 12, 0x10,
+ 12, 0x8,
+ 12, 0x4,
+ 12, 0x2,
+ 12, 0x1,
+ 16, 0x20,
+ 16, 0x10,
+ 16, 0x8,
+ 16, 0x4,
+ 16, 0x2,
+ 16, 0x1,
+ 4, 0x1000,
+ 8, 0x1000,
+ 12, 0x1000,
+ 16, 0x1000,
+ 4, 0x800,
+ 8, 0x800,
+ 12, 0x800,
+ 16, 0x800,
+ 4, 0x400,
+ 8, 0x400,
+ 12, 0x400,
+ 16, 0x400,
+ 4, 0x200,
+ 8, 0x200,
+ 12, 0x200,
+ 16, 0x200,
+ 4, 0x100,
+ 8, 0x100,
+ 12, 0x100,
+ 16, 0x100,
+ 4, 0x80,
+ 8, 0x80,
+ 12, 0x80,
+ 16, 0x80,
+ 4, 0x40,
+ 8, 0x40,
+ 12, 0x40,
+ 16, 0x40
+};
+static Word16 order_MR795[] =
+{
+ 0, 0x1,
+ 0, 0x2,
+ 0, 0x4,
+ 0, 0x8,
+ 0, 0x10,
+ 0, 0x20,
+ 0, 0x40,
+ 1, 0x8,
+ 1, 0x2,
+ 1, 0x100,
+ 1, 0x80,
+ 1, 0x20,
+ 1, 0x10,
+ 1, 0x4,
+ 1, 0x40,
+ 1, 0x1,
+ 2, 0x40,
+ 2, 0x10,
+ 2, 0x4,
+ 2, 0x8,
+ 2, 0x80,
+ 2, 0x100,
+ 2, 0x20,
+ 7, 0x10,
+ 12, 0x10,
+ 17, 0x10,
+ 22, 0x10,
+ 7, 0x8,
+ 12, 0x8,
+ 17, 0x8,
+ 22, 0x8,
+ 7, 0x4,
+ 12, 0x4,
+ 17, 0x4,
+ 22, 0x4,
+ 6, 0x8,
+ 11, 0x8,
+ 16, 0x8,
+ 21, 0x8,
+ 6, 0x4,
+ 11, 0x4,
+ 16, 0x4,
+ 21, 0x4,
+ 3, 0x80,
+ 13, 0x80,
+ 3, 0x40,
+ 13, 0x40,
+ 3, 0x20,
+ 13, 0x20,
+ 3, 0x10,
+ 13, 0x10,
+ 3, 0x8,
+ 13, 0x8,
+ 8, 0x20,
+ 18, 0x20,
+ 8, 0x10,
+ 18, 0x10,
+ 8, 0x8,
+ 18, 0x8,
+ 7, 0x2,
+ 12, 0x2,
+ 17, 0x2,
+ 22, 0x2,
+ 3, 0x4,
+ 13, 0x4,
+ 8, 0x4,
+ 18, 0x4,
+ 0, 0x80,
+ 0, 0x100,
+ 2, 0x2,
+ 2, 0x1,
+ 3, 0x2,
+ 13, 0x2,
+ 3, 0x1,
+ 13, 0x1,
+ 8, 0x2,
+ 18, 0x2,
+ 8, 0x1,
+ 18, 0x1,
+ 6, 0x2,
+ 11, 0x2,
+ 16, 0x2,
+ 21, 0x2,
+ 7, 0x1,
+ 12, 0x1,
+ 17, 0x1,
+ 22, 0x1,
+ 6, 0x1,
+ 11, 0x1,
+ 16, 0x1,
+ 21, 0x1,
+ 15, 0x1,
+ 15, 0x2,
+ 15, 0x4,
+ 4, 0x2,
+ 9, 0x2,
+ 14, 0x2,
+ 19, 0x2,
+ 4, 0x10,
+ 9, 0x10,
+ 14, 0x10,
+ 19, 0x10,
+ 4, 0x80,
+ 9, 0x80,
+ 14, 0x80,
+ 19, 0x80,
+ 4, 0x800,
+ 9, 0x800,
+ 14, 0x800,
+ 19, 0x800,
+ 15, 0x8,
+ 20, 0x1,
+ 20, 0x2,
+ 20, 0x4,
+ 20, 0x8,
+ 10, 0x1,
+ 10, 0x2,
+ 10, 0x4,
+ 10, 0x8,
+ 5, 0x1,
+ 5, 0x2,
+ 5, 0x4,
+ 5, 0x8,
+ 4, 0x1,
+ 4, 0x4,
+ 4, 0x8,
+ 4, 0x20,
+ 4, 0x100,
+ 4, 0x1000,
+ 9, 0x1,
+ 9, 0x4,
+ 9, 0x8,
+ 9, 0x20,
+ 9, 0x100,
+ 9, 0x1000,
+ 14, 0x1,
+ 14, 0x4,
+ 14, 0x8,
+ 14, 0x20,
+ 14, 0x100,
+ 14, 0x1000,
+ 19, 0x1,
+ 19, 0x4,
+ 19, 0x8,
+ 19, 0x20,
+ 19, 0x100,
+ 19, 0x1000,
+ 4, 0x40,
+ 9, 0x40,
+ 14, 0x40,
+ 19, 0x40,
+ 4, 0x400,
+ 9, 0x400,
+ 14, 0x400,
+ 19, 0x400,
+ 4, 0x200,
+ 9, 0x200,
+ 14, 0x200,
+ 19, 0x200,
+ 0, 0x1,
+ 0, 0x2,
+ 0, 0x4,
+ 0, 0x8,
+ 0, 0x10,
+ 0, 0x20,
+ 0, 0x40,
+ 1, 0x8,
+ 1, 0x2,
+ 1, 0x100,
+ 1, 0x80,
+ 1, 0x20,
+ 1, 0x10,
+ 1, 0x4,
+ 1, 0x40,
+ 1, 0x1,
+ 2, 0x40,
+ 2, 0x10,
+ 2, 0x4,
+ 2, 0x8,
+ 2, 0x80,
+ 2, 0x100,
+ 2, 0x20,
+ 7, 0x10,
+ 12, 0x10,
+ 17, 0x10,
+ 22, 0x10,
+ 7, 0x8,
+ 12, 0x8,
+ 17, 0x8,
+ 22, 0x8,
+ 7, 0x4,
+ 12, 0x4,
+ 17, 0x4,
+ 22, 0x4,
+ 6, 0x8,
+ 11, 0x8,
+ 16, 0x8,
+ 21, 0x8,
+ 6, 0x4,
+ 11, 0x4,
+ 16, 0x4,
+ 21, 0x4,
+ 3, 0x80,
+ 13, 0x80,
+ 3, 0x40,
+ 13, 0x40,
+ 3, 0x20,
+ 13, 0x20,
+ 3, 0x10,
+ 13, 0x10,
+ 3, 0x8,
+ 13, 0x8,
+ 8, 0x20,
+ 18, 0x20,
+ 8, 0x10,
+ 18, 0x10,
+ 8, 0x8,
+ 18, 0x8,
+ 7, 0x2,
+ 12, 0x2,
+ 17, 0x2,
+ 22, 0x2,
+ 3, 0x4,
+ 13, 0x4,
+ 8, 0x4,
+ 18, 0x4,
+ 0, 0x80,
+ 0, 0x100,
+ 2, 0x2,
+ 2, 0x1,
+ 3, 0x2,
+ 13, 0x2,
+ 3, 0x1,
+ 13, 0x1,
+ 8, 0x2,
+ 18, 0x2,
+ 8, 0x1,
+ 18, 0x1,
+ 6, 0x2,
+ 11, 0x2,
+ 16, 0x2,
+ 21, 0x2,
+ 7, 0x1,
+ 12, 0x1,
+ 17, 0x1,
+ 22, 0x1,
+ 6, 0x1,
+ 11, 0x1,
+ 16, 0x1,
+ 21, 0x1,
+ 15, 0x1,
+ 15, 0x2,
+ 15, 0x4,
+ 4, 0x2,
+ 9, 0x2,
+ 14, 0x2,
+ 19, 0x2,
+ 4, 0x10,
+ 9, 0x10,
+ 14, 0x10,
+ 19, 0x10,
+ 4, 0x80,
+ 9, 0x80,
+ 14, 0x80,
+ 19, 0x80,
+ 4, 0x800,
+ 9, 0x800,
+ 14, 0x800,
+ 19, 0x800,
+ 15, 0x8,
+ 20, 0x1,
+ 20, 0x2,
+ 20, 0x4,
+ 20, 0x8,
+ 10, 0x1,
+ 10, 0x2,
+ 10, 0x4,
+ 10, 0x8,
+ 5, 0x1,
+ 5, 0x2,
+ 5, 0x4,
+ 5, 0x8,
+ 4, 0x1,
+ 4, 0x4,
+ 4, 0x8,
+ 4, 0x20,
+ 4, 0x100,
+ 4, 0x1000,
+ 9, 0x1,
+ 9, 0x4,
+ 9, 0x8,
+ 9, 0x20,
+ 9, 0x100,
+ 9, 0x1000,
+ 14, 0x1,
+ 14, 0x4,
+ 14, 0x8,
+ 14, 0x20,
+ 14, 0x100,
+ 14, 0x1000,
+ 19, 0x1,
+ 19, 0x4,
+ 19, 0x8,
+ 19, 0x20,
+ 19, 0x100,
+ 19, 0x1000,
+ 4, 0x40,
+ 9, 0x40,
+ 14, 0x40,
+ 19, 0x40,
+ 4, 0x400,
+ 9, 0x400,
+ 14, 0x400,
+ 19, 0x400,
+ 4, 0x200,
+ 9, 0x200,
+ 14, 0x200,
+ 19, 0x200
+};
+static Word16 order_MR102[] =
+{
+ 0, 0x1,
+ 0, 0x2,
+ 0, 0x4,
+ 0, 0x8,
+ 0, 0x10,
+ 0, 0x20,
+ 0, 0x40,
+ 0, 0x80,
+ 1, 0x1,
+ 1, 0x2,
+ 1, 0x4,
+ 1, 0x8,
+ 1, 0x10,
+ 1, 0x20,
+ 1, 0x40,
+ 1, 0x80,
+ 1, 0x100,
+ 3, 0x80,
+ 3, 0x40,
+ 3, 0x20,
+ 3, 0x10,
+ 3, 0x8,
+ 3, 0x4,
+ 21, 0x80,
+ 21, 0x40,
+ 21, 0x20,
+ 21, 0x10,
+ 21, 0x8,
+ 21, 0x4,
+ 12, 0x10,
+ 12, 0x8,
+ 30, 0x10,
+ 30, 0x8,
+ 11, 0x40,
+ 11, 0x8,
+ 11, 0x4,
+ 20, 0x40,
+ 20, 0x8,
+ 20, 0x4,
+ 29, 0x40,
+ 29, 0x8,
+ 29, 0x4,
+ 38, 0x40,
+ 38, 0x8,
+ 38, 0x4,
+ 3, 0x2,
+ 3, 0x1,
+ 21, 0x2,
+ 21, 0x1,
+ 12, 0x4,
+ 12, 0x2,
+ 30, 0x4,
+ 30, 0x2,
+ 11, 0x20,
+ 20, 0x20,
+ 29, 0x20,
+ 38, 0x20,
+ 2, 0x40,
+ 2, 0x4,
+ 2, 0x10,
+ 2, 0x8,
+ 2, 0x80,
+ 2, 0x100,
+ 2, 0x20,
+ 2, 0x2,
+ 2, 0x1,
+ 7, 0x1,
+ 6, 0x1,
+ 5, 0x1,
+ 4, 0x1,
+ 16, 0x1,
+ 15, 0x1,
+ 14, 0x1,
+ 13, 0x1,
+ 25, 0x1,
+ 24, 0x1,
+ 23, 0x1,
+ 22, 0x1,
+ 34, 0x1,
+ 33, 0x1,
+ 32, 0x1,
+ 31, 0x1,
+ 11, 0x2,
+ 11, 0x10,
+ 11, 0x1,
+ 20, 0x2,
+ 20, 0x10,
+ 20, 0x1,
+ 29, 0x2,
+ 29, 0x10,
+ 29, 0x1,
+ 38, 0x2,
+ 38, 0x10,
+ 38, 0x1,
+ 12, 0x1,
+ 30, 0x1,
+ 17, 0x200,
+ 17, 0x100,
+ 18, 0x100,
+ 18, 0x200,
+ 18, 0x80,
+ 17, 0x80,
+ 18, 0x20,
+ 17, 0x20,
+ 17, 0x40,
+ 18, 0x40,
+ 19, 0x40,
+ 19, 0x20,
+ 18, 0x10,
+ 19, 0x8,
+ 17, 0x10,
+ 19, 0x10,
+ 17, 0x8,
+ 18, 0x8,
+ 26, 0x200,
+ 26, 0x100,
+ 27, 0x100,
+ 27, 0x200,
+ 27, 0x80,
+ 26, 0x80,
+ 27, 0x20,
+ 26, 0x20,
+ 26, 0x40,
+ 27, 0x40,
+ 28, 0x40,
+ 28, 0x20,
+ 27, 0x10,
+ 28, 0x8,
+ 26, 0x10,
+ 28, 0x10,
+ 26, 0x8,
+ 27, 0x8,
+ 35, 0x200,
+ 35, 0x100,
+ 36, 0x100,
+ 36, 0x200,
+ 36, 0x80,
+ 35, 0x80,
+ 36, 0x20,
+ 35, 0x20,
+ 35, 0x40,
+ 36, 0x40,
+ 37, 0x40,
+ 37, 0x20,
+ 36, 0x10,
+ 37, 0x8,
+ 35, 0x10,
+ 37, 0x10,
+ 35, 0x8,
+ 36, 0x8,
+ 8, 0x200,
+ 8, 0x100,
+ 9, 0x100,
+ 9, 0x200,
+ 9, 0x80,
+ 8, 0x80,
+ 9, 0x20,
+ 8, 0x20,
+ 8, 0x40,
+ 9, 0x40,
+ 10, 0x40,
+ 10, 0x20,
+ 9, 0x10,
+ 10, 0x8,
+ 8, 0x10,
+ 10, 0x10,
+ 8, 0x8,
+ 9, 0x8,
+ 37, 0x4,
+ 35, 0x1,
+ 36, 0x1,
+ 37, 0x1,
+ 35, 0x4,
+ 37, 0x2,
+ 35, 0x2,
+ 36, 0x4,
+ 36, 0x2,
+ 28, 0x4,
+ 26, 0x1,
+ 27, 0x1,
+ 28, 0x1,
+ 26, 0x4,
+ 28, 0x2,
+ 26, 0x2,
+ 27, 0x4,
+ 27, 0x2,
+ 19, 0x4,
+ 17, 0x1,
+ 18, 0x1,
+ 19, 0x1,
+ 17, 0x4,
+ 19, 0x2,
+ 17, 0x2,
+ 18, 0x4,
+ 18, 0x2,
+ 10, 0x4,
+ 8, 0x1,
+ 9, 0x1,
+ 10, 0x1,
+ 8, 0x4,
+ 10, 0x2,
+ 8, 0x2,
+ 9, 0x4,
+ 9, 0x2
+};
+static Word16 order_MR122[] =
+{
+ 0, 0x40,
+ 0, 0x20,
+ 0, 0x10,
+ 0, 0x8,
+ 0, 0x4,
+ 0, 0x2,
+ 0, 0x1,
+ 1, 0x80,
+ 1, 0x40,
+ 1, 0x20,
+ 1, 0x10,
+ 1, 0x8,
+ 1, 0x4,
+ 1, 0x2,
+ 1, 0x1,
+ 2, 0x1,
+ 2, 0x100,
+ 2, 0x80,
+ 2, 0x40,
+ 2, 0x20,
+ 2, 0x10,
+ 2, 0x8,
+ 2, 0x4,
+ 2, 0x2,
+ 3, 0x80,
+ 3, 0x40,
+ 3, 0x20,
+ 3, 0x10,
+ 3, 0x8,
+ 5, 0x100,
+ 31, 0x100,
+ 5, 0x80,
+ 31, 0x80,
+ 5, 0x40,
+ 31, 0x40,
+ 5, 0x20,
+ 31, 0x20,
+ 5, 0x10,
+ 31, 0x10,
+ 5, 0x8,
+ 31, 0x8,
+ 5, 0x4,
+ 31, 0x4,
+ 5, 0x2,
+ 31, 0x2,
+ 5, 0x1,
+ 31, 0x1,
+ 6, 0x8,
+ 19, 0x8,
+ 32, 0x8,
+ 45, 0x8,
+ 6, 0x4,
+ 19, 0x4,
+ 32, 0x4,
+ 45, 0x4,
+ 6, 0x2,
+ 19, 0x2,
+ 32, 0x2,
+ 45, 0x2,
+ 17, 0x10,
+ 30, 0x10,
+ 43, 0x10,
+ 56, 0x10,
+ 17, 0x8,
+ 30, 0x8,
+ 43, 0x8,
+ 56, 0x8,
+ 17, 0x4,
+ 30, 0x4,
+ 43, 0x4,
+ 56, 0x4,
+ 18, 0x20,
+ 44, 0x20,
+ 18, 0x10,
+ 44, 0x10,
+ 18, 0x8,
+ 44, 0x8,
+ 18, 0x4,
+ 44, 0x4,
+ 18, 0x2,
+ 44, 0x2,
+ 3, 0x4,
+ 3, 0x2,
+ 3, 0x1,
+ 4, 0x20,
+ 4, 0x10,
+ 4, 0x8,
+ 4, 0x4,
+ 6, 0x1,
+ 19, 0x1,
+ 32, 0x1,
+ 45, 0x1,
+ 17, 0x2,
+ 30, 0x2,
+ 43, 0x2,
+ 56, 0x2,
+ 7, 0x8,
+ 20, 0x8,
+ 33, 0x8,
+ 46, 0x8,
+ 8, 0x8,
+ 21, 0x8,
+ 34, 0x8,
+ 47, 0x8,
+ 17, 0x1,
+ 30, 0x1,
+ 43, 0x1,
+ 56, 0x1,
+ 9, 0x8,
+ 22, 0x8,
+ 35, 0x8,
+ 48, 0x8,
+ 10, 0x8,
+ 23, 0x8,
+ 36, 0x8,
+ 49, 0x8,
+ 11, 0x8,
+ 24, 0x8,
+ 37, 0x8,
+ 50, 0x8,
+ 4, 0x2,
+ 4, 0x1,
+ 7, 0x1,
+ 7, 0x2,
+ 7, 0x4,
+ 8, 0x1,
+ 8, 0x2,
+ 8, 0x4,
+ 9, 0x1,
+ 9, 0x2,
+ 9, 0x4,
+ 10, 0x1,
+ 10, 0x2,
+ 10, 0x4,
+ 11, 0x1,
+ 11, 0x2,
+ 11, 0x4,
+ 20, 0x1,
+ 20, 0x2,
+ 20, 0x4,
+ 21, 0x1,
+ 21, 0x2,
+ 21, 0x4,
+ 22, 0x1,
+ 22, 0x2,
+ 22, 0x4,
+ 23, 0x1,
+ 23, 0x2,
+ 23, 0x4,
+ 24, 0x1,
+ 24, 0x2,
+ 24, 0x4,
+ 33, 0x1,
+ 33, 0x2,
+ 33, 0x4,
+ 34, 0x1,
+ 34, 0x2,
+ 34, 0x4,
+ 35, 0x1,
+ 35, 0x2,
+ 35, 0x4,
+ 36, 0x1,
+ 36, 0x2,
+ 36, 0x4,
+ 37, 0x1,
+ 37, 0x2,
+ 37, 0x4,
+ 46, 0x1,
+ 46, 0x2,
+ 46, 0x4,
+ 47, 0x1,
+ 47, 0x2,
+ 47, 0x4,
+ 48, 0x1,
+ 48, 0x2,
+ 48, 0x4,
+ 49, 0x1,
+ 49, 0x2,
+ 49, 0x4,
+ 50, 0x1,
+ 50, 0x2,
+ 50, 0x4,
+ 12, 0x1,
+ 12, 0x2,
+ 12, 0x4,
+ 13, 0x1,
+ 13, 0x2,
+ 13, 0x4,
+ 14, 0x1,
+ 14, 0x2,
+ 14, 0x4,
+ 15, 0x1,
+ 15, 0x2,
+ 15, 0x4,
+ 16, 0x1,
+ 16, 0x2,
+ 16, 0x4,
+ 25, 0x1,
+ 25, 0x2,
+ 25, 0x4,
+ 26, 0x1,
+ 26, 0x2,
+ 26, 0x4,
+ 27, 0x1,
+ 27, 0x2,
+ 27, 0x4,
+ 28, 0x1,
+ 28, 0x2,
+ 28, 0x4,
+ 29, 0x1,
+ 29, 0x2,
+ 29, 0x4,
+ 38, 0x1,
+ 38, 0x2,
+ 38, 0x4,
+ 39, 0x1,
+ 39, 0x2,
+ 39, 0x4,
+ 40, 0x1,
+ 40, 0x2,
+ 40, 0x4,
+ 41, 0x1,
+ 41, 0x2,
+ 41, 0x4,
+ 42, 0x1,
+ 42, 0x2,
+ 42, 0x4,
+ 51, 0x1,
+ 51, 0x2,
+ 51, 0x4,
+ 52, 0x1,
+ 52, 0x2,
+ 52, 0x4,
+ 53, 0x1,
+ 53, 0x2,
+ 53, 0x4,
+ 54, 0x1,
+ 54, 0x2,
+ 54, 0x4,
+ 55, 0x1,
+ 55, 0x2,
+ 55, 0x4,
+ 18, 0x1,
+ 44, 0x1
+};
+static Word16 order_MRDTX[] =
+{
+ 0, 0x4,
+ 0, 0x2,
+ 0, 0x1,
+ 1, 0x80,
+ 1, 0x40,
+ 1, 0x20,
+ 1, 0x10,
+ 1, 0x8,
+ 1, 0x4,
+ 1, 0x2,
+ 1, 0x1,
+ 2, 0x100,
+ 2, 0x80,
+ 2, 0x40,
+ 2, 0x20,
+ 2, 0x10,
+ 2, 0x8,
+ 2, 0x4,
+ 2, 0x2,
+ 2, 0x1,
+ 3, 0x100,
+ 3, 0x80,
+ 3, 0x40,
+ 3, 0x20,
+ 3, 0x10,
+ 3, 0x8,
+ 3, 0x4,
+ 3, 0x2,
+ 3, 0x1,
+ 4, 0x20,
+ 4, 0x10,
+ 4, 0x8,
+ 4, 0x4,
+ 4, 0x2,
+ 4, 0x1
+};
+
+/* Homing frames for the decoder */
+static const Word16 dhf_MR475[PRMNO_MR475] =
+{
+ 0x00F8,
+ 0x009D,
+ 0x001C,
+ 0x0066,
+ 0x0000,
+ 0x0003,
+ 0x0028,
+ 0x000F,
+ 0x0038,
+ 0x0001,
+ 0x000F,
+ 0x0031,
+ 0x0002,
+ 0x0008,
+ 0x000F,
+ 0x0026,
+ 0x0003
+};
+static const Word16 dhf_MR515[PRMNO_MR515] =
+{
+ 0x00F8,
+ 0x009D,
+ 0x001C,
+ 0x0066,
+ 0x0000,
+ 0x0003,
+ 0x0037,
+ 0x000F,
+ 0x0000,
+ 0x0003,
+ 0x0005,
+ 0x000F,
+ 0x0037,
+ 0x0003,
+ 0x0037,
+ 0x000F,
+ 0x0023,
+ 0x0003,
+ 0x001F
+};
+static const Word16 dhf_MR59[PRMNO_MR59] =
+{
+ 0x00F8,
+ 0x00E3,
+ 0x002F,
+ 0x00BD,
+ 0x0000,
+ 0x0003,
+ 0x0037,
+ 0x000F,
+ 0x0001,
+ 0x0003,
+ 0x000F,
+ 0x0060,
+ 0x00F9,
+ 0x0003,
+ 0x0037,
+ 0x000F,
+ 0x0000,
+ 0x0003,
+ 0x0037
+};
+static const Word16 dhf_MR67[PRMNO_MR67] =
+{
+ 0x00F8,
+ 0x00E3,
+ 0x002F,
+ 0x00BD,
+ 0x0002,
+ 0x0007,
+ 0x0000,
+ 0x000F,
+ 0x0098,
+ 0x0007,
+ 0x0061,
+ 0x0060,
+ 0x05C5,
+ 0x0007,
+ 0x0000,
+ 0x000F,
+ 0x0318,
+ 0x0007,
+ 0x0000
+};
+static const Word16 dhf_MR74[PRMNO_MR74] =
+{
+ 0x00F8,
+ 0x00E3,
+ 0x002F,
+ 0x00BD,
+ 0x0006,
+ 0x000F,
+ 0x0000,
+ 0x001B,
+ 0x0208,
+ 0x000F,
+ 0x0062,
+ 0x0060,
+ 0x1BA6,
+ 0x000F,
+ 0x0000,
+ 0x001B,
+ 0x0006,
+ 0x000F,
+ 0x0000
+};
+static const Word16 dhf_MR795[PRMNO_MR795] =
+{
+ 0x00C2,
+ 0x00E3,
+ 0x002F,
+ 0x00BD,
+ 0x0006,
+ 0x000F,
+ 0x000A,
+ 0x0000,
+ 0x0039,
+ 0x1C08,
+ 0x0007,
+ 0x000A,
+ 0x000B,
+ 0x0063,
+ 0x11A6,
+ 0x000F,
+ 0x0001,
+ 0x0000,
+ 0x0039,
+ 0x09A0,
+ 0x000F,
+ 0x0002,
+ 0x0001
+};
+static const Word16 dhf_MR102[PRMNO_MR102] =
+{
+ 0x00F8,
+ 0x00E3,
+ 0x002F,
+ 0x0045,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x001B,
+ 0x0000,
+ 0x0001,
+ 0x0000,
+ 0x0001,
+ 0x0326,
+ 0x00CE,
+ 0x007E,
+ 0x0051,
+ 0x0062,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x015A,
+ 0x0359,
+ 0x0076,
+ 0x0000,
+ 0x001B,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x017C,
+ 0x0215,
+ 0x0038,
+ 0x0030
+};
+static const Word16 dhf_MR122[PRMNO_MR122] =
+{
+ 0x0004,
+ 0x002A,
+ 0x00DB,
+ 0x0096,
+ 0x002A,
+ 0x0156,
+ 0x000B,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0036,
+ 0x000B,
+ 0x0000,
+ 0x000F,
+ 0x000E,
+ 0x000C,
+ 0x000D,
+ 0x0000,
+ 0x0001,
+ 0x0005,
+ 0x0007,
+ 0x0001,
+ 0x0008,
+ 0x0024,
+ 0x0000,
+ 0x0001,
+ 0x0000,
+ 0x0005,
+ 0x0006,
+ 0x0001,
+ 0x0002,
+ 0x0004,
+ 0x0007,
+ 0x0004,
+ 0x0002,
+ 0x0003,
+ 0x0036,
+ 0x000B,
+ 0x0000,
+ 0x0002,
+ 0x0004,
+ 0x0000,
+ 0x0003,
+ 0x0006,
+ 0x0001,
+ 0x0007,
+ 0x0006,
+ 0x0005,
+ 0x0000
+};
+
+
+/* parameter sizes (# of bits), one table per mode */
+static const Word16 bitno_MR475[PRMNO_MR475] =
+{
+ 8, 8, 7, /* LSP VQ */
+ 8, 7, 2, 8, /* first subframe */
+ 4, 7, 2, /* second subframe */
+ 4, 7, 2, 8, /* third subframe */
+ 4, 7, 2 /* fourth subframe */
+};
+static const Word16 bitno_MR515[PRMNO_MR515] =
+{
+ 8, 8, 7, /* LSP VQ */
+ 8, 7, 2, 6, /* first subframe */
+ 4, 7, 2, 6, /* second subframe */
+ 4, 7, 2, 6, /* third subframe */
+ 4, 7, 2, 6 /* fourth subframe */
+};
+static const Word16 bitno_MR59[PRMNO_MR59] =
+{
+ 8, 9, 9, /* LSP VQ */
+ 8, 9, 2, 6, /* first subframe */
+ 4, 9, 2, 6, /* second subframe */
+ 8, 9, 2, 6, /* third subframe */
+ 4, 9, 2, 6 /* fourth subframe */
+};
+static const Word16 bitno_MR67[PRMNO_MR67] =
+{
+ 8, 9, 9, /* LSP VQ */
+ 8, 11, 3, 7, /* first subframe */
+ 4, 11, 3, 7, /* second subframe */
+ 8, 11, 3, 7, /* third subframe */
+ 4, 11, 3, 7 /* fourth subframe */
+};
+static const Word16 bitno_MR74[PRMNO_MR74] =
+{
+ 8, 9, 9, /* LSP VQ */
+ 8, 13, 4, 7, /* first subframe */
+ 5, 13, 4, 7, /* second subframe */
+ 8, 13, 4, 7, /* third subframe */
+ 5, 13, 4, 7 /* fourth subframe */
+};
+static const Word16 bitno_MR795[PRMNO_MR795] =
+{
+ 9, 9, 9, /* LSP VQ */
+ 8, 13, 4, 4, 5, /* first subframe */
+ 6, 13, 4, 4, 5, /* second subframe */
+ 8, 13, 4, 4, 5, /* third subframe */
+ 6, 13, 4, 4, 5 /* fourth subframe */
+};
+static const Word16 bitno_MR102[PRMNO_MR102] =
+{
+ 8, 9, 9, /* LSP VQ */
+ 8, 1, 1, 1, 1, 10, 10, 7, 7, /* first subframe */
+ 5, 1, 1, 1, 1, 10, 10, 7, 7, /* second subframe */
+ 8, 1, 1, 1, 1, 10, 10, 7, 7, /* third subframe */
+ 5, 1, 1, 1, 1, 10, 10, 7, 7 /* fourth subframe */
+};
+static const Word16 bitno_MR122[PRMNO_MR122] =
+{
+ 7, 8, 9, 8, 6, /* LSP VQ */
+ 9, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 5, /* first subframe */
+ 6, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 5, /* second subframe */
+ 9, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 5, /* third subframe */
+ 6, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 5 /* fourth subframe */
+};
+static const Word16 bitno_MRDTX[PRMNO_MRDTX] =
+{
+ 3, 8, 9, 9, 6
+};
+
+#endif
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/rom_dec.h b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/rom_dec.h
new file mode 100644
index 000000000..1b8b0b7ef
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/rom_dec.h
@@ -0,0 +1,13310 @@
+/*
+ * ===================================================================
+ * TS 26.104
+ * REL-5 V5.4.0 2004-03
+ * REL-6 V6.1.0 2004-03
+ * 3GPP AMR Floating-point Speech Codec
+ * ===================================================================
+ *
+ */
+
+/*
+ * rom_dec.h
+ *
+ *
+ * Project:
+ * AMR Floating-Point Codec
+ *
+ * Contains:
+ * This file contains all the tables needed by AMR decoder functions.
+ *
+ */
+
+#ifndef _ROM_DEC_H_
+#define _ROM_DEC_H_
+
+/*
+ * include files
+ */
+#include"typedef.h"
+#include"interf_rom.h"
+
+/*
+ * definition of constants
+ */
+#define M 10 /* Order of LP filter */
+#define MP1 (M+1) /* Order of LP filter + 1 */
+#define L_WINDOW 240 /* Window size in LP analysis */
+#define L_NEXT 40 /* Overhead in LP analysis */
+#define LTPG_MEM_SIZE 5 /* number of stored past LTP coding gains + 1 */
+#define N_FRAME 7 /* old pitch gains in average calculation */
+#define DTX_HIST_SIZE 8 /* DTX history size */
+#define L_TOTAL 320 /* Total size of speech buffer. */
+#define L_FRAME 160 /* Frame size */
+#define L_FRAME_BY2 80 /* Frame size divided by 2 */
+#define L_SUBFR 40 /* Subframe size */
+#define L_CODE 40 /* codevector length */
+#define PIT_MAX 143 /* Maximum pitch lag */
+#define PIT_MIN 20 /* Minimum pitch lag */
+#define PIT_MIN_MR122 18 /* Minimum pitch lag (MR122 mode) */
+#define L_INTERPOL (10+1) /* Length of filter for interpolation */
+#define NPRED 4 /* number of prediction taps */
+#define SHARPMIN 0 /* Minimum value of pitch sharpening */
+#define MAX_PRM_SIZE 57 /* max. num. of params */
+#define L_INTER_SRCH 4 /* Length of filter for CL LTP search interpolation */
+#define GP_CLIP 0.95F /* Pitch gain clipping */
+#define UP_SAMP_MAX 6
+#define NB_TRACK 5 /* number of tracks */
+#define NB_TRACK_MR102 4 /* number of tracks mode mr102 */
+#define STEP 5 /* codebook step size */
+#define STEP_MR102 4 /* codebook step size mode mr102 */
+#define NC M/2 /* Order of LP filter divided by 2 */
+
+/* vad */
+#define COMPLEN 9 /* Number of sub-bands used by VAD */
+#define L_ENERGYHIST 60
+#define L_CBGAINHIST 7
+#define PHDGAINMEMSIZE 5
+#define MIN_ENERGY -14336 /* 14 Q10 */
+#define MIN_ENERGY_MR122 -2381 /* 14 / (20*log10(2)) Q10 */
+#define PN_INITIAL_SEED 0x70816958L /* Pseudo noise generator seed value */
+#define MIN_16 (Word16)-32768
+#define MAX_16 (Word16)0x7fff
+#define MAX_32 (Word32)0x7fffffffL
+#define EXPCONST 5243 /* 0.16 in Q15 */
+#define DTX_MAX_EMPTY_THRESH 50
+#define DTX_ELAPSED_FRAMES_THRESH (24 + 7 -1)
+#define LSF_GAP 205 /* Minimum distance between LSF after quantization; 50 Hz = 205 */
+#define LSP_PRED_FAC_MR122 21299 /* MR122 LSP prediction factor (0.65 Q15) */
+#define POS_CODE 8191
+#define NEG_CODE 8191
+#define NMAX 9 /* largest N used in median calculation */
+#define MEAN_ENER_MR122 783741L /* 36/(20*log10(2)) (Q17) */
+#define SHARPMAX 13017 /* Maximum value of pitch sharpening */
+#define FRAMEENERGYLIMIT 17578 /* 150 */
+#define LOWERNOISELIMIT 20 /* 5 */
+#define UPPERNOISELIMIT 1953 /* 50 */
+#define AZ_SIZE (4*M+4) /* Size of array of LP filters in 4 subfr.s */
+#define AGC_FAC 29491 /* Factor for automatic gain control 0.9 */
+#define PHDGAINMEMSIZE 5
+#define PHDTHR1LTP 9830 /* 0.6 in Q14 */
+#define PHDTHR2LTP 14746 /* 0.9 in Q14 */
+#define ONFACTPLUS1 16384 /* 2.0 in Q13 */
+#define ONLENGTH 2
+#define DTX_HANG_CONST 7 /* yields eight frames of SP HANGOVER */
+
+/* number of parameters */
+#define PRMNO_MR475 17
+#define PRMNO_MR515 19
+#define PRMNO_MR59 19
+#define PRMNO_MR67 19
+#define PRMNO_MR74 19
+#define PRMNO_MR795 23
+#define PRMNO_MR102 39
+#define PRMNO_MR122 57
+#define PRMNO_MRDTX 5
+
+/*
+ * tables
+ */
+
+/* level adjustment for different modes Q11 */
+static const Word16 dtx_log_en_adjust[9] =
+{
+ - 1023,
+ /* MR475 */ - 878,
+ /* MR515 */ - 732,
+ /* MR59 */ - 586,
+ /* MR67 */ - 440,
+ /* MR74 */ - 294,
+ /* MR795 */ - 148,
+ /* MR102 */ 0,
+ /* MR122 */ 0,
+ /* MRDTX */
+};
+
+/* attenuation factors for codebook gain */
+static const Word32 cdown[7] =
+ {
+ 32767,
+ 32112,
+ 32112,
+ 32112,
+ 32112,
+ 32112,
+ 22937
+ };
+
+/* attenuation factors for adaptive codebook gain */
+static const Word32 pdown[7] =
+ {
+ 32767,
+ 32112,
+ 32112,
+ 26214,
+ 9830,
+ 6553,
+ 6553
+ };
+
+/* algebraic code book gain MA predictor coefficients */
+static const Word32 pred[NPRED] =
+{
+ 5571,
+ 4751,
+ 2785,
+ 1556
+};
+
+/* algebraic code book gain MA predictor coefficients (MR122) */
+static const Word32 pred_MR122[NPRED] =
+{
+ 44,
+ 37,
+ 22,
+ 12
+};
+
+static const Word32 gamma4_gamma3_MR122[M] =
+{
+ 22938,
+ 16057,
+ 11240,
+ 7868,
+ 5508,
+ 3856,
+ 2699,
+ 1889,
+ 1322,
+ 925
+};
+static const Word32 gamma3[M] =
+{
+ 18022,
+ 9912,
+ 5451,
+ 2998,
+ 1649,
+ 907,
+ 499,
+ 274,
+ 151,
+ 83
+};
+static const Word32 gamma4_MR122[M] =
+{
+ 24576,
+ 18432,
+ 13824,
+ 10368,
+ 7776,
+ 5832,
+ 4374,
+ 3281,
+ 2461,
+ 1846
+};
+
+
+/* adaptive codebook gain quantization table (MR122, MR795) */
+#define NB_QUA_PITCH 16
+static const Word32 qua_gain_pitch[NB_QUA_PITCH] =
+{
+ 0,
+ 3277,
+ 6556,
+ 8192,
+ 9830,
+ 11469,
+ 12288,
+ 13107,
+ 13926,
+ 14746,
+ 15565,
+ 16384,
+ 17203,
+ 18022,
+ 18842,
+ 19661
+};
+
+/* fixed codebook gain quantization table (MR122, MR795) */
+#define NB_QUA_CODE 32
+static const Word32 qua_gain_code[NB_QUA_CODE * 3] =
+{
+/* gain factor (g_fac) and quantized energy error (qua_ener_MR122, qua_ener)
+ * are stored:
+ *
+ * qua_ener_MR122 = log2(g_fac) (not the rounded floating point value, but
+ * the value the original EFR algorithm
+ * calculates from g_fac [using Log2])
+ * qua_ener = 20*log10(g_fac); (rounded floating point value)
+ *
+ *
+ * g_fac (Q11),
+ * qua_ener_MR122 (Q10),
+ * qua_ener (Q10)
+ */ 159,
+ - 3776,
+ - 22731,
+ 206,
+ - 3394,
+ - 20428,
+ 268,
+ - 3005,
+ - 18088,
+ 349,
+ - 2615,
+ - 15739,
+ 419,
+ - 2345,
+ - 14113,
+ 482,
+ - 2138,
+ - 12867,
+ 554,
+ - 1932,
+ - 11629,
+ 637,
+ - 1726,
+ - 10387,
+ 733,
+ - 1518,
+ - 9139,
+ 842,
+ - 1314,
+ - 7906,
+ 969,
+ - 1106,
+ - 6656,
+ 1114,
+ - 900,
+ - 5416,
+ 1281,
+ - 694,
+ - 4173,
+ 1473,
+ - 487,
+ - 2931,
+ 1694,
+ - 281,
+ - 1688,
+ 1948,
+ - 75,
+ - 445,
+ 2241,
+ 133,
+ 801,
+ 2577,
+ 339,
+ 2044,
+ 2963,
+ 545,
+ 3285,
+ 3408,
+ 752,
+ 4530,
+ 3919,
+ 958,
+ 5772,
+ 4507,
+ 1165,
+ 7016,
+ 5183,
+ 1371,
+ 8259,
+ 5960,
+ 1577,
+ 9501,
+ 6855,
+ 1784,
+ 10745,
+ 7883,
+ 1991,
+ 11988,
+ 9065,
+ 2197,
+ 13231,
+ 10425,
+ 2404,
+ 14474,
+ 12510,
+ 2673,
+ 16096,
+ 16263,
+ 3060,
+ 18429,
+ 21142,
+ 3448,
+ 20763,
+ 27485,
+ 3836,
+ 23097
+};
+
+/* gray coding table */
+static const Word8 gray[8] =
+{
+ 0,
+ 1,
+ 3,
+ 2,
+ 6,
+ 4,
+ 5,
+ 7
+};
+
+/* gray decoding table */
+static const Word32 dgray[8] =
+{
+ 0,
+ 1,
+ 3,
+ 2,
+ 5,
+ 6,
+ 4,
+ 7
+};
+
+/* table[i] = sqrt((i+16)*2^-6) * 2^15, i.e. sqrt(x) scaled Q15 */
+static const Word32 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
+};
+
+static const Word32 inv_sqrt_table[49] =
+{
+ 32767,
+ 31790,
+ 30894,
+ 30070,
+ 29309,
+ 28602,
+ 27945,
+ 27330,
+ 26755,
+ 26214,
+ 25705,
+ 25225,
+ 24770,
+ 24339,
+ 23930,
+ 23541,
+ 23170,
+ 22817,
+ 22479,
+ 22155,
+ 21845,
+ 21548,
+ 21263,
+ 20988,
+ 20724,
+ 20470,
+ 20225,
+ 19988,
+ 19760,
+ 19539,
+ 19326,
+ 19119,
+ 18919,
+ 18725,
+ 18536,
+ 18354,
+ 18176,
+ 18004,
+ 17837,
+ 17674,
+ 17515,
+ 17361,
+ 17211,
+ 17064,
+ 16921,
+ 16782,
+ 16646,
+ 16514,
+ 16384
+};
+/* table used inbase 2 logharithm computation */
+static const Word32 log2_table[33] =
+{
+ 0,
+ 1455,
+ 2866,
+ 4236,
+ 5568,
+ 6863,
+ 8124,
+ 9352,
+ 10549,
+ 11716,
+ 12855,
+ 13967,
+ 15054,
+ 16117,
+ 17156,
+ 18172,
+ 19167,
+ 20142,
+ 21097,
+ 22033,
+ 22951,
+ 23852,
+ 24735,
+ 25603,
+ 26455,
+ 27291,
+ 28113,
+ 28922,
+ 29716,
+ 30497,
+ 31266,
+ 32023,
+ 32767
+};
+
+/* table used in 2 to the power computation */
+static const Word32 pow2_table[33] =
+{
+ 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,
+ 32767
+};
+
+/* table of cos(x) */
+static const Word32 cos_table[65] =
+{
+ 32767,
+ 32729,
+ 32610,
+ 32413,
+ 32138,
+ 31786,
+ 31357,
+ 30853,
+ 30274,
+ 29622,
+ 28899,
+ 28106,
+ 27246,
+ 26320,
+ 25330,
+ 24279,
+ 23170,
+ 22006,
+ 20788,
+ 19520,
+ 18205,
+ 16846,
+ 15447,
+ 14010,
+ 12540,
+ 11039,
+ 9512,
+ 7962,
+ 6393,
+ 4808,
+ 3212,
+ 1608,
+ 0,
+ - 1608,
+ - 3212,
+ - 4808,
+ - 6393,
+ - 7962,
+ - 9512,
+ - 11039,
+ - 12540,
+ - 14010,
+ - 15447,
+ - 16846,
+ - 18205,
+ - 19520,
+ - 20788,
+ - 22006,
+ - 23170,
+ - 24279,
+ - 25330,
+ - 26320,
+ - 27246,
+ - 28106,
+ - 28899,
+ - 29622,
+ - 30274,
+ - 30853,
+ - 31357,
+ - 31786,
+ - 32138,
+ - 32413,
+ - 32610,
+ - 32729,
+ - 32768
+};
+
+/* slope used to compute y = acos(x) */
+static const Word32 acos_slope[64] =
+{
+ - 26887,
+ - 8812,
+ - 5323,
+ - 3813,
+ - 2979,
+ - 2444,
+ - 2081,
+ - 1811,
+ - 1608,
+ - 1450,
+ - 1322,
+ - 1219,
+ - 1132,
+ - 1059,
+ - 998,
+ - 946,
+ - 901,
+ - 861,
+ - 827,
+ - 797,
+ - 772,
+ - 750,
+ - 730,
+ - 713,
+ - 699,
+ - 687,
+ - 677,
+ - 668,
+ - 662,
+ - 657,
+ - 654,
+ - 652,
+ - 652,
+ - 654,
+ - 657,
+ - 662,
+ - 668,
+ - 677,
+ - 687,
+ - 699,
+ - 713,
+ - 730,
+ - 750,
+ - 772,
+ - 797,
+ - 827,
+ - 861,
+ - 901,
+ - 946,
+ - 998,
+ - 1059,
+ - 1132,
+ - 1219,
+ - 1322,
+ - 1450,
+ - 1608,
+ - 1811,
+ - 2081,
+ - 2444,
+ - 2979,
+ - 3813,
+ - 5323,
+ - 8812,
+ - 26887
+};
+
+/* All impulse responses are in Q15 */
+/* phase dispersion impulse response (MR795) */
+static const Word32 ph_imp_low_MR795[] =
+{
+ 26777,
+ 801,
+ 2505,
+ - 683,
+ - 1382,
+ 582,
+ 604,
+ - 1274,
+ 3511,
+ - 5894,
+ 4534,
+ - 499,
+ - 1940,
+ 3011,
+ - 5058,
+ 5614,
+ - 1990,
+ - 1061,
+ - 1459,
+ 4442,
+ - 700,
+ - 5335,
+ 4609,
+ 452,
+ - 589,
+ - 3352,
+ 2953,
+ 1267,
+ - 1212,
+ - 2590,
+ 1731,
+ 3670,
+ - 4475,
+ - 975,
+ 4391,
+ - 2537,
+ 949,
+ - 1363,
+ - 979,
+ 5734
+};
+/* phase dispersion impulse response (MR795) */
+static const Word32 ph_imp_mid_MR795[] =
+{
+ 30274,
+ 3831,
+ - 4036,
+ 2972,
+ - 1048,
+ - 1002,
+ 2477,
+ - 3043,
+ 2815,
+ - 2231,
+ 1753,
+ - 1611,
+ 1714,
+ - 1775,
+ 1543,
+ - 1008,
+ 429,
+ - 169,
+ 472,
+ - 1264,
+ 2176,
+ - 2706,
+ 2523,
+ - 1621,
+ 344,
+ 826,
+ - 1529,
+ 1724,
+ - 1657,
+ 1701,
+ - 2063,
+ 2644,
+ - 3060,
+ 2897,
+ - 1978,
+ 557,
+ 780,
+ - 1369,
+ 842,
+ 655
+};
+
+/* phase dispersion impulse response (MR475 - MR67) */
+static const Word32 ph_imp_low[] =
+{
+ 14690,
+ 11518,
+ 1268,
+ - 2761,
+ - 5671,
+ 7514,
+ - 35,
+ - 2807,
+ - 3040,
+ 4823,
+ 2952,
+ - 8424,
+ 3785,
+ 1455,
+ 2179,
+ - 8637,
+ 8051,
+ - 2103,
+ - 1454,
+ 777,
+ 1108,
+ - 2385,
+ 2254,
+ - 363,
+ - 674,
+ - 2103,
+ 6046,
+ - 5681,
+ 1072,
+ 3123,
+ - 5058,
+ 5312,
+ - 2329,
+ - 3728,
+ 6924,
+ - 3889,
+ 675,
+ - 1775,
+ 29,
+ 10145
+};
+
+/* phase dispersion impulse response (MR475 - MR67) */
+static const Word32 ph_imp_mid[] =
+{
+ 30274,
+ 3831,
+ - 4036,
+ 2972,
+ - 1048,
+ - 1002,
+ 2477,
+ - 3043,
+ 2815,
+ - 2231,
+ 1753,
+ - 1611,
+ 1714,
+ - 1775,
+ 1543,
+ - 1008,
+ 429,
+ - 169,
+ 472,
+ - 1264,
+ 2176,
+ - 2706,
+ 2523,
+ - 1621,
+ 344,
+ 826,
+ - 1529,
+ 1724,
+ - 1657,
+ 1701,
+ - 2063,
+ 2644,
+ - 3060,
+ 2897,
+ - 1978,
+ 557,
+ 780,
+ - 1369,
+ 842,
+ 655
+};
+
+/* initialization table for the MA predictor in DTX */
+#define PAST_RQ_INIT_SIZE 8
+
+/* initalization table for MA predictor in dtx mode */
+static const Word32 past_rq_init[80] =
+{
+ - 258,
+ - 318,
+ - 439,
+ - 634,
+ - 656,
+ - 773,
+ - 711,
+ - 502,
+ - 268,
+ - 193,
+ - 2,
+ 125,
+ 122,
+ - 39,
+ - 9,
+ 105,
+ 129,
+ 283,
+ 372,
+ 575,
+ - 277,
+ - 324,
+ - 197,
+ - 487,
+ - 445,
+ - 362,
+ - 292,
+ - 27,
+ 177,
+ 543,
+ 342,
+ 517,
+ 516,
+ 130,
+ 27,
+ - 104,
+ - 120,
+ - 140,
+ - 74,
+ - 56,
+ - 564,
+ - 943,
+ - 1520,
+ - 965,
+ - 814,
+ - 526,
+ - 322,
+ - 2,
+ 159,
+ 657,
+ - 312,
+ - 284,
+ - 386,
+ - 597,
+ - 493,
+ - 526,
+ - 418,
+ - 229,
+ 105,
+ 449,
+ - 557,
+ - 870,
+ - 1075,
+ - 919,
+ - 950,
+ - 752,
+ - 709,
+ - 316,
+ 62,
+ 486,
+ - 314,
+ - 191,
+ - 203,
+ - 330,
+ - 160,
+ - 103,
+ - 51,
+ 131,
+ 338,
+ 515
+};
+
+#define ALPHA 29491
+#define ONE_ALPHA 3277
+/* LSF means (not in MR122) */
+static const Word32 mean_lsf_3[10] =
+{
+ 1546,
+ 2272,
+ 3778,
+ 5488,
+ 6972,
+ 8382,
+ 10047,
+ 11229,
+ 12766,
+ 13714
+};
+
+#define ALPHA_122 31128
+#define ONE_ALPHA_122 1639
+/* LSF means ->normalize frequency domain */
+static const Word32 mean_lsf_5[10] =
+{
+ 1384,
+ 2077,
+ 3420,
+ 5108,
+ 6742,
+ 8122,
+ 9863,
+ 11092,
+ 12714,
+ 13701
+};
+
+/* LSF prediction factors (not in MR122) */
+static const Word32 pred_fac[10] =
+{
+ 9556,
+ 10769,
+ 12571,
+ 13292,
+ 14381,
+ 11651,
+ 10588,
+ 9767,
+ 8593,
+ 6484
+};
+#define DICO1_SIZE_3 256
+#define DICO2_SIZE_3 512
+#define DICO3_SIZE_3 512
+
+/* 1st LSF quantizer (not in MR122 and MR795) */
+static const Word32 dico1_lsf_3[] =
+{
+ 6,
+ 82,
+ - 131,
+ 154,
+ - 56,
+ - 735,
+ 183,
+ - 65,
+ - 265,
+ 9,
+ - 210,
+ - 361,
+ 113,
+ 718,
+ 1817,
+ 1010,
+ 1214,
+ 1573,
+ 857,
+ 1333,
+ 2276,
+ 827,
+ 1568,
+ 1933,
+ 717,
+ 1989,
+ 2206,
+ 838,
+ 1172,
+ 1823,
+ 721,
+ 1000,
+ 2154,
+ 286,
+ 476,
+ 1509,
+ - 247,
+ - 531,
+ 230,
+ 147,
+ - 82,
+ 569,
+ 26,
+ - 177,
+ - 944,
+ - 27,
+ - 273,
+ 692,
+ - 164,
+ - 264,
+ - 183,
+ 224,
+ 790,
+ 1039,
+ 899,
+ 946,
+ 601,
+ 485,
+ 771,
+ 1150,
+ 524,
+ 677,
+ 903,
+ - 140,
+ 375,
+ 778,
+ 410,
+ 676,
+ 429,
+ 301,
+ 530,
+ 1009,
+ 719,
+ 646,
+ 38,
+ 226,
+ 367,
+ 40,
+ 145,
+ - 45,
+ - 505,
+ 290,
+ 121,
+ - 121,
+ 302,
+ 127,
+ 166,
+ - 124,
+ - 383,
+ - 956,
+ - 358,
+ - 455,
+ - 977,
+ 715,
+ 878,
+ 894,
+ 978,
+ 923,
+ 211,
+ 477,
+ 272,
+ 64,
+ 188,
+ - 78,
+ 17,
+ - 143,
+ - 65,
+ 38,
+ 643,
+ 586,
+ 621,
+ - 134,
+ - 426,
+ - 651,
+ 347,
+ 545,
+ 2820,
+ 1188,
+ 2726,
+ 2442,
+ 142,
+ - 80,
+ 1735,
+ 283,
+ 130,
+ 461,
+ - 262,
+ - 399,
+ - 1145,
+ - 411,
+ 155,
+ 430,
+ 329,
+ 375,
+ 779,
+ 53,
+ - 226,
+ - 139,
+ - 129,
+ - 236,
+ 1682,
+ 285,
+ 744,
+ 1327,
+ 738,
+ 697,
+ 1664,
+ 312,
+ 409,
+ 266,
+ 325,
+ 720,
+ 135,
+ 1,
+ 221,
+ 453,
+ 8,
+ 203,
+ 145,
+ 299,
+ 640,
+ 760,
+ 29,
+ 468,
+ 638,
+ 103,
+ 429,
+ 379,
+ 420,
+ 954,
+ 932,
+ 1326,
+ 1210,
+ 1258,
+ 704,
+ 1012,
+ 1152,
+ - 166,
+ - 444,
+ - 266,
+ - 316,
+ - 130,
+ - 376,
+ 191,
+ 1151,
+ 1904,
+ - 240,
+ - 543,
+ - 1260,
+ - 112,
+ 268,
+ 1207,
+ 70,
+ 1062,
+ 1583,
+ 278,
+ 1360,
+ 1574,
+ - 258,
+ - 272,
+ - 768,
+ 19,
+ 563,
+ 2240,
+ - 3,
+ - 265,
+ 135,
+ - 295,
+ - 591,
+ - 388,
+ 140,
+ 354,
+ - 206,
+ - 260,
+ - 504,
+ - 795,
+ - 433,
+ - 718,
+ - 1319,
+ 109,
+ 331,
+ 962,
+ - 429,
+ - 87,
+ 652,
+ - 296,
+ 426,
+ 1019,
+ - 239,
+ 775,
+ 851,
+ 489,
+ 1334,
+ 1073,
+ - 334,
+ - 332,
+ 25,
+ 543,
+ 1206,
+ 1807,
+ 326,
+ 61,
+ 727,
+ 578,
+ 849,
+ 1405,
+ - 208,
+ - 277,
+ 329,
+ - 152,
+ 64,
+ 669,
+ - 434,
+ - 678,
+ - 727,
+ - 454,
+ - 71,
+ 251,
+ 605,
+ 480,
+ 254,
+ - 482,
+ 11,
+ 996,
+ - 289,
+ 395,
+ 486,
+ 722,
+ 1049,
+ 1440,
+ - 30,
+ - 316,
+ - 786,
+ - 106,
+ - 115,
+ - 619,
+ 861,
+ 1474,
+ 1412,
+ 1055,
+ 1366,
+ 1184,
+ 812,
+ 1237,
+ 925,
+ 42,
+ - 251,
+ - 576,
+ 342,
+ 141,
+ - 454,
+ - 168,
+ - 80,
+ 1359,
+ - 342,
+ - 656,
+ - 1763,
+ 100,
+ 821,
+ 725,
+ 990,
+ 747,
+ 800,
+ 332,
+ 440,
+ 568,
+ 663,
+ 379,
+ 852,
+ 112,
+ 165,
+ - 369,
+ 597,
+ 910,
+ 282,
+ - 8,
+ 834,
+ 1281,
+ - 352,
+ 572,
+ 695,
+ 462,
+ 2246,
+ 1806,
+ 345,
+ 190,
+ 1374,
+ 416,
+ 915,
+ 2166,
+ 168,
+ - 82,
+ 280,
+ - 516,
+ - 446,
+ 840,
+ 47,
+ 533,
+ 44,
+ - 362,
+ - 711,
+ - 1143,
+ 22,
+ 193,
+ 1472,
+ - 85,
+ 233,
+ 1813,
+ - 62,
+ 579,
+ 1504,
+ 550,
+ 944,
+ 1749,
+ 723,
+ 650,
+ 1148,
+ 972,
+ 884,
+ 1395,
+ - 425,
+ 643,
+ 0,
+ 1000,
+ 952,
+ 1098,
+ 249,
+ 1446,
+ 672,
+ - 334,
+ - 87,
+ 2172,
+ - 554,
+ 1882,
+ 2672,
+ 140,
+ 1826,
+ 1853,
+ 920,
+ 1749,
+ 2590,
+ 1076,
+ 1933,
+ 2038,
+ - 137,
+ - 443,
+ - 1555,
+ 1269,
+ 1174,
+ 468,
+ - 493,
+ - 122,
+ 1521,
+ - 451,
+ 1033,
+ 1214,
+ 482,
+ 1695,
+ 1118,
+ 815,
+ 649,
+ 384,
+ - 446,
+ - 692,
+ 107,
+ - 319,
+ - 605,
+ - 118,
+ - 207,
+ - 505,
+ 525,
+ - 468,
+ - 12,
+ 2736,
+ 75,
+ 1934,
+ 1305,
+ 880,
+ 2358,
+ 2267,
+ 1285,
+ 1575,
+ 2004,
+ - 48,
+ - 304,
+ - 1186,
+ - 435,
+ - 461,
+ - 251,
+ - 366,
+ - 404,
+ - 547,
+ - 289,
+ - 605,
+ - 597,
+ - 538,
+ - 810,
+ - 165,
+ - 120,
+ 3,
+ 356,
+ 639,
+ 1241,
+ 1502,
+ 96,
+ 177,
+ 750,
+ - 435,
+ - 585,
+ - 1174,
+ - 356,
+ 109,
+ - 79,
+ - 485,
+ 288,
+ 2005,
+ 9,
+ 1116,
+ 731,
+ 880,
+ 2134,
+ 946,
+ - 265,
+ 1585,
+ 1065,
+ 1157,
+ 1210,
+ 843,
+ - 498,
+ - 668,
+ 431,
+ 374,
+ 321,
+ - 229,
+ 1440,
+ 2101,
+ 1381,
+ 449,
+ 461,
+ 1155,
+ - 105,
+ 39,
+ - 384,
+ - 263,
+ 367,
+ 182,
+ - 371,
+ - 660,
+ 773,
+ - 188,
+ 1151,
+ 971,
+ 1333,
+ 1632,
+ 1435,
+ 774,
+ 1267,
+ 1221,
+ - 482,
+ - 832,
+ - 1489,
+ - 237,
+ - 210,
+ 860,
+ 890,
+ 1615,
+ 1064,
+ 472,
+ 1062,
+ 1192,
+ 185,
+ 1077,
+ 989,
+ - 568,
+ - 992,
+ - 1704,
+ - 449,
+ - 902,
+ - 2043,
+ - 142,
+ - 377,
+ - 458,
+ - 210,
+ - 554,
+ - 1029,
+ - 11,
+ 1133,
+ 2265,
+ - 329,
+ - 675,
+ - 893,
+ - 250,
+ 657,
+ 1187,
+ 519,
+ 1510,
+ 1779,
+ 520,
+ 539,
+ 1403,
+ 527,
+ 1421,
+ 1302,
+ - 563,
+ - 871,
+ - 1248,
+ - 147,
+ - 463,
+ 879,
+ - 76,
+ 2334,
+ 2840,
+ 563,
+ 2573,
+ 2385,
+ 632,
+ 1926,
+ 2920,
+ 719,
+ 2023,
+ 1840,
+ - 545,
+ - 723,
+ 1108,
+ 129,
+ - 125,
+ 884,
+ 1417,
+ 1632,
+ 925,
+ - 94,
+ 1566,
+ 1751,
+ - 341,
+ 1533,
+ 1551,
+ 591,
+ 395,
+ - 274,
+ - 76,
+ 981,
+ 2831,
+ 153,
+ 2985,
+ 1844,
+ 1032,
+ 2565,
+ 2749,
+ 1508,
+ 2832,
+ 1879,
+ 791,
+ 1199,
+ 538,
+ - 190,
+ - 453,
+ 1489,
+ - 278,
+ - 548,
+ 1158,
+ - 245,
+ 1941,
+ 2044,
+ 1024,
+ 1560,
+ 1650,
+ 512,
+ 253,
+ 466,
+ - 62,
+ - 323,
+ 1151,
+ - 473,
+ - 376,
+ 507,
+ - 433,
+ 1380,
+ 2162,
+ 899,
+ 1943,
+ 1445,
+ 134,
+ 704,
+ 440,
+ 460,
+ 525,
+ - 28,
+ - 450,
+ 279,
+ 1338,
+ 0,
+ 971,
+ 252,
+ - 445,
+ - 627,
+ - 991,
+ - 348,
+ - 602,
+ - 1424,
+ 398,
+ 712,
+ 1656,
+ - 107,
+ 314,
+ - 178,
+ 93,
+ 2226,
+ 2238,
+ 518,
+ 849,
+ 656,
+ - 462,
+ - 711,
+ - 447,
+ 174,
+ - 34,
+ 1191,
+ - 119,
+ 42,
+ 1005,
+ - 372,
+ 274,
+ 758,
+ 1036,
+ 2352,
+ 1838,
+ 675,
+ 1724,
+ 1498,
+ 430,
+ 1286,
+ 2133,
+ - 129,
+ - 439,
+ 0,
+ - 373,
+ 800,
+ 2144,
+ 6,
+ 1587,
+ 2478,
+ 478,
+ 596,
+ 2128,
+ - 428,
+ - 736,
+ 1505,
+ 385,
+ 178,
+ 980,
+ 139,
+ 449,
+ 1225,
+ - 526,
+ - 842,
+ - 982,
+ 145,
+ 1554,
+ 1242,
+ 623,
+ 1448,
+ 656,
+ 349,
+ 1016,
+ 1482,
+ 31,
+ - 280,
+ 415,
+ - 316,
+ 724,
+ 1641,
+ 360,
+ 1058,
+ 556,
+ - 436,
+ - 358,
+ 1201,
+ - 355,
+ 1123,
+ 1939,
+ 401,
+ 1584,
+ 2248,
+ - 527,
+ - 1012,
+ 355,
+ 233,
+ 238,
+ 2233,
+ - 550,
+ - 897,
+ - 639,
+ - 365,
+ - 501,
+ 1957,
+ 389,
+ 1860,
+ 1621,
+ 162,
+ 1132,
+ 1264,
+ - 237,
+ 1174,
+ 1390,
+ - 640,
+ - 411,
+ 116,
+ - 228,
+ 1694,
+ 2298,
+ 1639,
+ 2186,
+ 2267,
+ 562,
+ 1273,
+ 2658,
+ 323,
+ 338,
+ 1774,
+ 578,
+ 1107,
+ 852,
+ 22,
+ 594,
+ 934,
+ - 143,
+ 718,
+ 446
+};
+
+/* 2nd LSF quantizer (not in MR122) */
+static const Word32 dico2_lsf_3[] =
+{
+ 50,
+ 71,
+ - 9,
+ - 338,
+ - 698,
+ - 1407,
+ 102,
+ - 138,
+ - 820,
+ - 310,
+ - 469,
+ - 1147,
+ 414,
+ 67,
+ - 267,
+ 1060,
+ 814,
+ 1441,
+ 1548,
+ 1360,
+ 1272,
+ 1754,
+ 1895,
+ 1661,
+ 2019,
+ 2133,
+ 1820,
+ 1808,
+ 2318,
+ 1845,
+ 644,
+ - 93,
+ 454,
+ 858,
+ 329,
+ - 136,
+ 489,
+ - 258,
+ - 128,
+ - 198,
+ - 745,
+ - 41,
+ - 52,
+ - 265,
+ - 985,
+ 346,
+ 137,
+ 479,
+ - 1741,
+ - 748,
+ - 684,
+ - 1163,
+ - 1725,
+ - 367,
+ - 895,
+ - 1145,
+ - 784,
+ - 488,
+ - 946,
+ - 968,
+ - 85,
+ - 390,
+ - 725,
+ 215,
+ - 340,
+ - 171,
+ 1020,
+ 916,
+ 1969,
+ 564,
+ 179,
+ 746,
+ 662,
+ 977,
+ 1734,
+ 887,
+ 622,
+ 914,
+ 939,
+ 856,
+ 1165,
+ 309,
+ 688,
+ 803,
+ 917,
+ 161,
+ 570,
+ 118,
+ - 20,
+ - 283,
+ - 816,
+ - 42,
+ 204,
+ - 1228,
+ - 325,
+ - 462,
+ - 963,
+ - 202,
+ - 143,
+ - 988,
+ - 484,
+ - 361,
+ - 702,
+ - 978,
+ - 477,
+ - 302,
+ - 790,
+ - 1188,
+ - 100,
+ - 786,
+ - 1088,
+ - 1054,
+ - 947,
+ - 1684,
+ - 202,
+ - 843,
+ - 782,
+ - 1039,
+ - 1378,
+ - 901,
+ - 624,
+ - 110,
+ - 85,
+ 356,
+ 213,
+ - 10,
+ - 493,
+ 364,
+ 774,
+ 425,
+ 822,
+ 479,
+ - 83,
+ 557,
+ 520,
+ - 992,
+ - 1560,
+ - 572,
+ - 603,
+ - 741,
+ - 26,
+ - 502,
+ - 638,
+ - 903,
+ 209,
+ 306,
+ 147,
+ - 316,
+ - 593,
+ - 596,
+ - 85,
+ - 211,
+ - 225,
+ - 918,
+ - 529,
+ 117,
+ 233,
+ - 439,
+ - 738,
+ 1101,
+ 751,
+ 633,
+ 1457,
+ 1716,
+ 1511,
+ 1765,
+ 1457,
+ 910,
+ 1122,
+ 1156,
+ 849,
+ 1354,
+ 868,
+ 470,
+ - 871,
+ - 1150,
+ - 1796,
+ - 871,
+ - 861,
+ - 992,
+ - 118,
+ 155,
+ 212,
+ - 1051,
+ - 849,
+ - 606,
+ - 1117,
+ - 1849,
+ - 2750,
+ - 1019,
+ - 1427,
+ - 1869,
+ 370,
+ - 184,
+ - 414,
+ 959,
+ 493,
+ 104,
+ 958,
+ 1039,
+ 543,
+ 154,
+ 653,
+ 201,
+ 1249,
+ 507,
+ 150,
+ 663,
+ 503,
+ 230,
+ 623,
+ 777,
+ 675,
+ 659,
+ 88,
+ - 110,
+ 843,
+ 244,
+ 224,
+ 382,
+ 541,
+ 302,
+ 724,
+ 433,
+ 666,
+ 1166,
+ 734,
+ 341,
+ - 138,
+ 20,
+ - 397,
+ - 1183,
+ - 424,
+ - 46,
+ - 321,
+ - 352,
+ - 124,
+ 1333,
+ 1021,
+ 1080,
+ 262,
+ 366,
+ 723,
+ 922,
+ 283,
+ - 551,
+ 31,
+ - 636,
+ - 611,
+ - 689,
+ - 697,
+ - 415,
+ - 952,
+ - 779,
+ - 201,
+ - 1329,
+ - 598,
+ - 359,
+ - 953,
+ - 1285,
+ 166,
+ 493,
+ 305,
+ 221,
+ 846,
+ 703,
+ 610,
+ 840,
+ 936,
+ 774,
+ - 723,
+ - 1324,
+ - 1261,
+ - 357,
+ - 1025,
+ - 1388,
+ - 1096,
+ - 1376,
+ - 365,
+ - 1416,
+ - 1881,
+ - 608,
+ - 1798,
+ - 1727,
+ - 674,
+ - 545,
+ - 1173,
+ - 703,
+ 678,
+ 786,
+ 148,
+ - 123,
+ 696,
+ 1288,
+ 644,
+ 350,
+ - 10,
+ 414,
+ 614,
+ 15,
+ 137,
+ 344,
+ - 211,
+ - 814,
+ - 1512,
+ - 819,
+ - 391,
+ - 930,
+ - 588,
+ 47,
+ - 591,
+ - 898,
+ - 909,
+ - 1097,
+ - 163,
+ - 1272,
+ - 1167,
+ - 157,
+ - 1464,
+ - 1525,
+ - 389,
+ - 1274,
+ - 1188,
+ - 624,
+ 671,
+ 213,
+ 454,
+ 124,
+ - 274,
+ - 525,
+ - 729,
+ - 496,
+ - 152,
+ - 1344,
+ 122,
+ 135,
+ - 2905,
+ - 589,
+ - 394,
+ - 1728,
+ 441,
+ - 50,
+ 1476,
+ 904,
+ 787,
+ 316,
+ 236,
+ - 440,
+ - 347,
+ 217,
+ 413,
+ - 911,
+ - 917,
+ 121,
+ - 455,
+ - 932,
+ 202,
+ - 92,
+ - 465,
+ - 375,
+ 488,
+ 390,
+ 474,
+ 876,
+ 729,
+ 316,
+ - 1815,
+ - 1312,
+ - 669,
+ 87,
+ 962,
+ 432,
+ 563,
+ - 249,
+ - 1058,
+ 250,
+ 285,
+ 1105,
+ 1141,
+ 427,
+ 696,
+ - 1038,
+ - 1664,
+ - 1582,
+ - 948,
+ 346,
+ 160,
+ - 309,
+ - 272,
+ - 858,
+ 670,
+ 624,
+ 1250,
+ - 944,
+ - 408,
+ - 666,
+ - 606,
+ - 320,
+ - 384,
+ - 492,
+ 230,
+ 65,
+ 334,
+ - 50,
+ - 16,
+ - 16,
+ - 690,
+ - 1397,
+ 1791,
+ 1716,
+ 1399,
+ 2478,
+ 2063,
+ 1404,
+ 1245,
+ 1471,
+ 1426,
+ - 382,
+ - 1037,
+ - 2,
+ 173,
+ - 398,
+ 1145,
+ 1491,
+ 2024,
+ 1801,
+ 772,
+ 1274,
+ 1506,
+ 1429,
+ 1735,
+ 2001,
+ 1079,
+ 1218,
+ 1273,
+ - 1154,
+ - 1851,
+ - 1329,
+ - 808,
+ - 1133,
+ - 1096,
+ - 451,
+ - 1033,
+ - 1722,
+ 65,
+ 578,
+ - 84,
+ - 1476,
+ - 2434,
+ - 1778,
+ - 765,
+ - 1366,
+ - 494,
+ - 218,
+ - 594,
+ - 931,
+ 337,
+ - 236,
+ 562,
+ 2357,
+ 2662,
+ 1938,
+ 1489,
+ 1276,
+ 874,
+ 189,
+ 358,
+ 374,
+ - 1519,
+ - 2281,
+ - 2346,
+ - 967,
+ - 1271,
+ - 2095,
+ - 628,
+ - 1188,
+ - 1542,
+ 1661,
+ 1043,
+ 546,
+ 565,
+ 1061,
+ 732,
+ - 64,
+ - 836,
+ - 434,
+ - 436,
+ - 96,
+ 203,
+ 1078,
+ 1216,
+ 1636,
+ 907,
+ 1534,
+ 986,
+ 326,
+ 965,
+ 845,
+ 142,
+ - 84,
+ 197,
+ 470,
+ 2379,
+ 1570,
+ 1133,
+ 470,
+ 1214,
+ 395,
+ 1376,
+ 1200,
+ 1125,
+ 1042,
+ 348,
+ - 543,
+ - 1234,
+ - 376,
+ - 215,
+ - 181,
+ 481,
+ - 1947,
+ - 1621,
+ - 210,
+ - 750,
+ - 1185,
+ 390,
+ 29,
+ - 399,
+ 27,
+ 820,
+ 1236,
+ 755,
+ 695,
+ 979,
+ 409,
+ - 174,
+ 1197,
+ 1035,
+ 912,
+ 1356,
+ 1846,
+ - 992,
+ - 1437,
+ 484,
+ - 1485,
+ - 1700,
+ 208,
+ - 412,
+ 1204,
+ 1432,
+ - 271,
+ 896,
+ 1144,
+ - 416,
+ 1777,
+ 1434,
+ - 1696,
+ - 2644,
+ - 204,
+ - 1789,
+ - 1551,
+ 1033,
+ - 1656,
+ - 1559,
+ 1303,
+ - 1253,
+ - 1589,
+ 1081,
+ - 669,
+ - 1095,
+ - 66,
+ - 682,
+ 320,
+ - 345,
+ 659,
+ 305,
+ 1069,
+ - 1292,
+ - 804,
+ - 19,
+ - 1635,
+ - 1291,
+ 29,
+ - 1683,
+ - 497,
+ 71,
+ - 287,
+ - 7,
+ - 100,
+ - 494,
+ - 962,
+ - 237,
+ 852,
+ 1881,
+ 1740,
+ - 1217,
+ - 1387,
+ 227,
+ - 660,
+ 302,
+ 373,
+ 96,
+ 1087,
+ 1257,
+ - 1074,
+ - 1669,
+ 160,
+ 485,
+ 2076,
+ 1798,
+ - 934,
+ - 220,
+ 552,
+ - 596,
+ - 612,
+ 237,
+ 336,
+ 1720,
+ 879,
+ 643,
+ 629,
+ 434,
+ 1267,
+ 522,
+ 1633,
+ 15,
+ 244,
+ - 441,
+ 1475,
+ 717,
+ 184,
+ 1819,
+ 1590,
+ 1709,
+ 988,
+ 261,
+ 937,
+ 2093,
+ 2345,
+ 1520,
+ 2139,
+ 1858,
+ 1606,
+ - 577,
+ - 579,
+ - 1203,
+ - 956,
+ 135,
+ - 488,
+ - 464,
+ 51,
+ - 338,
+ - 629,
+ - 348,
+ - 723,
+ 1146,
+ 2073,
+ 1442,
+ 2192,
+ 1466,
+ 911,
+ - 1444,
+ - 1572,
+ - 2278,
+ 1400,
+ 710,
+ 1297,
+ 1335,
+ 633,
+ 928,
+ 1434,
+ 2194,
+ 2594,
+ 2422,
+ 2204,
+ 1881,
+ 982,
+ 2242,
+ 1854,
+ 380,
+ 792,
+ 1145,
+ - 63,
+ - 539,
+ 414,
+ - 252,
+ - 964,
+ - 314,
+ - 1261,
+ - 683,
+ - 780,
+ - 831,
+ - 526,
+ - 1005,
+ - 1666,
+ - 1135,
+ - 424,
+ - 1611,
+ - 452,
+ - 299,
+ 1268,
+ 1048,
+ 642,
+ 1147,
+ 853,
+ 856,
+ - 675,
+ - 336,
+ 139,
+ 2268,
+ 1343,
+ 1418,
+ 29,
+ 768,
+ 797,
+ - 1224,
+ 423,
+ 564,
+ - 1318,
+ - 1082,
+ 245,
+ - 1302,
+ - 812,
+ 573,
+ - 1298,
+ - 1617,
+ 646,
+ - 968,
+ 834,
+ 723,
+ 993,
+ 1652,
+ 2027,
+ - 191,
+ - 817,
+ 432,
+ 662,
+ 60,
+ 198,
+ 626,
+ 997,
+ 1330,
+ 1648,
+ 1963,
+ 1289,
+ - 1597,
+ - 93,
+ - 45,
+ - 1088,
+ 37,
+ - 84,
+ 1653,
+ 2607,
+ 2337,
+ 1065,
+ 2040,
+ 2377,
+ 1139,
+ 2326,
+ 2118,
+ 859,
+ 357,
+ 1510,
+ 664,
+ 1227,
+ 1099,
+ 479,
+ 1360,
+ 912,
+ 1897,
+ 1754,
+ 2019,
+ 1168,
+ 1909,
+ 1784,
+ 399,
+ 34,
+ 256,
+ - 593,
+ - 304,
+ - 1053,
+ 547,
+ 1694,
+ 1407,
+ 647,
+ - 99,
+ - 341,
+ 1492,
+ 1647,
+ 1190,
+ 38,
+ - 644,
+ - 212,
+ 395,
+ 846,
+ 222,
+ - 704,
+ - 765,
+ - 716,
+ - 724,
+ - 1964,
+ - 2804,
+ - 150,
+ 291,
+ - 82,
+ 1233,
+ 1459,
+ 1007,
+ - 140,
+ - 155,
+ 153,
+ 439,
+ 297,
+ 1568,
+ - 1529,
+ - 410,
+ - 636,
+ 1536,
+ 455,
+ - 237,
+ - 1328,
+ - 139,
+ - 260,
+ 531,
+ 554,
+ 868,
+ 269,
+ 1264,
+ 606,
+ - 233,
+ 883,
+ 463,
+ 742,
+ 600,
+ - 120,
+ - 73,
+ 421,
+ 212,
+ - 439,
+ - 58,
+ 804,
+ - 1286,
+ - 1241,
+ 728,
+ 294,
+ - 490,
+ 50,
+ - 591,
+ - 905,
+ - 1254,
+ 42,
+ - 687,
+ 147,
+ - 25,
+ 273,
+ 596,
+ - 311,
+ 1213,
+ 601,
+ - 754,
+ 849,
+ 584,
+ 429,
+ 607,
+ 587,
+ - 602,
+ - 166,
+ 461,
+ - 796,
+ - 823,
+ 777,
+ 1380,
+ 910,
+ 1755,
+ 119,
+ 1417,
+ 972,
+ - 219,
+ - 880,
+ - 1596,
+ - 1049,
+ - 1010,
+ 438,
+ - 713,
+ - 1379,
+ 78,
+ 0,
+ - 447,
+ - 1179,
+ - 1136,
+ - 1319,
+ - 1573,
+ 2248,
+ 1767,
+ 1309,
+ 946,
+ 1583,
+ 1432,
+ 1150,
+ 482,
+ 436,
+ - 469,
+ - 1108,
+ 618,
+ - 447,
+ - 966,
+ 1088,
+ - 1252,
+ - 1515,
+ - 114,
+ - 1104,
+ - 2008,
+ - 579,
+ 210,
+ 613,
+ 497,
+ - 1975,
+ - 1437,
+ 642,
+ - 1269,
+ - 856,
+ 1011,
+ - 1646,
+ - 1185,
+ 1063,
+ - 1555,
+ - 672,
+ 1204,
+ - 1692,
+ - 1114,
+ 623,
+ - 979,
+ - 1326,
+ - 1277,
+ 539,
+ - 147,
+ 894,
+ - 1354,
+ - 897,
+ - 434,
+ 888,
+ 475,
+ 428,
+ 153,
+ - 384,
+ 338,
+ - 1492,
+ - 511,
+ 359,
+ - 974,
+ - 1115,
+ - 470,
+ 105,
+ - 550,
+ 677,
+ - 937,
+ - 1145,
+ 877,
+ 380,
+ - 260,
+ 210,
+ 1685,
+ 924,
+ 1256,
+ 1775,
+ 1190,
+ 1095,
+ 1419,
+ 631,
+ 533,
+ 627,
+ 299,
+ - 347,
+ - 411,
+ - 534,
+ 647,
+ - 650,
+ 29,
+ - 595,
+ - 378,
+ - 1367,
+ 1563,
+ 1402,
+ 1121,
+ 1465,
+ 1089,
+ 1410,
+ 648,
+ - 2096,
+ - 1090,
+ - 6,
+ 311,
+ - 194,
+ - 869,
+ - 639,
+ - 831,
+ 416,
+ - 1162,
+ - 1224,
+ 1349,
+ - 1247,
+ - 941,
+ 1813,
+ - 2193,
+ - 1987,
+ 453,
+ - 619,
+ - 1367,
+ - 956,
+ - 1606,
+ - 1972,
+ - 1507,
+ - 1175,
+ - 1057,
+ - 1104,
+ - 377,
+ 601,
+ 201,
+ 1876,
+ 825,
+ 374,
+ - 430,
+ - 1323,
+ 29,
+ - 1397,
+ - 1249,
+ - 1331,
+ - 1007,
+ - 1504,
+ 960,
+ - 1401,
+ - 2009,
+ 197,
+ - 1379,
+ - 1949,
+ - 236,
+ - 1077,
+ 123,
+ 422,
+ 615,
+ 1269,
+ 546,
+ - 306,
+ 1526,
+ 904,
+ 1194,
+ 1788,
+ 1177,
+ - 626,
+ - 884,
+ - 1526,
+ 199,
+ 766,
+ 1504,
+ - 1065,
+ 862,
+ 197,
+ - 1034,
+ - 1773,
+ - 887,
+ - 800,
+ 145,
+ 599,
+ - 1134,
+ - 519,
+ 626,
+ - 1205,
+ - 1926,
+ 500,
+ - 910,
+ - 1041,
+ - 1395,
+ - 1476,
+ - 1567,
+ - 969,
+ - 523,
+ 842,
+ 34,
+ 1794,
+ 646,
+ 862,
+ - 1207,
+ - 1888,
+ - 1002,
+ - 78,
+ - 9,
+ - 672,
+ 1044,
+ 759,
+ 80,
+ - 600,
+ 1139,
+ 1019,
+ 57,
+ 2000,
+ 1422,
+ - 833,
+ 1414,
+ 1121,
+ - 1202,
+ 1630,
+ 1260,
+ - 461,
+ 1420,
+ 1244,
+ 1537,
+ 975,
+ 253,
+ - 283,
+ 324,
+ - 359,
+ 599,
+ - 195,
+ 106,
+ 588,
+ 62,
+ - 587,
+ - 757,
+ 645,
+ 205,
+ 51,
+ 1201,
+ 758,
+ - 1209,
+ 673,
+ - 390,
+ - 624,
+ 1581,
+ 941,
+ - 151,
+ 1023,
+ 735,
+ 2820,
+ 1301,
+ 690,
+ - 302,
+ 524,
+ - 99,
+ - 900,
+ - 1588,
+ - 1189,
+ 1084,
+ 251,
+ 238,
+ 2014,
+ 1792,
+ 1010,
+ 1245,
+ 1633,
+ 1741,
+ - 1227,
+ - 1540,
+ - 1208,
+ - 621,
+ 456,
+ - 109,
+ 40,
+ - 65,
+ 788,
+ - 805,
+ - 699,
+ - 1350,
+ - 583,
+ 904,
+ 832,
+ - 801,
+ 532,
+ 594,
+ 1972,
+ 1408,
+ 1351,
+ - 1177,
+ - 1880,
+ - 2114,
+ - 773,
+ 568,
+ 948,
+ - 1015,
+ 1079,
+ 1260,
+ - 1111,
+ 482,
+ - 130,
+ 1778,
+ 1044,
+ 780,
+ - 1491,
+ 245,
+ 912,
+ - 316,
+ - 1141,
+ - 917,
+ - 536,
+ - 1442,
+ - 2346,
+ - 785,
+ - 1546,
+ - 1988,
+ - 2003,
+ 257,
+ 909,
+ - 1849,
+ - 633,
+ - 1209,
+ - 1538,
+ - 1918,
+ - 1054,
+ 1606,
+ 2239,
+ 1576,
+ - 567,
+ - 1500,
+ - 1544,
+ - 1279,
+ 195,
+ 1369,
+ - 817,
+ 293,
+ 1219,
+ - 525,
+ 630,
+ 1197,
+ - 1698,
+ - 2425,
+ - 1840,
+ - 303,
+ 731,
+ 747,
+ - 1169,
+ - 251,
+ 269,
+ - 950,
+ - 75,
+ 1684,
+ - 1182,
+ - 453,
+ 1005,
+ - 1599,
+ 585,
+ 378,
+ - 2075,
+ - 571,
+ - 427,
+ - 529,
+ - 1159,
+ - 1171,
+ - 283,
+ - 205,
+ - 564,
+ - 796,
+ 1246,
+ 717,
+ 2277,
+ 927,
+ 539,
+ - 454,
+ 559,
+ 440,
+ - 717,
+ 1460,
+ 1615,
+ - 1030,
+ 1052,
+ 1610,
+ - 1169,
+ - 138,
+ 847,
+ 226,
+ 39,
+ - 612,
+ - 1251,
+ - 106,
+ - 729,
+ - 651,
+ 968,
+ 1302,
+ - 714,
+ - 636,
+ 1727,
+ 353,
+ 1069,
+ 410,
+ - 798,
+ - 156,
+ 1099,
+ - 574,
+ 918,
+ 446,
+ - 1310,
+ 1012,
+ 466,
+ 1408,
+ 1591,
+ 765,
+ 1429,
+ 1380,
+ 1757,
+ 1949,
+ 1956,
+ 2378,
+ 1578,
+ 2047,
+ 2148,
+ 916,
+ 98,
+ - 7,
+ 1893,
+ 1418,
+ 2141,
+ 348,
+ 1405,
+ 1579,
+ 152,
+ 1134,
+ 1801,
+ - 267,
+ 154,
+ 1395,
+ - 1166,
+ 469,
+ 1054,
+ - 1142,
+ - 405,
+ - 1073,
+ - 1341,
+ - 2264,
+ - 1581,
+ - 364,
+ 869,
+ 1706,
+ - 1162,
+ 549,
+ 1550,
+ - 1225,
+ - 1932,
+ - 1666,
+ - 1485,
+ - 1977,
+ - 2055,
+ - 1727,
+ - 906,
+ - 98,
+ - 1897,
+ 233,
+ 1492,
+ 892,
+ 108,
+ - 331,
+ - 1728,
+ - 1170,
+ - 1700,
+ - 1060,
+ 1980,
+ 1790,
+ - 1070,
+ - 1741,
+ - 1909,
+ - 11,
+ 1539,
+ 1317,
+ - 1600,
+ 94,
+ 497,
+ 421,
+ 443,
+ - 197,
+ - 1578,
+ - 349,
+ - 994,
+ - 599,
+ - 539,
+ 1140,
+ - 965,
+ - 1419,
+ - 129,
+ - 1341,
+ 175,
+ - 447,
+ - 375,
+ 1311,
+ 2055,
+ - 371,
+ - 650,
+ - 307,
+ - 1073,
+ 605,
+ 365,
+ - 2057,
+ - 113,
+ 430,
+ 652,
+ 914,
+ 967,
+ - 1012,
+ - 1586,
+ - 2323,
+ 1505,
+ 1248,
+ 559,
+ 262,
+ - 486,
+ - 401,
+ - 1727,
+ 1342,
+ 1546,
+ 50,
+ 56,
+ 432,
+ - 330,
+ 119,
+ - 604,
+ - 1517,
+ - 1080,
+ - 810,
+ 946,
+ 1127,
+ 1055,
+ - 1400,
+ - 1703,
+ - 1712,
+ - 1270,
+ - 704,
+ - 1317,
+ 807,
+ 1821,
+ 1143,
+ 2760,
+ 1606,
+ 2171,
+ 1120,
+ 409,
+ - 150,
+ - 147,
+ 404,
+ 959,
+ 2439,
+ 1911,
+ 2189,
+ - 906,
+ - 141,
+ - 866,
+ - 904,
+ - 142,
+ - 458,
+ - 557,
+ - 708,
+ - 1679,
+ - 830,
+ - 1431,
+ - 1583,
+ - 1842,
+ - 1346,
+ - 1086,
+ - 1604,
+ - 272,
+ 915,
+ - 1196,
+ 772,
+ 1056,
+ - 638,
+ - 1234,
+ - 1897,
+ - 500,
+ - 81,
+ - 822,
+ - 1289,
+ - 1613,
+ - 735,
+ - 117,
+ 785,
+ 168,
+ - 1090,
+ 1133,
+ 922,
+ - 1096,
+ - 746,
+ 1384,
+ 287,
+ - 547,
+ - 1063,
+ - 1376,
+ - 2201,
+ - 1204,
+ - 2176,
+ - 1570,
+ - 1757,
+ - 1511,
+ - 2241,
+ - 771,
+ - 1737,
+ 1099,
+ 830,
+ - 1588,
+ 724,
+ 1243,
+ - 1542,
+ 693,
+ 805,
+ - 1690,
+ - 240,
+ 1665,
+ - 1700,
+ - 4,
+ - 668,
+ 2149,
+ 816,
+ 1042,
+ - 818,
+ - 1841,
+ 22,
+ - 764,
+ - 507,
+ 449,
+ - 1151,
+ - 617,
+ 289,
+ - 843,
+ - 1596,
+ - 240,
+ 498,
+ - 234,
+ - 657,
+ - 752,
+ 480,
+ 1678,
+ - 319,
+ - 481,
+ 193,
+ - 811,
+ 171,
+ - 119,
+ - 2128,
+ - 202,
+ - 848,
+ 1717,
+ 1140,
+ 1700
+};
+
+/* 3rd LSF quantizer (not in MR122, MR515 and MR475) */
+static const Word32 dico3_lsf_3[] =
+{
+ 67,
+ - 17,
+ 66,
+ - 12,
+ - 1690,
+ - 581,
+ - 104,
+ - 272,
+ - 1076,
+ - 1186,
+ - 1845,
+ - 376,
+ - 1140,
+ - 926,
+ - 420,
+ - 58,
+ - 259,
+ - 656,
+ - 1134,
+ - 553,
+ 1788,
+ 1227,
+ 455,
+ 129,
+ 462,
+ 441,
+ - 240,
+ - 528,
+ 840,
+ 514,
+ 130,
+ - 75,
+ 1114,
+ 623,
+ 153,
+ 216,
+ 1068,
+ 564,
+ - 6,
+ - 276,
+ 1119,
+ 727,
+ 190,
+ - 68,
+ 704,
+ 306,
+ 119,
+ - 264,
+ 329,
+ 61,
+ - 100,
+ 156,
+ 364,
+ 123,
+ 183,
+ - 208,
+ - 171,
+ - 123,
+ 220,
+ - 65,
+ - 306,
+ - 62,
+ 402,
+ 17,
+ - 660,
+ - 938,
+ - 266,
+ 0,
+ 385,
+ 235,
+ 276,
+ 285,
+ 320,
+ 268,
+ - 336,
+ - 200,
+ - 724,
+ 17,
+ - 84,
+ 381,
+ - 544,
+ 429,
+ 494,
+ 519,
+ - 117,
+ 288,
+ 304,
+ 329,
+ 643,
+ 157,
+ 701,
+ 508,
+ 1200,
+ 625,
+ 796,
+ 608,
+ 998,
+ 421,
+ 492,
+ 632,
+ 1204,
+ 780,
+ 446,
+ 132,
+ 1257,
+ 844,
+ 547,
+ 449,
+ 829,
+ 658,
+ 541,
+ 470,
+ 1132,
+ 1258,
+ 918,
+ 639,
+ 547,
+ 51,
+ 423,
+ 279,
+ 9,
+ 392,
+ 83,
+ 94,
+ 542,
+ 543,
+ 229,
+ - 147,
+ - 198,
+ 129,
+ 194,
+ - 185,
+ - 863,
+ - 1321,
+ - 302,
+ 30,
+ - 597,
+ - 629,
+ - 19,
+ 114,
+ - 900,
+ - 1081,
+ 466,
+ 353,
+ - 1483,
+ - 1573,
+ 15,
+ - 143,
+ - 1708,
+ - 2059,
+ - 751,
+ 196,
+ - 1876,
+ - 2067,
+ - 642,
+ - 258,
+ - 2335,
+ - 1470,
+ - 450,
+ - 564,
+ - 584,
+ - 186,
+ - 872,
+ - 414,
+ - 1805,
+ - 988,
+ - 1125,
+ - 1310,
+ - 726,
+ - 1129,
+ 28,
+ 169,
+ - 1039,
+ - 864,
+ - 718,
+ - 246,
+ 484,
+ 36,
+ - 233,
+ - 49,
+ 265,
+ 67,
+ 289,
+ 467,
+ 178,
+ 543,
+ 810,
+ 540,
+ 84,
+ 282,
+ 672,
+ 703,
+ - 975,
+ - 777,
+ 129,
+ 287,
+ - 938,
+ - 227,
+ 955,
+ 595,
+ - 1617,
+ - 289,
+ 836,
+ 649,
+ - 1847,
+ - 215,
+ 1106,
+ 718,
+ - 2034,
+ - 1085,
+ 650,
+ 440,
+ - 2101,
+ - 529,
+ 907,
+ 575,
+ - 2011,
+ - 336,
+ 670,
+ 204,
+ - 2389,
+ - 692,
+ 360,
+ 137,
+ - 2156,
+ - 2204,
+ - 9,
+ 280,
+ - 266,
+ 119,
+ 39,
+ 193,
+ 78,
+ - 59,
+ - 120,
+ 226,
+ - 975,
+ - 858,
+ - 781,
+ - 1095,
+ - 619,
+ - 413,
+ - 451,
+ - 842,
+ - 1216,
+ - 1321,
+ - 813,
+ - 883,
+ - 1376,
+ - 1615,
+ - 394,
+ - 428,
+ - 737,
+ - 1113,
+ - 549,
+ - 790,
+ - 880,
+ - 975,
+ - 967,
+ - 642,
+ - 985,
+ - 886,
+ - 1273,
+ - 1361,
+ - 473,
+ - 804,
+ - 1401,
+ - 1407,
+ 160,
+ - 265,
+ - 919,
+ - 275,
+ - 248,
+ - 250,
+ - 718,
+ - 380,
+ 97,
+ - 103,
+ - 375,
+ - 229,
+ - 415,
+ - 193,
+ - 135,
+ - 555,
+ 628,
+ 361,
+ 119,
+ 216,
+ 579,
+ 364,
+ 391,
+ 209,
+ 634,
+ 522,
+ - 154,
+ - 148,
+ 526,
+ 389,
+ 170,
+ 33,
+ 105,
+ 267,
+ 64,
+ 380,
+ - 1503,
+ - 1000,
+ - 30,
+ - 369,
+ - 1070,
+ 58,
+ 647,
+ 223,
+ - 1520,
+ - 291,
+ 621,
+ 307,
+ - 1531,
+ 156,
+ 762,
+ 404,
+ - 2029,
+ 141,
+ 734,
+ 499,
+ - 1849,
+ - 650,
+ 306,
+ 512,
+ - 187,
+ - 104,
+ - 59,
+ 438,
+ 134,
+ - 230,
+ 156,
+ - 186,
+ - 61,
+ - 260,
+ - 16,
+ 10,
+ - 569,
+ - 3,
+ - 421,
+ - 297,
+ - 1725,
+ - 521,
+ - 346,
+ 178,
+ - 1362,
+ - 59,
+ - 44,
+ 157,
+ - 2146,
+ - 461,
+ - 470,
+ - 349,
+ - 2170,
+ - 1,
+ - 369,
+ - 121,
+ - 1579,
+ - 373,
+ - 900,
+ - 1015,
+ - 1117,
+ - 591,
+ - 613,
+ - 784,
+ - 561,
+ 122,
+ - 75,
+ - 449,
+ - 4,
+ - 171,
+ - 123,
+ - 372,
+ 192,
+ 168,
+ - 76,
+ - 132,
+ 252,
+ - 107,
+ 340,
+ 210,
+ 392,
+ 509,
+ 272,
+ 181,
+ - 109,
+ 145,
+ 218,
+ 119,
+ - 416,
+ - 263,
+ 485,
+ 265,
+ - 181,
+ - 8,
+ - 286,
+ 226,
+ - 244,
+ - 218,
+ 69,
+ - 290,
+ - 158,
+ 191,
+ - 1,
+ - 64,
+ - 592,
+ - 90,
+ 213,
+ - 96,
+ 255,
+ 435,
+ 178,
+ - 80,
+ - 369,
+ - 18,
+ - 33,
+ - 80,
+ - 42,
+ 415,
+ 140,
+ - 222,
+ 1143,
+ 651,
+ 649,
+ 329,
+ 767,
+ 556,
+ 249,
+ 235,
+ 948,
+ 413,
+ 442,
+ 279,
+ 141,
+ 339,
+ 356,
+ 557,
+ - 470,
+ - 170,
+ 99,
+ 237,
+ - 569,
+ - 800,
+ 352,
+ 565,
+ 282,
+ 473,
+ 470,
+ 332,
+ - 199,
+ - 690,
+ - 1284,
+ - 917,
+ - 193,
+ - 426,
+ - 800,
+ - 1122,
+ - 26,
+ - 371,
+ - 490,
+ - 193,
+ 637,
+ 595,
+ 519,
+ 330,
+ 408,
+ - 115,
+ 79,
+ 12,
+ 477,
+ 87,
+ - 103,
+ - 376,
+ - 666,
+ - 347,
+ - 277,
+ - 291,
+ - 510,
+ - 481,
+ 169,
+ 297,
+ - 829,
+ - 738,
+ - 205,
+ - 171,
+ - 320,
+ - 540,
+ 328,
+ 283,
+ - 859,
+ - 958,
+ 442,
+ - 2,
+ 556,
+ 686,
+ 130,
+ 56,
+ 1383,
+ 1012,
+ 755,
+ 427,
+ 612,
+ 741,
+ 628,
+ 553,
+ - 339,
+ - 796,
+ 134,
+ 277,
+ - 633,
+ - 1085,
+ - 2,
+ - 246,
+ - 880,
+ - 1035,
+ - 1607,
+ - 1064,
+ - 994,
+ - 474,
+ - 1138,
+ - 488,
+ - 414,
+ - 795,
+ 73,
+ - 206,
+ - 8,
+ - 139,
+ 439,
+ 204,
+ - 176,
+ - 578,
+ 23,
+ 131,
+ - 269,
+ - 757,
+ - 191,
+ 245,
+ - 109,
+ - 338,
+ 112,
+ 316,
+ 120,
+ - 406,
+ - 118,
+ 611,
+ - 180,
+ - 186,
+ - 645,
+ 115,
+ - 173,
+ 34,
+ - 518,
+ - 489,
+ - 151,
+ 61,
+ - 583,
+ - 844,
+ 220,
+ - 138,
+ - 681,
+ - 1020,
+ 391,
+ - 17,
+ - 598,
+ - 321,
+ 157,
+ - 295,
+ 129,
+ 155,
+ - 926,
+ - 875,
+ - 987,
+ 285,
+ 241,
+ - 83,
+ - 125,
+ - 125,
+ 620,
+ 597,
+ 432,
+ 92,
+ 393,
+ 78,
+ 409,
+ 61,
+ - 393,
+ - 739,
+ - 413,
+ - 748,
+ 83,
+ 54,
+ 361,
+ 27,
+ - 1084,
+ 130,
+ - 337,
+ - 694,
+ - 1565,
+ 297,
+ 318,
+ - 19,
+ - 1873,
+ 36,
+ 51,
+ - 317,
+ - 2323,
+ - 246,
+ 231,
+ - 84,
+ - 2306,
+ - 783,
+ 40,
+ - 179,
+ - 2233,
+ - 930,
+ - 474,
+ - 462,
+ - 754,
+ - 86,
+ - 288,
+ - 626,
+ - 2411,
+ - 455,
+ - 63,
+ 171,
+ - 1099,
+ - 1094,
+ - 26,
+ - 143,
+ - 1193,
+ - 455,
+ - 406,
+ - 381,
+ - 605,
+ - 210,
+ - 96,
+ - 51,
+ - 580,
+ - 476,
+ - 276,
+ - 15,
+ - 1195,
+ - 634,
+ - 1203,
+ - 881,
+ - 378,
+ - 221,
+ - 669,
+ - 952,
+ 594,
+ 178,
+ - 403,
+ - 676,
+ 763,
+ 327,
+ 601,
+ 290,
+ 172,
+ 300,
+ 203,
+ 157,
+ - 56,
+ - 336,
+ 356,
+ 24,
+ - 228,
+ - 296,
+ - 259,
+ - 29,
+ - 186,
+ 263,
+ 416,
+ 14,
+ - 353,
+ 373,
+ - 12,
+ - 216,
+ 257,
+ 96,
+ 174,
+ 57,
+ - 1526,
+ - 616,
+ - 954,
+ - 499,
+ - 497,
+ - 152,
+ - 333,
+ 125,
+ 105,
+ 200,
+ 179,
+ - 97,
+ - 331,
+ - 224,
+ 765,
+ 697,
+ 760,
+ 256,
+ 301,
+ 59,
+ 455,
+ - 85,
+ 204,
+ 288,
+ - 514,
+ 240,
+ 251,
+ - 109,
+ 256,
+ 417,
+ - 34,
+ - 413,
+ 101,
+ 430,
+ 384,
+ 156,
+ - 31,
+ - 10,
+ 206,
+ 426,
+ 589,
+ 145,
+ 143,
+ 71,
+ 808,
+ 906,
+ 333,
+ 349,
+ 986,
+ 938,
+ 589,
+ 331,
+ 1300,
+ 824,
+ 187,
+ 509,
+ 1062,
+ 653,
+ 379,
+ 466,
+ 1462,
+ 937,
+ 401,
+ 274,
+ 787,
+ 861,
+ 265,
+ 2,
+ 609,
+ 553,
+ 28,
+ 305,
+ 926,
+ 340,
+ 106,
+ 386,
+ 241,
+ - 267,
+ - 147,
+ 225,
+ - 178,
+ - 534,
+ 347,
+ 502,
+ - 643,
+ - 381,
+ 397,
+ 30,
+ - 651,
+ - 733,
+ - 435,
+ 398,
+ - 407,
+ - 726,
+ - 484,
+ - 248,
+ - 789,
+ - 914,
+ - 438,
+ - 476,
+ - 498,
+ - 390,
+ 75,
+ - 295,
+ - 964,
+ - 590,
+ - 606,
+ 150,
+ - 121,
+ - 49,
+ - 155,
+ - 78,
+ 935,
+ 550,
+ 389,
+ 38,
+ - 321,
+ 127,
+ 424,
+ 315,
+ - 285,
+ - 113,
+ 283,
+ 259,
+ 658,
+ 203,
+ 322,
+ 486,
+ 903,
+ 505,
+ 748,
+ 417,
+ 611,
+ 423,
+ 555,
+ 512,
+ 239,
+ - 83,
+ - 578,
+ - 19,
+ - 339,
+ - 731,
+ 349,
+ 13,
+ - 934,
+ - 1399,
+ - 114,
+ - 360,
+ 107,
+ 692,
+ 182,
+ 90,
+ - 1243,
+ - 1538,
+ - 1551,
+ - 725,
+ - 568,
+ - 903,
+ - 1363,
+ - 525,
+ - 517,
+ - 853,
+ - 861,
+ - 1004,
+ - 168,
+ - 690,
+ - 835,
+ 63,
+ - 137,
+ - 556,
+ - 547,
+ 144,
+ - 286,
+ - 817,
+ 485,
+ 319,
+ - 147,
+ - 408,
+ 526,
+ 246,
+ - 347,
+ - 434,
+ 297,
+ - 28,
+ - 290,
+ - 471,
+ - 1110,
+ - 1285,
+ - 460,
+ - 359,
+ - 988,
+ - 794,
+ 1347,
+ 1299,
+ 690,
+ 523,
+ 1216,
+ 1068,
+ 1094,
+ 757,
+ 825,
+ 1140,
+ 752,
+ 494,
+ 1252,
+ 1365,
+ 1195,
+ 898,
+ 521,
+ 1053,
+ 532,
+ 432,
+ - 334,
+ - 216,
+ - 313,
+ - 263,
+ - 160,
+ 52,
+ - 472,
+ - 155,
+ 127,
+ 136,
+ - 380,
+ 44,
+ 851,
+ 410,
+ - 162,
+ - 489,
+ 123,
+ - 255,
+ - 796,
+ - 667,
+ 1090,
+ 917,
+ 789,
+ 493,
+ 1397,
+ 1197,
+ 558,
+ 202,
+ - 51,
+ - 118,
+ - 342,
+ - 701,
+ 83,
+ 108,
+ - 42,
+ - 441,
+ 61,
+ 95,
+ 287,
+ 256,
+ - 27,
+ 89,
+ 524,
+ 531,
+ 351,
+ 227,
+ 592,
+ 545,
+ 697,
+ 155,
+ - 164,
+ 307,
+ 638,
+ 274,
+ - 489,
+ - 50,
+ 754,
+ 240,
+ - 166,
+ - 124,
+ - 116,
+ - 579,
+ - 1212,
+ - 63,
+ 190,
+ - 295,
+ - 1040,
+ - 1296,
+ 147,
+ - 376,
+ - 177,
+ - 113,
+ 841,
+ 1241,
+ 1051,
+ 668,
+ 2,
+ 293,
+ 551,
+ 304,
+ - 1096,
+ - 953,
+ - 248,
+ 376,
+ - 750,
+ - 965,
+ 87,
+ 516,
+ - 275,
+ - 516,
+ 689,
+ 391,
+ - 379,
+ - 643,
+ 876,
+ 594,
+ - 390,
+ - 1013,
+ - 645,
+ 573,
+ - 107,
+ - 568,
+ - 689,
+ - 826,
+ - 1025,
+ - 27,
+ - 328,
+ - 203,
+ 861,
+ 749,
+ 548,
+ 233,
+ - 1660,
+ - 1043,
+ 451,
+ 108,
+ - 660,
+ - 620,
+ 430,
+ 236,
+ 21,
+ - 396,
+ - 1158,
+ - 631,
+ 1372,
+ 1298,
+ 967,
+ 577,
+ 1125,
+ 1125,
+ 589,
+ 454,
+ - 323,
+ - 865,
+ - 467,
+ 153,
+ - 468,
+ - 699,
+ - 804,
+ - 509,
+ - 392,
+ - 718,
+ - 204,
+ - 35,
+ - 603,
+ - 1093,
+ - 567,
+ - 162,
+ - 505,
+ - 1004,
+ - 102,
+ 350,
+ 219,
+ 224,
+ 423,
+ 252,
+ 395,
+ 591,
+ 608,
+ 363,
+ - 746,
+ - 96,
+ 373,
+ 172,
+ 171,
+ 295,
+ 714,
+ 339,
+ 233,
+ 77,
+ 107,
+ 277,
+ 157,
+ 153,
+ - 499,
+ - 356,
+ 1547,
+ 1073,
+ 576,
+ 494,
+ - 292,
+ - 339,
+ - 504,
+ - 592,
+ - 903,
+ - 72,
+ - 619,
+ - 481,
+ - 1594,
+ - 1117,
+ - 567,
+ - 254,
+ - 793,
+ - 507,
+ - 564,
+ - 291,
+ - 492,
+ - 532,
+ 502,
+ 560,
+ - 382,
+ 427,
+ 600,
+ 230,
+ - 227,
+ 477,
+ 251,
+ 75,
+ 285,
+ 842,
+ 813,
+ 476,
+ - 1310,
+ - 1333,
+ 186,
+ 377,
+ - 587,
+ - 917,
+ 643,
+ 381,
+ - 1186,
+ - 553,
+ 411,
+ 82,
+ - 1127,
+ - 820,
+ - 174,
+ - 540,
+ - 604,
+ 119,
+ 543,
+ 205,
+ - 380,
+ 657,
+ 909,
+ 567,
+ 112,
+ - 298,
+ - 374,
+ 114,
+ - 857,
+ - 251,
+ 56,
+ 159,
+ 401,
+ 345,
+ - 34,
+ - 140,
+ - 111,
+ - 607,
+ 41,
+ 614,
+ 355,
+ - 114,
+ - 77,
+ 474,
+ 578,
+ 56,
+ 1450,
+ 924,
+ 1098,
+ 1420,
+ 741,
+ 400,
+ 246,
+ 22,
+ 588,
+ 313,
+ - 121,
+ 327,
+ 831,
+ 472,
+ - 1138,
+ - 608,
+ 856,
+ 552,
+ - 1241,
+ - 1072,
+ 638,
+ 600,
+ - 358,
+ 254,
+ - 333,
+ - 303,
+ - 646,
+ 739,
+ 358,
+ 74,
+ 1226,
+ 1671,
+ 1221,
+ 849,
+ 2241,
+ 1624,
+ 983,
+ 636,
+ 1841,
+ 1477,
+ 749,
+ 384,
+ 350,
+ 263,
+ 87,
+ 128,
+ - 1902,
+ - 941,
+ - 144,
+ - 64,
+ - 1734,
+ - 255,
+ 288,
+ - 31,
+ - 2644,
+ - 1238,
+ 366,
+ 235,
+ - 1643,
+ - 1092,
+ - 1344,
+ - 304,
+ - 541,
+ - 1075,
+ - 1116,
+ 123,
+ - 1178,
+ - 252,
+ - 816,
+ - 180,
+ - 1016,
+ 533,
+ 565,
+ 233,
+ - 487,
+ - 430,
+ - 188,
+ 334,
+ 867,
+ 1236,
+ 534,
+ 171,
+ - 1590,
+ - 1607,
+ 635,
+ 630,
+ - 2196,
+ 310,
+ 924,
+ 412,
+ - 2358,
+ - 328,
+ 956,
+ 529,
+ - 2639,
+ - 377,
+ 630,
+ 278,
+ - 2602,
+ 317,
+ 799,
+ 299,
+ - 2406,
+ 133,
+ 340,
+ 31,
+ - 2156,
+ - 1468,
+ 131,
+ 125,
+ - 1184,
+ - 490,
+ - 139,
+ 46,
+ - 744,
+ 447,
+ 891,
+ 564,
+ 67,
+ - 451,
+ 646,
+ 604,
+ - 553,
+ - 429,
+ - 876,
+ 396,
+ 162,
+ - 66,
+ 1305,
+ 915,
+ 479,
+ 579,
+ 1088,
+ 794,
+ 450,
+ 278,
+ 566,
+ 324,
+ - 1057,
+ - 154,
+ 148,
+ - 177,
+ - 2545,
+ 168,
+ 1070,
+ 592,
+ - 2351,
+ - 42,
+ 819,
+ 345,
+ - 2344,
+ - 707,
+ 721,
+ 250,
+ - 2175,
+ - 1497,
+ - 309,
+ 122,
+ - 78,
+ - 73,
+ 120,
+ 173,
+ - 4,
+ 262,
+ - 263,
+ - 261,
+ - 431,
+ - 64,
+ - 405,
+ - 732,
+ - 2609,
+ 116,
+ - 83,
+ - 193,
+ - 1525,
+ - 944,
+ - 477,
+ - 725,
+ - 508,
+ 307,
+ 170,
+ 172,
+ 832,
+ 417,
+ 832,
+ 686,
+ - 225,
+ 177,
+ 894,
+ 818,
+ - 482,
+ - 389,
+ 1279,
+ 1039,
+ - 383,
+ 201,
+ - 350,
+ 40,
+ 730,
+ 635,
+ 226,
+ 526,
+ 503,
+ 462,
+ 338,
+ 398,
+ 535,
+ 714,
+ 40,
+ - 282,
+ 1482,
+ 1471,
+ 1085,
+ 731,
+ 1561,
+ 1072,
+ 909,
+ 693,
+ 1419,
+ 1282,
+ 889,
+ 879,
+ 1153,
+ 728,
+ 1186,
+ 840,
+ - 226,
+ 1130,
+ 949,
+ 689,
+ - 494,
+ - 986,
+ - 1556,
+ - 128,
+ - 568,
+ - 721,
+ - 713,
+ - 26,
+ 317,
+ 524,
+ 70,
+ 135,
+ - 405,
+ - 865,
+ - 1766,
+ - 652,
+ - 174,
+ - 801,
+ 885,
+ 773,
+ - 153,
+ - 91,
+ 1099,
+ 751,
+ - 506,
+ - 1149,
+ 853,
+ 646,
+ 241,
+ 782,
+ 519,
+ 539,
+ 1853,
+ 1700,
+ 1101,
+ 684,
+ - 1249,
+ - 1486,
+ - 464,
+ 188,
+ - 893,
+ - 1409,
+ - 1312,
+ - 341,
+ - 135,
+ 438,
+ - 175,
+ 18,
+ 1111,
+ 976,
+ 319,
+ 208,
+ - 1430,
+ - 1768,
+ 83,
+ 458,
+ - 530,
+ - 1000,
+ 307,
+ 129,
+ - 840,
+ - 15,
+ - 29,
+ - 356,
+ - 911,
+ - 924,
+ - 1147,
+ - 242,
+ - 119,
+ - 528,
+ 127,
+ - 133,
+ - 761,
+ - 765,
+ 190,
+ - 83,
+ - 315,
+ 895,
+ 522,
+ 231,
+ - 222,
+ 102,
+ - 63,
+ - 428,
+ 316,
+ 699,
+ 379,
+ 70,
+ 25,
+ 716,
+ 314,
+ - 108,
+ 507,
+ 874,
+ 566,
+ 238,
+ 108,
+ 941,
+ 519,
+ 195,
+ 425,
+ - 60,
+ - 427,
+ 257,
+ 139,
+ - 103,
+ - 630,
+ 446,
+ 334,
+ 370,
+ 412,
+ 48,
+ - 172,
+ - 690,
+ - 283,
+ 557,
+ 187,
+ - 286,
+ 158,
+ 483,
+ 140,
+ 270,
+ - 344,
+ - 631,
+ 924,
+ 579,
+ - 116,
+ 132,
+ 142,
+ 466,
+ - 68,
+ - 64,
+ 230,
+ - 145,
+ - 302,
+ - 542,
+ - 803,
+ - 912,
+ 1018,
+ 737,
+ - 773,
+ 1015,
+ 630,
+ 297,
+ - 2596,
+ 95,
+ 445,
+ 336,
+ - 2122,
+ 491,
+ 510,
+ 191,
+ - 1253,
+ 161,
+ - 2,
+ - 324,
+ - 1450,
+ - 633,
+ - 712,
+ - 105,
+ - 842,
+ - 254,
+ - 411,
+ 100,
+ - 640,
+ - 290,
+ 1010,
+ 763,
+ - 650,
+ 313,
+ 1169,
+ 730,
+ 140,
+ 505,
+ 1030,
+ 766,
+ 772,
+ 287,
+ 1067,
+ 823,
+ 495,
+ 749,
+ 305,
+ 323,
+ - 164,
+ 462,
+ 78,
+ 399,
+ - 342,
+ - 874,
+ 69,
+ 597,
+ - 16,
+ 620,
+ 621,
+ 337,
+ - 138,
+ - 444,
+ - 265,
+ 218,
+ 84,
+ - 450,
+ 953,
+ 666,
+ - 222,
+ - 803,
+ 541,
+ 604,
+ - 921,
+ - 1376,
+ 244,
+ 116,
+ - 841,
+ - 723,
+ 630,
+ 588,
+ 140,
+ 663,
+ 294,
+ 368,
+ 935,
+ 1046,
+ 881,
+ 759,
+ 1746,
+ 1464,
+ 916,
+ 628,
+ 436,
+ 963,
+ 281,
+ 1,
+ - 119,
+ 74,
+ 542,
+ 213,
+ 1,
+ - 567,
+ 301,
+ 241,
+ 260,
+ 435,
+ 222,
+ 396,
+ 936,
+ 957,
+ 1108,
+ 703,
+ 510,
+ 506,
+ 808,
+ 478,
+ 601,
+ 694,
+ 960,
+ 620,
+ 972,
+ 741,
+ 980,
+ 600,
+ 834,
+ 717,
+ 767,
+ 684,
+ 643,
+ 972,
+ 935,
+ 638,
+ 501,
+ 661,
+ 720,
+ 851,
+ - 105,
+ - 632,
+ - 303,
+ - 117,
+ - 429,
+ 130,
+ 789,
+ 442,
+ - 522,
+ - 188,
+ 704,
+ 373,
+ - 759,
+ 42,
+ 814,
+ 523,
+ - 531,
+ - 1137,
+ 373,
+ 578,
+ - 682,
+ - 1203,
+ - 455,
+ 285,
+ - 1163,
+ - 1577,
+ - 1098,
+ 44,
+ 81,
+ - 82,
+ 712,
+ 363,
+ 477,
+ 246,
+ 954,
+ 622,
+ 1604,
+ 1622,
+ 1277,
+ 891,
+ 1409,
+ 859,
+ 924,
+ 892,
+ 774,
+ 1041,
+ 947,
+ 1142,
+ 40,
+ - 546,
+ - 75,
+ 288,
+ - 616,
+ - 106,
+ - 697,
+ - 26,
+ - 169,
+ - 160,
+ - 891,
+ - 739,
+ - 279,
+ - 384,
+ - 1029,
+ - 350,
+ 1781,
+ 1308,
+ 1046,
+ 816,
+ 1580,
+ 1533,
+ 1472,
+ 1178,
+ 1505,
+ 1076,
+ 1216,
+ 899,
+ 890,
+ 904,
+ 564,
+ 654,
+ 920,
+ 692,
+ 1021,
+ 856,
+ - 493,
+ 132,
+ 177,
+ 505,
+ 71,
+ 195,
+ - 28,
+ 97,
+ 456,
+ 351,
+ - 164,
+ 88,
+ 439,
+ 278,
+ - 40,
+ 350,
+ 1395,
+ 949,
+ 234,
+ - 95,
+ - 805,
+ - 472,
+ 38,
+ - 163,
+ 367,
+ - 98,
+ 489,
+ 523,
+ 1025,
+ 1178,
+ 1212,
+ 906,
+ 319,
+ 1314,
+ 814,
+ 461,
+ - 123,
+ - 543,
+ - 804,
+ 447,
+ - 748,
+ - 324,
+ - 897,
+ - 1127,
+ - 737,
+ - 501,
+ - 789,
+ - 713,
+ 715,
+ 777,
+ 1239,
+ 922,
+ 1949,
+ 1939,
+ 1368,
+ 865,
+ 730,
+ 880,
+ 758,
+ 388,
+ - 871,
+ 454,
+ 17,
+ - 251,
+ - 381,
+ - 810,
+ - 1583,
+ 239,
+ - 521,
+ - 966,
+ - 792,
+ 259,
+ - 890,
+ - 1358,
+ - 770,
+ - 73,
+ 166,
+ 349,
+ - 212,
+ 323,
+ - 840,
+ - 301,
+ 473,
+ 435,
+ - 679,
+ - 464,
+ 728,
+ 351,
+ - 156,
+ - 199,
+ 667,
+ 432,
+ 29,
+ - 252,
+ 415,
+ 480,
+ - 731,
+ - 379,
+ 145,
+ 559,
+ - 528,
+ - 631,
+ - 1158,
+ - 159,
+ 445,
+ 273,
+ 123,
+ 639,
+ 373,
+ - 126,
+ 800,
+ 568,
+ 84,
+ - 162,
+ 720,
+ 712,
+ - 830,
+ - 536,
+ - 185,
+ 222,
+ 408,
+ 452,
+ 501,
+ 771,
+ - 897,
+ - 1355,
+ - 67,
+ 442,
+ - 792,
+ - 1406,
+ 566,
+ 602,
+ 167,
+ - 326,
+ 509,
+ 330,
+ - 95,
+ - 626,
+ - 730,
+ - 344,
+ 1668,
+ 1217,
+ 779,
+ 455,
+ 1316,
+ 828,
+ 584,
+ 719,
+ 404,
+ - 31,
+ 1013,
+ 789,
+ 89,
+ 107,
+ 891,
+ 549,
+ 871,
+ 1581,
+ 917,
+ 671,
+ 866,
+ 1479,
+ 1289,
+ 854,
+ 391,
+ 1068,
+ 1122,
+ 812,
+ 78,
+ - 562,
+ 345,
+ 563,
+ 429,
+ - 103,
+ 417,
+ 787,
+ - 122,
+ - 437,
+ 411,
+ 788,
+ - 913,
+ - 417,
+ 602,
+ 754,
+ - 226,
+ - 16,
+ 151,
+ 760,
+ - 700,
+ 118,
+ - 104,
+ - 14,
+ - 1128,
+ 48,
+ 284,
+ 393,
+ - 390,
+ - 419,
+ - 639,
+ - 116,
+ - 910,
+ 306,
+ 316,
+ - 13,
+ 1207,
+ 984,
+ 821,
+ 669,
+ - 1195,
+ - 693,
+ 140,
+ - 213,
+ - 884,
+ - 416,
+ - 199,
+ - 558,
+ - 616,
+ 245,
+ - 404,
+ - 664,
+ 262,
+ 56,
+ - 617,
+ - 724,
+ - 85,
+ - 491,
+ - 320,
+ - 656,
+ - 570,
+ - 831,
+ - 129,
+ - 528,
+ - 1506,
+ - 63,
+ - 367,
+ - 385,
+ - 358,
+ - 321,
+ 4,
+ 51,
+ - 366,
+ - 214,
+ 319,
+ 511,
+ 146,
+ 671,
+ - 17,
+ - 291,
+ - 110,
+ 464,
+ - 139,
+ - 496,
+ - 202,
+ 220,
+ - 312,
+ - 631,
+ - 660,
+ - 73,
+ - 655,
+ - 820,
+ - 662,
+ - 653,
+ - 1288,
+ - 857,
+ - 430,
+ - 953,
+ - 959,
+ - 264,
+ - 49,
+ - 468,
+ - 72,
+ - 381,
+ - 350,
+ - 563,
+ - 193,
+ - 407,
+ 55,
+ - 408,
+ - 803,
+ 11,
+ - 309,
+ 649,
+ 188,
+ - 198,
+ - 512,
+ 461,
+ - 79,
+ - 458,
+ - 1318,
+ - 263,
+ - 134,
+ - 523,
+ - 1657,
+ - 435,
+ - 495,
+ - 765,
+ 57,
+ - 347,
+ - 414,
+ 434,
+ - 1141,
+ - 242,
+ - 664,
+ - 857,
+ 34,
+ - 68,
+ - 707,
+ - 338
+};
+#define MR515_3_SIZE 128
+
+/* 3rd LSF quantizer (MR515 and MR475) */
+static const Word32 mr515_3_lsf[] =
+{
+ 419,
+ 163,
+ - 30,
+ - 262,
+ - 455,
+ - 789,
+ - 1430,
+ - 721,
+ 1006,
+ 664,
+ 269,
+ 25,
+ 619,
+ 260,
+ 183,
+ 96,
+ - 968,
+ - 1358,
+ - 388,
+ 135,
+ - 693,
+ 835,
+ 456,
+ 154,
+ 1105,
+ 703,
+ 569,
+ 363,
+ 1625,
+ 1326,
+ 985,
+ 748,
+ - 220,
+ 219,
+ 76,
+ - 208,
+ - 1455,
+ - 1662,
+ 49,
+ 149,
+ - 964,
+ - 172,
+ - 752,
+ - 336,
+ 625,
+ 209,
+ - 250,
+ - 66,
+ - 1017,
+ - 838,
+ - 2,
+ 317,
+ - 2168,
+ - 1485,
+ - 138,
+ 123,
+ - 1876,
+ - 2099,
+ - 521,
+ 85,
+ - 967,
+ - 366,
+ - 695,
+ - 881,
+ - 921,
+ - 1011,
+ - 763,
+ - 949,
+ - 124,
+ - 256,
+ - 352,
+ - 660,
+ 178,
+ 463,
+ 354,
+ 304,
+ - 1744,
+ - 591,
+ - 282,
+ 79,
+ - 2249,
+ 175,
+ 867,
+ 499,
+ - 138,
+ - 180,
+ - 181,
+ - 21,
+ - 2291,
+ - 1241,
+ - 460,
+ - 520,
+ - 771,
+ 451,
+ - 10,
+ - 308,
+ 271,
+ - 65,
+ 4,
+ 214,
+ - 279,
+ - 435,
+ - 43,
+ - 348,
+ - 670,
+ 35,
+ - 65,
+ - 211,
+ 806,
+ 535,
+ 85,
+ 297,
+ 57,
+ 239,
+ 722,
+ 493,
+ 225,
+ 661,
+ 840,
+ 547,
+ - 540,
+ - 376,
+ 14,
+ 349,
+ 469,
+ 721,
+ 331,
+ 162,
+ - 544,
+ - 752,
+ - 62,
+ - 10,
+ 398,
+ - 88,
+ 724,
+ 701,
+ - 19,
+ - 533,
+ - 94,
+ 601,
+ 136,
+ - 71,
+ - 681,
+ - 747,
+ - 166,
+ - 344,
+ 261,
+ - 50,
+ 161,
+ - 52,
+ 485,
+ 337,
+ - 1675,
+ 50,
+ 190,
+ - 93,
+ - 2282,
+ - 231,
+ - 194,
+ - 82,
+ - 95,
+ - 595,
+ - 154,
+ 128,
+ 894,
+ 501,
+ 588,
+ 457,
+ - 345,
+ 206,
+ 122,
+ 110,
+ - 631,
+ - 227,
+ - 569,
+ 3,
+ 408,
+ 239,
+ 397,
+ 226,
+ - 197,
+ - 2,
+ 128,
+ 491,
+ 1281,
+ 904,
+ 292,
+ 215,
+ 538,
+ 306,
+ 259,
+ 509,
+ - 677,
+ - 1047,
+ 13,
+ 321,
+ - 679,
+ - 588,
+ - 358,
+ - 212,
+ - 558,
+ 243,
+ 646,
+ 479,
+ 486,
+ 342,
+ 634,
+ 532,
+ 107,
+ 802,
+ 331,
+ 136,
+ - 112,
+ - 398,
+ - 1031,
+ - 286,
+ - 326,
+ - 705,
+ 288,
+ 272,
+ 1299,
+ 1144,
+ 1178,
+ 860,
+ - 423,
+ 121,
+ - 385,
+ - 148,
+ - 295,
+ - 302,
+ - 834,
+ - 819,
+ 16,
+ - 24,
+ - 201,
+ - 476,
+ 555,
+ 91,
+ - 245,
+ 294,
+ - 38,
+ - 379,
+ - 962,
+ - 1221,
+ - 1191,
+ - 1518,
+ - 273,
+ - 395,
+ - 390,
+ - 1013,
+ - 645,
+ 573,
+ - 1843,
+ - 1030,
+ 505,
+ 468,
+ 744,
+ 947,
+ 609,
+ 493,
+ - 689,
+ - 1172,
+ - 628,
+ - 135,
+ - 1026,
+ 195,
+ 411,
+ 196,
+ 1582,
+ 1147,
+ 575,
+ 337,
+ - 1239,
+ - 777,
+ - 648,
+ - 142,
+ 595,
+ 825,
+ 967,
+ 735,
+ - 1206,
+ - 970,
+ - 81,
+ - 342,
+ - 745,
+ 13,
+ - 72,
+ 375,
+ 454,
+ 19,
+ 1407,
+ 921,
+ - 1647,
+ - 172,
+ 861,
+ 562,
+ 928,
+ 1537,
+ 1063,
+ 740,
+ - 2472,
+ - 952,
+ 264,
+ 82,
+ - 502,
+ - 965,
+ - 1334,
+ 123,
+ 867,
+ 1236,
+ 534,
+ 171,
+ - 2320,
+ - 460,
+ 780,
+ 363,
+ - 1190,
+ - 617,
+ 252,
+ - 61,
+ - 174,
+ 34,
+ 1011,
+ 788,
+ - 2333,
+ 247,
+ 423,
+ 153,
+ - 16,
+ - 355,
+ 262,
+ 449,
+ - 1576,
+ - 1073,
+ - 544,
+ - 371,
+ - 615,
+ - 305,
+ 1051,
+ 805,
+ 687,
+ 528,
+ 6,
+ - 182,
+ 935,
+ 875,
+ 1002,
+ 809,
+ 199,
+ 257,
+ 126,
+ 76,
+ - 584,
+ - 1138,
+ 599,
+ 556,
+ - 1105,
+ - 1391,
+ - 1591,
+ - 519,
+ - 977,
+ - 1325,
+ 108,
+ 347,
+ - 722,
+ - 975,
+ 365,
+ 101,
+ - 145,
+ 681,
+ 249,
+ - 153,
+ 0,
+ - 334,
+ - 570,
+ 159,
+ 412,
+ 285,
+ - 336,
+ - 617,
+ - 953,
+ - 966,
+ 887,
+ 689,
+ - 1251,
+ 84,
+ - 185,
+ - 398,
+ - 592,
+ 433,
+ 1044,
+ 653,
+ 85,
+ 329,
+ - 40,
+ 361,
+ - 433,
+ - 705,
+ 466,
+ 574,
+ - 154,
+ 654,
+ 592,
+ 290,
+ - 167,
+ 72,
+ 349,
+ 175,
+ 674,
+ 297,
+ 977,
+ 720,
+ 1235,
+ 1204,
+ 757,
+ 488,
+ - 400,
+ - 269,
+ 538,
+ 372,
+ - 1350,
+ - 1387,
+ - 1194,
+ - 91,
+ 1262,
+ 876,
+ 775,
+ 700,
+ - 599,
+ - 38,
+ - 430,
+ - 722,
+ 1976,
+ 1630,
+ 991,
+ 608,
+ 111,
+ 276,
+ - 226,
+ - 96,
+ - 947,
+ - 388,
+ - 11,
+ - 7,
+ - 303,
+ - 531,
+ - 839,
+ 338,
+ 1734,
+ 1710,
+ 1405,
+ 1013,
+ - 516,
+ - 855,
+ - 645,
+ 210,
+ - 688,
+ - 416,
+ 513,
+ 230,
+ - 822,
+ - 637,
+ - 1146,
+ - 320,
+ - 952,
+ - 658,
+ - 694,
+ 183,
+ - 114,
+ - 623,
+ 818,
+ 674,
+ - 191,
+ - 204,
+ 731,
+ 635,
+ 51,
+ 1221,
+ 883,
+ 576,
+ - 954,
+ - 431,
+ 826,
+ 598,
+ - 342,
+ - 755,
+ - 900,
+ - 407,
+ - 1126,
+ - 354,
+ - 206,
+ - 512,
+ - 547,
+ - 810,
+ - 357,
+ - 620,
+ 66,
+ 515,
+ - 73,
+ - 410,
+ - 872,
+ - 945,
+ - 1444,
+ - 1227,
+ 191,
+ - 17,
+ - 544,
+ - 231,
+ - 1540,
+ - 544,
+ - 901,
+ - 886
+};
+#define MR795_1_SIZE 512
+
+/* 1st LSF quantizer (MR795) */
+static const Word32 mr795_1_lsf[] =
+{
+ - 890,
+ - 1550,
+ - 2541,
+ - 819,
+ - 970,
+ 175,
+ - 826,
+ - 1234,
+ - 762,
+ - 599,
+ - 22,
+ 634,
+ - 811,
+ - 987,
+ - 902,
+ - 323,
+ 203,
+ 26,
+ - 383,
+ - 235,
+ - 781,
+ - 399,
+ 1262,
+ 906,
+ - 932,
+ - 1399,
+ - 1380,
+ - 624,
+ 93,
+ 87,
+ - 414,
+ - 539,
+ - 691,
+ 37,
+ 633,
+ 510,
+ - 387,
+ - 476,
+ - 1330,
+ 399,
+ 66,
+ 263,
+ - 407,
+ - 49,
+ - 335,
+ - 417,
+ 1041,
+ 1865,
+ - 779,
+ - 1089,
+ - 1440,
+ - 746,
+ - 858,
+ 832,
+ - 581,
+ - 759,
+ - 371,
+ - 673,
+ - 506,
+ 2088,
+ - 560,
+ - 634,
+ - 1179,
+ 271,
+ 241,
+ 14,
+ - 438,
+ - 244,
+ - 397,
+ 463,
+ 1202,
+ 1047,
+ - 606,
+ - 797,
+ - 1438,
+ - 51,
+ - 323,
+ 481,
+ - 224,
+ - 584,
+ - 527,
+ 494,
+ 881,
+ 682,
+ - 433,
+ - 306,
+ - 1002,
+ 554,
+ 659,
+ 222,
+ 171,
+ - 160,
+ - 353,
+ 681,
+ 1798,
+ 1565,
+ - 852,
+ - 1181,
+ - 1695,
+ - 336,
+ - 666,
+ 114,
+ - 581,
+ - 756,
+ - 744,
+ - 195,
+ 375,
+ 497,
+ - 465,
+ - 804,
+ - 1098,
+ 154,
+ 282,
+ - 131,
+ - 50,
+ - 191,
+ - 719,
+ 323,
+ 732,
+ 1542,
+ - 722,
+ - 819,
+ - 1404,
+ 105,
+ - 250,
+ 185,
+ - 178,
+ - 502,
+ - 742,
+ 321,
+ 510,
+ 1111,
+ - 323,
+ - 567,
+ - 966,
+ 127,
+ 484,
+ 338,
+ - 160,
+ 52,
+ - 338,
+ 732,
+ 1367,
+ 1554,
+ - 626,
+ - 802,
+ - 1696,
+ - 286,
+ - 586,
+ 676,
+ - 695,
+ - 343,
+ - 370,
+ - 490,
+ 295,
+ 1893,
+ - 630,
+ - 574,
+ - 1014,
+ - 80,
+ 645,
+ - 69,
+ - 6,
+ - 318,
+ - 364,
+ 782,
+ 1450,
+ 1038,
+ - 313,
+ - 733,
+ - 1395,
+ 120,
+ 60,
+ 477,
+ - 264,
+ - 585,
+ - 123,
+ 711,
+ 1245,
+ 633,
+ - 91,
+ - 355,
+ - 1016,
+ 771,
+ 758,
+ 261,
+ 253,
+ 81,
+ - 474,
+ 930,
+ 2215,
+ 1720,
+ - 808,
+ - 1099,
+ - 1925,
+ - 560,
+ - 782,
+ 169,
+ - 804,
+ - 1074,
+ - 188,
+ - 626,
+ - 55,
+ 1405,
+ - 694,
+ - 716,
+ - 1194,
+ - 660,
+ 354,
+ 329,
+ - 514,
+ - 55,
+ - 543,
+ 366,
+ 1033,
+ 1182,
+ - 658,
+ - 959,
+ - 1357,
+ - 55,
+ - 184,
+ 93,
+ - 605,
+ - 286,
+ - 662,
+ 404,
+ 449,
+ 827,
+ - 286,
+ - 350,
+ - 1263,
+ 628,
+ 306,
+ 227,
+ - 16,
+ 147,
+ - 623,
+ 186,
+ 923,
+ 2146,
+ - 674,
+ - 890,
+ - 1606,
+ - 443,
+ - 228,
+ 339,
+ - 369,
+ - 790,
+ - 409,
+ 231,
+ 86,
+ 1469,
+ - 448,
+ - 581,
+ - 1061,
+ 594,
+ 450,
+ - 177,
+ - 124,
+ - 170,
+ - 447,
+ 671,
+ 1159,
+ 1404,
+ - 476,
+ - 667,
+ - 1511,
+ - 77,
+ - 138,
+ 716,
+ - 177,
+ - 372,
+ - 381,
+ 451,
+ 934,
+ 915,
+ - 250,
+ - 432,
+ - 822,
+ 272,
+ 828,
+ 446,
+ 26,
+ 19,
+ - 31,
+ 698,
+ 1692,
+ 2168,
+ - 646,
+ - 977,
+ - 1924,
+ - 179,
+ - 473,
+ 268,
+ - 379,
+ - 745,
+ - 691,
+ 11,
+ 127,
+ 1033,
+ - 488,
+ - 917,
+ - 825,
+ 61,
+ 323,
+ 135,
+ 147,
+ - 145,
+ - 686,
+ 685,
+ 786,
+ 1682,
+ - 506,
+ - 848,
+ - 1297,
+ 35,
+ 90,
+ 222,
+ - 23,
+ - 346,
+ - 670,
+ 455,
+ 591,
+ 1287,
+ - 203,
+ - 593,
+ - 1086,
+ 652,
+ 352,
+ 437,
+ 39,
+ 63,
+ - 457,
+ 841,
+ 1265,
+ 2105,
+ - 520,
+ - 882,
+ - 1584,
+ - 328,
+ - 711,
+ 1421,
+ - 596,
+ - 342,
+ - 70,
+ 209,
+ 173,
+ 1928,
+ - 423,
+ - 598,
+ - 921,
+ 421,
+ 605,
+ - 38,
+ - 2,
+ - 245,
+ - 127,
+ 896,
+ 1969,
+ 1135,
+ - 379,
+ - 518,
+ - 1579,
+ 173,
+ 118,
+ 753,
+ - 55,
+ - 381,
+ - 52,
+ 985,
+ 1021,
+ 753,
+ - 2,
+ - 291,
+ - 891,
+ 753,
+ 992,
+ 423,
+ 264,
+ 131,
+ - 196,
+ 895,
+ 2274,
+ 2543,
+ - 635,
+ - 1088,
+ - 2499,
+ - 529,
+ - 982,
+ 526,
+ - 764,
+ - 830,
+ - 548,
+ - 436,
+ 316,
+ 599,
+ - 675,
+ - 940,
+ - 746,
+ - 57,
+ 236,
+ - 11,
+ - 201,
+ - 81,
+ - 798,
+ 16,
+ 845,
+ 1558,
+ - 737,
+ - 985,
+ - 1212,
+ - 468,
+ 17,
+ 290,
+ - 279,
+ - 584,
+ - 700,
+ 183,
+ 822,
+ 705,
+ - 265,
+ - 492,
+ - 1187,
+ 421,
+ 152,
+ 468,
+ - 390,
+ 166,
+ - 268,
+ 39,
+ 1550,
+ 1868,
+ - 635,
+ - 966,
+ - 1571,
+ - 453,
+ - 492,
+ 910,
+ - 284,
+ - 1027,
+ - 75,
+ - 181,
+ - 133,
+ 1852,
+ - 445,
+ - 624,
+ - 1174,
+ 420,
+ 367,
+ - 49,
+ - 389,
+ - 212,
+ - 169,
+ 707,
+ 1073,
+ 1208,
+ - 539,
+ - 710,
+ - 1449,
+ 83,
+ - 163,
+ 484,
+ - 236,
+ - 543,
+ - 355,
+ 338,
+ 1175,
+ 814,
+ - 246,
+ - 309,
+ - 958,
+ 606,
+ 760,
+ 60,
+ 166,
+ - 8,
+ - 163,
+ - 306,
+ 1849,
+ 2563,
+ - 747,
+ - 1025,
+ - 1783,
+ - 419,
+ - 446,
+ 209,
+ - 718,
+ - 566,
+ - 534,
+ - 506,
+ 693,
+ 857,
+ - 463,
+ - 697,
+ - 1082,
+ 325,
+ 431,
+ - 206,
+ - 15,
+ - 8,
+ - 763,
+ 545,
+ 919,
+ 1518,
+ - 611,
+ - 783,
+ - 1313,
+ 256,
+ - 55,
+ 208,
+ - 165,
+ - 348,
+ - 662,
+ 321,
+ 680,
+ 930,
+ - 326,
+ - 429,
+ - 951,
+ 484,
+ 446,
+ 570,
+ - 197,
+ 72,
+ - 73,
+ 909,
+ 1455,
+ 1741,
+ - 563,
+ - 737,
+ - 1974,
+ - 124,
+ - 416,
+ 718,
+ - 478,
+ - 404,
+ - 314,
+ - 16,
+ 446,
+ 1636,
+ - 551,
+ - 537,
+ - 750,
+ - 58,
+ 638,
+ 214,
+ 55,
+ - 185,
+ - 271,
+ 1148,
+ 1301,
+ 1212,
+ - 483,
+ - 671,
+ - 1264,
+ 117,
+ 285,
+ 543,
+ - 204,
+ - 391,
+ - 111,
+ 513,
+ 1538,
+ 854,
+ - 114,
+ - 190,
+ - 978,
+ 877,
+ 595,
+ 464,
+ 260,
+ 260,
+ - 311,
+ 748,
+ 2283,
+ 2216,
+ - 517,
+ - 945,
+ - 2171,
+ - 326,
+ - 708,
+ 378,
+ - 812,
+ - 691,
+ - 232,
+ - 560,
+ 687,
+ 1409,
+ - 732,
+ - 690,
+ - 836,
+ - 359,
+ 645,
+ 386,
+ - 265,
+ 62,
+ - 678,
+ 145,
+ 1644,
+ 1208,
+ - 555,
+ - 988,
+ - 1233,
+ - 78,
+ 14,
+ 114,
+ - 327,
+ - 358,
+ - 489,
+ 392,
+ 677,
+ 697,
+ - 201,
+ - 236,
+ - 1140,
+ 693,
+ 449,
+ 178,
+ - 243,
+ 256,
+ - 433,
+ 611,
+ 1385,
+ 2456,
+ - 612,
+ - 901,
+ - 1464,
+ - 307,
+ - 17,
+ 499,
+ - 315,
+ - 667,
+ - 254,
+ 256,
+ 428,
+ 1463,
+ - 486,
+ - 422,
+ - 1056,
+ 655,
+ 370,
+ 18,
+ - 102,
+ - 185,
+ - 276,
+ 755,
+ 1578,
+ 1335,
+ - 488,
+ - 603,
+ - 1418,
+ 182,
+ - 93,
+ 870,
+ - 73,
+ - 458,
+ - 348,
+ 835,
+ 862,
+ 957,
+ - 282,
+ - 333,
+ - 746,
+ 547,
+ 839,
+ 428,
+ 273,
+ - 89,
+ 13,
+ 940,
+ 1708,
+ 2576,
+ - 418,
+ - 1084,
+ - 1758,
+ - 44,
+ - 358,
+ 259,
+ - 497,
+ - 643,
+ - 560,
+ 99,
+ 557,
+ 961,
+ - 421,
+ - 766,
+ - 917,
+ 295,
+ 326,
+ 184,
+ 175,
+ 15,
+ - 626,
+ 532,
+ 878,
+ 1981,
+ - 443,
+ - 768,
+ - 1275,
+ 221,
+ 156,
+ 268,
+ 39,
+ - 363,
+ - 505,
+ 695,
+ 772,
+ 1140,
+ - 162,
+ - 459,
+ - 912,
+ 709,
+ 444,
+ 658,
+ 25,
+ 303,
+ - 312,
+ 1268,
+ 1410,
+ 1715,
+ - 297,
+ - 766,
+ - 1836,
+ - 263,
+ - 108,
+ 1070,
+ - 406,
+ - 13,
+ - 129,
+ 57,
+ 438,
+ 2734,
+ - 374,
+ - 487,
+ - 835,
+ 304,
+ 696,
+ 164,
+ 104,
+ - 235,
+ 5,
+ 1611,
+ 1900,
+ 1399,
+ - 229,
+ - 582,
+ - 1325,
+ 405,
+ 192,
+ 817,
+ - 87,
+ - 438,
+ 111,
+ 1028,
+ 1199,
+ 993,
+ 68,
+ - 175,
+ - 934,
+ 1033,
+ 1117,
+ 451,
+ 478,
+ 200,
+ - 248,
+ 2127,
+ 2696,
+ 2042,
+ - 835,
+ - 1323,
+ - 2131,
+ - 799,
+ - 692,
+ 466,
+ - 812,
+ - 1032,
+ - 469,
+ - 622,
+ 288,
+ 920,
+ - 701,
+ - 841,
+ - 1070,
+ - 411,
+ 512,
+ 8,
+ - 390,
+ - 91,
+ - 744,
+ - 30,
+ 1043,
+ 1161,
+ - 822,
+ - 1148,
+ - 1156,
+ - 294,
+ - 46,
+ 110,
+ - 411,
+ - 374,
+ - 678,
+ 214,
+ 531,
+ 668,
+ - 406,
+ - 420,
+ - 1194,
+ 487,
+ 232,
+ 303,
+ - 318,
+ 91,
+ - 472,
+ 123,
+ 1232,
+ 2445,
+ - 722,
+ - 952,
+ - 1495,
+ - 738,
+ - 675,
+ 1332,
+ - 543,
+ - 606,
+ - 211,
+ - 95,
+ - 98,
+ 1508,
+ - 549,
+ - 514,
+ - 1193,
+ 473,
+ 211,
+ 73,
+ - 288,
+ - 112,
+ - 389,
+ 537,
+ 1332,
+ 1258,
+ - 567,
+ - 755,
+ - 1545,
+ 71,
+ - 283,
+ 632,
+ - 170,
+ - 481,
+ - 493,
+ 681,
+ 1002,
+ 817,
+ - 356,
+ - 331,
+ - 877,
+ 419,
+ 706,
+ 346,
+ 241,
+ - 34,
+ - 326,
+ 377,
+ 1950,
+ 1883,
+ - 727,
+ - 1075,
+ - 1625,
+ - 233,
+ - 543,
+ 116,
+ - 524,
+ - 806,
+ - 585,
+ - 73,
+ 478,
+ 729,
+ - 288,
+ - 925,
+ - 1143,
+ 173,
+ 447,
+ - 52,
+ 68,
+ - 229,
+ - 606,
+ 449,
+ 529,
+ 1797,
+ - 591,
+ - 875,
+ - 1363,
+ 183,
+ - 144,
+ 324,
+ - 103,
+ - 452,
+ - 666,
+ 623,
+ 488,
+ 1176,
+ - 238,
+ - 511,
+ - 1004,
+ 326,
+ 552,
+ 458,
+ 136,
+ 108,
+ - 319,
+ 626,
+ 1343,
+ 1883,
+ - 490,
+ - 646,
+ - 1730,
+ - 186,
+ - 449,
+ 984,
+ - 738,
+ - 76,
+ - 170,
+ - 550,
+ 755,
+ 2560,
+ - 496,
+ - 510,
+ - 947,
+ 210,
+ 694,
+ - 52,
+ 84,
+ - 322,
+ - 199,
+ 1090,
+ 1625,
+ 1224,
+ - 376,
+ - 603,
+ - 1396,
+ 343,
+ 74,
+ 632,
+ - 175,
+ - 502,
+ - 32,
+ 972,
+ 1332,
+ 734,
+ 52,
+ - 295,
+ - 1113,
+ 1065,
+ 918,
+ 160,
+ 393,
+ 107,
+ - 397,
+ 1214,
+ 2649,
+ 1741,
+ - 632,
+ - 1201,
+ - 1891,
+ - 719,
+ - 277,
+ 353,
+ - 651,
+ - 880,
+ - 122,
+ - 211,
+ 209,
+ 1338,
+ - 562,
+ - 714,
+ - 1059,
+ - 208,
+ 388,
+ 159,
+ - 320,
+ - 61,
+ - 551,
+ 293,
+ 1092,
+ 1443,
+ - 648,
+ - 865,
+ - 1253,
+ - 49,
+ - 143,
+ 305,
+ - 401,
+ - 227,
+ - 585,
+ 561,
+ 532,
+ 927,
+ - 117,
+ - 443,
+ - 1188,
+ 507,
+ 436,
+ 292,
+ - 79,
+ 233,
+ - 458,
+ 671,
+ 1025,
+ 2396,
+ - 633,
+ - 842,
+ - 1525,
+ - 308,
+ - 286,
+ 640,
+ - 373,
+ - 621,
+ - 407,
+ 418,
+ 253,
+ 1305,
+ - 315,
+ - 581,
+ - 1137,
+ 572,
+ 685,
+ - 281,
+ 61,
+ - 68,
+ - 371,
+ 991,
+ 1101,
+ 1498,
+ - 493,
+ - 683,
+ - 1362,
+ - 47,
+ 164,
+ 704,
+ - 256,
+ - 314,
+ - 268,
+ 631,
+ 949,
+ 1052,
+ - 118,
+ - 348,
+ - 833,
+ 68,
+ 1180,
+ 568,
+ 152,
+ 117,
+ 34,
+ 1113,
+ 1902,
+ 2239,
+ - 601,
+ - 959,
+ - 1706,
+ - 143,
+ - 489,
+ 480,
+ - 332,
+ - 655,
+ - 574,
+ 54,
+ 353,
+ 1192,
+ - 462,
+ - 652,
+ - 796,
+ 150,
+ 549,
+ 112,
+ 195,
+ - 111,
+ - 515,
+ 679,
+ 1108,
+ 1647,
+ - 558,
+ - 749,
+ - 1217,
+ - 9,
+ 272,
+ 341,
+ - 53,
+ - 265,
+ - 535,
+ 489,
+ 843,
+ 1298,
+ - 120,
+ - 482,
+ - 1032,
+ 632,
+ 543,
+ 408,
+ 179,
+ 306,
+ - 526,
+ 1124,
+ 1464,
+ 2244,
+ - 417,
+ - 786,
+ - 1562,
+ - 224,
+ - 384,
+ 1364,
+ - 377,
+ - 459,
+ - 25,
+ 385,
+ 489,
+ 2174,
+ - 332,
+ - 651,
+ - 829,
+ 544,
+ 553,
+ 61,
+ 22,
+ - 113,
+ - 89,
+ 1128,
+ 1725,
+ 1524,
+ - 216,
+ - 373,
+ - 1653,
+ 161,
+ 316,
+ 908,
+ - 165,
+ - 222,
+ - 67,
+ 1362,
+ 1175,
+ 789,
+ 73,
+ - 252,
+ - 767,
+ 738,
+ 932,
+ 616,
+ 362,
+ 246,
+ - 126,
+ 787,
+ 2654,
+ 3027,
+ - 691,
+ - 1106,
+ - 2190,
+ - 565,
+ - 588,
+ 524,
+ - 590,
+ - 979,
+ - 490,
+ - 263,
+ 397,
+ 982,
+ - 577,
+ - 837,
+ - 945,
+ - 22,
+ 435,
+ - 49,
+ - 190,
+ - 118,
+ - 629,
+ - 88,
+ 1240,
+ 1513,
+ - 636,
+ - 1051,
+ - 1019,
+ - 291,
+ 189,
+ 259,
+ - 257,
+ - 470,
+ - 629,
+ 145,
+ 945,
+ 894,
+ - 326,
+ - 364,
+ - 1094,
+ 543,
+ 260,
+ 630,
+ - 202,
+ 189,
+ - 209,
+ 357,
+ 1379,
+ 2091,
+ - 569,
+ - 1075,
+ - 1449,
+ - 714,
+ - 239,
+ 919,
+ - 420,
+ - 705,
+ - 84,
+ - 109,
+ - 114,
+ 2407,
+ - 413,
+ - 529,
+ - 1177,
+ 482,
+ 368,
+ 131,
+ - 186,
+ - 72,
+ - 131,
+ 861,
+ 1255,
+ 1220,
+ - 611,
+ - 658,
+ - 1341,
+ 227,
+ - 121,
+ 631,
+ - 176,
+ - 489,
+ - 218,
+ 745,
+ 1175,
+ 957,
+ - 321,
+ - 148,
+ - 936,
+ 671,
+ 966,
+ 216,
+ 340,
+ - 3,
+ - 143,
+ 469,
+ 1848,
+ 2437,
+ - 729,
+ - 961,
+ - 1683,
+ - 213,
+ - 254,
+ 321,
+ - 511,
+ - 438,
+ - 521,
+ - 126,
+ 725,
+ 903,
+ - 340,
+ - 685,
+ - 1032,
+ 316,
+ 480,
+ 20,
+ 23,
+ - 89,
+ - 551,
+ 353,
+ 1051,
+ 1789,
+ - 544,
+ - 757,
+ - 1364,
+ 298,
+ - 25,
+ 436,
+ - 100,
+ - 392,
+ - 519,
+ 467,
+ 754,
+ 1078,
+ - 210,
+ - 398,
+ - 1078,
+ 620,
+ 658,
+ 630,
+ 33,
+ 147,
+ - 178,
+ 921,
+ 1687,
+ 1921,
+ - 325,
+ - 528,
+ - 1978,
+ 2,
+ - 285,
+ 910,
+ - 371,
+ - 490,
+ - 230,
+ 0,
+ 597,
+ 2010,
+ - 496,
+ - 395,
+ - 834,
+ 37,
+ 945,
+ 245,
+ 181,
+ - 160,
+ - 144,
+ 1481,
+ 1373,
+ 1357,
+ - 355,
+ - 601,
+ - 1270,
+ 298,
+ 322,
+ 672,
+ - 193,
+ - 336,
+ 77,
+ 1089,
+ 1533,
+ 922,
+ 177,
+ - 39,
+ - 1125,
+ 996,
+ 781,
+ 536,
+ 456,
+ 366,
+ - 432,
+ 1415,
+ 2440,
+ 2279,
+ - 466,
+ - 758,
+ - 2325,
+ - 303,
+ - 509,
+ 387,
+ - 727,
+ - 557,
+ 66,
+ - 145,
+ 643,
+ 1248,
+ - 544,
+ - 676,
+ - 916,
+ - 225,
+ 862,
+ 588,
+ - 152,
+ 40,
+ - 533,
+ 423,
+ 1423,
+ 1558,
+ - 572,
+ - 843,
+ - 1145,
+ - 128,
+ 85,
+ 461,
+ - 238,
+ - 257,
+ - 584,
+ 605,
+ 748,
+ 861,
+ 24,
+ - 202,
+ - 1409,
+ 797,
+ 487,
+ 303,
+ - 181,
+ 364,
+ - 182,
+ 616,
+ 1378,
+ 2942,
+ - 494,
+ - 852,
+ - 1441,
+ - 292,
+ 61,
+ 812,
+ - 84,
+ - 723,
+ - 182,
+ 555,
+ 532,
+ 1506,
+ - 365,
+ - 493,
+ - 1057,
+ 822,
+ 588,
+ 11,
+ - 14,
+ - 18,
+ - 230,
+ 1001,
+ 1401,
+ 1451,
+ - 474,
+ - 569,
+ - 1292,
+ 302,
+ 62,
+ 1062,
+ - 70,
+ - 376,
+ - 222,
+ 982,
+ 974,
+ 1149,
+ - 196,
+ - 234,
+ - 795,
+ 479,
+ 1098,
+ 499,
+ 362,
+ 58,
+ 70,
+ 1147,
+ 2069,
+ 2857,
+ - 487,
+ - 878,
+ - 1824,
+ 73,
+ - 288,
+ 348,
+ - 358,
+ - 500,
+ - 508,
+ 199,
+ 721,
+ 1242,
+ - 78,
+ - 697,
+ - 795,
+ 361,
+ 536,
+ 196,
+ 374,
+ 110,
+ - 735,
+ 847,
+ 1051,
+ 1896,
+ - 366,
+ - 713,
+ - 1182,
+ 315,
+ 320,
+ 429,
+ 72,
+ - 215,
+ - 450,
+ 759,
+ 886,
+ 1363,
+ - 30,
+ - 428,
+ - 834,
+ 861,
+ 627,
+ 796,
+ 118,
+ 468,
+ - 279,
+ 1355,
+ 1883,
+ 1893,
+ - 188,
+ - 642,
+ - 1612,
+ 63,
+ - 175,
+ 1198,
+ - 418,
+ - 211,
+ 51,
+ 414,
+ 587,
+ 2601,
+ - 234,
+ - 557,
+ - 858,
+ 424,
+ 889,
+ 222,
+ 136,
+ - 101,
+ 83,
+ 1413,
+ 2278,
+ 1383,
+ - 84,
+ - 445,
+ - 1389,
+ 414,
+ 313,
+ 1045,
+ 29,
+ - 343,
+ 65,
+ 1552,
+ 1647,
+ 980,
+ 183,
+ - 91,
+ - 829,
+ 1273,
+ 1413,
+ 360,
+ 553,
+ 272,
+ - 107,
+ 1587,
+ 3149,
+ 2603
+};
+#define DICO1_SIZE_5 128
+#define DICO2_SIZE_5 256
+#define DICO3_SIZE_5 256
+#define DICO4_SIZE_5 256
+#define DICO5_SIZE_5 64
+
+/* 1st LSF quantizer (MR122) */
+static const Word32 dico1_lsf_5[DICO1_SIZE_5 * 4] =
+{
+ - 451,
+ - 1065,
+ - 529,
+ - 1305,
+ - 450,
+ - 756,
+ - 497,
+ - 863,
+ - 384,
+ - 619,
+ - 413,
+ - 669,
+ - 317,
+ - 538,
+ - 331,
+ - 556,
+ - 414,
+ - 508,
+ - 424,
+ - 378,
+ - 274,
+ - 324,
+ - 434,
+ - 614,
+ - 226,
+ - 500,
+ - 232,
+ - 514,
+ - 263,
+ - 377,
+ - 298,
+ - 410,
+ - 151,
+ - 710,
+ - 174,
+ - 818,
+ - 149,
+ - 412,
+ - 156,
+ - 429,
+ - 288,
+ - 462,
+ - 186,
+ - 203,
+ - 170,
+ - 302,
+ - 191,
+ - 321,
+ - 131,
+ - 147,
+ - 297,
+ - 395,
+ - 228,
+ - 214,
+ - 245,
+ - 192,
+ - 67,
+ - 316,
+ - 71,
+ - 327,
+ - 104,
+ - 205,
+ - 94,
+ - 183,
+ - 143,
+ - 38,
+ - 193,
+ - 95,
+ 16,
+ - 76,
+ - 124,
+ - 248,
+ 23,
+ - 237,
+ 24,
+ - 244,
+ 18,
+ - 136,
+ 44,
+ - 111,
+ - 33,
+ - 24,
+ - 25,
+ 0,
+ 149,
+ 19,
+ 23,
+ - 143,
+ 158,
+ - 169,
+ 174,
+ - 181,
+ 133,
+ - 55,
+ 165,
+ - 26,
+ 111,
+ 84,
+ 98,
+ 75,
+ 87,
+ 183,
+ - 115,
+ - 11,
+ - 8,
+ 130,
+ 11,
+ 170,
+ 254,
+ 77,
+ 205,
+ 17,
+ 183,
+ 112,
+ 262,
+ 194,
+ 202,
+ 287,
+ 95,
+ 189,
+ - 42,
+ - 105,
+ 234,
+ 179,
+ 39,
+ 186,
+ 163,
+ 345,
+ 332,
+ 199,
+ 299,
+ 161,
+ - 54,
+ 285,
+ - 78,
+ 281,
+ - 133,
+ 141,
+ - 182,
+ 111,
+ 249,
+ 341,
+ 271,
+ 364,
+ 93,
+ 403,
+ 75,
+ 391,
+ 92,
+ 510,
+ - 138,
+ 220,
+ - 185,
+ - 29,
+ - 34,
+ 361,
+ - 115,
+ 320,
+ 3,
+ 554,
+ 99,
+ 286,
+ 218,
+ 591,
+ - 245,
+ 406,
+ - 268,
+ 453,
+ 0,
+ 580,
+ 25,
+ 606,
+ 275,
+ 532,
+ 148,
+ 450,
+ - 73,
+ 739,
+ - 285,
+ 518,
+ - 288,
+ 94,
+ - 203,
+ 674,
+ - 140,
+ - 74,
+ 205,
+ 714,
+ - 114,
+ 299,
+ 176,
+ 923,
+ 182,
+ 557,
+ 240,
+ 705,
+ - 16,
+ 513,
+ 485,
+ 593,
+ 293,
+ 384,
+ 451,
+ 617,
+ - 38,
+ 50,
+ 563,
+ 529,
+ 303,
+ 209,
+ 459,
+ 363,
+ 433,
+ 452,
+ 450,
+ 454,
+ 367,
+ 606,
+ 477,
+ 741,
+ 432,
+ 353,
+ 368,
+ 267,
+ 361,
+ 716,
+ 273,
+ 583,
+ 453,
+ 166,
+ 510,
+ 172,
+ 201,
+ 629,
+ 274,
+ 191,
+ 568,
+ 639,
+ 302,
+ 298,
+ 634,
+ 387,
+ 643,
+ 350,
+ 587,
+ 560,
+ 612,
+ 565,
+ 600,
+ 788,
+ 487,
+ 672,
+ 512,
+ 1015,
+ 321,
+ 333,
+ 357,
+ 854,
+ - 125,
+ 413,
+ 474,
+ 712,
+ 17,
+ - 151,
+ 564,
+ 285,
+ 270,
+ - 241,
+ 971,
+ 889,
+ 489,
+ 220,
+ 510,
+ 896,
+ 549,
+ 924,
+ 327,
+ 825,
+ 290,
+ 911,
+ 540,
+ 1108,
+ 158,
+ 805,
+ 199,
+ 957,
+ 511,
+ 730,
+ 100,
+ 874,
+ 13,
+ 791,
+ 435,
+ 632,
+ 676,
+ 972,
+ 249,
+ 900,
+ 467,
+ 1218,
+ 781,
+ 1074,
+ 585,
+ 785,
+ - 23,
+ 669,
+ 267,
+ 1043,
+ 619,
+ 1084,
+ 615,
+ 1145,
+ 622,
+ 905,
+ 916,
+ 1049,
+ 80,
+ 331,
+ 584,
+ 1075,
+ 89,
+ 639,
+ 988,
+ 961,
+ 770,
+ 720,
+ 798,
+ 699,
+ 492,
+ 447,
+ 899,
+ 627,
+ 271,
+ 1188,
+ 725,
+ 1333,
+ 87,
+ 603,
+ 832,
+ 1603,
+ 616,
+ 1127,
+ 890,
+ 1505,
+ 1000,
+ 1156,
+ 866,
+ 1009,
+ 995,
+ 827,
+ 1149,
+ 858,
+ 817,
+ 1450,
+ 773,
+ 1320,
+ 500,
+ 1389,
+ 312,
+ 1153,
+ - 20,
+ 1084,
+ 64,
+ 1283,
+ 2,
+ 1172,
+ 399,
+ 1869,
+ 514,
+ 1706,
+ 502,
+ 1636,
+ 886,
+ 1522,
+ 416,
+ 600,
+ 1131,
+ 1350,
+ 1275,
+ 1390,
+ 889,
+ 1795,
+ 914,
+ 1766,
+ 227,
+ 1183,
+ 1250,
+ 1826,
+ 505,
+ 1854,
+ 919,
+ 2353,
+ - 199,
+ 431,
+ 152,
+ 1735,
+ - 213,
+ - 28,
+ 392,
+ 1334,
+ - 153,
+ - 52,
+ 978,
+ 1151,
+ - 323,
+ - 400,
+ 813,
+ 1703,
+ - 136,
+ 84,
+ 1449,
+ 2015,
+ - 331,
+ - 143,
+ - 137,
+ 1192,
+ - 256,
+ 534,
+ - 157,
+ 1031,
+ - 307,
+ - 439,
+ 542,
+ 731,
+ - 329,
+ - 420,
+ - 97,
+ 616,
+ - 362,
+ - 168,
+ - 322,
+ 366,
+ - 247,
+ - 110,
+ - 211,
+ 89,
+ - 196,
+ - 309,
+ 20,
+ 59,
+ - 364,
+ - 463,
+ - 286,
+ 89,
+ - 336,
+ 175,
+ - 432,
+ 141,
+ - 379,
+ - 190,
+ - 434,
+ - 196,
+ - 79,
+ 150,
+ - 278,
+ - 227,
+ - 280,
+ 166,
+ - 555,
+ - 422,
+ - 155,
+ 541,
+ - 366,
+ 54,
+ - 29,
+ - 83,
+ - 301,
+ - 774,
+ 186,
+ 628,
+ - 397,
+ - 264,
+ 242,
+ 293,
+ - 197,
+ - 585,
+ 124,
+ 410,
+ 53,
+ - 133,
+ 10,
+ 340,
+ - 570,
+ - 1065,
+ 65,
+ - 446,
+ 68,
+ - 493,
+ 383,
+ 937,
+ - 357,
+ - 711,
+ - 359,
+ - 250,
+ - 677,
+ - 1068,
+ 292,
+ - 26,
+ 363,
+ 6,
+ 607,
+ 1313,
+ - 127,
+ - 10,
+ 1513,
+ 1886,
+ 713,
+ 972,
+ 1469,
+ 2181,
+ 1443,
+ 2016
+};
+
+/* 2nd LSF quantizer (MR122) */
+static const Word32 dico2_lsf_5[DICO2_SIZE_5 * 4] =
+{
+ - 1631,
+ - 1600,
+ - 1796,
+ - 2290,
+ - 1027,
+ - 1770,
+ - 1100,
+ - 2025,
+ - 1277,
+ - 1388,
+ - 1367,
+ - 1534,
+ - 947,
+ - 1461,
+ - 972,
+ - 1524,
+ - 999,
+ - 1222,
+ - 1020,
+ - 1172,
+ - 815,
+ - 987,
+ - 992,
+ - 1371,
+ - 1216,
+ - 1006,
+ - 1289,
+ - 1094,
+ - 744,
+ - 1268,
+ - 755,
+ - 1293,
+ - 862,
+ - 923,
+ - 905,
+ - 984,
+ - 678,
+ - 1051,
+ - 685,
+ - 1050,
+ - 1087,
+ - 985,
+ - 1062,
+ - 679,
+ - 989,
+ - 641,
+ - 1127,
+ - 976,
+ - 762,
+ - 654,
+ - 890,
+ - 806,
+ - 833,
+ - 1091,
+ - 706,
+ - 629,
+ - 621,
+ - 806,
+ - 640,
+ - 812,
+ - 775,
+ - 634,
+ - 779,
+ - 543,
+ - 996,
+ - 565,
+ - 1075,
+ - 580,
+ - 546,
+ - 611,
+ - 572,
+ - 619,
+ - 760,
+ - 290,
+ - 879,
+ - 526,
+ - 823,
+ - 462,
+ - 795,
+ - 253,
+ - 553,
+ - 415,
+ - 589,
+ - 439,
+ - 533,
+ - 340,
+ - 692,
+ - 935,
+ - 505,
+ - 772,
+ - 702,
+ - 1131,
+ - 263,
+ - 306,
+ - 971,
+ - 483,
+ - 445,
+ - 74,
+ - 555,
+ - 548,
+ - 614,
+ - 129,
+ - 693,
+ - 234,
+ - 396,
+ - 246,
+ - 475,
+ - 250,
+ - 265,
+ - 404,
+ - 376,
+ - 514,
+ - 417,
+ - 510,
+ - 300,
+ - 313,
+ - 334,
+ - 664,
+ - 463,
+ - 814,
+ - 386,
+ - 704,
+ - 337,
+ - 615,
+ - 234,
+ - 201,
+ - 233,
+ - 239,
+ - 167,
+ - 567,
+ - 203,
+ - 619,
+ - 147,
+ - 415,
+ - 115,
+ - 352,
+ - 166,
+ - 750,
+ - 171,
+ - 761,
+ - 270,
+ - 879,
+ - 264,
+ - 903,
+ - 367,
+ - 744,
+ 43,
+ - 475,
+ 14,
+ - 653,
+ 43,
+ - 670,
+ 11,
+ - 448,
+ - 59,
+ - 521,
+ - 126,
+ - 119,
+ - 155,
+ - 613,
+ - 42,
+ - 863,
+ - 27,
+ - 931,
+ 136,
+ - 483,
+ 183,
+ - 468,
+ 55,
+ - 298,
+ 55,
+ - 304,
+ 313,
+ - 609,
+ 313,
+ - 720,
+ 322,
+ - 167,
+ 100,
+ - 541,
+ - 3,
+ - 119,
+ - 111,
+ - 187,
+ 233,
+ - 236,
+ 260,
+ - 234,
+ 26,
+ - 165,
+ 134,
+ - 45,
+ - 40,
+ - 549,
+ 360,
+ - 203,
+ 378,
+ - 388,
+ 450,
+ - 383,
+ 275,
+ 20,
+ 182,
+ - 103,
+ 246,
+ - 111,
+ 431,
+ 37,
+ 462,
+ - 146,
+ 487,
+ - 157,
+ - 284,
+ - 59,
+ 503,
+ - 184,
+ 24,
+ 53,
+ - 3,
+ 54,
+ 122,
+ 259,
+ 333,
+ 66,
+ 484,
+ 104,
+ 436,
+ 68,
+ 195,
+ 116,
+ 190,
+ 206,
+ 269,
+ - 9,
+ 482,
+ 352,
+ 382,
+ 285,
+ 399,
+ 277,
+ 452,
+ 256,
+ 69,
+ 186,
+ 13,
+ 297,
+ - 13,
+ 259,
+ - 95,
+ 30,
+ 56,
+ 394,
+ 196,
+ 425,
+ 205,
+ 456,
+ 281,
+ 577,
+ 15,
+ 191,
+ 375,
+ 290,
+ 407,
+ 576,
+ - 56,
+ 227,
+ 544,
+ 405,
+ 0,
+ 549,
+ - 92,
+ 528,
+ - 229,
+ 351,
+ - 245,
+ 338,
+ - 362,
+ 435,
+ 167,
+ 527,
+ - 75,
+ 302,
+ 91,
+ 824,
+ 129,
+ 599,
+ 496,
+ 679,
+ 186,
+ 749,
+ 153,
+ 737,
+ - 281,
+ 600,
+ - 348,
+ 615,
+ - 236,
+ 769,
+ 41,
+ 881,
+ 38,
+ 890,
+ - 220,
+ 841,
+ - 357,
+ 883,
+ - 393,
+ 903,
+ - 634,
+ 474,
+ - 444,
+ 850,
+ - 175,
+ 678,
+ - 493,
+ 242,
+ - 519,
+ 785,
+ - 714,
+ 582,
+ - 541,
+ 366,
+ - 543,
+ 434,
+ - 597,
+ 500,
+ - 765,
+ 222,
+ - 702,
+ 917,
+ - 743,
+ 962,
+ - 869,
+ 501,
+ - 899,
+ 548,
+ - 379,
+ 200,
+ - 435,
+ 157,
+ - 819,
+ 214,
+ - 861,
+ 157,
+ - 614,
+ 40,
+ - 632,
+ 94,
+ - 883,
+ - 54,
+ - 741,
+ 516,
+ - 501,
+ 298,
+ - 614,
+ - 171,
+ - 870,
+ - 161,
+ - 865,
+ - 23,
+ - 818,
+ 93,
+ - 1015,
+ - 267,
+ - 662,
+ - 359,
+ - 549,
+ 2,
+ - 442,
+ - 121,
+ - 377,
+ 0,
+ - 227,
+ 33,
+ - 414,
+ - 126,
+ - 129,
+ 212,
+ - 934,
+ 34,
+ - 1082,
+ - 282,
+ - 1119,
+ - 268,
+ - 710,
+ - 825,
+ - 420,
+ - 191,
+ - 1076,
+ - 928,
+ - 917,
+ - 93,
+ - 628,
+ - 358,
+ 97,
+ 7,
+ - 206,
+ - 393,
+ - 101,
+ 24,
+ - 203,
+ 38,
+ - 168,
+ 83,
+ - 599,
+ - 423,
+ - 279,
+ 426,
+ - 700,
+ 118,
+ - 75,
+ 206,
+ - 981,
+ - 673,
+ - 680,
+ 417,
+ - 367,
+ 37,
+ - 279,
+ 474,
+ - 129,
+ - 318,
+ 319,
+ 296,
+ - 626,
+ - 39,
+ 343,
+ 602,
+ - 696,
+ - 39,
+ - 303,
+ 940,
+ 104,
+ 233,
+ - 380,
+ 137,
+ - 36,
+ 269,
+ - 75,
+ - 214,
+ 120,
+ 43,
+ - 529,
+ - 477,
+ 459,
+ 164,
+ - 202,
+ - 229,
+ - 49,
+ - 167,
+ 609,
+ 792,
+ 98,
+ - 220,
+ 915,
+ 148,
+ 293,
+ 283,
+ 869,
+ 91,
+ 575,
+ 394,
+ 326,
+ - 78,
+ 717,
+ 67,
+ 365,
+ - 323,
+ 616,
+ - 36,
+ 731,
+ 27,
+ 619,
+ 238,
+ 632,
+ 273,
+ 448,
+ 99,
+ 801,
+ 476,
+ 869,
+ 273,
+ 685,
+ 64,
+ 789,
+ 72,
+ 1021,
+ 217,
+ 793,
+ 459,
+ 734,
+ 360,
+ 646,
+ 480,
+ 360,
+ 322,
+ 429,
+ 464,
+ 638,
+ 430,
+ 756,
+ 363,
+ 1000,
+ 404,
+ 683,
+ 528,
+ 602,
+ 615,
+ 655,
+ 413,
+ 946,
+ 687,
+ 937,
+ 602,
+ 904,
+ 604,
+ 555,
+ 737,
+ 786,
+ 662,
+ 467,
+ 654,
+ 362,
+ 589,
+ 929,
+ 710,
+ 498,
+ 478,
+ 415,
+ 420,
+ 693,
+ 883,
+ 813,
+ 683,
+ 781,
+ 925,
+ 913,
+ 939,
+ 726,
+ 732,
+ 491,
+ 853,
+ 531,
+ 948,
+ 734,
+ 963,
+ 315,
+ 808,
+ 761,
+ 755,
+ 1144,
+ 760,
+ 655,
+ 1076,
+ 826,
+ 1057,
+ 1091,
+ 838,
+ 1003,
+ 808,
+ 1047,
+ 1133,
+ 659,
+ 1101,
+ 992,
+ 1050,
+ 1074,
+ 1075,
+ 971,
+ 694,
+ 1226,
+ 1054,
+ 571,
+ 841,
+ 884,
+ 1404,
+ 1379,
+ 1096,
+ 1080,
+ 861,
+ 1231,
+ 735,
+ 1284,
+ 760,
+ 1272,
+ 991,
+ 1367,
+ 1053,
+ 1257,
+ 700,
+ 1050,
+ 534,
+ 988,
+ 453,
+ 1264,
+ 599,
+ 1140,
+ 679,
+ 1621,
+ 815,
+ 1384,
+ 521,
+ 1317,
+ 393,
+ 1564,
+ 805,
+ 1448,
+ 686,
+ 1068,
+ 648,
+ 875,
+ 307,
+ 1083,
+ 361,
+ 1047,
+ 317,
+ 1417,
+ 964,
+ 675,
+ 571,
+ 1152,
+ 79,
+ 1114,
+ - 47,
+ 1530,
+ 311,
+ 1721,
+ 314,
+ 1166,
+ 689,
+ 514,
+ - 94,
+ 349,
+ 282,
+ 1412,
+ 328,
+ 1025,
+ 487,
+ - 65,
+ 57,
+ 805,
+ 970,
+ 36,
+ 62,
+ 769,
+ - 263,
+ 791,
+ - 346,
+ 637,
+ 699,
+ - 137,
+ 620,
+ 534,
+ 541,
+ - 735,
+ 194,
+ 711,
+ 300,
+ - 268,
+ - 863,
+ 926,
+ 769,
+ - 708,
+ - 428,
+ 506,
+ 174,
+ - 892,
+ - 630,
+ 435,
+ 547,
+ - 1435,
+ - 258,
+ 621,
+ 471,
+ - 1018,
+ - 1368,
+ - 393,
+ 521,
+ - 920,
+ - 686,
+ - 25,
+ 20,
+ - 982,
+ - 1156,
+ 340,
+ 9,
+ - 1558,
+ - 1135,
+ - 352,
+ 48,
+ - 1579,
+ - 402,
+ - 887,
+ 6,
+ - 1156,
+ - 888,
+ - 548,
+ - 352,
+ - 1643,
+ - 1168,
+ - 159,
+ 610,
+ - 2024,
+ - 963,
+ - 225,
+ 193,
+ - 1656,
+ - 1960,
+ - 245,
+ - 493,
+ - 964,
+ - 1680,
+ - 936,
+ - 635,
+ - 1299,
+ - 1744,
+ - 1388,
+ - 604,
+ - 1540,
+ - 835,
+ - 1397,
+ - 135,
+ - 1588,
+ - 290,
+ - 1670,
+ - 712,
+ - 2011,
+ - 1632,
+ - 1663,
+ - 27,
+ - 2258,
+ - 811,
+ - 1157,
+ 184,
+ - 1265,
+ 189,
+ - 1367,
+ 586,
+ - 2011,
+ 201,
+ - 790,
+ 712,
+ - 1210,
+ 3,
+ - 1033,
+ 808,
+ - 1251,
+ 830,
+ - 111,
+ 635,
+ - 1636,
+ 447,
+ - 463,
+ - 949,
+ - 445,
+ - 928,
+ - 504,
+ - 1162,
+ - 501,
+ - 1211,
+ 144,
+ - 351,
+ - 372,
+ - 1052,
+ - 283,
+ - 1059,
+ - 279,
+ - 1123,
+ - 575,
+ - 1438,
+ - 587,
+ - 1614,
+ - 935,
+ - 984,
+ 229,
+ 690,
+ - 921,
+ - 719,
+ - 403,
+ 1362,
+ - 685,
+ - 465,
+ 874,
+ 397,
+ - 509,
+ - 46,
+ 317,
+ 1334,
+ - 485,
+ 456,
+ 813,
+ 439,
+ - 411,
+ 339,
+ 898,
+ 1067,
+ - 425,
+ 46,
+ 1441,
+ 497,
+ - 909,
+ - 800,
+ 1465,
+ 1046,
+ - 254,
+ - 321,
+ 1430,
+ 1165,
+ 68,
+ 350,
+ 1034,
+ 666,
+ 370,
+ 11,
+ 1311,
+ 790,
+ 143,
+ 232,
+ 1041,
+ 1562,
+ - 114,
+ 663,
+ 1616,
+ 1078,
+ 454,
+ 579,
+ 1275,
+ 1040,
+ - 76,
+ 909,
+ 752,
+ 1067,
+ 153,
+ 512,
+ 348,
+ 1214,
+ 614,
+ 385,
+ 1843,
+ 808,
+ 269,
+ 1034,
+ 203,
+ 1086,
+ 652,
+ 1017,
+ 1783,
+ 1130,
+ 429,
+ 1327,
+ 387,
+ 1384,
+ - 49,
+ 1183,
+ - 72,
+ 1215,
+ - 416,
+ 1001,
+ 544,
+ 1749,
+ - 352,
+ 1223,
+ - 502,
+ 1199,
+ - 589,
+ 569,
+ - 227,
+ 1630,
+ - 142,
+ 1578,
+ - 230,
+ 1715,
+ - 714,
+ 1288,
+ - 838,
+ 1398,
+ 1131,
+ 1357,
+ - 208,
+ 1232,
+ 437,
+ 965,
+ - 929,
+ 818,
+ 811,
+ 1410,
+ 859,
+ 1507,
+ 164,
+ 1212,
+ 1387,
+ 1793,
+ 484,
+ 1874,
+ 456,
+ 2063,
+ 996,
+ 1170,
+ 1326,
+ 1402,
+ 1316,
+ 1360,
+ 1135,
+ 1262,
+ 1234,
+ 1618,
+ 1361,
+ 1768,
+ 1421,
+ 1227,
+ 1584,
+ 1347,
+ 854,
+ 672,
+ 1685,
+ 1566,
+ 1139,
+ 1270,
+ 2016,
+ 1825,
+ 1773,
+ 1581,
+ 1532,
+ 1460,
+ 1487,
+ 946,
+ 1659,
+ 1021,
+ 1744,
+ 1212,
+ 1392,
+ 977,
+ 1772,
+ 1161,
+ 1826,
+ 1164,
+ 1718,
+ 1429,
+ 1973,
+ 1591,
+ 1185,
+ 864,
+ 2132,
+ 1061,
+ 1799,
+ 814,
+ 1838,
+ 757,
+ 2104,
+ 1315,
+ 2054,
+ 1258,
+ 2113,
+ 915,
+ 2331,
+ 930,
+ 1467,
+ 1147,
+ 2590,
+ 1439,
+ 2245,
+ 1744,
+ 2090,
+ 1620,
+ 2358,
+ 1454,
+ 2666,
+ 1506,
+ 1876,
+ 1837,
+ 2070,
+ 1975,
+ 1739,
+ 1577,
+ 682,
+ 1289,
+ 1584,
+ 2045,
+ 1454,
+ 2098,
+ 2498,
+ 2004,
+ 2711,
+ 2066,
+ 726,
+ 1588,
+ 2756,
+ 2336,
+ 228,
+ 847,
+ 2456,
+ 1659,
+ 36,
+ 301,
+ 1942,
+ 1957,
+ - 446,
+ - 96,
+ 2154,
+ 1396,
+ 1533,
+ 1101,
+ 14,
+ 608,
+ - 923,
+ - 732,
+ 1383,
+ 1982,
+ 1345,
+ 952,
+ - 680,
+ 321,
+ 1281,
+ 1268,
+ - 1594,
+ 365,
+ 941,
+ 946,
+ - 1737,
+ - 822,
+ 2374,
+ 2787,
+ 1821,
+ 2788
+};
+
+/* 3rd LSF quantizer (MR122) */
+static const Word32 dico3_lsf_5[DICO3_SIZE_5 * 4] =
+{
+ - 1812,
+ - 2275,
+ - 1879,
+ - 2537,
+ - 1640,
+ - 1848,
+ - 1695,
+ - 2004,
+ - 1220,
+ - 1912,
+ - 1221,
+ - 2106,
+ - 1559,
+ - 1588,
+ - 1573,
+ - 1556,
+ - 1195,
+ - 1615,
+ - 1224,
+ - 1727,
+ - 1359,
+ - 1151,
+ - 1616,
+ - 1948,
+ - 1274,
+ - 1391,
+ - 1305,
+ - 1403,
+ - 1607,
+ - 1179,
+ - 1676,
+ - 1311,
+ - 1443,
+ - 1478,
+ - 1367,
+ - 898,
+ - 1256,
+ - 1059,
+ - 1331,
+ - 1134,
+ - 982,
+ - 1133,
+ - 1149,
+ - 1504,
+ - 1080,
+ - 1308,
+ - 1020,
+ - 1183,
+ - 980,
+ - 1486,
+ - 967,
+ - 1495,
+ - 988,
+ - 922,
+ - 1047,
+ - 1077,
+ - 838,
+ - 1179,
+ - 858,
+ - 1222,
+ - 1131,
+ - 1041,
+ - 1064,
+ - 767,
+ - 872,
+ - 1157,
+ - 701,
+ - 880,
+ - 706,
+ - 906,
+ - 774,
+ - 1016,
+ - 578,
+ - 1080,
+ - 801,
+ - 1478,
+ - 591,
+ - 1111,
+ - 592,
+ - 1146,
+ - 713,
+ - 1388,
+ - 640,
+ - 1376,
+ - 597,
+ - 1059,
+ - 416,
+ - 903,
+ - 686,
+ - 832,
+ - 661,
+ - 708,
+ - 444,
+ - 868,
+ - 490,
+ - 921,
+ - 374,
+ - 776,
+ - 619,
+ - 1170,
+ - 585,
+ - 549,
+ - 769,
+ - 795,
+ - 435,
+ - 659,
+ - 530,
+ - 741,
+ - 498,
+ - 837,
+ - 357,
+ - 597,
+ - 279,
+ - 871,
+ - 243,
+ - 887,
+ - 282,
+ - 665,
+ - 280,
+ - 667,
+ - 165,
+ - 560,
+ - 394,
+ - 903,
+ - 362,
+ - 410,
+ - 448,
+ - 583,
+ - 409,
+ - 574,
+ - 313,
+ - 357,
+ - 637,
+ - 548,
+ - 570,
+ - 436,
+ - 896,
+ - 504,
+ - 382,
+ - 757,
+ - 58,
+ - 481,
+ - 165,
+ - 618,
+ - 191,
+ - 374,
+ - 234,
+ - 382,
+ - 222,
+ - 683,
+ - 25,
+ - 480,
+ - 418,
+ - 359,
+ - 730,
+ - 353,
+ - 324,
+ - 157,
+ - 432,
+ - 322,
+ - 394,
+ - 303,
+ - 284,
+ - 104,
+ - 601,
+ - 289,
+ - 556,
+ - 196,
+ - 588,
+ - 150,
+ - 659,
+ - 608,
+ - 473,
+ - 24,
+ - 68,
+ - 448,
+ - 474,
+ - 8,
+ - 506,
+ - 45,
+ - 748,
+ - 184,
+ - 844,
+ - 252,
+ - 901,
+ - 91,
+ - 584,
+ - 97,
+ - 652,
+ 138,
+ - 764,
+ - 131,
+ - 678,
+ - 12,
+ - 670,
+ 165,
+ - 259,
+ - 3,
+ - 840,
+ - 107,
+ - 909,
+ 37,
+ - 992,
+ 44,
+ - 854,
+ - 415,
+ - 839,
+ 13,
+ - 1001,
+ - 271,
+ - 1026,
+ - 309,
+ - 798,
+ - 478,
+ - 832,
+ - 488,
+ - 943,
+ 168,
+ - 1112,
+ - 387,
+ - 1185,
+ - 101,
+ - 1183,
+ - 40,
+ - 941,
+ - 316,
+ - 1030,
+ - 770,
+ - 1044,
+ - 625,
+ - 1081,
+ - 538,
+ - 1224,
+ - 299,
+ - 1312,
+ - 436,
+ - 1197,
+ - 663,
+ - 1167,
+ - 161,
+ - 1216,
+ - 690,
+ - 1237,
+ - 831,
+ - 1432,
+ - 720,
+ - 1403,
+ - 493,
+ - 898,
+ - 740,
+ - 922,
+ - 801,
+ - 1102,
+ - 402,
+ - 1579,
+ - 964,
+ - 1061,
+ - 638,
+ - 1269,
+ - 1438,
+ - 1499,
+ - 934,
+ - 1502,
+ - 895,
+ - 1598,
+ - 564,
+ - 1723,
+ - 717,
+ - 606,
+ - 597,
+ - 1166,
+ - 1085,
+ - 1369,
+ - 468,
+ - 1946,
+ - 1493,
+ - 1838,
+ - 953,
+ - 1932,
+ - 931,
+ - 1499,
+ - 188,
+ - 1635,
+ - 421,
+ - 1457,
+ - 338,
+ - 1448,
+ - 22,
+ - 1942,
+ - 422,
+ - 2006,
+ - 249,
+ - 496,
+ - 114,
+ - 1910,
+ - 755,
+ - 1289,
+ 174,
+ - 1451,
+ - 109,
+ - 482,
+ - 257,
+ - 1221,
+ - 508,
+ - 1617,
+ 151,
+ - 1694,
+ 208,
+ - 654,
+ 107,
+ - 1651,
+ 29,
+ - 1141,
+ 279,
+ - 1215,
+ 306,
+ - 1228,
+ - 506,
+ - 730,
+ - 175,
+ - 1236,
+ - 101,
+ - 969,
+ 551,
+ - 870,
+ 278,
+ - 823,
+ 315,
+ - 563,
+ 376,
+ - 1051,
+ 228,
+ - 507,
+ 280,
+ - 599,
+ 281,
+ - 758,
+ 253,
+ - 305,
+ 379,
+ - 755,
+ - 134,
+ - 611,
+ 660,
+ - 824,
+ 536,
+ - 817,
+ 646,
+ - 413,
+ 49,
+ - 341,
+ 177,
+ - 453,
+ 526,
+ - 482,
+ 589,
+ - 71,
+ 339,
+ - 657,
+ 264,
+ - 244,
+ 295,
+ - 237,
+ 315,
+ - 387,
+ 569,
+ - 506,
+ - 9,
+ - 377,
+ 14,
+ - 160,
+ 661,
+ - 216,
+ 40,
+ - 308,
+ - 46,
+ 95,
+ 214,
+ - 242,
+ 167,
+ - 86,
+ 192,
+ - 56,
+ 27,
+ - 76,
+ 31,
+ 36,
+ 309,
+ - 106,
+ - 182,
+ - 113,
+ 74,
+ - 441,
+ - 22,
+ 23,
+ 139,
+ 81,
+ - 11,
+ 44,
+ 15,
+ - 87,
+ - 137,
+ - 118,
+ - 207,
+ - 158,
+ - 58,
+ 272,
+ - 92,
+ - 156,
+ - 441,
+ 8,
+ - 136,
+ 128,
+ - 221,
+ 101,
+ - 218,
+ 40,
+ - 197,
+ - 76,
+ - 456,
+ 9,
+ - 445,
+ 33,
+ - 423,
+ 226,
+ 60,
+ 73,
+ - 222,
+ 156,
+ - 399,
+ 280,
+ - 318,
+ 245,
+ - 341,
+ 166,
+ - 499,
+ 339,
+ - 190,
+ 327,
+ - 219,
+ 325,
+ - 137,
+ - 89,
+ - 596,
+ 100,
+ - 627,
+ 144,
+ - 677,
+ 487,
+ 28,
+ 252,
+ - 391,
+ 214,
+ - 41,
+ 282,
+ - 28,
+ 99,
+ - 286,
+ 331,
+ 49,
+ 459,
+ - 388,
+ 565,
+ - 369,
+ 436,
+ 28,
+ 336,
+ - 9,
+ 397,
+ - 167,
+ 618,
+ 34,
+ 596,
+ - 17,
+ 561,
+ - 140,
+ 299,
+ 79,
+ 522,
+ 125,
+ 203,
+ 2,
+ 244,
+ 288,
+ 255,
+ 211,
+ 175,
+ 82,
+ 596,
+ 187,
+ 517,
+ 108,
+ 381,
+ 255,
+ 365,
+ 297,
+ 497,
+ 352,
+ 327,
+ - 82,
+ 25,
+ 210,
+ 371,
+ 245,
+ 261,
+ 3,
+ 545,
+ 449,
+ 140,
+ 294,
+ 44,
+ 295,
+ 212,
+ 347,
+ 244,
+ 494,
+ 331,
+ 528,
+ 201,
+ 307,
+ 349,
+ 411,
+ 613,
+ 284,
+ 614,
+ 413,
+ 464,
+ 322,
+ 624,
+ 397,
+ 97,
+ 200,
+ - 160,
+ 384,
+ 149,
+ 362,
+ 495,
+ 525,
+ 269,
+ 585,
+ 33,
+ 491,
+ - 121,
+ 433,
+ 427,
+ 611,
+ 498,
+ 516,
+ 171,
+ 443,
+ 497,
+ 666,
+ 440,
+ 275,
+ 566,
+ 575,
+ 146,
+ 639,
+ 155,
+ 670,
+ - 33,
+ 173,
+ 212,
+ 696,
+ - 166,
+ 601,
+ - 191,
+ 695,
+ - 489,
+ 503,
+ 175,
+ 742,
+ 214,
+ 476,
+ 372,
+ 1083,
+ 578,
+ 530,
+ 586,
+ 777,
+ 425,
+ 874,
+ 315,
+ 841,
+ 374,
+ 848,
+ - 165,
+ 565,
+ 35,
+ 991,
+ - 39,
+ 1062,
+ 329,
+ 712,
+ 786,
+ 840,
+ 645,
+ 795,
+ 661,
+ 676,
+ 571,
+ 918,
+ 632,
+ 1079,
+ 673,
+ 817,
+ 318,
+ 388,
+ 874,
+ 1012,
+ 564,
+ 848,
+ 880,
+ 620,
+ 557,
+ 479,
+ 671,
+ 453,
+ 692,
+ 468,
+ 840,
+ 642,
+ 844,
+ 645,
+ 506,
+ 428,
+ 897,
+ 567,
+ 837,
+ 387,
+ 962,
+ 499,
+ 691,
+ 561,
+ 939,
+ 926,
+ 783,
+ 296,
+ 790,
+ 268,
+ 1028,
+ 530,
+ 874,
+ 329,
+ 548,
+ 143,
+ 675,
+ 291,
+ 503,
+ 66,
+ 1041,
+ 359,
+ 786,
+ 97,
+ 805,
+ 33,
+ 837,
+ 470,
+ 511,
+ 49,
+ 1092,
+ 327,
+ 1174,
+ 323,
+ 3,
+ 242,
+ 872,
+ 474,
+ 689,
+ 429,
+ 1329,
+ 678,
+ 1042,
+ 620,
+ 1109,
+ 664,
+ 321,
+ 193,
+ 889,
+ 950,
+ 1153,
+ 874,
+ 893,
+ 635,
+ 877,
+ 862,
+ 948,
+ 913,
+ 1293,
+ 665,
+ 1320,
+ 639,
+ 997,
+ 793,
+ 1402,
+ 1030,
+ 1176,
+ 1012,
+ 1110,
+ 959,
+ 1410,
+ 925,
+ 1403,
+ 915,
+ 543,
+ 862,
+ 1116,
+ 1222,
+ 835,
+ 1190,
+ 835,
+ 1190,
+ 959,
+ 1148,
+ 1147,
+ 1376,
+ 1300,
+ 1193,
+ 1415,
+ 1231,
+ 1335,
+ 1341,
+ 746,
+ 1092,
+ 1711,
+ 1283,
+ 1389,
+ 1073,
+ 1334,
+ 1566,
+ 1153,
+ 1475,
+ 1645,
+ 1137,
+ 1825,
+ 1220,
+ 1056,
+ 1382,
+ 1521,
+ 1730,
+ 1632,
+ 1545,
+ 1620,
+ 1542,
+ 855,
+ 1596,
+ 865,
+ 1667,
+ 693,
+ 885,
+ 1716,
+ 1519,
+ 1167,
+ 1296,
+ 2209,
+ 1760,
+ 1952,
+ 1493,
+ 2020,
+ 1482,
+ 1534,
+ 1866,
+ 1694,
+ 2008,
+ 1566,
+ 748,
+ 1761,
+ 825,
+ 294,
+ 1392,
+ 1084,
+ 2058,
+ 621,
+ 1315,
+ 365,
+ 1287,
+ 198,
+ 1028,
+ 488,
+ 1408,
+ 249,
+ 403,
+ 1014,
+ 1561,
+ 324,
+ 363,
+ 1645,
+ 1044,
+ 193,
+ 367,
+ 2034,
+ 1859,
+ - 251,
+ 579,
+ 750,
+ 994,
+ - 243,
+ 30,
+ 1325,
+ 879,
+ - 28,
+ - 169,
+ 624,
+ 917,
+ - 453,
+ 159,
+ 186,
+ 1370,
+ - 614,
+ 6,
+ 537,
+ 392,
+ - 94,
+ - 291,
+ 781,
+ 229,
+ - 128,
+ - 298,
+ 245,
+ 491,
+ - 701,
+ - 648,
+ 972,
+ 789,
+ - 501,
+ - 640,
+ 178,
+ 255,
+ - 365,
+ - 390,
+ - 255,
+ 317,
+ - 958,
+ - 294,
+ - 191,
+ 228,
+ - 775,
+ - 447,
+ 157,
+ - 237,
+ - 657,
+ - 720,
+ - 407,
+ 92,
+ - 117,
+ - 611,
+ 334,
+ - 230,
+ - 679,
+ - 1084,
+ - 144,
+ - 317,
+ - 901,
+ - 861,
+ - 738,
+ - 360,
+ - 85,
+ - 727,
+ - 90,
+ - 787,
+ 100,
+ - 22,
+ - 391,
+ - 263,
+ - 56,
+ - 73,
+ - 337,
+ - 754,
+ 5,
+ - 189,
+ - 706,
+ - 624,
+ 89,
+ - 344,
+ - 135,
+ - 1113,
+ - 353,
+ - 237,
+ - 684,
+ - 1135,
+ - 275,
+ - 1102,
+ - 269,
+ - 1203,
+ 152,
+ 145,
+ - 722,
+ - 1232,
+ 49,
+ 80,
+ - 1248,
+ - 776,
+ - 248,
+ 391,
+ - 732,
+ - 547,
+ 469,
+ 218,
+ - 255,
+ - 864,
+ 69,
+ 366,
+ - 166,
+ - 485,
+ - 688,
+ 191,
+ - 1212,
+ - 1196,
+ - 170,
+ - 169,
+ - 1308,
+ - 1631,
+ 321,
+ 470,
+ - 1419,
+ - 1243,
+ - 64,
+ 272,
+ - 1361,
+ - 248,
+ 492,
+ 565,
+ - 721,
+ - 609,
+ 195,
+ 485,
+ - 573,
+ - 133,
+ 427,
+ 202,
+ - 171,
+ - 118,
+ 199,
+ 575,
+ 2,
+ - 31,
+ 694,
+ 755,
+ - 1366,
+ - 39,
+ 552,
+ 557,
+ - 489,
+ 271,
+ 680,
+ 537,
+ 13,
+ - 453,
+ 855,
+ 954,
+ - 133,
+ - 52,
+ - 81,
+ 738,
+ - 1169,
+ 637,
+ 1055,
+ 1059,
+ - 95,
+ 676,
+ 1259,
+ 1081,
+ 489,
+ 305,
+ - 449,
+ 954,
+ - 534,
+ 996,
+ - 969,
+ 866,
+ - 1058,
+ 1059,
+ - 1294,
+ 618,
+ - 1416,
+ 617,
+ - 458,
+ 1366,
+ - 159,
+ 1821,
+ - 774,
+ - 528,
+ - 14,
+ 1110,
+ - 1202,
+ - 901,
+ - 772,
+ 433,
+ - 1256,
+ - 1255,
+ - 1011,
+ - 302,
+ - 602,
+ - 585,
+ - 759,
+ - 1618,
+ - 760,
+ - 1549,
+ - 840,
+ - 1921,
+ - 816,
+ - 539,
+ - 1769,
+ - 2235,
+ - 227,
+ - 36,
+ - 2034,
+ - 1831,
+ - 2107,
+ - 1126,
+ - 2471,
+ - 1816,
+ - 1470,
+ 252,
+ - 2701,
+ - 415,
+ - 571,
+ - 467,
+ 1509,
+ 1554,
+ 2180,
+ 1975,
+ 2326,
+ 2020
+};
+
+/* 4th LSF quantizer (MR122) */
+static const Word32 dico4_lsf_5[DICO4_SIZE_5 * 4] =
+{
+ - 1857,
+ - 1681,
+ - 1857,
+ - 1755,
+ - 2056,
+ - 1150,
+ - 2134,
+ - 1654,
+ - 1619,
+ - 1099,
+ - 1704,
+ - 1131,
+ - 1345,
+ - 1608,
+ - 1359,
+ - 1638,
+ - 1338,
+ - 1293,
+ - 1325,
+ - 1265,
+ - 1664,
+ - 1649,
+ - 1487,
+ - 851,
+ - 1346,
+ - 1832,
+ - 1413,
+ - 2188,
+ - 1282,
+ - 681,
+ - 1785,
+ - 1649,
+ - 966,
+ - 1082,
+ - 1183,
+ - 1676,
+ - 1054,
+ - 1073,
+ - 1142,
+ - 1158,
+ - 1207,
+ - 744,
+ - 1274,
+ - 997,
+ - 934,
+ - 1383,
+ - 927,
+ - 1416,
+ - 1010,
+ - 1305,
+ - 783,
+ - 955,
+ - 1049,
+ - 900,
+ - 993,
+ - 817,
+ - 737,
+ - 823,
+ - 972,
+ - 1189,
+ - 738,
+ - 1094,
+ - 738,
+ - 1154,
+ - 784,
+ - 801,
+ - 810,
+ - 786,
+ - 892,
+ - 520,
+ - 1000,
+ - 818,
+ - 644,
+ - 965,
+ - 577,
+ - 882,
+ - 541,
+ - 694,
+ - 671,
+ - 917,
+ - 595,
+ - 642,
+ - 646,
+ - 615,
+ - 956,
+ - 621,
+ - 925,
+ - 515,
+ - 727,
+ - 483,
+ - 815,
+ - 485,
+ - 840,
+ - 578,
+ - 440,
+ - 713,
+ - 578,
+ - 325,
+ - 657,
+ - 670,
+ - 386,
+ - 570,
+ - 441,
+ - 666,
+ - 514,
+ - 787,
+ - 392,
+ - 529,
+ - 522,
+ - 453,
+ - 487,
+ - 423,
+ - 616,
+ - 585,
+ - 617,
+ - 157,
+ - 662,
+ - 268,
+ - 680,
+ - 348,
+ - 322,
+ - 323,
+ - 632,
+ - 444,
+ - 304,
+ - 430,
+ - 332,
+ - 458,
+ - 277,
+ - 468,
+ - 659,
+ - 793,
+ - 319,
+ - 636,
+ - 227,
+ - 554,
+ - 373,
+ - 347,
+ - 334,
+ - 210,
+ - 456,
+ - 192,
+ - 530,
+ - 242,
+ - 216,
+ - 198,
+ - 366,
+ - 370,
+ - 338,
+ - 161,
+ - 409,
+ - 748,
+ - 107,
+ - 380,
+ - 294,
+ - 643,
+ - 223,
+ - 665,
+ - 234,
+ - 741,
+ - 141,
+ - 496,
+ - 130,
+ - 510,
+ - 139,
+ - 327,
+ - 172,
+ - 305,
+ - 306,
+ - 580,
+ - 164,
+ - 263,
+ - 262,
+ - 172,
+ - 67,
+ - 402,
+ 31,
+ - 366,
+ - 10,
+ - 436,
+ - 86,
+ - 527,
+ 71,
+ - 377,
+ - 22,
+ - 609,
+ - 12,
+ - 678,
+ - 67,
+ - 319,
+ 63,
+ - 191,
+ 35,
+ - 181,
+ - 39,
+ - 242,
+ 126,
+ - 167,
+ - 140,
+ - 544,
+ 155,
+ - 297,
+ 174,
+ - 297,
+ 38,
+ - 8,
+ 117,
+ - 380,
+ 197,
+ - 452,
+ 240,
+ - 522,
+ 223,
+ - 103,
+ 110,
+ - 187,
+ 87,
+ - 155,
+ 169,
+ - 47,
+ 157,
+ 26,
+ - 83,
+ - 100,
+ 128,
+ 80,
+ 209,
+ - 62,
+ 6,
+ 7,
+ 22,
+ 5,
+ 318,
+ - 20,
+ 248,
+ - 45,
+ - 200,
+ - 63,
+ 156,
+ - 69,
+ 250,
+ - 183,
+ 369,
+ - 126,
+ - 113,
+ - 76,
+ - 142,
+ - 122,
+ - 64,
+ - 254,
+ - 31,
+ 35,
+ - 177,
+ - 71,
+ - 7,
+ 171,
+ 93,
+ 27,
+ 108,
+ 212,
+ - 330,
+ - 209,
+ - 123,
+ - 70,
+ - 279,
+ 95,
+ - 96,
+ 20,
+ - 188,
+ - 61,
+ - 314,
+ 87,
+ - 300,
+ - 78,
+ - 354,
+ - 134,
+ 11,
+ 122,
+ - 140,
+ 122,
+ - 275,
+ 152,
+ - 293,
+ 140,
+ - 82,
+ 138,
+ - 321,
+ - 111,
+ - 480,
+ - 156,
+ - 359,
+ 76,
+ - 254,
+ - 40,
+ - 635,
+ - 96,
+ - 522,
+ 79,
+ - 507,
+ 8,
+ - 268,
+ 303,
+ - 539,
+ 68,
+ - 446,
+ 61,
+ - 522,
+ 306,
+ 111,
+ 189,
+ - 435,
+ 122,
+ - 379,
+ 166,
+ - 571,
+ - 398,
+ - 632,
+ - 74,
+ - 747,
+ - 95,
+ - 455,
+ 194,
+ - 952,
+ 83,
+ - 798,
+ 192,
+ - 755,
+ 192,
+ - 781,
+ - 162,
+ - 619,
+ 234,
+ - 663,
+ - 297,
+ - 488,
+ - 109,
+ - 964,
+ - 132,
+ - 838,
+ - 68,
+ - 843,
+ 58,
+ - 1112,
+ - 86,
+ - 805,
+ - 299,
+ - 944,
+ - 253,
+ - 778,
+ - 50,
+ - 965,
+ - 549,
+ - 352,
+ - 98,
+ - 992,
+ - 343,
+ - 1117,
+ - 315,
+ - 1117,
+ - 307,
+ - 1155,
+ - 374,
+ - 637,
+ - 230,
+ - 1166,
+ - 43,
+ - 1299,
+ - 100,
+ - 925,
+ - 393,
+ - 1274,
+ - 600,
+ - 689,
+ - 130,
+ - 1479,
+ - 312,
+ - 1321,
+ - 254,
+ - 1464,
+ - 442,
+ - 1292,
+ - 613,
+ - 1261,
+ - 503,
+ - 1501,
+ - 368,
+ - 1322,
+ 26,
+ - 1432,
+ - 66,
+ - 1743,
+ - 161,
+ - 1644,
+ - 467,
+ - 1760,
+ - 548,
+ - 1393,
+ - 568,
+ - 1556,
+ - 871,
+ - 1495,
+ - 1034,
+ - 1387,
+ - 571,
+ - 1917,
+ - 528,
+ - 1783,
+ - 123,
+ - 1897,
+ - 231,
+ - 2054,
+ - 323,
+ - 2052,
+ - 906,
+ - 1976,
+ - 567,
+ - 1917,
+ - 620,
+ - 2047,
+ - 989,
+ - 1077,
+ - 370,
+ - 2031,
+ - 704,
+ - 2355,
+ - 749,
+ - 2740,
+ - 1089,
+ - 1909,
+ 159,
+ - 2012,
+ 248,
+ - 626,
+ - 123,
+ - 2339,
+ - 962,
+ - 669,
+ - 408,
+ - 1379,
+ - 1174,
+ - 452,
+ - 364,
+ - 1044,
+ - 735,
+ - 132,
+ 183,
+ - 1620,
+ - 752,
+ - 547,
+ - 307,
+ - 777,
+ - 1261,
+ - 98,
+ 41,
+ - 880,
+ - 1091,
+ - 257,
+ 97,
+ - 1602,
+ - 1833,
+ 31,
+ - 26,
+ - 644,
+ - 561,
+ - 180,
+ - 546,
+ - 385,
+ - 1095,
+ - 410,
+ - 802,
+ - 414,
+ - 827,
+ - 457,
+ - 970,
+ - 490,
+ - 1109,
+ - 215,
+ - 916,
+ - 144,
+ - 937,
+ - 493,
+ - 1269,
+ - 517,
+ - 1507,
+ 181,
+ 101,
+ - 332,
+ - 889,
+ - 836,
+ - 937,
+ - 559,
+ - 429,
+ - 629,
+ - 547,
+ - 183,
+ - 337,
+ - 545,
+ - 82,
+ - 250,
+ - 286,
+ 5,
+ - 132,
+ - 348,
+ - 252,
+ - 293,
+ - 472,
+ - 158,
+ 100,
+ - 29,
+ 197,
+ - 236,
+ - 424,
+ - 861,
+ - 213,
+ - 140,
+ - 7,
+ - 427,
+ - 443,
+ 187,
+ - 97,
+ - 684,
+ - 736,
+ - 293,
+ 258,
+ - 368,
+ - 152,
+ - 150,
+ 392,
+ - 609,
+ 175,
+ - 142,
+ 299,
+ - 138,
+ 152,
+ - 119,
+ 329,
+ - 486,
+ - 52,
+ 293,
+ 198,
+ - 183,
+ 117,
+ 175,
+ 331,
+ - 58,
+ - 274,
+ 231,
+ 300,
+ - 288,
+ 330,
+ - 305,
+ 372,
+ - 111,
+ 409,
+ - 9,
+ 423,
+ 83,
+ 256,
+ 67,
+ 367,
+ - 19,
+ 248,
+ 91,
+ 113,
+ - 35,
+ 406,
+ - 191,
+ 154,
+ 238,
+ 296,
+ 5,
+ 197,
+ 141,
+ 221,
+ 313,
+ 198,
+ 211,
+ 421,
+ 244,
+ 334,
+ 88,
+ 426,
+ - 243,
+ 454,
+ 202,
+ 552,
+ - 5,
+ 403,
+ 291,
+ 185,
+ 219,
+ 301,
+ 251,
+ 138,
+ 128,
+ 69,
+ 197,
+ 288,
+ - 140,
+ - 61,
+ 188,
+ 361,
+ 197,
+ 598,
+ 442,
+ 273,
+ 290,
+ 143,
+ 472,
+ 482,
+ 157,
+ 370,
+ 415,
+ 321,
+ 372,
+ 385,
+ 402,
+ 552,
+ 155,
+ 24,
+ 550,
+ 263,
+ - 11,
+ 21,
+ 360,
+ 227,
+ 147,
+ - 254,
+ 424,
+ 97,
+ 366,
+ - 13,
+ 375,
+ 141,
+ 449,
+ 232,
+ 396,
+ 507,
+ 474,
+ 272,
+ 701,
+ 324,
+ 362,
+ - 47,
+ 587,
+ 148,
+ 543,
+ 69,
+ 400,
+ - 51,
+ 561,
+ 59,
+ 220,
+ - 10,
+ 352,
+ 147,
+ 206,
+ 211,
+ 653,
+ 185,
+ 563,
+ 297,
+ 565,
+ 284,
+ 594,
+ 121,
+ 766,
+ 192,
+ 398,
+ 118,
+ 642,
+ 434,
+ 233,
+ 264,
+ 481,
+ 467,
+ 129,
+ - 165,
+ 699,
+ 239,
+ 90,
+ 26,
+ 342,
+ 474,
+ - 55,
+ 27,
+ 388,
+ 94,
+ - 172,
+ 0,
+ 725,
+ 379,
+ - 60,
+ 337,
+ 370,
+ 465,
+ 95,
+ 319,
+ 806,
+ 595,
+ 78,
+ 260,
+ 497,
+ 851,
+ 210,
+ 560,
+ 458,
+ 574,
+ - 464,
+ 202,
+ 497,
+ 625,
+ - 202,
+ 152,
+ 48,
+ 712,
+ - 20,
+ 566,
+ 100,
+ 715,
+ 455,
+ 468,
+ 411,
+ 605,
+ 319,
+ 646,
+ 195,
+ 615,
+ 401,
+ 538,
+ 680,
+ 739,
+ 201,
+ 667,
+ 434,
+ 954,
+ 454,
+ 425,
+ 646,
+ 491,
+ 606,
+ 681,
+ 416,
+ 508,
+ 497,
+ 822,
+ 426,
+ 815,
+ 660,
+ 647,
+ 628,
+ 716,
+ 697,
+ 466,
+ 618,
+ 457,
+ 685,
+ 460,
+ 365,
+ 309,
+ 721,
+ 567,
+ 836,
+ 601,
+ 609,
+ 300,
+ 825,
+ 459,
+ 943,
+ 687,
+ 681,
+ 533,
+ 915,
+ 598,
+ 591,
+ 243,
+ 876,
+ 451,
+ 874,
+ 420,
+ 786,
+ 317,
+ 732,
+ 220,
+ 922,
+ 317,
+ 1108,
+ 367,
+ 531,
+ 466,
+ 1028,
+ 649,
+ 1053,
+ 615,
+ 1034,
+ 553,
+ 829,
+ 602,
+ 1021,
+ 799,
+ 927,
+ 803,
+ 878,
+ 763,
+ 799,
+ 496,
+ 1373,
+ 773,
+ 585,
+ 770,
+ 803,
+ 930,
+ 1099,
+ 793,
+ 1222,
+ 862,
+ 1209,
+ 895,
+ 1025,
+ 727,
+ 772,
+ 845,
+ 1172,
+ 1115,
+ 867,
+ 1021,
+ 830,
+ 1013,
+ 841,
+ 910,
+ 506,
+ 703,
+ 1239,
+ 1077,
+ 620,
+ 819,
+ 1196,
+ 1083,
+ 1155,
+ 1081,
+ 1142,
+ 907,
+ 1547,
+ 1121,
+ 1309,
+ 648,
+ 1343,
+ 612,
+ 1484,
+ 988,
+ 1479,
+ 937,
+ 985,
+ 1328,
+ 955,
+ 1341,
+ 429,
+ 910,
+ 841,
+ 1338,
+ 564,
+ 1179,
+ 412,
+ 1156,
+ 1427,
+ 1320,
+ 1434,
+ 1330,
+ 640,
+ 760,
+ 1726,
+ 1410,
+ 190,
+ 555,
+ 1073,
+ 1005,
+ 426,
+ 257,
+ 839,
+ 980,
+ 235,
+ 231,
+ 1520,
+ 1167,
+ 109,
+ 293,
+ 1014,
+ 1569,
+ 305,
+ 142,
+ 1148,
+ 539,
+ - 291,
+ - 108,
+ 1213,
+ 972,
+ 22,
+ - 216,
+ 667,
+ 828,
+ - 482,
+ 438,
+ 453,
+ 1431,
+ - 581,
+ - 422,
+ 789,
+ 387,
+ - 358,
+ - 454,
+ 174,
+ 780,
+ - 36,
+ - 372,
+ 390,
+ - 134,
+ - 629,
+ 160,
+ - 306,
+ 751,
+ - 1258,
+ - 331,
+ 177,
+ 522,
+ - 248,
+ 574,
+ - 251,
+ 639,
+ - 531,
+ 407,
+ - 596,
+ 394,
+ - 419,
+ 789,
+ - 617,
+ 801,
+ - 986,
+ 399,
+ - 857,
+ 727,
+ - 7,
+ 518,
+ - 703,
+ 310,
+ - 1143,
+ - 24,
+ - 1002,
+ 287,
+ - 960,
+ 363,
+ - 1299,
+ 312,
+ - 1534,
+ 245,
+ - 1557,
+ 305,
+ 28,
+ 153,
+ - 859,
+ - 175,
+ - 33,
+ 332,
+ - 1398,
+ - 154,
+ 212,
+ 410,
+ - 593,
+ - 197,
+ - 1092,
+ - 704,
+ - 904,
+ - 65,
+ 282,
+ 367,
+ - 918,
+ - 686,
+ 345,
+ 93,
+ - 258,
+ - 357,
+ 696,
+ 644,
+ - 693,
+ - 28,
+ 448,
+ 493,
+ - 273,
+ 193,
+ 527,
+ 546,
+ - 243,
+ - 513,
+ 384,
+ - 136,
+ 273,
+ - 353,
+ 512,
+ - 142,
+ 537,
+ - 198,
+ 941,
+ 750,
+ 83,
+ 248,
+ 578,
+ 861,
+ - 56,
+ 592,
+ 842,
+ 44,
+ 892,
+ 24,
+ 33,
+ 890,
+ - 16,
+ 982,
+ 831,
+ 1398,
+ 1535,
+ 1898,
+ 1716,
+ 1376,
+ 1948,
+ 1465
+};
+
+/* 5th LSF quantizer (MR122) */
+static const Word32 dico5_lsf_5[DICO5_SIZE_5 * 4] =
+{
+ - 1002,
+ - 929,
+ - 1096,
+ - 1203,
+ - 641,
+ - 931,
+ - 604,
+ - 961,
+ - 779,
+ - 673,
+ - 835,
+ - 788,
+ - 416,
+ - 664,
+ - 458,
+ - 766,
+ - 652,
+ - 521,
+ - 662,
+ - 495,
+ - 1023,
+ - 509,
+ - 1023,
+ - 428,
+ - 444,
+ - 552,
+ - 368,
+ - 449,
+ - 479,
+ - 211,
+ - 1054,
+ - 903,
+ - 316,
+ - 249,
+ - 569,
+ - 591,
+ - 569,
+ - 275,
+ - 541,
+ - 191,
+ - 716,
+ - 188,
+ - 842,
+ - 264,
+ - 333,
+ - 248,
+ - 318,
+ - 228,
+ - 275,
+ 1,
+ - 567,
+ - 228,
+ - 115,
+ - 221,
+ - 238,
+ - 374,
+ - 197,
+ - 507,
+ - 222,
+ - 579,
+ - 258,
+ - 432,
+ - 61,
+ - 244,
+ - 345,
+ 2,
+ - 338,
+ 39,
+ - 215,
+ - 169,
+ - 58,
+ 0,
+ - 56,
+ - 6,
+ - 203,
+ - 131,
+ 1,
+ - 186,
+ - 5,
+ - 211,
+ 6,
+ - 380,
+ 11,
+ - 418,
+ - 116,
+ 131,
+ - 134,
+ 113,
+ 89,
+ - 4,
+ 71,
+ - 2,
+ - 19,
+ - 192,
+ 262,
+ 24,
+ 189,
+ 151,
+ - 133,
+ - 109,
+ 186,
+ - 153,
+ 166,
+ - 219,
+ 37,
+ 139,
+ 193,
+ 171,
+ 337,
+ 124,
+ 158,
+ - 61,
+ 141,
+ 226,
+ - 13,
+ 190,
+ 231,
+ 34,
+ 354,
+ 109,
+ 316,
+ 201,
+ 244,
+ 164,
+ 330,
+ - 85,
+ 390,
+ - 84,
+ 254,
+ 327,
+ 257,
+ 335,
+ 491,
+ 147,
+ 476,
+ 105,
+ 54,
+ 77,
+ 437,
+ 370,
+ 421,
+ 314,
+ 449,
+ 342,
+ 329,
+ 126,
+ 673,
+ 292,
+ 571,
+ 388,
+ 243,
+ 193,
+ 653,
+ 320,
+ 621,
+ 280,
+ 194,
+ 380,
+ 517,
+ 581,
+ 45,
+ 323,
+ 111,
+ 422,
+ 489,
+ 395,
+ 734,
+ 534,
+ 622,
+ 546,
+ 486,
+ 502,
+ 318,
+ 572,
+ 189,
+ 550,
+ 385,
+ 422,
+ - 157,
+ 153,
+ - 125,
+ 382,
+ - 197,
+ 386,
+ - 263,
+ 334,
+ 228,
+ 697,
+ - 188,
+ 1,
+ 51,
+ 297,
+ - 507,
+ 213,
+ - 376,
+ 397,
+ - 24,
+ 255,
+ - 547,
+ 89,
+ - 502,
+ - 94,
+ 387,
+ 179,
+ - 620,
+ 68,
+ - 684,
+ 112,
+ - 642,
+ - 350,
+ - 260,
+ 172,
+ - 438,
+ - 324,
+ 264,
+ 648,
+ - 964,
+ - 4,
+ - 1121,
+ 7,
+ - 134,
+ 134,
+ - 1133,
+ - 306,
+ 143,
+ 96,
+ - 420,
+ - 497,
+ - 1221,
+ - 350,
+ - 1527,
+ - 685,
+ - 161,
+ 72,
+ 873,
+ 691,
+ 732,
+ 283,
+ 921,
+ 353,
+ 334,
+ 475,
+ 1095,
+ 821,
+ 864,
+ 524,
+ 843,
+ 497,
+ 714,
+ 711,
+ 788,
+ 750,
+ 1076,
+ 714,
+ 1204,
+ 753
+};
+
+
+
+/* Scaling factors for the lsp variability operation */
+static const Word16 lsf_hist_mean_scale[M] =
+{
+ 20000,
+ 20000,
+ 20000,
+ 20000,
+ 20000,
+ 18000,
+ 16384,
+ 8192,
+ 0,
+ 0
+};
+
+/*
+ * The tables contains the following data:
+ *
+ * g_pitch (Q14),
+ * g_fac (Q12), (g_code = g_code0*g_fac),
+ * qua_ener_MR122 (Q10), (log2(g_fac))
+ * qua_ener (Q10) (20*log10(g_fac))
+ *
+ * The log2() and log10() values are calculated on the fixed point value
+ * (g_fac Q12) and not on the original floating point value of g_fac
+ * to make the quantizer/MA predictdor use corresponding values.
+ */
+
+#define MR475_VQ_SIZE 256
+
+/* The table contains the following data:
+ *
+ * g_pitch(0) (Q14) for sub-
+ * g_fac(0) (Q12) frame 0 and 2
+ * g_pitch(1) (Q14) for sub-
+ * g_fac(2) (Q12) frame 1 and 3
+ *
+ */
+static const Word32 table_gain_MR475[MR475_VQ_SIZE * 4] =
+{
+/*
+ * g_pit(0),
+ * g_fac(0),
+ * g_pit(1),
+ * g_fac(1)
+ */ 812,
+ 128,
+ 542,
+ 140,
+ 2873,
+ 1135,
+ 2266,
+ 3402,
+ 2067,
+ 563,
+ 12677,
+ 647,
+ 4132,
+ 1798,
+ 5601,
+ 5285,
+ 7689,
+ 374,
+ 3735,
+ 441,
+ 10912,
+ 2638,
+ 11807,
+ 2494,
+ 20490,
+ 797,
+ 5218,
+ 675,
+ 6724,
+ 8354,
+ 5282,
+ 1696,
+ 1488,
+ 428,
+ 5882,
+ 452,
+ 5332,
+ 4072,
+ 3583,
+ 1268,
+ 2469,
+ 901,
+ 15894,
+ 1005,
+ 14982,
+ 3271,
+ 10331,
+ 4858,
+ 3635,
+ 2021,
+ 2596,
+ 835,
+ 12360,
+ 4892,
+ 12206,
+ 1704,
+ 13432,
+ 1604,
+ 9118,
+ 2341,
+ 3968,
+ 1538,
+ 5479,
+ 9936,
+ 3795,
+ 417,
+ 1359,
+ 414,
+ 3640,
+ 1569,
+ 7995,
+ 3541,
+ 11405,
+ 645,
+ 8552,
+ 635,
+ 4056,
+ 1377,
+ 16608,
+ 6124,
+ 11420,
+ 700,
+ 2007,
+ 607,
+ 12415,
+ 1578,
+ 11119,
+ 4654,
+ 13680,
+ 1708,
+ 11990,
+ 1229,
+ 7996,
+ 7297,
+ 13231,
+ 5715,
+ 2428,
+ 1159,
+ 2073,
+ 1941,
+ 6218,
+ 6121,
+ 3546,
+ 1804,
+ 8925,
+ 1802,
+ 8679,
+ 1580,
+ 13935,
+ 3576,
+ 13313,
+ 6237,
+ 6142,
+ 1130,
+ 5994,
+ 1734,
+ 14141,
+ 4662,
+ 11271,
+ 3321,
+ 12226,
+ 1551,
+ 13931,
+ 3015,
+ 5081,
+ 10464,
+ 9444,
+ 6706,
+ 1689,
+ 683,
+ 1436,
+ 1306,
+ 7212,
+ 3933,
+ 4082,
+ 2713,
+ 7793,
+ 704,
+ 15070,
+ 802,
+ 6299,
+ 5212,
+ 4337,
+ 5357,
+ 6676,
+ 541,
+ 6062,
+ 626,
+ 13651,
+ 3700,
+ 11498,
+ 2408,
+ 16156,
+ 716,
+ 12177,
+ 751,
+ 8065,
+ 11489,
+ 6314,
+ 2256,
+ 4466,
+ 496,
+ 7293,
+ 523,
+ 10213,
+ 3833,
+ 8394,
+ 3037,
+ 8403,
+ 966,
+ 14228,
+ 1880,
+ 8703,
+ 5409,
+ 16395,
+ 4863,
+ 7420,
+ 1979,
+ 6089,
+ 1230,
+ 9371,
+ 4398,
+ 14558,
+ 3363,
+ 13559,
+ 2873,
+ 13163,
+ 1465,
+ 5534,
+ 1678,
+ 13138,
+ 14771,
+ 7338,
+ 600,
+ 1318,
+ 548,
+ 4252,
+ 3539,
+ 10044,
+ 2364,
+ 10587,
+ 622,
+ 13088,
+ 669,
+ 14126,
+ 3526,
+ 5039,
+ 9784,
+ 15338,
+ 619,
+ 3115,
+ 590,
+ 16442,
+ 3013,
+ 15542,
+ 4168,
+ 15537,
+ 1611,
+ 15405,
+ 1228,
+ 16023,
+ 9299,
+ 7534,
+ 4976,
+ 1990,
+ 1213,
+ 11447,
+ 1157,
+ 12512,
+ 5519,
+ 9475,
+ 2644,
+ 7716,
+ 2034,
+ 13280,
+ 2239,
+ 16011,
+ 5093,
+ 8066,
+ 6761,
+ 10083,
+ 1413,
+ 5002,
+ 2347,
+ 12523,
+ 5975,
+ 15126,
+ 2899,
+ 18264,
+ 2289,
+ 15827,
+ 2527,
+ 16265,
+ 10254,
+ 14651,
+ 11319,
+ 1797,
+ 337,
+ 3115,
+ 397,
+ 3510,
+ 2928,
+ 4592,
+ 2670,
+ 7519,
+ 628,
+ 11415,
+ 656,
+ 5946,
+ 2435,
+ 6544,
+ 7367,
+ 8238,
+ 829,
+ 4000,
+ 863,
+ 10032,
+ 2492,
+ 16057,
+ 3551,
+ 18204,
+ 1054,
+ 6103,
+ 1454,
+ 5884,
+ 7900,
+ 18752,
+ 3468,
+ 1864,
+ 544,
+ 9198,
+ 683,
+ 11623,
+ 4160,
+ 4594,
+ 1644,
+ 3158,
+ 1157,
+ 15953,
+ 2560,
+ 12349,
+ 3733,
+ 17420,
+ 5260,
+ 6106,
+ 2004,
+ 2917,
+ 1742,
+ 16467,
+ 5257,
+ 16787,
+ 1680,
+ 17205,
+ 1759,
+ 4773,
+ 3231,
+ 7386,
+ 6035,
+ 14342,
+ 10012,
+ 4035,
+ 442,
+ 4194,
+ 458,
+ 9214,
+ 2242,
+ 7427,
+ 4217,
+ 12860,
+ 801,
+ 11186,
+ 825,
+ 12648,
+ 2084,
+ 12956,
+ 6554,
+ 9505,
+ 996,
+ 6629,
+ 985,
+ 10537,
+ 2502,
+ 15289,
+ 5006,
+ 12602,
+ 2055,
+ 15484,
+ 1653,
+ 16194,
+ 6921,
+ 14231,
+ 5790,
+ 2626,
+ 828,
+ 5615,
+ 1686,
+ 13663,
+ 5778,
+ 3668,
+ 1554,
+ 11313,
+ 2633,
+ 9770,
+ 1459,
+ 14003,
+ 4733,
+ 15897,
+ 6291,
+ 6278,
+ 1870,
+ 7910,
+ 2285,
+ 16978,
+ 4571,
+ 16576,
+ 3849,
+ 15248,
+ 2311,
+ 16023,
+ 3244,
+ 14459,
+ 17808,
+ 11847,
+ 2763,
+ 1981,
+ 1407,
+ 1400,
+ 876,
+ 4335,
+ 3547,
+ 4391,
+ 4210,
+ 5405,
+ 680,
+ 17461,
+ 781,
+ 6501,
+ 5118,
+ 8091,
+ 7677,
+ 7355,
+ 794,
+ 8333,
+ 1182,
+ 15041,
+ 3160,
+ 14928,
+ 3039,
+ 20421,
+ 880,
+ 14545,
+ 852,
+ 12337,
+ 14708,
+ 6904,
+ 1920,
+ 4225,
+ 933,
+ 8218,
+ 1087,
+ 10659,
+ 4084,
+ 10082,
+ 4533,
+ 2735,
+ 840,
+ 20657,
+ 1081,
+ 16711,
+ 5966,
+ 15873,
+ 4578,
+ 10871,
+ 2574,
+ 3773,
+ 1166,
+ 14519,
+ 4044,
+ 20699,
+ 2627,
+ 15219,
+ 2734,
+ 15274,
+ 2186,
+ 6257,
+ 3226,
+ 13125,
+ 19480,
+ 7196,
+ 930,
+ 2462,
+ 1618,
+ 4515,
+ 3092,
+ 13852,
+ 4277,
+ 10460,
+ 833,
+ 17339,
+ 810,
+ 16891,
+ 2289,
+ 15546,
+ 8217,
+ 13603,
+ 1684,
+ 3197,
+ 1834,
+ 15948,
+ 2820,
+ 15812,
+ 5327,
+ 17006,
+ 2438,
+ 16788,
+ 1326,
+ 15671,
+ 8156,
+ 11726,
+ 8556,
+ 3762,
+ 2053,
+ 9563,
+ 1317,
+ 13561,
+ 6790,
+ 12227,
+ 1936,
+ 8180,
+ 3550,
+ 13287,
+ 1778,
+ 16299,
+ 6599,
+ 16291,
+ 7758,
+ 8521,
+ 2551,
+ 7225,
+ 2645,
+ 18269,
+ 7489,
+ 16885,
+ 2248,
+ 17882,
+ 2884,
+ 17265,
+ 3328,
+ 9417,
+ 20162,
+ 11042,
+ 8320,
+ 1286,
+ 620,
+ 1431,
+ 583,
+ 5993,
+ 2289,
+ 3978,
+ 3626,
+ 5144,
+ 752,
+ 13409,
+ 830,
+ 5553,
+ 2860,
+ 11764,
+ 5908,
+ 10737,
+ 560,
+ 5446,
+ 564,
+ 13321,
+ 3008,
+ 11946,
+ 3683,
+ 19887,
+ 798,
+ 9825,
+ 728,
+ 13663,
+ 8748,
+ 7391,
+ 3053,
+ 2515,
+ 778,
+ 6050,
+ 833,
+ 6469,
+ 5074,
+ 8305,
+ 2463,
+ 6141,
+ 1865,
+ 15308,
+ 1262,
+ 14408,
+ 4547,
+ 13663,
+ 4515,
+ 3137,
+ 2983,
+ 2479,
+ 1259,
+ 15088,
+ 4647,
+ 15382,
+ 2607,
+ 14492,
+ 2392,
+ 12462,
+ 2537,
+ 7539,
+ 2949,
+ 12909,
+ 12060,
+ 5468,
+ 684,
+ 3141,
+ 722,
+ 5081,
+ 1274,
+ 12732,
+ 4200,
+ 15302,
+ 681,
+ 7819,
+ 592,
+ 6534,
+ 2021,
+ 16478,
+ 8737,
+ 13364,
+ 882,
+ 5397,
+ 899,
+ 14656,
+ 2178,
+ 14741,
+ 4227,
+ 14270,
+ 1298,
+ 13929,
+ 2029,
+ 15477,
+ 7482,
+ 15815,
+ 4572,
+ 2521,
+ 2013,
+ 5062,
+ 1804,
+ 5159,
+ 6582,
+ 7130,
+ 3597,
+ 10920,
+ 1611,
+ 11729,
+ 1708,
+ 16903,
+ 3455,
+ 16268,
+ 6640,
+ 9306,
+ 1007,
+ 9369,
+ 2106,
+ 19182,
+ 5037,
+ 12441,
+ 4269,
+ 15919,
+ 1332,
+ 15357,
+ 3512,
+ 11898,
+ 14141,
+ 16101,
+ 6854,
+ 2010,
+ 737,
+ 3779,
+ 861,
+ 11454,
+ 2880,
+ 3564,
+ 3540,
+ 9057,
+ 1241,
+ 12391,
+ 896,
+ 8546,
+ 4629,
+ 11561,
+ 5776,
+ 8129,
+ 589,
+ 8218,
+ 588,
+ 18728,
+ 3755,
+ 12973,
+ 3149,
+ 15729,
+ 758,
+ 16634,
+ 754,
+ 15222,
+ 11138,
+ 15871,
+ 2208,
+ 4673,
+ 610,
+ 10218,
+ 678,
+ 15257,
+ 4146,
+ 5729,
+ 3327,
+ 8377,
+ 1670,
+ 19862,
+ 2321,
+ 15450,
+ 5511,
+ 14054,
+ 5481,
+ 5728,
+ 2888,
+ 7580,
+ 1346,
+ 14384,
+ 5325,
+ 16236,
+ 3950,
+ 15118,
+ 3744,
+ 15306,
+ 1435,
+ 14597,
+ 4070,
+ 12301,
+ 15696,
+ 7617,
+ 1699,
+ 2170,
+ 884,
+ 4459,
+ 4567,
+ 18094,
+ 3306,
+ 12742,
+ 815,
+ 14926,
+ 907,
+ 15016,
+ 4281,
+ 15518,
+ 8368,
+ 17994,
+ 1087,
+ 2358,
+ 865,
+ 16281,
+ 3787,
+ 15679,
+ 4596,
+ 16356,
+ 1534,
+ 16584,
+ 2210,
+ 16833,
+ 9697,
+ 15929,
+ 4513,
+ 3277,
+ 1085,
+ 9643,
+ 2187,
+ 11973,
+ 6068,
+ 9199,
+ 4462,
+ 8955,
+ 1629,
+ 10289,
+ 3062,
+ 16481,
+ 5155,
+ 15466,
+ 7066,
+ 13678,
+ 2543,
+ 5273,
+ 2277,
+ 16746,
+ 6213,
+ 16655,
+ 3408,
+ 20304,
+ 3363,
+ 18688,
+ 1985,
+ 14172,
+ 12867,
+ 15154,
+ 15703,
+ 4473,
+ 1020,
+ 1681,
+ 886,
+ 4311,
+ 4301,
+ 8952,
+ 3657,
+ 5893,
+ 1147,
+ 11647,
+ 1452,
+ 15886,
+ 2227,
+ 4582,
+ 6644,
+ 6929,
+ 1205,
+ 6220,
+ 799,
+ 12415,
+ 3409,
+ 15968,
+ 3877,
+ 19859,
+ 2109,
+ 9689,
+ 2141,
+ 14742,
+ 8830,
+ 14480,
+ 2599,
+ 1817,
+ 1238,
+ 7771,
+ 813,
+ 19079,
+ 4410,
+ 5554,
+ 2064,
+ 3687,
+ 2844,
+ 17435,
+ 2256,
+ 16697,
+ 4486,
+ 16199,
+ 5388,
+ 8028,
+ 2763,
+ 3405,
+ 2119,
+ 17426,
+ 5477,
+ 13698,
+ 2786,
+ 19879,
+ 2720,
+ 9098,
+ 3880,
+ 18172,
+ 4833,
+ 17336,
+ 12207,
+ 5116,
+ 996,
+ 4935,
+ 988,
+ 9888,
+ 3081,
+ 6014,
+ 5371,
+ 15881,
+ 1667,
+ 8405,
+ 1183,
+ 15087,
+ 2366,
+ 19777,
+ 7002,
+ 11963,
+ 1562,
+ 7279,
+ 1128,
+ 16859,
+ 1532,
+ 15762,
+ 5381,
+ 14708,
+ 2065,
+ 20105,
+ 2155,
+ 17158,
+ 8245,
+ 17911,
+ 6318,
+ 5467,
+ 1504,
+ 4100,
+ 2574,
+ 17421,
+ 6810,
+ 5673,
+ 2888,
+ 16636,
+ 3382,
+ 8975,
+ 1831,
+ 20159,
+ 4737,
+ 19550,
+ 7294,
+ 6658,
+ 2781,
+ 11472,
+ 3321,
+ 19397,
+ 5054,
+ 18878,
+ 4722,
+ 16439,
+ 2373,
+ 20430,
+ 4386,
+ 11353,
+ 26526,
+ 11593,
+ 3068,
+ 2866,
+ 1566,
+ 5108,
+ 1070,
+ 9614,
+ 4915,
+ 4939,
+ 3536,
+ 7541,
+ 878,
+ 20717,
+ 851,
+ 6938,
+ 4395,
+ 16799,
+ 7733,
+ 10137,
+ 1019,
+ 9845,
+ 964,
+ 15494,
+ 3955,
+ 15459,
+ 3430,
+ 18863,
+ 982,
+ 20120,
+ 963,
+ 16876,
+ 12887,
+ 14334,
+ 4200,
+ 6599,
+ 1220,
+ 9222,
+ 814,
+ 16942,
+ 5134,
+ 5661,
+ 4898,
+ 5488,
+ 1798,
+ 20258,
+ 3962,
+ 17005,
+ 6178,
+ 17929,
+ 5929,
+ 9365,
+ 3420,
+ 7474,
+ 1971,
+ 19537,
+ 5177,
+ 19003,
+ 3006,
+ 16454,
+ 3788,
+ 16070,
+ 2367,
+ 8664,
+ 2743,
+ 9445,
+ 26358,
+ 10856,
+ 1287,
+ 3555,
+ 1009,
+ 5606,
+ 3622,
+ 19453,
+ 5512,
+ 12453,
+ 797,
+ 20634,
+ 911,
+ 15427,
+ 3066,
+ 17037,
+ 10275,
+ 18883,
+ 2633,
+ 3913,
+ 1268,
+ 19519,
+ 3371,
+ 18052,
+ 5230,
+ 19291,
+ 1678,
+ 19508,
+ 3172,
+ 18072,
+ 10754,
+ 16625,
+ 6845,
+ 3134,
+ 2298,
+ 10869,
+ 2437,
+ 15580,
+ 6913,
+ 12597,
+ 3381,
+ 11116,
+ 3297,
+ 16762,
+ 2424,
+ 18853,
+ 6715,
+ 17171,
+ 9887,
+ 12743,
+ 2605,
+ 8937,
+ 3140,
+ 19033,
+ 7764,
+ 18347,
+ 3880,
+ 20475,
+ 3682,
+ 19602,
+ 3380,
+ 13044,
+ 19373,
+ 10526,
+ 23124
+};
+
+
+/* table used in 'high' rates: MR67 MR74 */
+#define VQ_SIZE_HIGHRATES 128
+static const Word32 table_gain_highrates[VQ_SIZE_HIGHRATES * 4] =
+{
+/*
+ * Note: every 4th value (qua_ener) contains the original values from IS641
+ * to ensure bit-exactness; however, they are not exactly the
+ * rounded value of (20*log10(g_fac))
+ */ /*
+ * g_pit,
+ * g_fac,
+ * qua_ener_MR122,
+ * qua_ener
+ */ 577,
+ 662,
+ - 2692,
+ - 16214,
+ 806,
+ 1836,
+ - 1185,
+ - 7135,
+ 3109,
+ 1052,
+ - 2008,
+ - 12086,
+ 4181,
+ 1387,
+ - 1600,
+ - 9629,
+ 2373,
+ 1425,
+ - 1560,
+ - 9394,
+ 3248,
+ 1985,
+ - 1070,
+ - 6442,
+ 1827,
+ 2320,
+ - 840,
+ - 5056,
+ 941,
+ 3314,
+ - 313,
+ - 1885,
+ 2351,
+ 2977,
+ - 471,
+ - 2838,
+ 3616,
+ 2420,
+ - 777,
+ - 4681,
+ 3451,
+ 3096,
+ - 414,
+ - 2490,
+ 2955,
+ 4301,
+ 72,
+ 434,
+ 1848,
+ 4500,
+ 139,
+ 836,
+ 3884,
+ 5416,
+ 413,
+ 2484,
+ 1187,
+ 7210,
+ 835,
+ 5030,
+ 3083,
+ 9000,
+ 1163,
+ 7002,
+ 7384,
+ 883,
+ - 2267,
+ - 13647,
+ 5962,
+ 1506,
+ - 1478,
+ - 8900,
+ 5155,
+ 2134,
+ - 963,
+ - 5800,
+ 7944,
+ 2009,
+ - 1052,
+ - 6335,
+ 6507,
+ 2250,
+ - 885,
+ - 5327,
+ 7670,
+ 2752,
+ - 588,
+ - 3537,
+ 5952,
+ 3016,
+ - 452,
+ - 2724,
+ 4898,
+ 3764,
+ - 125,
+ - 751,
+ 6989,
+ 3588,
+ - 196,
+ - 1177,
+ 8174,
+ 3978,
+ - 43,
+ - 260,
+ 6064,
+ 4404,
+ 107,
+ 645,
+ 7709,
+ 5087,
+ 320,
+ 1928,
+ 5523,
+ 6021,
+ 569,
+ 3426,
+ 7769,
+ 7126,
+ 818,
+ 4926,
+ 6060,
+ 7938,
+ 977,
+ 5885,
+ 5594,
+ 11487,
+ 1523,
+ 9172,
+ 10581,
+ 1356,
+ - 1633,
+ - 9831,
+ 9049,
+ 1597,
+ - 1391,
+ - 8380,
+ 9794,
+ 2035,
+ - 1033,
+ - 6220,
+ 8946,
+ 2415,
+ - 780,
+ - 4700,
+ 10296,
+ 2584,
+ - 681,
+ - 4099,
+ 9407,
+ 2734,
+ - 597,
+ - 3595,
+ 8700,
+ 3218,
+ - 356,
+ - 2144,
+ 9757,
+ 3395,
+ - 277,
+ - 1669,
+ 10177,
+ 3892,
+ - 75,
+ - 454,
+ 9170,
+ 4528,
+ 148,
+ 891,
+ 10152,
+ 5004,
+ 296,
+ 1781,
+ 9114,
+ 5735,
+ 497,
+ 2993,
+ 10500,
+ 6266,
+ 628,
+ 3782,
+ 10110,
+ 7631,
+ 919,
+ 5534,
+ 8844,
+ 8727,
+ 1117,
+ 6728,
+ 8956,
+ 12496,
+ 1648,
+ 9921,
+ 12924,
+ 976,
+ - 2119,
+ - 12753,
+ 11435,
+ 1755,
+ - 1252,
+ - 7539,
+ 12138,
+ 2328,
+ - 835,
+ - 5024,
+ 11388,
+ 2368,
+ - 810,
+ - 4872,
+ 10700,
+ 3064,
+ - 429,
+ - 2580,
+ 12332,
+ 2861,
+ - 530,
+ - 3192,
+ 11722,
+ 3327,
+ - 307,
+ - 1848,
+ 11270,
+ 3700,
+ - 150,
+ - 904,
+ 10861,
+ 4413,
+ 110,
+ 663,
+ 12082,
+ 4533,
+ 150,
+ 902,
+ 11283,
+ 5205,
+ 354,
+ 2132,
+ 11960,
+ 6305,
+ 637,
+ 3837,
+ 11167,
+ 7534,
+ 900,
+ 5420,
+ 12128,
+ 8329,
+ 1049,
+ 6312,
+ 10969,
+ 10777,
+ 1429,
+ 8604,
+ 10300,
+ 17376,
+ 2135,
+ 12853,
+ 13899,
+ 1681,
+ - 1316,
+ - 7921,
+ 12580,
+ 2045,
+ - 1026,
+ - 6179,
+ 13265,
+ 2439,
+ - 766,
+ - 4610,
+ 14033,
+ 2989,
+ - 465,
+ - 2802,
+ 13452,
+ 3098,
+ - 413,
+ - 2482,
+ 12396,
+ 3658,
+ - 167,
+ - 1006,
+ 13510,
+ 3780,
+ - 119,
+ - 713,
+ 12880,
+ 4272,
+ 62,
+ 374,
+ 13533,
+ 4861,
+ 253,
+ 1523,
+ 12667,
+ 5457,
+ 424,
+ 2552,
+ 13854,
+ 6106,
+ 590,
+ 3551,
+ 13031,
+ 6483,
+ 678,
+ 4084,
+ 13557,
+ 7721,
+ 937,
+ 5639,
+ 12957,
+ 9311,
+ 1213,
+ 7304,
+ 13714,
+ 11551,
+ 1532,
+ 9221,
+ 12591,
+ 15206,
+ 1938,
+ 11667,
+ 15113,
+ 1540,
+ - 1445,
+ - 8700,
+ 15072,
+ 2333,
+ - 832,
+ - 5007,
+ 14527,
+ 2511,
+ - 723,
+ - 4352,
+ 14692,
+ 3199,
+ - 365,
+ - 2197,
+ 15382,
+ 3560,
+ - 207,
+ - 1247,
+ 14133,
+ 3960,
+ - 50,
+ - 300,
+ 15102,
+ 4236,
+ 50,
+ 298,
+ 14332,
+ 4824,
+ 242,
+ 1454,
+ 14846,
+ 5451,
+ 422,
+ 2542,
+ 15306,
+ 6083,
+ 584,
+ 3518,
+ 14329,
+ 6888,
+ 768,
+ 4623,
+ 15060,
+ 7689,
+ 930,
+ 5602,
+ 14406,
+ 9426,
+ 1231,
+ 7413,
+ 15387,
+ 9741,
+ 1280,
+ 7706,
+ 14824,
+ 14271,
+ 1844,
+ 11102,
+ 13600,
+ 24939,
+ 2669,
+ 16067,
+ 16396,
+ 1969,
+ - 1082,
+ - 6517,
+ 16817,
+ 2832,
+ - 545,
+ - 3283,
+ 15713,
+ 2843,
+ - 539,
+ - 3248,
+ 16104,
+ 3336,
+ - 303,
+ - 1825,
+ 16384,
+ 3963,
+ - 49,
+ - 294,
+ 16940,
+ 4579,
+ 165,
+ 992,
+ 15711,
+ 4599,
+ 171,
+ 1030,
+ 16222,
+ 5448,
+ 421,
+ 2537,
+ 16832,
+ 6382,
+ 655,
+ 3945,
+ 15745,
+ 7141,
+ 821,
+ 4944,
+ 16326,
+ 7469,
+ 888,
+ 5343,
+ 16611,
+ 8624,
+ 1100,
+ 6622,
+ 17028,
+ 10418,
+ 1379,
+ 8303,
+ 15905,
+ 11817,
+ 1565,
+ 9423,
+ 16878,
+ 14690,
+ 1887,
+ 11360,
+ 16515,
+ 20870,
+ 2406,
+ 14483,
+ 18142,
+ 2083,
+ - 999,
+ - 6013,
+ 19401,
+ 3178,
+ - 375,
+ - 2257,
+ 17508,
+ 3426,
+ - 264,
+ - 1589,
+ 20054,
+ 4027,
+ - 25,
+ - 151,
+ 18069,
+ 4249,
+ 54,
+ 326,
+ 18952,
+ 5066,
+ 314,
+ 1890,
+ 17711,
+ 5402,
+ 409,
+ 2461,
+ 19835,
+ 6192,
+ 610,
+ 3676,
+ 17950,
+ 7014,
+ 795,
+ 4784,
+ 21318,
+ 7877,
+ 966,
+ 5816,
+ 17910,
+ 9289,
+ 1210,
+ 7283,
+ 19144,
+ 9290,
+ 1210,
+ 7284,
+ 20517,
+ 11381,
+ 1510,
+ 9089,
+ 18075,
+ 14485,
+ 1866,
+ 11234,
+ 19999,
+ 17882,
+ 2177,
+ 13108,
+ 18842,
+ 32764,
+ 3072,
+ 18494
+};
+
+/* table used in 'low' rates: MR475, MR515, MR59 */
+#define VQ_SIZE_LOWRATES 64
+static const Word32 table_gain_lowrates[VQ_SIZE_LOWRATES * 4] =
+{
+/*
+ * g_pit,
+ * g_fac,
+ * qua_ener_MR122,
+ * qua_ener
+ */ 10813,
+ 28753,
+ 2879,
+ 17333,
+ 20480,
+ 2785,
+ - 570,
+ - 3431,
+ 18841,
+ 6594,
+ 703,
+ 4235,
+ 6225,
+ 7413,
+ 876,
+ 5276,
+ 17203,
+ 10444,
+ 1383,
+ 8325,
+ 21626,
+ 1269,
+ - 1731,
+ - 10422,
+ 21135,
+ 4423,
+ 113,
+ 683,
+ 11304,
+ 1556,
+ - 1430,
+ - 8609,
+ 19005,
+ 12820,
+ 1686,
+ 10148,
+ 17367,
+ 2498,
+ - 731,
+ - 4398,
+ 17858,
+ 4833,
+ 244,
+ 1472,
+ 9994,
+ 2498,
+ - 731,
+ - 4398,
+ 17530,
+ 7864,
+ 964,
+ 5802,
+ 14254,
+ 1884,
+ - 1147,
+ - 6907,
+ 15892,
+ 3153,
+ - 387,
+ - 2327,
+ 6717,
+ 1802,
+ - 1213,
+ - 7303,
+ 18186,
+ 20193,
+ 2357,
+ 14189,
+ 18022,
+ 3031,
+ - 445,
+ - 2678,
+ 16711,
+ 5857,
+ 528,
+ 3181,
+ 8847,
+ 4014,
+ - 30,
+ - 180,
+ 15892,
+ 8970,
+ 1158,
+ 6972,
+ 18022,
+ 1392,
+ - 1594,
+ - 9599,
+ 16711,
+ 4096,
+ 0,
+ 0,
+ 8192,
+ 655,
+ - 2708,
+ - 16305,
+ 15237,
+ 13926,
+ 1808,
+ 10884,
+ 14254,
+ 3112,
+ - 406,
+ - 2444,
+ 14090,
+ 4669,
+ 193,
+ 1165,
+ 5406,
+ 2703,
+ - 614,
+ - 3697,
+ 13434,
+ 6553,
+ 694,
+ 4180,
+ 12451,
+ 901,
+ - 2237,
+ - 13468,
+ 12451,
+ 2662,
+ - 637,
+ - 3833,
+ 3768,
+ 655,
+ - 2708,
+ - 16305,
+ 14745,
+ 23511,
+ 2582,
+ 15543,
+ 19169,
+ 2457,
+ - 755,
+ - 4546,
+ 20152,
+ 5079,
+ 318,
+ 1913,
+ 6881,
+ 4096,
+ 0,
+ 0,
+ 20480,
+ 8560,
+ 1089,
+ 6556,
+ 19660,
+ 737,
+ - 2534,
+ - 15255,
+ 19005,
+ 4259,
+ 58,
+ 347,
+ 7864,
+ 2088,
+ - 995,
+ - 5993,
+ 11468,
+ 12288,
+ 1623,
+ 9771,
+ 15892,
+ 1474,
+ - 1510,
+ - 9090,
+ 15728,
+ 4628,
+ 180,
+ 1086,
+ 9175,
+ 1433,
+ - 1552,
+ - 9341,
+ 16056,
+ 7004,
+ 793,
+ 4772,
+ 14827,
+ 737,
+ - 2534,
+ - 15255,
+ 15073,
+ 2252,
+ - 884,
+ - 5321,
+ 5079,
+ 1228,
+ - 1780,
+ - 10714,
+ 13271,
+ 17326,
+ 2131,
+ 12827,
+ 16547,
+ 2334,
+ - 831,
+ - 5002,
+ 15073,
+ 5816,
+ 518,
+ 3118,
+ 3932,
+ 3686,
+ - 156,
+ - 938,
+ 14254,
+ 8601,
+ 1096,
+ 6598,
+ 16875,
+ 778,
+ - 2454,
+ - 14774,
+ 15073,
+ 3809,
+ - 107,
+ - 646,
+ 6062,
+ 614,
+ - 2804,
+ - 16879,
+ 9338,
+ 9256,
+ 1204,
+ 7251,
+ 13271,
+ 1761,
+ - 1247,
+ - 7508,
+ 13271,
+ 3522,
+ - 223,
+ - 1343,
+ 2457,
+ 1966,
+ - 1084,
+ - 6529,
+ 11468,
+ 5529,
+ 443,
+ 2668,
+ 10485,
+ 737,
+ - 2534,
+ - 15255,
+ 11632,
+ 3194,
+ - 367,
+ - 2212,
+ 1474,
+ 778,
+ - 2454,
+ - 14774
+};
+
+static const Word32 inter6[61] =
+{
+ 29443,
+ 28346,
+ 25207,
+ 20449,
+ 14701,
+ 8693,
+ 3143,
+ - 1352,
+ - 4402,
+ - 5865,
+ - 5850,
+ - 4673,
+ - 2783,
+ - 672,
+ 1211,
+ 2536,
+ 3130,
+ 2991,
+ 2259,
+ 1170,
+ 0,
+ - 1001,
+ - 1652,
+ - 1868,
+ - 1666,
+ - 1147,
+ - 464,
+ 218,
+ 756,
+ 1060,
+ 1099,
+ 904,
+ 550,
+ 135,
+ - 245,
+ - 514,
+ - 634,
+ - 602,
+ - 451,
+ - 231,
+ 0,
+ 191,
+ 308,
+ 340,
+ 296,
+ 198,
+ 78,
+ - 36,
+ - 120,
+ - 163,
+ - 165,
+ - 132,
+ - 79,
+ - 19,
+ 34,
+ 73,
+ 91,
+ 89,
+ 70,
+ 38,
+ 0
+};
+
+/*
+ * window for non-MR122 modesm; uses 40 samples lookahead
+ * used only in BuildCNParam
+ */
+static const Word32 window_200_40[L_WINDOW] = {
+ 2621, 2623, 2629, 2638, 2651, 2668, 2689, 2713, 2741, 2772,
+ 2808, 2847, 2890, 2936, 2986, 3040, 3097, 3158, 3223, 3291,
+ 3363, 3438, 3517, 3599, 3685, 3774, 3867, 3963, 4063, 4166,
+ 4272, 4382, 4495, 4611, 4731, 4853, 4979, 5108, 5240, 5376,
+ 5514, 5655, 5800, 5947, 6097, 6250, 6406, 6565, 6726, 6890,
+ 7057, 7227, 7399, 7573, 7750, 7930, 8112, 8296, 8483, 8672,
+ 8863, 9057, 9252, 9450, 9650, 9852, 10055, 10261, 10468, 10677,
+ 10888, 11101, 11315, 11531, 11748, 11967, 12187, 12409, 12632, 12856,
+ 13082, 13308, 13536, 13764, 13994, 14225, 14456, 14688, 14921, 15155,
+ 15389, 15624, 15859, 16095, 16331, 16568, 16805, 17042, 17279, 17516,
+ 17754, 17991, 18228, 18465, 18702, 18939, 19175, 19411, 19647, 19882,
+ 20117, 20350, 20584, 20816, 21048, 21279, 21509, 21738, 21967, 22194,
+ 22420, 22644, 22868, 23090, 23311, 23531, 23749, 23965, 24181, 24394,
+ 24606, 24816, 25024, 25231, 25435, 25638, 25839, 26037, 26234, 26428,
+ 26621, 26811, 26999, 27184, 27368, 27548, 27727, 27903, 28076, 28247,
+ 28415, 28581, 28743, 28903, 29061, 29215, 29367, 29515, 29661, 29804,
+ 29944, 30081, 30214, 30345, 30472, 30597, 30718, 30836, 30950, 31062,
+ 31170, 31274, 31376, 31474, 31568, 31659, 31747, 31831, 31911, 31988,
+ 32062, 32132, 32198, 32261, 32320, 32376, 32428, 32476, 32521, 32561,
+ 32599, 32632, 32662, 32688, 32711, 32729, 32744, 32755, 32763, 32767,
+ 32767, 32741, 32665, 32537, 32359, 32129, 31850, 31521, 31143, 30716,
+ 30242, 29720, 29151, 28538, 27879, 27177, 26433, 25647, 24821, 23957,
+ 23055, 22117, 21145, 20139, 19102, 18036, 16941, 15820, 14674, 13505,
+ 12315, 11106, 9879, 8637, 7381, 6114, 4838, 3554, 2264, 971};
+
+
+
+
+/* comparision optimization tables */
+/* definition of bad speech */
+static const UWord8 table_speech_bad[9] = {0, 0, 1, 1, 0, 0, 0, 1, 0};
+static const UWord8 table_SID[9] = {0, 0, 0, 0, 1, 1, 1, 0, 0};
+static const UWord8 table_DTX[9] = {0, 0, 0, 0, 1, 1, 1, 1, 0};
+static const UWord8 table_mute[9] = {0, 0, 0, 0, 1, 0, 1, 1, 0};
+
+/* track start positions for fixed codebook routines */
+static const Word8 startPos[16] =
+ {
+ 0,
+ 2,
+ 0,
+ 3,
+ 0,
+ 2,
+ 0,
+ 3,
+ 1,
+ 3,
+ 2,
+ 4,
+ 1,
+ 4,
+ 1,
+ 4
+ };
+
+
+
+
+
+
+
+#endif
+
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/rom_enc.h b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/rom_enc.h
new file mode 100644
index 000000000..a506e49fb
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/rom_enc.h
@@ -0,0 +1,14473 @@
+/*
+ * ===================================================================
+ * TS 26.104
+ * REL-5 V5.4.0 2004-03
+ * REL-6 V6.1.0 2004-03
+ * 3GPP AMR Floating-point Speech Codec
+ * ===================================================================
+ *
+ */
+
+/*
+ * rom_enc.h
+ *
+ *
+ * Project:
+ * AMR Floating-Point Codec
+ *
+ * Contains:
+ * This file contains all the tables needed by AMR encoder functions.
+ *
+ */
+#ifndef _ROM_ENC_H_
+#define _ROM_ENC_H_
+
+
+#include "typedef.h"
+#include "sp_enc.h"
+
+#define M 10 /* Order of LP filter */
+#define MP1 (M+1) /* Order of LP filter + 1 */
+#define L_WINDOW 240 /* Window size in LP analysis */
+#define L_NEXT 40 /* Overhead in LP analysis */
+#define LTPG_MEM_SIZE 5 /* number of stored past LTP coding gains + 1 */
+#define N_FRAME 7 /* old pitch gains in average calculation */
+#define DTX_HIST_SIZE 8 /* DTX history size */
+#define L_TOTAL 320 /* Total size of speech buffer. */
+#define L_FRAME 160 /* Frame size */
+#define L_FRAME_BY2 80 /* Frame size divided by 2 */
+#define L_SUBFR 40 /* Subframe size */
+#define L_CODE 40 /* codevector length */
+#define PIT_MAX 143 /* Maximum pitch lag */
+#define PIT_MIN 20 /* Minimum pitch lag */
+#define PIT_MIN_MR122 18 /* Minimum pitch lag (MR122 mode) */
+#define L_INTERPOL (10+1)/* Length of filter for interpolation */
+#define NPRED 4 /* number of prediction taps */
+#define SHARPMIN 0 /* Minimum value of pitch sharpening */
+#define MAX_PRM_SIZE 57 /* max. num. of params */
+#define L_INTER_SRCH 4 /* Length of filter for CL LTP search interpolation */
+#define GP_CLIP 0.95F /* Pitch gain clipping */
+#define UP_SAMP_MAX 6
+#define NB_TRACK 5 /* number of tracks */
+#define NB_TRACK_MR102 4 /* number of tracks mode mr102 */
+#define STEP 5 /* codebook step size */
+#define STEP_MR102 4 /* codebook step size mode mr102 */
+#define NC M/2 /* Order of LP filter divided by 2 */
+
+#define SCALE_LSP_FREQ (Float32)(4000.0/3.141592654)
+#define SCALE_FREQ_LSP (Float32)(3.141592654/4000.0)
+#define SLOPE1_WGHT_LSF (Float32)((3.347-1.8)/(450.0-0.0))
+#define SLOPE2_WGHT_LSF (Float32)((1.8-1.0)/(1500.0-450.0))
+
+#define FRAME_LEN 160 /* Length (samples) of the input frame */
+#define COMPLEN 9 /* Number of sub-bands used by VAD */
+#define INV_COMPLEN 3641 /* 1.0/COMPLEN*2^15 */
+#define LOOKAHEAD 40 /* length of the lookahead used by speech coder */
+
+#define UNITY 512 /* Scaling used with SNR calculation */
+#define UNIRSHFT 6 /* = log2(MAX_16/UNITY) */
+
+#define TONE_THR 0.65F /* Threshold for tone detection */
+
+/* Constants for background spectrum update */
+#define ALPHA_UP1 (Float32)(1.0 - 0.95) /* Normal update, upwards: */
+#define ALPHA_DOWN1 (Float32)(1.0 - 0.936) /* Normal update, downwards */
+#define ALPHA_UP2 (Float32)(1.0 - 0.985) /* Forced update, upwards */
+#define ALPHA_DOWN2 (Float32)(1.0 - 0.943) /* Forced update, downwards */
+#define ALPHA3 (Float32)(1.0 - 0.95) /* Update downwards */
+#define ALPHA4 (Float32)(1.0 - 0.9) /* For stationary estimation */
+#define ALPHA5 (Float32)(1.0 - 0.5) /* For stationary estimation */
+
+/* Constants for VAD threshold */
+#define VAD_THR_HIGH 1260 /* Highest threshold */
+#define VAD_THR_LOW 720 /* Lowest threshold */
+#define VAD_P1 0 /* Noise level for highest threshold */
+#define VAD_P2 6300 /* Noise level for lowest threshold */
+#define VAD_SLOPE (float)(VAD_THR_LOW-VAD_THR_HIGH)/(float)(VAD_P2-VAD_P1)
+
+/* Parameters for background spectrum recovery function */
+#define STAT_COUNT 20 /* threshold of stationary detection counter */
+#define STAT_COUNT_BY_2 10 /* threshold of stationary detection counter */
+#define CAD_MIN_STAT_COUNT 5 /* threshold of stationary detection counter */
+
+#define STAT_THR_LEVEL 184 /* Threshold level for stationarity detection */
+#define STAT_THR 1000 /* Threshold for stationarity detection */
+
+/* Limits for background noise estimate */
+#define NOISE_MIN 40 /* minimum */
+#define NOISE_MAX 16000 /* maximum */
+#define NOISE_INIT 150 /* initial */
+
+/* Constants for VAD hangover addition */
+#define HANG_NOISE_THR 100
+#define BURST_LEN_HIGH_NOISE 4
+#define HANG_LEN_HIGH_NOISE 7
+#define BURST_LEN_LOW_NOISE 5
+#define HANG_LEN_LOW_NOISE 4
+
+/* Thresholds for signal power */
+#define VAD_POW_LOW (Word32)15000/2 /* If input power is lower, */
+ /* VAD is set to 0 */
+#define POW_PITCH_THR (Word32)343040/2 /* If input power is lower, pitch */
+ /* detection is ignored */
+
+#define POW_COMPLEX_THR (Word32)15000/2/* If input power is lower, complex */
+ /* flags value for previous frame is un-set */
+/*
+ * VAD Constants
+ */
+
+/* Constants for the filter bank */
+#define LEVEL_SHIFT 0 /* scaling */
+#define COEFF3 (Float32)13363/32768 /* coefficient for the 3rd order filter */
+#define COEFF5_1 (Float32)21955/32768 /* 1st coefficient the for 5th order filter */
+#define COEFF5_2 (Float32)6390/32768 /* 2nd coefficient the for 5th order filter */
+
+/* Constants for pitch detection */
+#define LTHRESH 4
+#define NTHRESH 4
+
+/* Constants for complex signal VAD */
+#define CVAD_THRESH_ADAPT_HIGH 0.6F /* threshold for adapt stopping high */
+#define CVAD_THRESH_ADAPT_LOW 0.5F /* threshold for adapt stopping low */
+#define CVAD_THRESH_IN_NOISE 0.65F * 32768.0F /* threshold going into speech on
+ a short term basis */
+#define CVAD_THRESH_HANG 0.70F /* threshold */
+#define CVAD_HANG_LIMIT (Word16)(100) /* 2 second estimation time */
+#define CVAD_HANG_LENGTH (Word16)(250) /* 5 second hangover */
+
+#define CVAD_LOWPOW_RESET 0.40F /* init in low power segment */
+#define CVAD_MIN_CORR 0.40F /* lowest adaptation value */
+
+#define CVAD_BURST 20 /* speech burst length for speech reset */
+#define CVAD_ADAPT_SLOW 1.0F - 0.98F /* threshold for slow adaption */
+#define CVAD_ADAPT_FAST 1.0F - 0.92F /* threshold for fast adaption */
+#define CVAD_ADAPT_REALLY_FAST 1.0F - 0.80F /* threshold for really fast adaption */
+
+/* track table for algebraic code book search (MR475, MR515) */
+static Word8 trackTable[4 * 5] =
+ {
+ /* subframe 1; track to code; -1 do not code this position */ 0,
+ 1,
+ 0,
+ 1,
+ - 1,
+ /* subframe 2 */ 0,
+ - 1,
+ 1,
+ 0,
+ 1,
+ /* subframe 3 */ 0,
+ 1,
+ 0,
+ - 1,
+ 1,
+ /* subframe 4 */ 0,
+ 1,
+ - 1,
+ 0,
+ 1
+ };
+static const Float32 gamma1[M] =
+{
+ 0.9400024414063F,
+ 0.8836059570313F,
+ 0.8305969238281F,
+ 0.78076171875F,
+ 0.7339172363281F,
+ 0.6898803710938F,
+ 0.6484985351563F,
+ 0.6095886230469F,
+ 0.5730285644531F,
+ 0.5386352539063F
+};
+
+/*
+ * gamma1 for the 12k2 coder
+ */
+static const Float32 gamma1_12k2[M] =
+{
+ 0.8999938964844F,
+ 0.8099975585938F,
+ 0.72900390625F,
+ 0.6560974121094F,
+ 0.5904846191406F,
+ 0.5314331054688F,
+ 0.478271484375F,
+ 0.4304504394531F,
+ 0.3873901367188F,
+ 0.3486633300781F
+};
+static const Float32 gamma2[M] =
+{
+ 0.6000061035156F,
+ 0.3600158691406F,
+ 0.2160034179688F,
+ 0.1296081542969F,
+ 0.0777587890625F,
+ 0.04666137695313F,
+ 0.02798461914063F,
+ 0.01678466796875F,
+ 0.01007080078125F,
+ 0.00604248046875F
+};
+
+/* 1/6 resolution interpolation filter (-3 dB at 3600 Hz)
+ * Note: the 1/3 resolution filter is simply a subsampled
+ * version of the 1/6 resolution filter, i.e. it uses
+ * every second coefficient:
+ *
+ * inter_6(1/3)[k] = inter_6(1/3)[2*k], 0 <= k <= 3*L_INTER10
+ */
+static Float32 b60[UP_SAMP_MAX*(L_INTERPOL-1)+1] =
+{
+ 0.898529F,
+ 0.865051F,
+ 0.769257F,
+ 0.624054F,
+ 0.448639F,
+ 0.265289F,
+ 0.0959167F,
+ - 0.0412598F,
+ - 0.134338F,
+ - 0.178986F,
+ - 0.178528F,
+ - 0.142609F,
+ - 0.0849304F,
+ - 0.0205078F,
+ 0.0369568F,
+ 0.0773926F,
+ 0.0955200F,
+ 0.0912781F,
+ 0.0689392F,
+ 0.0357056F,
+ 0.000000F,
+ - 0.0305481F,
+ - 0.0504150F,
+ - 0.0570068F,
+ - 0.0508423F,
+ - 0.0350037F,
+ - 0.0141602F,
+ 0.00665283F,
+ 0.0230713F,
+ 0.0323486F,
+ 0.0335388F,
+ 0.0275879F,
+ 0.0167847F,
+ 0.00411987F,
+ - 0.00747681F,
+ - 0.0156860F,
+ - 0.0193481F,
+ - 0.0183716F,
+ - 0.0137634F,
+ - 0.00704956F,
+ 0.000000F,
+ 0.00582886F,
+ 0.00939941F,
+ 0.0103760F,
+ 0.00903320F,
+ 0.00604248F,
+ 0.00238037F,
+ - 0.00109863F,
+ - 0.00366211F,
+ - 0.00497437F,
+ - 0.00503540F,
+ - 0.00402832F,
+ - 0.00241089F,
+ - 0.000579834F,
+ 0.00103760F,
+ 0.00222778F,
+ 0.00277710F,
+ 0.00271606F,
+ 0.00213623F,
+ 0.00115967F,
+ 0.000000F
+};
+
+/* same in fixed-point */
+static const Word32 inter6[61] =
+{
+ 29443,
+ 28346,
+ 25207,
+ 20449,
+ 14701,
+ 8693,
+ 3143,
+ - 1352,
+ - 4402,
+ - 5865,
+ - 5850,
+ - 4673,
+ - 2783,
+ - 672,
+ 1211,
+ 2536,
+ 3130,
+ 2991,
+ 2259,
+ 1170,
+ 0,
+ - 1001,
+ - 1652,
+ - 1868,
+ - 1666,
+ - 1147,
+ - 464,
+ 218,
+ 756,
+ 1060,
+ 1099,
+ 904,
+ 550,
+ 135,
+ - 245,
+ - 514,
+ - 634,
+ - 602,
+ - 451,
+ - 231,
+ 0,
+ 191,
+ 308,
+ 340,
+ 296,
+ 198,
+ 78,
+ - 36,
+ - 120,
+ - 163,
+ - 165,
+ - 132,
+ - 79,
+ - 19,
+ 34,
+ 73,
+ 91,
+ 89,
+ 70,
+ 38,
+ 0
+};
+
+static const Word16 startPos1[2] =
+ {
+ 1,
+ 3
+ };
+
+static const Word16 startPos2[4] =
+ {
+ 0,
+ 1,
+ 2,
+ 4
+ };
+
+static const Word16 startPos[2 * 4 * 2] =
+ {
+ 0,
+ 2,
+ 0,
+ 3,
+ 0,
+ 2,
+ 0,
+ 3,
+ 1,
+ 3,
+ 2,
+ 4,
+ 1,
+ 4,
+ 1,
+ 4
+ };
+
+/* Scalar quantization tables of the pitch gain and the codebook gain. */
+#define NB_QUA_PITCH 16
+
+static const Float32 qua_gain_pitch[NB_QUA_PITCH] =
+{
+0.0F,
+0.20001220703125F,
+0.400146484375F,
+0.5F,
+0.5999755859375F,
+0.70001220703125F,
+0.75F,
+0.79998779296875F,
+0.8499755859375F,
+0.9000244140625F,
+0.95001220703125F,
+1.0F,
+1.04998779296875F,
+1.0999755859375F,
+1.1500244140625F,
+1.20001220703125F
+};
+
+static const Float32 qua_gain_pitch_MR122[NB_QUA_PITCH] =
+{
+0.0F,
+0.199951171875F,
+0.400146484375F,
+0.5F,
+0.599853515625F,
+0.699951171875F,
+0.75F,
+0.7998046875F,
+0.849853515625F,
+0.89990234375F,
+0.949951171875F,
+1.0F,
+1.0498046875F,
+1.099853515625F,
+1.14990234375F,
+1.199951171875F
+};
+
+#define NB_QUA_CODE 32
+static const Float32 gain_factor[NB_QUA_CODE] =
+{
+/* gain factor (g_fac) */
+ 0.0776367F,
+ 0.100586F,
+ 0.130859F,
+ 0.170410F,
+ 0.204590F,
+ 0.235352F,
+ 0.270508F,
+ 0.311035F,
+ 0.357910F,
+ 0.411133F,
+ 0.473145F,
+ 0.543945F,
+ 0.625488F,
+ 0.719238F,
+ 0.827148F,
+ 0.951172F,
+ 1.09424F,
+ 1.25830F,
+ 1.44678F,
+ 1.66406F,
+ 1.91357F,
+ 2.20068F,
+ 2.53076F,
+ 2.91016F,
+ 3.34717F,
+ 3.84912F,
+ 4.42627F,
+ 5.09033F,
+ 6.10840F,
+ 7.94092F,
+ 10.3232F,
+ 13.4204F
+};
+
+
+
+
+
+
+static const Word8 gray[8] =
+ {
+ 0,
+ 1,
+ 3,
+ 2,
+ 6,
+ 4,
+ 5,
+ 7
+ };
+
+/*
+ * grid[0] = 1.0;
+ * grid[61] = -1.0;
+ * for (i = 1; i < 61; i++)
+ * grid[i] = (Float32)cos((6.283185307*i)/(2.0*60));
+ */
+static const Float32 grid[61] =
+{
+ 1.00000F,
+ 0.998630F,
+ 0.994522F,
+ 0.987688F,
+ 0.978148F,
+ 0.965926F,
+ 0.951057F,
+ 0.933580F,
+ 0.913545F,
+ 0.891007F,
+ 0.866025F,
+ 0.838671F,
+ 0.809017F,
+ 0.777146F,
+ 0.743145F,
+ 0.707107F,
+ 0.669131F,
+ 0.629320F,
+ 0.587785F,
+ 0.544639F,
+ 0.500000F,
+ 0.453990F,
+ 0.406737F,
+ 0.358368F,
+ 0.309017F,
+ 0.258819F,
+ 0.207912F,
+ 0.156434F,
+ 0.104528F,
+ 0.0523360F,
+ 4.48966e-011F,
+ - 0.0523360F,
+ - 0.104528F,
+ - 0.156434F,
+ - 0.207912F,
+ - 0.258819F,
+ - 0.309017F,
+ - 0.358368F,
+ - 0.406737F,
+ - 0.453990F,
+ - 0.500000F,
+ - 0.544639F,
+ - 0.587785F,
+ - 0.629320F,
+ - 0.669131F,
+ - 0.707107F,
+ - 0.743145F,
+ - 0.777146F,
+ - 0.809017F,
+ - 0.838671F,
+ - 0.866025F,
+ - 0.891007F,
+ - 0.913545F,
+ - 0.933580F,
+ - 0.951057F,
+ - 0.965926F,
+ - 0.978148F,
+ - 0.987688F,
+ - 0.994522F,
+ - 0.998630F,
+ - 1.00000F
+};
+
+/*
+ * 1/6 resolution interpolation filter (-3 dB at 3600 Hz)
+ * Note: The IS641 (7.4) 1/3 resolution filter is simply a subsampled
+ * version of the 1/6 resolution filter, i.e. it uses
+ * every second coefficient:
+ *
+ * b24[k](1/3) = b24[2*k](1/6), 0 <= k <= 3*L_INTER_SRCH
+ */
+static const Float32 b24[UP_SAMP_MAX*L_INTER_SRCH+1] =
+{
+ 0.900848F,
+ 0.864136F,
+ 0.760071F,
+ 0.605408F,
+ 0.424072F,
+ 0.242462F,
+ 0.0840759F,
+ - 0.0343933F,
+ - 0.105560F,
+ - 0.131348F,
+ - 0.121124F,
+ - 0.0884705F,
+ - 0.0476379F,
+ - 0.0102539F,
+ 0.0162964F,
+ 0.0296021F,
+ 0.0312195F,
+ 0.0251160F,
+ 0.0157471F,
+ 0.00671387F,
+ 0.000000F,
+ - 0.00399780F,
+ - 0.00592041F,
+ - 0.00656128F,
+ 0.000000F
+};
+
+/*
+ * Exponential Window coefficients used to weight the autocorrelation
+ * coefficients for 60 Hz bandwidth expansion of high pitched voice
+ * before Levinson-Durbin recursion to compute the LPC coefficients.
+ *
+ * lagwindow[i] = exp( -0.5*(2*pi*F0*(i+1)/Fs)^2 ); i = 0,...,9
+ * F0 = 60 Hz, Fs = 8000 Hz
+ */
+static Float32 lag_wind[M] =
+{
+ 0.99889028F,
+ 0.99556851F,
+ 0.99005681F,
+ 0.98239160F,
+ 0.97262347F,
+ 0.96081644F,
+ 0.94704735F,
+ 0.93140495F,
+ 0.91398895F,
+ 0.89490914F
+};
+
+/* initialization table for lsp history in DTX */
+static const Float32 lsp_init_data[M] =
+ {
+ 0.9595F,
+ 0.8413F,
+ 0.6549F,
+ 0.4154F,
+ 0.1423F,
+ - 0.1423F,
+ - 0.4154F,
+ - 0.6549F,
+ - 0.8413F,
+ - 0.9595F
+ };
+
+#define PAST_RQ_INIT_SIZE 8
+
+/* initalization table for MA predictor in dtx mode */
+static const Float32 past_rq_init[80] =
+{
+-62.9883F, -77.6367F, -107.178F, -154.785F, -160.156F, -188.721F, -173.584F, -122.559F,
+-65.4297F, -47.1191F, -0.488281F, 30.5176F, 29.7852F, -9.52148F, -2.19727F, 25.6348F,
+31.4941F, 69.0918F, 90.8203F, 140.381F, -67.627F, -79.1016F, -48.0957F, -118.896F,
+-108.643F, -88.3789F, -71.2891F, -6.5918F, 43.2129F, 132.568F, 83.4961F, 126.221F,
+125.977F, 31.7383F, 6.5918F, -25.3906F, -29.2969F, -34.1797F, -18.0664F, -13.6719F,
+-137.695F, -230.225F, -371.094F, -235.596F, -198.73F, -128.418F, -78.6133F, -0.488281F,
+38.8184F, 160.4F, -76.1719F, -69.3359F, -94.2383F, -145.752F, -120.361F, -128.418F,
+-102.051F, -55.9082F, 25.6348F, 109.619F, -135.986F, -212.402F, -262.451F, -224.365F,
+-231.934F, -183.594F, -173.096F, -77.1484F, 15.1367F, 118.652F, -76.6602F, -46.6309F,
+-49.5605F, -80.5664F, -39.0625F, -25.1465F, -12.4512F, 31.9824F, 82.5195F, 125.732F
+};
+
+/* LSF means ->normalize frequency domain */
+
+static const Float32 mean_lsf_3[10] =
+{
+ 377.441F,
+ 554.688F,
+ 922.363F,
+ 1339.84F,
+ 1702.15F,
+ 2046.39F,
+ 2452.88F,
+ 2741.46F,
+ 3116.70F,
+ 3348.14F,
+};
+
+static const Float32 mean_lsf_5[10] =
+{
+ 337.891F,
+ 507.080F,
+ 834.961F,
+ 1247.07F,
+ 1646.00F,
+ 1982.91F,
+ 2407.96F,
+ 2708.01F,
+ 3104.00F,
+ 3344.97F,
+};
+
+/* LSF prediction factors (not in MR122) */
+static const Float32 pred_fac[10] =
+{
+ 0.291626F,
+ 0.328644F,
+ 0.383636F,
+ 0.405640F,
+ 0.438873F,
+ 0.355560F,
+ 0.323120F,
+ 0.298065F,
+ 0.262238F,
+ 0.197876F
+};
+
+/* codebooks from IS641 */
+#define DICO1_SIZE_3 256
+#define DICO2_SIZE_3 512
+#define DICO3_SIZE_3 512
+static const Float32 dico1_lsf_3[] =
+{
+ 1.46484F,
+ 20.0195F,
+ -31.9824F,
+ 37.5977F,
+ -13.6719F,
+ -179.443F,
+ 44.6777F,
+ -15.8691F,
+ -64.6973F,
+ 2.19727F,
+ -51.2695F,
+ -88.1348F,
+ 27.5879F,
+ 175.293F,
+ 443.604F,
+ 246.582F,
+ 296.387F,
+ 384.033F,
+ 209.229F,
+ 325.439F,
+ 555.664F,
+ 201.904F,
+ 382.813F,
+ 471.924F,
+ 175.049F,
+ 485.596F,
+ 538.574F,
+ 204.590F,
+ 286.133F,
+ 445.068F,
+ 176.025F,
+ 244.141F,
+ 525.879F,
+ 69.8242F,
+ 116.211F,
+ 368.408F,
+ -60.3027F,
+ -129.639F,
+ 56.1523F,
+ 35.8887F,
+ -20.0195F,
+ 138.916F,
+ 6.34766F,
+ -43.2129F,
+ -230.469F,
+ -6.59180F,
+ -66.6504F,
+ 168.945F,
+ -40.0391F,
+ -64.4531F,
+ -44.6777F,
+ 54.6875F,
+ 192.871F,
+ 253.662F,
+ 219.482F,
+ 230.957F,
+ 146.729F,
+ 118.408F,
+ 188.232F,
+ 280.762F,
+ 127.930F,
+ 165.283F,
+ 220.459F,
+ -34.1797F,
+ 91.5527F,
+ 189.941F,
+ 100.098F,
+ 165.039F,
+ 104.736F,
+ 73.4863F,
+ 129.395F,
+ 246.338F,
+ 175.537F,
+ 157.715F,
+ 9.27734F,
+ 55.1758F,
+ 89.5996F,
+ 9.76563F,
+ 35.4004F,
+ -10.9863F,
+ -123.291F,
+ 70.8008F,
+ 29.5410F,
+ -29.5410F,
+ 73.7305F,
+ 31.0059F,
+ 40.5273F,
+ -30.2734F,
+ -93.5059F,
+ -233.398F,
+ -87.4023F,
+ -111.084F,
+ -238.525F,
+ 174.561F,
+ 214.355F,
+ 218.262F,
+ 238.770F,
+ 225.342F,
+ 51.5137F,
+ 116.455F,
+ 66.4063F,
+ 15.6250F,
+ 45.8984F,
+ -19.0430F,
+ 4.15039F,
+ -34.9121F,
+ -15.8691F,
+ 9.27734F,
+ 156.982F,
+ 143.066F,
+ 151.611F,
+ -32.7148F,
+ -104.004F,
+ -158.936F,
+ 84.7168F,
+ 133.057F,
+ 688.477F,
+ 290.039F,
+ 665.527F,
+ 596.191F,
+ 34.6680F,
+ -19.5313F,
+ 423.584F,
+ 69.0918F,
+ 31.7383F,
+ 112.549F,
+ -63.9648F,
+ -97.4121F,
+ -279.541F,
+ -100.342F,
+ 37.8418F,
+ 104.980F,
+ 80.3223F,
+ 91.5527F,
+ 190.186F,
+ 12.9395F,
+ -55.1758F,
+ -33.9355F,
+ -31.4941F,
+ -57.6172F,
+ 410.645F,
+ 69.5801F,
+ 181.641F,
+ 323.975F,
+ 180.176F,
+ 170.166F,
+ 406.250F,
+ 76.1719F,
+ 99.8535F,
+ 64.9414F,
+ 79.3457F,
+ 175.781F,
+ 32.9590F,
+ 0.244141F,
+ 53.9551F,
+ 110.596F,
+ 1.95313F,
+ 49.5605F,
+ 35.4004F,
+ 72.9980F,
+ 156.250F,
+ 185.547F,
+ 7.08008F,
+ 114.258F,
+ 155.762F,
+ 25.1465F,
+ 104.736F,
+ 92.5293F,
+ 102.539F,
+ 232.910F,
+ 227.539F,
+ 323.730F,
+ 295.410F,
+ 307.129F,
+ 171.875F,
+ 247.070F,
+ 281.250F,
+ -40.5273F,
+ -108.398F,
+ -64.9414F,
+ -77.1484F,
+ -31.7383F,
+ -91.7969F,
+ 46.6309F,
+ 281.006F,
+ 464.844F,
+ -58.5938F,
+ -132.568F,
+ -307.617F,
+ -27.3438F,
+ 65.4297F,
+ 294.678F,
+ 17.0898F,
+ 259.277F,
+ 386.475F,
+ 67.8711F,
+ 332.031F,
+ 384.277F,
+ -62.9883F,
+ -66.4063F,
+ -187.500F,
+ 4.63867F,
+ 137.451F,
+ 546.875F,
+ -0.732422F,
+ -64.6973F,
+ 32.9590F,
+ -72.0215F,
+ -144.287F,
+ -94.7266F,
+ 34.1797F,
+ 86.4258F,
+ -50.2930F,
+ -63.4766F,
+ -123.047F,
+ -194.092F,
+ -105.713F,
+ -175.293F,
+ -322.021F,
+ 26.6113F,
+ 80.8105F,
+ 234.863F,
+ -104.736F,
+ -21.2402F,
+ 159.180F,
+ -72.2656F,
+ 104.004F,
+ 248.779F,
+ -58.3496F,
+ 189.209F,
+ 207.764F,
+ 119.385F,
+ 325.684F,
+ 261.963F,
+ -81.5430F,
+ -81.0547F,
+ 6.10352F,
+ 132.568F,
+ 294.434F,
+ 441.162F,
+ 79.5898F,
+ 14.8926F,
+ 177.490F,
+ 141.113F,
+ 207.275F,
+ 343.018F,
+ -50.7813F,
+ -67.6270F,
+ 80.3223F,
+ -37.1094F,
+ 15.6250F,
+ 163.330F,
+ -105.957F,
+ -165.527F,
+ -177.490F,
+ -110.840F,
+ -17.3340F,
+ 61.2793F,
+ 147.705F,
+ 117.188F,
+ 62.0117F,
+ -117.676F,
+ 2.68555F,
+ 243.164F,
+ -70.5566F,
+ 96.4355F,
+ 118.652F,
+ 176.270F,
+ 256.104F,
+ 351.563F,
+ -7.32422F,
+ -77.1484F,
+ -191.895F,
+ -25.8789F,
+ -28.0762F,
+ -151.123F,
+ 210.205F,
+ 359.863F,
+ 344.727F,
+ 257.568F,
+ 333.496F,
+ 289.063F,
+ 198.242F,
+ 302.002F,
+ 225.830F,
+ 10.2539F,
+ -61.2793F,
+ -140.625F,
+ 83.4961F,
+ 34.4238F,
+ -110.840F,
+ -41.0156F,
+ -19.5313F,
+ 331.787F,
+ -83.4961F,
+ -160.156F,
+ -430.420F,
+ 24.4141F,
+ 200.439F,
+ 177.002F,
+ 241.699F,
+ 182.373F,
+ 195.313F,
+ 81.0547F,
+ 107.422F,
+ 138.672F,
+ 161.865F,
+ 92.5293F,
+ 208.008F,
+ 27.3438F,
+ 40.2832F,
+ -90.0879F,
+ 145.752F,
+ 222.168F,
+ 68.8477F,
+ -1.95313F,
+ 203.613F,
+ 312.744F,
+ -85.9375F,
+ 139.648F,
+ 169.678F,
+ 112.793F,
+ 548.340F,
+ 440.918F,
+ 84.2285F,
+ 46.3867F,
+ 335.449F,
+ 101.563F,
+ 223.389F,
+ 528.809F,
+ 41.0156F,
+ -20.0195F,
+ 68.3594F,
+ -125.977F,
+ -108.887F,
+ 205.078F,
+ 11.4746F,
+ 130.127F,
+ 10.7422F,
+ -88.3789F,
+ -173.584F,
+ -279.053F,
+ 5.37109F,
+ 47.1191F,
+ 359.375F,
+ -20.7520F,
+ 56.8848F,
+ 442.627F,
+ -15.1367F,
+ 141.357F,
+ 367.188F,
+ 134.277F,
+ 230.469F,
+ 427.002F,
+ 176.514F,
+ 158.691F,
+ 280.273F,
+ 237.305F,
+ 215.820F,
+ 340.576F,
+ -103.760F,
+ 156.982F,
+ 0.000000F,
+ 244.141F,
+ 232.422F,
+ 268.066F,
+ 60.7910F,
+ 353.027F,
+ 164.063F,
+ -81.5430F,
+ -21.2402F,
+ 530.273F,
+ -135.254F,
+ 459.473F,
+ 652.344F,
+ 34.1797F,
+ 445.801F,
+ 452.393F,
+ 224.609F,
+ 427.002F,
+ 632.324F,
+ 262.695F,
+ 471.924F,
+ 497.559F,
+ -33.4473F,
+ -108.154F,
+ -379.639F,
+ 309.814F,
+ 286.621F,
+ 114.258F,
+ -120.361F,
+ -29.7852F,
+ 371.338F,
+ -110.107F,
+ 252.197F,
+ 296.387F,
+ 117.676F,
+ 413.818F,
+ 272.949F,
+ 198.975F,
+ 158.447F,
+ 93.7500F,
+ -108.887F,
+ -168.945F,
+ 26.1230F,
+ -77.8809F,
+ -147.705F,
+ -28.8086F,
+ -50.5371F,
+ -123.291F,
+ 128.174F,
+ -114.258F,
+ -2.92969F,
+ 667.969F,
+ 18.3105F,
+ 472.168F,
+ 318.604F,
+ 214.844F,
+ 575.684F,
+ 553.467F,
+ 313.721F,
+ 384.521F,
+ 489.258F,
+ -11.7188F,
+ -74.2188F,
+ -289.551F,
+ -106.201F,
+ -112.549F,
+ -61.2793F,
+ -89.3555F,
+ -98.6328F,
+ -133.545F,
+ -70.5566F,
+ -147.705F,
+ -145.752F,
+ -131.348F,
+ -197.754F,
+ -40.2832F,
+ -29.2969F,
+ 0.732422F,
+ 86.9141F,
+ 156.006F,
+ 302.979F,
+ 366.699F,
+ 23.4375F,
+ 43.2129F,
+ 183.105F,
+ -106.201F,
+ -142.822F,
+ -286.621F,
+ -86.9141F,
+ 26.6113F,
+ -19.2871F,
+ -118.408F,
+ 70.3125F,
+ 489.502F,
+ 2.19727F,
+ 272.461F,
+ 178.467F,
+ 214.844F,
+ 520.996F,
+ 230.957F,
+ -64.6973F,
+ 386.963F,
+ 260.010F,
+ 282.471F,
+ 295.410F,
+ 205.811F,
+ -121.582F,
+ -163.086F,
+ 105.225F,
+ 91.3086F,
+ 78.3691F,
+ -55.9082F,
+ 351.563F,
+ 512.939F,
+ 337.158F,
+ 109.619F,
+ 112.549F,
+ 281.982F,
+ -25.6348F,
+ 9.52148F,
+ -93.7500F,
+ -64.2090F,
+ 89.5996F,
+ 44.4336F,
+ -90.5762F,
+ -161.133F,
+ 188.721F,
+ -45.8984F,
+ 281.006F,
+ 237.061F,
+ 325.439F,
+ 398.438F,
+ 350.342F,
+ 188.965F,
+ 309.326F,
+ 298.096F,
+ -117.676F,
+ -203.125F,
+ -363.525F,
+ -57.8613F,
+ -51.2695F,
+ 209.961F,
+ 217.285F,
+ 394.287F,
+ 259.766F,
+ 115.234F,
+ 259.277F,
+ 291.016F,
+ 45.1660F,
+ 262.939F,
+ 241.455F,
+ -138.672F,
+ -242.188F,
+ -416.016F,
+ -109.619F,
+ -220.215F,
+ -498.779F,
+ -34.6680F,
+ -92.0410F,
+ -111.816F,
+ -51.2695F,
+ -135.254F,
+ -251.221F,
+ -2.68555F,
+ 276.611F,
+ 552.979F,
+ -80.3223F,
+ -164.795F,
+ -218.018F,
+ -61.0352F,
+ 160.400F,
+ 289.795F,
+ 126.709F,
+ 368.652F,
+ 434.326F,
+ 126.953F,
+ 131.592F,
+ 342.529F,
+ 128.662F,
+ 346.924F,
+ 317.871F,
+ -137.451F,
+ -212.646F,
+ -304.688F,
+ -35.8887F,
+ -113.037F,
+ 214.600F,
+ -18.5547F,
+ 569.824F,
+ 693.359F,
+ 137.451F,
+ 628.174F,
+ 582.275F,
+ 154.297F,
+ 470.215F,
+ 712.891F,
+ 175.537F,
+ 493.896F,
+ 449.219F,
+ -133.057F,
+ -176.514F,
+ 270.508F,
+ 31.4941F,
+ -30.5176F,
+ 215.820F,
+ 345.947F,
+ 398.438F,
+ 225.830F,
+ -22.9492F,
+ 382.324F,
+ 427.490F,
+ -83.2520F,
+ 374.268F,
+ 378.662F,
+ 144.287F,
+ 96.4355F,
+ -66.8945F,
+ -18.5547F,
+ 239.502F,
+ 691.162F,
+ 37.3535F,
+ 728.760F,
+ 450.195F,
+ 251.953F,
+ 626.221F,
+ 671.143F,
+ 368.164F,
+ 691.406F,
+ 458.740F,
+ 193.115F,
+ 292.725F,
+ 131.348F,
+ -46.3867F,
+ -110.596F,
+ 363.525F,
+ -67.8711F,
+ -133.789F,
+ 282.715F,
+ -59.8145F,
+ 473.877F,
+ 499.023F,
+ 250.000F,
+ 380.859F,
+ 402.832F,
+ 125.000F,
+ 61.7676F,
+ 113.770F,
+ -15.1367F,
+ -78.8574F,
+ 281.006F,
+ -115.479F,
+ -91.7969F,
+ 123.779F,
+ -105.713F,
+ 336.914F,
+ 527.832F,
+ 219.482F,
+ 474.365F,
+ 352.783F,
+ 32.7148F,
+ 171.875F,
+ 107.422F,
+ 112.305F,
+ 128.174F,
+ -6.83594F,
+ -109.863F,
+ 68.1152F,
+ 326.660F,
+ 0.000000F,
+ 237.061F,
+ 61.5234F,
+ -108.643F,
+ -153.076F,
+ -241.943F,
+ -84.9609F,
+ -146.973F,
+ -347.656F,
+ 97.1680F,
+ 173.828F,
+ 404.297F,
+ -26.1230F,
+ 76.6602F,
+ -43.4570F,
+ 22.7051F,
+ 543.457F,
+ 546.387F,
+ 126.465F,
+ 207.275F,
+ 160.156F,
+ -112.793F,
+ -173.584F,
+ -109.131F,
+ 42.4805F,
+ -8.30078F,
+ 290.771F,
+ -29.0527F,
+ 10.2539F,
+ 245.361F,
+ -90.8203F,
+ 66.8945F,
+ 185.059F,
+ 252.930F,
+ 574.219F,
+ 448.730F,
+ 164.795F,
+ 420.898F,
+ 365.723F,
+ 104.980F,
+ 313.965F,
+ 520.752F,
+ -31.4941F,
+ -107.178F,
+ 0.000000F,
+ -91.0645F,
+ 195.313F,
+ 523.438F,
+ 1.46484F,
+ 387.451F,
+ 604.980F,
+ 116.699F,
+ 145.508F,
+ 519.531F,
+ -104.492F,
+ -179.688F,
+ 367.432F,
+ 93.9941F,
+ 43.4570F,
+ 239.258F,
+ 33.9355F,
+ 109.619F,
+ 299.072F,
+ -128.418F,
+ -205.566F,
+ -239.746F,
+ 35.4004F,
+ 379.395F,
+ 303.223F,
+ 152.100F,
+ 353.516F,
+ 160.156F,
+ 85.2051F,
+ 248.047F,
+ 361.816F,
+ 7.56836F,
+ -68.3594F,
+ 101.318F,
+ -77.1484F,
+ 176.758F,
+ 400.635F,
+ 87.8906F,
+ 258.301F,
+ 135.742F,
+ -106.445F,
+ -87.4023F,
+ 293.213F,
+ -86.6699F,
+ 274.170F,
+ 473.389F,
+ 97.9004F,
+ 386.719F,
+ 548.828F,
+ -128.662F,
+ -247.070F,
+ 86.6699F,
+ 56.8848F,
+ 58.1055F,
+ 545.166F,
+ -134.277F,
+ -218.994F,
+ -156.006F,
+ -89.1113F,
+ -122.314F,
+ 477.783F,
+ 94.9707F,
+ 454.102F,
+ 395.752F,
+ 39.5508F,
+ 276.367F,
+ 308.594F,
+ -57.8613F,
+ 286.621F,
+ 339.355F,
+ -156.250F,
+ -100.342F,
+ 28.3203F,
+ -55.6641F,
+ 413.574F,
+ 561.035F,
+ 400.146F,
+ 533.691F,
+ 553.467F,
+ 137.207F,
+ 310.791F,
+ 648.926F,
+ 78.8574F,
+ 82.5195F,
+ 433.105F,
+ 141.113F,
+ 270.264F,
+ 208.008F,
+ 5.37109F,
+ 145.020F,
+ 228.027F,
+ -34.9121F,
+ 175.293F,
+ 108.887F
+
+};
+static const Float32 dico2_lsf_3[] =
+{
+ 12.2070F,
+ 17.3340F,
+ -2.19727F,
+ -82.5195F,
+ -170.410F,
+ -343.506F,
+ 24.9023F,
+ -33.6914F,
+ -200.195F,
+ -75.6836F,
+ -114.502F,
+ -280.029F,
+ 101.074F,
+ 16.3574F,
+ -65.1855F,
+ 258.789F,
+ 198.730F,
+ 351.807F,
+ 377.930F,
+ 332.031F,
+ 310.547F,
+ 428.223F,
+ 462.646F,
+ 405.518F,
+ 492.920F,
+ 520.752F,
+ 444.336F,
+ 441.406F,
+ 565.918F,
+ 450.439F,
+ 157.227F,
+ -22.7051F,
+ 110.840F,
+ 209.473F,
+ 80.3223F,
+ -33.2031F,
+ 119.385F,
+ -62.9883F,
+ -31.2500F,
+ -48.3398F,
+ -181.885F,
+ -10.0098F,
+ -12.6953F,
+ -64.6973F,
+ -240.479F,
+ 84.4727F,
+ 33.4473F,
+ 116.943F,
+ -425.049F,
+ -182.617F,
+ -166.992F,
+ -283.936F,
+ -421.143F,
+ -89.5996F,
+ -218.506F,
+ -279.541F,
+ -191.406F,
+ -119.141F,
+ -230.957F,
+ -236.328F,
+ -20.7520F,
+ -95.2148F,
+ -177.002F,
+ 52.4902F,
+ -83.0078F,
+ -41.7480F,
+ 249.023F,
+ 223.633F,
+ 480.713F,
+ 137.695F,
+ 43.7012F,
+ 182.129F,
+ 161.621F,
+ 238.525F,
+ 423.340F,
+ 216.553F,
+ 151.855F,
+ 223.145F,
+ 229.248F,
+ 208.984F,
+ 284.424F,
+ 75.4395F,
+ 167.969F,
+ 196.045F,
+ 223.877F,
+ 39.3066F,
+ 139.160F,
+ 28.8086F,
+ -4.88281F,
+ -69.0918F,
+ -199.219F,
+ -10.2539F,
+ 49.8047F,
+ -299.805F,
+ -79.3457F,
+ -112.793F,
+ -235.107F,
+ -49.3164F,
+ -34.9121F,
+ -241.211F,
+ -118.164F,
+ -88.1348F,
+ -171.387F,
+ -238.770F,
+ -116.455F,
+ -73.7305F,
+ -192.871F,
+ -290.039F,
+ -24.4141F,
+ -191.895F,
+ -265.625F,
+ -257.324F,
+ -231.201F,
+ -411.133F,
+ -49.3164F,
+ -205.811F,
+ -190.918F,
+ -253.662F,
+ -336.426F,
+ -219.971F,
+ -152.344F,
+ -26.8555F,
+ -20.7520F,
+ 86.9141F,
+ 52.0020F,
+ -2.44141F,
+ -120.361F,
+ 88.8672F,
+ 188.965F,
+ 103.760F,
+ 200.684F,
+ 116.943F,
+ -20.2637F,
+ 135.986F,
+ 126.953F,
+ -242.188F,
+ -380.859F,
+ -139.648F,
+ -147.217F,
+ -180.908F,
+ -6.34766F,
+ -122.559F,
+ -155.762F,
+ -220.459F,
+ 51.0254F,
+ 74.7070F,
+ 35.8887F,
+ -77.1484F,
+ -144.775F,
+ -145.508F,
+ -20.7520F,
+ -51.5137F,
+ -54.9316F,
+ -224.121F,
+ -129.150F,
+ 28.5645F,
+ 56.8848F,
+ -107.178F,
+ -180.176F,
+ 268.799F,
+ 183.350F,
+ 154.541F,
+ 355.713F,
+ 418.945F,
+ 368.896F,
+ 430.908F,
+ 355.713F,
+ 222.168F,
+ 273.926F,
+ 282.227F,
+ 207.275F,
+ 330.566F,
+ 211.914F,
+ 114.746F,
+ -212.646F,
+ -280.762F,
+ -438.477F,
+ -212.646F,
+ -210.205F,
+ -242.188F,
+ -28.8086F,
+ 37.8418F,
+ 51.7578F,
+ -256.592F,
+ -207.275F,
+ -147.949F,
+ -272.705F,
+ -451.416F,
+ -671.387F,
+ -248.779F,
+ -348.389F,
+ -456.299F,
+ 90.3320F,
+ -44.9219F,
+ -101.074F,
+ 234.131F,
+ 120.361F,
+ 25.3906F,
+ 233.887F,
+ 253.662F,
+ 132.568F,
+ 37.5977F,
+ 159.424F,
+ 49.0723F,
+ 304.932F,
+ 123.779F,
+ 36.6211F,
+ 161.865F,
+ 122.803F,
+ 56.1523F,
+ 152.100F,
+ 189.697F,
+ 164.795F,
+ 160.889F,
+ 21.4844F,
+ -26.8555F,
+ 205.811F,
+ 59.5703F,
+ 54.6875F,
+ 93.2617F,
+ 132.080F,
+ 73.7305F,
+ 176.758F,
+ 105.713F,
+ 162.598F,
+ 284.668F,
+ 179.199F,
+ 83.2520F,
+ -33.6914F,
+ 4.88281F,
+ -96.9238F,
+ -288.818F,
+ -103.516F,
+ -11.2305F,
+ -78.3691F,
+ -85.9375F,
+ -30.2734F,
+ 325.439F,
+ 249.268F,
+ 263.672F,
+ 63.9648F,
+ 89.3555F,
+ 176.514F,
+ 225.098F,
+ 69.0918F,
+ -134.521F,
+ 7.56836F,
+ -155.273F,
+ -149.170F,
+ -168.213F,
+ -170.166F,
+ -101.318F,
+ -232.422F,
+ -190.186F,
+ -49.0723F,
+ -324.463F,
+ -145.996F,
+ -87.6465F,
+ -232.666F,
+ -313.721F,
+ 40.5273F,
+ 120.361F,
+ 74.4629F,
+ 53.9551F,
+ 206.543F,
+ 171.631F,
+ 148.926F,
+ 205.078F,
+ 228.516F,
+ 188.965F,
+ -176.514F,
+ -323.242F,
+ -307.861F,
+ -87.1582F,
+ -250.244F,
+ -338.867F,
+ -267.578F,
+ -335.938F,
+ -89.1113F,
+ -345.703F,
+ -459.229F,
+ -148.438F,
+ -438.965F,
+ -421.631F,
+ -164.551F,
+ -133.057F,
+ -286.377F,
+ -171.631F,
+ 165.527F,
+ 191.895F,
+ 36.1328F,
+ -30.0293F,
+ 169.922F,
+ 314.453F,
+ 157.227F,
+ 85.4492F,
+ -2.44141F,
+ 101.074F,
+ 149.902F,
+ 3.66211F,
+ 33.4473F,
+ 83.9844F,
+ -51.5137F,
+ -198.730F,
+ -369.141F,
+ -199.951F,
+ -95.4590F,
+ -227.051F,
+ -143.555F,
+ 11.4746F,
+ -144.287F,
+ -219.238F,
+ -221.924F,
+ -267.822F,
+ -39.7949F,
+ -310.547F,
+ -284.912F,
+ -38.3301F,
+ -357.422F,
+ -372.314F,
+ -94.9707F,
+ -311.035F,
+ -290.039F,
+ -152.344F,
+ 163.818F,
+ 52.0020F,
+ 110.840F,
+ 30.2734F,
+ -66.8945F,
+ -128.174F,
+ -177.979F,
+ -121.094F,
+ -37.1094F,
+ -328.125F,
+ 29.7852F,
+ 32.9590F,
+ -709.229F,
+ -143.799F,
+ -96.1914F,
+ -421.875F,
+ 107.666F,
+ -12.2070F,
+ 360.352F,
+ 220.703F,
+ 192.139F,
+ 77.1484F,
+ 57.6172F,
+ -107.422F,
+ -84.7168F,
+ 52.9785F,
+ 100.830F,
+ -222.412F,
+ -223.877F,
+ 29.5410F,
+ -111.084F,
+ -227.539F,
+ 49.3164F,
+ -22.4609F,
+ -113.525F,
+ -91.5527F,
+ 119.141F,
+ 95.2148F,
+ 115.723F,
+ 213.867F,
+ 177.979F,
+ 77.1484F,
+ -443.115F,
+ -320.313F,
+ -163.330F,
+ 21.2402F,
+ 234.863F,
+ 105.469F,
+ 137.451F,
+ -60.7910F,
+ -258.301F,
+ 61.0352F,
+ 69.5801F,
+ 269.775F,
+ 278.564F,
+ 104.248F,
+ 169.922F,
+ -253.418F,
+ -406.250F,
+ -386.230F,
+ -231.445F,
+ 84.4727F,
+ 39.0625F,
+ -75.4395F,
+ -66.4063F,
+ -209.473F,
+ 163.574F,
+ 152.344F,
+ 305.176F,
+ -230.469F,
+ -99.6094F,
+ -162.598F,
+ -147.949F,
+ -78.1250F,
+ -93.7500F,
+ -120.117F,
+ 56.1523F,
+ 15.8691F,
+ 81.5430F,
+ -12.2070F,
+ -3.90625F,
+ -3.90625F,
+ -168.457F,
+ -341.064F,
+ 437.256F,
+ 418.945F,
+ 341.553F,
+ 604.980F,
+ 503.662F,
+ 342.773F,
+ 303.955F,
+ 359.131F,
+ 348.145F,
+ -93.2617F,
+ -253.174F,
+ -0.488281F,
+ 42.2363F,
+ -97.1680F,
+ 279.541F,
+ 364.014F,
+ 494.141F,
+ 439.697F,
+ 188.477F,
+ 311.035F,
+ 367.676F,
+ 348.877F,
+ 423.584F,
+ 488.525F,
+ 263.428F,
+ 297.363F,
+ 310.791F,
+ -281.738F,
+ -451.904F,
+ -324.463F,
+ -197.266F,
+ -276.611F,
+ -267.578F,
+ -110.107F,
+ -252.197F,
+ -420.410F,
+ 15.8691F,
+ 141.113F,
+ -20.5078F,
+ -360.352F,
+ -594.238F,
+ -434.082F,
+ -186.768F,
+ -333.496F,
+ -120.605F,
+ -53.2227F,
+ -145.020F,
+ -227.295F,
+ 82.2754F,
+ -57.6172F,
+ 137.207F,
+ 575.439F,
+ 649.902F,
+ 473.145F,
+ 363.525F,
+ 311.523F,
+ 213.379F,
+ 46.1426F,
+ 87.4023F,
+ 91.3086F,
+ -370.850F,
+ -556.885F,
+ -572.754F,
+ -236.084F,
+ -310.303F,
+ -511.475F,
+ -153.320F,
+ -290.039F,
+ -376.465F,
+ 405.518F,
+ 254.639F,
+ 133.301F,
+ 137.939F,
+ 259.033F,
+ 178.711F,
+ -15.6250F,
+ -204.102F,
+ -105.957F,
+ -106.445F,
+ -23.4375F,
+ 49.5605F,
+ 263.184F,
+ 296.875F,
+ 399.414F,
+ 221.436F,
+ 374.512F,
+ 240.723F,
+ 79.5898F,
+ 235.596F,
+ 206.299F,
+ 34.6680F,
+ -20.5078F,
+ 48.0957F,
+ 114.746F,
+ 580.811F,
+ 383.301F,
+ 276.611F,
+ 114.746F,
+ 296.387F,
+ 96.4355F,
+ 335.938F,
+ 292.969F,
+ 274.658F,
+ 254.395F,
+ 84.9609F,
+ -132.568F,
+ -301.270F,
+ -91.7969F,
+ -52.4902F,
+ -44.1895F,
+ 117.432F,
+ -475.342F,
+ -395.752F,
+ -51.2695F,
+ -183.105F,
+ -289.307F,
+ 95.2148F,
+ 7.08008F,
+ -97.4121F,
+ 6.59180F,
+ 200.195F,
+ 301.758F,
+ 184.326F,
+ 169.678F,
+ 239.014F,
+ 99.8535F,
+ -42.4805F,
+ 292.236F,
+ 252.686F,
+ 222.656F,
+ 331.055F,
+ 450.684F,
+ -242.188F,
+ -350.830F,
+ 118.164F,
+ -362.549F,
+ -415.039F,
+ 50.7813F,
+ -100.586F,
+ 293.945F,
+ 349.609F,
+ -66.1621F,
+ 218.750F,
+ 279.297F,
+ -101.563F,
+ 433.838F,
+ 350.098F,
+ -414.063F,
+ -645.508F,
+ -49.8047F,
+ -436.768F,
+ -378.662F,
+ 252.197F,
+ -404.297F,
+ -380.615F,
+ 318.115F,
+ -305.908F,
+ -387.939F,
+ 263.916F,
+ -163.330F,
+ -267.334F,
+ -16.1133F,
+ -166.504F,
+ 78.1250F,
+ -84.2285F,
+ 160.889F,
+ 74.4629F,
+ 260.986F,
+ -315.430F,
+ -196.289F,
+ -4.63867F,
+ -399.170F,
+ -315.186F,
+ 7.08008F,
+ -410.889F,
+ -121.338F,
+ 17.3340F,
+ -70.0684F,
+ -1.70898F,
+ -24.4141F,
+ -120.605F,
+ -234.863F,
+ -57.8613F,
+ 208.008F,
+ 459.229F,
+ 424.805F,
+ -297.119F,
+ -338.623F,
+ 55.4199F,
+ -161.133F,
+ 73.7305F,
+ 91.0645F,
+ 23.4375F,
+ 265.381F,
+ 306.885F,
+ -262.207F,
+ -407.471F,
+ 39.0625F,
+ 118.408F,
+ 506.836F,
+ 438.965F,
+ -228.027F,
+ -53.7109F,
+ 134.766F,
+ -145.508F,
+ -149.414F,
+ 57.8613F,
+ 82.0313F,
+ 419.922F,
+ 214.600F,
+ 156.982F,
+ 153.564F,
+ 105.957F,
+ 309.326F,
+ 127.441F,
+ 398.682F,
+ 3.66211F,
+ 59.5703F,
+ -107.666F,
+ 360.107F,
+ 175.049F,
+ 44.9219F,
+ 444.092F,
+ 388.184F,
+ 417.236F,
+ 241.211F,
+ 63.7207F,
+ 228.760F,
+ 510.986F,
+ 572.510F,
+ 371.094F,
+ 522.217F,
+ 453.613F,
+ 392.090F,
+ -140.869F,
+ -141.357F,
+ -293.701F,
+ -233.398F,
+ 32.9590F,
+ -119.141F,
+ -113.281F,
+ 12.4512F,
+ -82.5195F,
+ -153.564F,
+ -84.9609F,
+ -176.514F,
+ 279.785F,
+ 506.104F,
+ 352.051F,
+ 535.156F,
+ 357.910F,
+ 222.412F,
+ -352.539F,
+ -383.789F,
+ -556.152F,
+ 341.797F,
+ 173.340F,
+ 316.650F,
+ 325.928F,
+ 154.541F,
+ 226.563F,
+ 350.098F,
+ 535.645F,
+ 633.301F,
+ 591.309F,
+ 538.086F,
+ 459.229F,
+ 239.746F,
+ 547.363F,
+ 452.637F,
+ 92.7734F,
+ 193.359F,
+ 279.541F,
+ -15.3809F,
+ -131.592F,
+ 101.074F,
+ -61.5234F,
+ -235.352F,
+ -76.6602F,
+ -307.861F,
+ -166.748F,
+ -190.430F,
+ -202.881F,
+ -128.418F,
+ -245.361F,
+ -406.738F,
+ -277.100F,
+ -103.516F,
+ -393.311F,
+ -110.352F,
+ -72.9980F,
+ 309.570F,
+ 255.859F,
+ 156.738F,
+ 280.029F,
+ 208.252F,
+ 208.984F,
+ -164.795F,
+ -82.0313F,
+ 33.9355F,
+ 553.711F,
+ 327.881F,
+ 346.191F,
+ 7.08008F,
+ 187.500F,
+ 194.580F,
+ -298.828F,
+ 103.271F,
+ 137.695F,
+ -321.777F,
+ -264.160F,
+ 59.8145F,
+ -317.871F,
+ -198.242F,
+ 139.893F,
+ -316.895F,
+ -394.775F,
+ 157.715F,
+ -236.328F,
+ 203.613F,
+ 176.514F,
+ 242.432F,
+ 403.320F,
+ 494.873F,
+ -46.6309F,
+ -199.463F,
+ 105.469F,
+ 161.621F,
+ 14.6484F,
+ 48.3398F,
+ 152.832F,
+ 243.408F,
+ 324.707F,
+ 402.344F,
+ 479.248F,
+ 314.697F,
+ -389.893F,
+ -22.7051F,
+ -10.9863F,
+ -265.625F,
+ 9.03320F,
+ -20.5078F,
+ 403.564F,
+ 636.475F,
+ 570.557F,
+ 260.010F,
+ 498.047F,
+ 580.322F,
+ 278.076F,
+ 567.871F,
+ 517.090F,
+ 209.717F,
+ 87.1582F,
+ 368.652F,
+ 162.109F,
+ 299.561F,
+ 268.311F,
+ 116.943F,
+ 332.031F,
+ 222.656F,
+ 463.135F,
+ 428.223F,
+ 492.920F,
+ 285.156F,
+ 466.064F,
+ 435.547F,
+ 97.4121F,
+ 8.30078F,
+ 62.5000F,
+ -144.775F,
+ -74.2188F,
+ -257.080F,
+ 133.545F,
+ 413.574F,
+ 343.506F,
+ 157.959F,
+ -24.1699F,
+ -83.2520F,
+ 364.258F,
+ 402.100F,
+ 290.527F,
+ 9.27734F,
+ -157.227F,
+ -51.7578F,
+ 96.4355F,
+ 206.543F,
+ 54.1992F,
+ -171.875F,
+ -186.768F,
+ -174.805F,
+ -176.758F,
+ -479.492F,
+ -684.570F,
+ -36.6211F,
+ 71.0449F,
+ -20.0195F,
+ 301.025F,
+ 356.201F,
+ 245.850F,
+ -34.1797F,
+ -37.8418F,
+ 37.3535F,
+ 107.178F,
+ 72.5098F,
+ 382.813F,
+ -373.291F,
+ -100.098F,
+ -155.273F,
+ 375.000F,
+ 111.084F,
+ -57.8613F,
+ -324.219F,
+ -33.9355F,
+ -63.4766F,
+ 129.639F,
+ 135.254F,
+ 211.914F,
+ 65.6738F,
+ 308.594F,
+ 147.949F,
+ -56.8848F,
+ 215.576F,
+ 113.037F,
+ 181.152F,
+ 146.484F,
+ -29.2969F,
+ -17.8223F,
+ 102.783F,
+ 51.7578F,
+ -107.178F,
+ -14.1602F,
+ 196.289F,
+ -313.965F,
+ -302.979F,
+ 177.734F,
+ 71.7773F,
+ -119.629F,
+ 12.2070F,
+ -144.287F,
+ -220.947F,
+ -306.152F,
+ 10.2539F,
+ -167.725F,
+ 35.8887F,
+ -6.10352F,
+ 66.6504F,
+ 145.508F,
+ -75.9277F,
+ 296.143F,
+ 146.729F,
+ -184.082F,
+ 207.275F,
+ 142.578F,
+ 104.736F,
+ 148.193F,
+ 143.311F,
+ -146.973F,
+ -40.5273F,
+ 112.549F,
+ -194.336F,
+ -200.928F,
+ 189.697F,
+ 336.914F,
+ 222.168F,
+ 428.467F,
+ 29.0527F,
+ 345.947F,
+ 237.305F,
+ -53.4668F,
+ -214.844F,
+ -389.648F,
+ -256.104F,
+ -246.582F,
+ 106.934F,
+ -174.072F,
+ -336.670F,
+ 19.0430F,
+ 0.000000F,
+ -109.131F,
+ -287.842F,
+ -277.344F,
+ -322.021F,
+ -384.033F,
+ 548.828F,
+ 431.396F,
+ 319.580F,
+ 230.957F,
+ 386.475F,
+ 349.609F,
+ 280.762F,
+ 117.676F,
+ 106.445F,
+ -114.502F,
+ -270.508F,
+ 150.879F,
+ -109.131F,
+ -235.840F,
+ 265.625F,
+ -305.664F,
+ -369.873F,
+ -27.8320F,
+ -269.531F,
+ -490.234F,
+ -141.357F,
+ 51.2695F,
+ 149.658F,
+ 121.338F,
+ -482.178F,
+ -350.830F,
+ 156.738F,
+ -309.814F,
+ -208.984F,
+ 246.826F,
+ -401.855F,
+ -289.307F,
+ 259.521F,
+ -379.639F,
+ -164.063F,
+ 293.945F,
+ -413.086F,
+ -271.973F,
+ 152.100F,
+ -239.014F,
+ -323.730F,
+ -311.768F,
+ 131.592F,
+ -35.8887F,
+ 218.262F,
+ -330.566F,
+ -218.994F,
+ -105.957F,
+ 216.797F,
+ 115.967F,
+ 104.492F,
+ 37.3535F,
+ -93.7500F,
+ 82.5195F,
+ -364.258F,
+ -124.756F,
+ 87.6465F,
+ -237.793F,
+ -272.217F,
+ -114.746F,
+ 25.6348F,
+ -134.277F,
+ 165.283F,
+ -228.760F,
+ -279.541F,
+ 214.111F,
+ 92.7734F,
+ -63.4766F,
+ 51.2695F,
+ 411.377F,
+ 225.586F,
+ 306.641F,
+ 433.350F,
+ 290.527F,
+ 267.334F,
+ 346.436F,
+ 154.053F,
+ 130.127F,
+ 153.076F,
+ 72.9980F,
+ -84.7168F,
+ -100.342F,
+ -130.371F,
+ 157.959F,
+ -158.691F,
+ 7.08008F,
+ -145.264F,
+ -92.2852F,
+ -333.740F,
+ 381.592F,
+ 342.285F,
+ 273.682F,
+ 357.666F,
+ 265.869F,
+ 344.238F,
+ 158.203F,
+ -511.719F,
+ -266.113F,
+ -1.46484F,
+ 75.9277F,
+ -47.3633F,
+ -212.158F,
+ -156.006F,
+ -202.881F,
+ 101.563F,
+ -283.691F,
+ -298.828F,
+ 329.346F,
+ -304.443F,
+ -229.736F,
+ 442.627F,
+ -535.400F,
+ -485.107F,
+ 110.596F,
+ -151.123F,
+ -333.740F,
+ -233.398F,
+ -392.090F,
+ -481.445F,
+ -367.920F,
+ -286.865F,
+ -258.057F,
+ -269.531F,
+ -92.0410F,
+ 146.729F,
+ 49.0723F,
+ 458.008F,
+ 201.416F,
+ 91.3086F,
+ -104.980F,
+ -322.998F,
+ 7.08008F,
+ -341.064F,
+ -304.932F,
+ -324.951F,
+ -245.850F,
+ -367.188F,
+ 234.375F,
+ -342.041F,
+ -490.479F,
+ 48.0957F,
+ -336.670F,
+ -475.830F,
+ -57.6172F,
+ -262.939F,
+ 30.0293F,
+ 103.027F,
+ 150.146F,
+ 309.814F,
+ 133.301F,
+ -74.7070F,
+ 372.559F,
+ 220.703F,
+ 291.504F,
+ 436.523F,
+ 287.354F,
+ -152.832F,
+ -215.820F,
+ -372.559F,
+ 48.5840F,
+ 187.012F,
+ 367.188F,
+ -260.010F,
+ 210.449F,
+ 48.0957F,
+ -252.441F,
+ -432.861F,
+ -216.553F,
+ -195.313F,
+ 35.4004F,
+ 146.240F,
+ -276.855F,
+ -126.709F,
+ 152.832F,
+ -294.189F,
+ -470.215F,
+ 122.070F,
+ -222.168F,
+ -254.150F,
+ -340.576F,
+ -360.352F,
+ -382.568F,
+ -236.572F,
+ -127.686F,
+ 205.566F,
+ 8.30078F,
+ 437.988F,
+ 157.715F,
+ 210.449F,
+ -294.678F,
+ -460.938F,
+ -244.629F,
+ -19.0430F,
+ -2.19727F,
+ -164.063F,
+ 254.883F,
+ 185.303F,
+ 19.5313F,
+ -146.484F,
+ 278.076F,
+ 248.779F,
+ 13.9160F,
+ 488.281F,
+ 347.168F,
+ -203.369F,
+ 345.215F,
+ 273.682F,
+ -293.457F,
+ 397.949F,
+ 307.617F,
+ -112.549F,
+ 346.680F,
+ 303.711F,
+ 375.244F,
+ 238.037F,
+ 61.7676F,
+ -69.0918F,
+ 79.1016F,
+ -87.6465F,
+ 146.240F,
+ -47.6074F,
+ 25.8789F,
+ 143.555F,
+ 15.1367F,
+ -143.311F,
+ -184.814F,
+ 157.471F,
+ 50.0488F,
+ 12.4512F,
+ 293.213F,
+ 185.059F,
+ -295.166F,
+ 164.307F,
+ -95.2148F,
+ -152.344F,
+ 385.986F,
+ 229.736F,
+ -36.8652F,
+ 249.756F,
+ 179.443F,
+ 688.477F,
+ 317.627F,
+ 168.457F,
+ -73.7305F,
+ 127.930F,
+ -24.1699F,
+ -219.727F,
+ -387.695F,
+ -290.283F,
+ 264.648F,
+ 61.2793F,
+ 58.1055F,
+ 491.699F,
+ 437.500F,
+ 246.582F,
+ 303.955F,
+ 398.682F,
+ 425.049F,
+ -299.561F,
+ -375.977F,
+ -294.922F,
+ -151.611F,
+ 111.328F,
+ -26.6113F,
+ 9.76563F,
+ -15.8691F,
+ 192.383F,
+ -196.533F,
+ -170.654F,
+ -329.590F,
+ -142.334F,
+ 220.703F,
+ 203.125F,
+ -195.557F,
+ 129.883F,
+ 145.020F,
+ 481.445F,
+ 343.750F,
+ 329.834F,
+ -287.354F,
+ -458.984F,
+ -516.113F,
+ -188.721F,
+ 138.672F,
+ 231.445F,
+ -247.803F,
+ 263.428F,
+ 307.617F,
+ -271.240F,
+ 117.676F,
+ -31.7383F,
+ 434.082F,
+ 254.883F,
+ 190.430F,
+ -364.014F,
+ 59.8145F,
+ 222.656F,
+ -77.1484F,
+ -278.564F,
+ -223.877F,
+ -130.859F,
+ -352.051F,
+ -572.754F,
+ -191.650F,
+ -377.441F,
+ -485.352F,
+ -489.014F,
+ 62.7441F,
+ 221.924F,
+ -451.416F,
+ -154.541F,
+ -295.166F,
+ -375.488F,
+ -468.262F,
+ -257.324F,
+ 392.090F,
+ 546.631F,
+ 384.766F,
+ -138.428F,
+ -366.211F,
+ -376.953F,
+ -312.256F,
+ 47.6074F,
+ 334.229F,
+ -199.463F,
+ 71.5332F,
+ 297.607F,
+ -128.174F,
+ 153.809F,
+ 292.236F,
+ -414.551F,
+ -592.041F,
+ -449.219F,
+ -73.9746F,
+ 178.467F,
+ 182.373F,
+ -285.400F,
+ -61.2793F,
+ 65.6738F,
+ -231.934F,
+ -18.3105F,
+ 411.133F,
+ -288.574F,
+ -110.596F,
+ 245.361F,
+ -390.381F,
+ 142.822F,
+ 92.2852F,
+ -506.592F,
+ -139.404F,
+ -104.248F,
+ -129.150F,
+ -282.959F,
+ -285.889F,
+ -69.0918F,
+ -50.0488F,
+ -137.695F,
+ -194.336F,
+ 304.199F,
+ 175.049F,
+ 555.908F,
+ 226.318F,
+ 131.592F,
+ -110.840F,
+ 136.475F,
+ 107.422F,
+ -175.049F,
+ 356.445F,
+ 394.287F,
+ -251.465F,
+ 256.836F,
+ 393.066F,
+ -285.400F,
+ -33.6914F,
+ 206.787F,
+ 55.1758F,
+ 9.52148F,
+ -149.414F,
+ -305.420F,
+ -25.8789F,
+ -177.979F,
+ -158.936F,
+ 236.328F,
+ 317.871F,
+ -174.316F,
+ -155.273F,
+ 421.631F,
+ 86.1816F,
+ 260.986F,
+ 100.098F,
+ -194.824F,
+ -38.0859F,
+ 268.311F,
+ -140.137F,
+ 224.121F,
+ 108.887F,
+ -319.824F,
+ 247.070F,
+ 113.770F,
+ 343.750F,
+ 388.428F,
+ 186.768F,
+ 348.877F,
+ 336.914F,
+ 428.955F,
+ 475.830F,
+ 477.539F,
+ 580.566F,
+ 385.254F,
+ 499.756F,
+ 524.414F,
+ 223.633F,
+ 23.9258F,
+ -1.70898F,
+ 462.158F,
+ 346.191F,
+ 522.705F,
+ 84.9609F,
+ 343.018F,
+ 385.498F,
+ 37.1094F,
+ 276.855F,
+ 439.697F,
+ -65.1855F,
+ 37.5977F,
+ 340.576F,
+ -284.668F,
+ 114.502F,
+ 257.324F,
+ -278.809F,
+ -98.8770F,
+ -261.963F,
+ -327.393F,
+ -552.734F,
+ -385.986F,
+ -88.8672F,
+ 212.158F,
+ 416.504F,
+ -283.691F,
+ 134.033F,
+ 378.418F,
+ -299.072F,
+ -471.680F,
+ -406.738F,
+ -362.549F,
+ -482.666F,
+ -501.709F,
+ -421.631F,
+ -221.191F,
+ -23.9258F,
+ -463.135F,
+ 56.8848F,
+ 364.258F,
+ 217.773F,
+ 26.3672F,
+ -80.8105F,
+ -421.875F,
+ -285.645F,
+ -415.039F,
+ -258.789F,
+ 483.398F,
+ 437.012F,
+ -261.230F,
+ -425.049F,
+ -466.064F,
+ -2.68555F,
+ 375.732F,
+ 321.533F,
+ -390.625F,
+ 22.9492F,
+ 121.338F,
+ 102.783F,
+ 108.154F,
+ -48.0957F,
+ -385.254F,
+ -85.2051F,
+ -242.676F,
+ -146.240F,
+ -131.592F,
+ 278.320F,
+ -235.596F,
+ -346.436F,
+ -31.4941F,
+ -327.393F,
+ 42.7246F,
+ -109.131F,
+ -91.5527F,
+ 320.068F,
+ 501.709F,
+ -90.5762F,
+ -158.691F,
+ -74.9512F,
+ -261.963F,
+ 147.705F,
+ 89.1113F,
+ -502.197F,
+ -27.5879F,
+ 104.980F,
+ 159.180F,
+ 223.145F,
+ 236.084F,
+ -247.070F,
+ -387.207F,
+ -567.139F,
+ 367.432F,
+ 304.688F,
+ 136.475F,
+ 63.9648F,
+ -118.652F,
+ -97.9004F,
+ -421.631F,
+ 327.637F,
+ 377.441F,
+ 12.2070F,
+ 13.6719F,
+ 105.469F,
+ -80.5664F,
+ 29.0527F,
+ -147.461F,
+ -370.361F,
+ -263.672F,
+ -197.754F,
+ 230.957F,
+ 275.146F,
+ 257.568F,
+ -341.797F,
+ -415.771F,
+ -417.969F,
+ -310.059F,
+ -171.875F,
+ -321.533F,
+ 197.021F,
+ 444.580F,
+ 279.053F,
+ 673.828F,
+ 392.090F,
+ 530.029F,
+ 273.438F,
+ 99.8535F,
+ -36.6211F,
+ -35.8887F,
+ 98.6328F,
+ 234.131F,
+ 595.459F,
+ 466.553F,
+ 534.424F,
+ -221.191F,
+ -34.4238F,
+ -211.426F,
+ -220.703F,
+ -34.6680F,
+ -111.816F,
+ -135.986F,
+ -172.852F,
+ -409.912F,
+ -202.637F,
+ -349.365F,
+ -386.475F,
+ -449.707F,
+ -328.613F,
+ -265.137F,
+ -391.602F,
+ -66.4063F,
+ 223.389F,
+ -291.992F,
+ 188.477F,
+ 257.813F,
+ -155.762F,
+ -301.270F,
+ -463.135F,
+ -122.070F,
+ -19.7754F,
+ -200.684F,
+ -314.697F,
+ -393.799F,
+ -179.443F,
+ -28.5645F,
+ 191.650F,
+ 41.0156F,
+ -266.113F,
+ 276.611F,
+ 225.098F,
+ -267.578F,
+ -182.129F,
+ 337.891F,
+ 70.0684F,
+ -133.545F,
+ -259.521F,
+ -335.938F,
+ -537.354F,
+ -293.945F,
+ -531.250F,
+ -383.301F,
+ -428.955F,
+ -368.896F,
+ -547.119F,
+ -188.232F,
+ -424.072F,
+ 268.311F,
+ 202.637F,
+ -387.695F,
+ 176.758F,
+ 303.467F,
+ -376.465F,
+ 169.189F,
+ 196.533F,
+ -412.598F,
+ -58.5938F,
+ 406.494F,
+ -415.039F,
+ -0.976563F,
+ -163.086F,
+ 524.658F,
+ 199.219F,
+ 254.395F,
+ -199.707F,
+ -449.463F,
+ 5.37109F,
+ -186.523F,
+ -123.779F,
+ 109.619F,
+ -281.006F,
+ -150.635F,
+ 70.5566F,
+ -205.811F,
+ -389.648F,
+ -58.5938F,
+ 121.582F,
+ -57.1289F,
+ -160.400F,
+ -183.594F,
+ 117.188F,
+ 409.668F,
+ -77.8809F,
+ -117.432F,
+ 47.1191F,
+ -197.998F,
+ 41.7480F,
+ -29.0527F,
+ -519.531F,
+ -49.3164F,
+ -207.031F,
+ 419.189F,
+ 278.320F,
+ 415.039F
+
+};
+static const Float32 dico3_lsf_3[] =
+{
+ 16.3574F,
+ -4.15039F,
+ 16.1133F,
+ -2.92969F,
+ -412.598F,
+ -141.846F,
+ -25.3906F,
+ -66.4063F,
+ -262.695F,
+ -289.551F,
+ -450.439F,
+ -91.7969F,
+ -278.320F,
+ -226.074F,
+ -102.539F,
+ -14.1602F,
+ -63.2324F,
+ -160.156F,
+ -276.855F,
+ -135.010F,
+ 436.523F,
+ 299.561F,
+ 111.084F,
+ 31.4941F,
+ 112.793F,
+ 107.666F,
+ -58.5938F,
+ -128.906F,
+ 205.078F,
+ 125.488F,
+ 31.7383F,
+ -18.3105F,
+ 271.973F,
+ 152.100F,
+ 37.3535F,
+ 52.7344F,
+ 260.742F,
+ 137.695F,
+ -1.46484F,
+ -67.3828F,
+ 273.193F,
+ 177.490F,
+ 46.3867F,
+ -16.6016F,
+ 171.875F,
+ 74.7070F,
+ 29.0527F,
+ -64.4531F,
+ 80.3223F,
+ 14.8926F,
+ -24.4141F,
+ 38.0859F,
+ 88.8672F,
+ 30.0293F,
+ 44.6777F,
+ -50.7813F,
+ -41.7480F,
+ -30.0293F,
+ 53.7109F,
+ -15.8691F,
+ -74.7070F,
+ -15.1367F,
+ 98.1445F,
+ 4.15039F,
+ -161.133F,
+ -229.004F,
+ -64.9414F,
+ 0.000000F,
+ 93.9941F,
+ 57.3730F,
+ 67.3828F,
+ 69.5801F,
+ 78.1250F,
+ 65.4297F,
+ -82.0313F,
+ -48.8281F,
+ -176.758F,
+ 4.15039F,
+ -20.5078F,
+ 93.0176F,
+ -132.813F,
+ 104.736F,
+ 120.605F,
+ 126.709F,
+ -28.5645F,
+ 70.3125F,
+ 74.2188F,
+ 80.3223F,
+ 156.982F,
+ 38.3301F,
+ 171.143F,
+ 124.023F,
+ 292.969F,
+ 152.588F,
+ 194.336F,
+ 148.438F,
+ 243.652F,
+ 102.783F,
+ 120.117F,
+ 154.297F,
+ 293.945F,
+ 190.430F,
+ 108.887F,
+ 32.2266F,
+ 306.885F,
+ 206.055F,
+ 133.545F,
+ 109.619F,
+ 202.393F,
+ 160.645F,
+ 132.080F,
+ 114.746F,
+ 276.367F,
+ 307.129F,
+ 224.121F,
+ 156.006F,
+ 133.545F,
+ 12.4512F,
+ 103.271F,
+ 68.1152F,
+ 2.19727F,
+ 95.7031F,
+ 20.2637F,
+ 22.9492F,
+ 132.324F,
+ 132.568F,
+ 55.9082F,
+ -35.8887F,
+ -48.3398F,
+ 31.4941F,
+ 47.3633F,
+ -45.1660F,
+ -210.693F,
+ -322.510F,
+ -73.7305F,
+ 7.32422F,
+ -145.752F,
+ -153.564F,
+ -4.63867F,
+ 27.8320F,
+ -219.727F,
+ -263.916F,
+ 113.770F,
+ 86.1816F,
+ -362.061F,
+ -384.033F,
+ 3.66211F,
+ -34.9121F,
+ -416.992F,
+ -502.686F,
+ -183.350F,
+ 47.8516F,
+ -458.008F,
+ -504.639F,
+ -156.738F,
+ -62.9883F,
+ -570.068F,
+ -358.887F,
+ -109.863F,
+ -137.695F,
+ -142.578F,
+ -45.4102F,
+ -212.891F,
+ -101.074F,
+ -440.674F,
+ -241.211F,
+ -274.658F,
+ -319.824F,
+ -177.246F,
+ -275.635F,
+ 6.83594F,
+ 41.2598F,
+ -253.662F,
+ -210.938F,
+ -175.293F,
+ -60.0586F,
+ 118.164F,
+ 8.78906F,
+ -56.8848F,
+ -11.9629F,
+ 64.6973F,
+ 16.3574F,
+ 70.5566F,
+ 114.014F,
+ 43.4570F,
+ 132.568F,
+ 197.754F,
+ 131.836F,
+ 20.5078F,
+ 68.8477F,
+ 164.063F,
+ 171.631F,
+ -238.037F,
+ -189.697F,
+ 31.4941F,
+ 70.0684F,
+ -229.004F,
+ -55.4199F,
+ 233.154F,
+ 145.264F,
+ -394.775F,
+ -70.5566F,
+ 204.102F,
+ 158.447F,
+ -450.928F,
+ -52.4902F,
+ 270.020F,
+ 175.293F,
+ -496.582F,
+ -264.893F,
+ 158.691F,
+ 107.422F,
+ -512.939F,
+ -129.150F,
+ 221.436F,
+ 140.381F,
+ -490.967F,
+ -82.0313F,
+ 163.574F,
+ 49.8047F,
+ -583.252F,
+ -168.945F,
+ 87.8906F,
+ 33.4473F,
+ -526.367F,
+ -538.086F,
+ -2.19727F,
+ 68.3594F,
+ -64.9414F,
+ 29.0527F,
+ 9.52148F,
+ 47.1191F,
+ 19.0430F,
+ -14.4043F,
+ -29.2969F,
+ 55.1758F,
+ -238.037F,
+ -209.473F,
+ -190.674F,
+ -267.334F,
+ -151.123F,
+ -100.830F,
+ -110.107F,
+ -205.566F,
+ -296.875F,
+ -322.510F,
+ -198.486F,
+ -215.576F,
+ -335.938F,
+ -394.287F,
+ -96.1914F,
+ -104.492F,
+ -179.932F,
+ -271.729F,
+ -134.033F,
+ -192.871F,
+ -214.844F,
+ -238.037F,
+ -236.084F,
+ -156.738F,
+ -240.479F,
+ -216.309F,
+ -310.791F,
+ -332.275F,
+ -115.479F,
+ -196.289F,
+ -342.041F,
+ -343.506F,
+ 39.0625F,
+ -64.6973F,
+ -224.365F,
+ -67.1387F,
+ -60.5469F,
+ -61.0352F,
+ -175.293F,
+ -92.7734F,
+ 23.6816F,
+ -25.1465F,
+ -91.5527F,
+ -55.9082F,
+ -101.318F,
+ -47.1191F,
+ -32.9590F,
+ -135.498F,
+ 153.320F,
+ 88.1348F,
+ 29.0527F,
+ 52.7344F,
+ 141.357F,
+ 88.8672F,
+ 95.4590F,
+ 51.0254F,
+ 154.785F,
+ 127.441F,
+ -37.5977F,
+ -36.1328F,
+ 128.418F,
+ 94.9707F,
+ 41.5039F,
+ 8.05664F,
+ 25.6348F,
+ 65.1855F,
+ 15.6250F,
+ 92.7734F,
+ -366.943F,
+ -244.141F,
+ -7.32422F,
+ -90.0879F,
+ -261.230F,
+ 14.1602F,
+ 157.959F,
+ 54.4434F,
+ -371.094F,
+ -71.0449F,
+ 151.611F,
+ 74.9512F,
+ -373.779F,
+ 38.0859F,
+ 186.035F,
+ 98.6328F,
+ -495.361F,
+ 34.4238F,
+ 179.199F,
+ 121.826F,
+ -451.416F,
+ -158.691F,
+ 74.7070F,
+ 125.000F,
+ -45.6543F,
+ -25.3906F,
+ -14.4043F,
+ 106.934F,
+ 32.7148F,
+ -56.1523F,
+ 38.0859F,
+ -45.4102F,
+ -14.8926F,
+ -63.4766F,
+ -3.90625F,
+ 2.44141F,
+ -138.916F,
+ -0.732422F,
+ -102.783F,
+ -72.5098F,
+ -421.143F,
+ -127.197F,
+ -84.4727F,
+ 43.4570F,
+ -332.520F,
+ -14.4043F,
+ -10.7422F,
+ 38.3301F,
+ -523.926F,
+ -112.549F,
+ -114.746F,
+ -85.2051F,
+ -529.785F,
+ -0.244141F,
+ -90.0879F,
+ -29.5410F,
+ -385.498F,
+ -91.0645F,
+ -219.727F,
+ -247.803F,
+ -272.705F,
+ -144.287F,
+ -149.658F,
+ -191.406F,
+ -136.963F,
+ 29.7852F,
+ -18.3105F,
+ -109.619F,
+ -0.976563F,
+ -41.7480F,
+ -30.0293F,
+ -90.8203F,
+ 46.8750F,
+ 41.0156F,
+ -18.5547F,
+ -32.2266F,
+ 61.5234F,
+ -26.1230F,
+ 83.0078F,
+ 51.2695F,
+ 95.7031F,
+ 124.268F,
+ 66.4063F,
+ 44.1895F,
+ -26.6113F,
+ 35.4004F,
+ 53.2227F,
+ 29.0527F,
+ -101.563F,
+ -64.2090F,
+ 118.408F,
+ 64.6973F,
+ -44.1895F,
+ -1.95313F,
+ -69.8242F,
+ 55.1758F,
+ -59.5703F,
+ -53.2227F,
+ 16.8457F,
+ -70.8008F,
+ -38.5742F,
+ 46.6309F,
+ -0.244141F,
+ -15.6250F,
+ -144.531F,
+ -21.9727F,
+ 52.0020F,
+ -23.4375F,
+ 62.2559F,
+ 106.201F,
+ 43.4570F,
+ -19.5313F,
+ -90.0879F,
+ -4.39453F,
+ -8.05664F,
+ -19.5313F,
+ -10.2539F,
+ 101.318F,
+ 34.1797F,
+ -54.1992F,
+ 279.053F,
+ 158.936F,
+ 158.447F,
+ 80.3223F,
+ 187.256F,
+ 135.742F,
+ 60.7910F,
+ 57.3730F,
+ 231.445F,
+ 100.830F,
+ 107.910F,
+ 68.1152F,
+ 34.4238F,
+ 82.7637F,
+ 86.9141F,
+ 135.986F,
+ -114.746F,
+ -41.5039F,
+ 24.1699F,
+ 57.8613F,
+ -138.916F,
+ -195.313F,
+ 85.9375F,
+ 137.939F,
+ 68.8477F,
+ 115.479F,
+ 114.746F,
+ 81.0547F,
+ -48.5840F,
+ -168.457F,
+ -313.477F,
+ -223.877F,
+ -47.1191F,
+ -104.004F,
+ -195.313F,
+ -273.926F,
+ -6.34766F,
+ -90.5762F,
+ -119.629F,
+ -47.1191F,
+ 155.518F,
+ 145.264F,
+ 126.709F,
+ 80.5664F,
+ 99.6094F,
+ -28.0762F,
+ 19.2871F,
+ 2.92969F,
+ 116.455F,
+ 21.2402F,
+ -25.1465F,
+ -91.7969F,
+ -162.598F,
+ -84.7168F,
+ -67.6270F,
+ -71.0449F,
+ -124.512F,
+ -117.432F,
+ 41.2598F,
+ 72.5098F,
+ -202.393F,
+ -180.176F,
+ -50.0488F,
+ -41.7480F,
+ -78.1250F,
+ -131.836F,
+ 80.0781F,
+ 69.0918F,
+ -209.717F,
+ -233.887F,
+ 107.910F,
+ -0.488281F,
+ 135.742F,
+ 167.480F,
+ 31.7383F,
+ 13.6719F,
+ 337.646F,
+ 247.070F,
+ 184.326F,
+ 104.248F,
+ 149.414F,
+ 180.908F,
+ 153.320F,
+ 135.010F,
+ -82.7637F,
+ -194.336F,
+ 32.7148F,
+ 67.6270F,
+ -154.541F,
+ -264.893F,
+ -0.488281F,
+ -60.0586F,
+ -214.844F,
+ -252.686F,
+ -392.334F,
+ -259.766F,
+ -242.676F,
+ -115.723F,
+ -277.832F,
+ -119.141F,
+ -101.074F,
+ -194.092F,
+ 17.8223F,
+ -50.2930F,
+ -1.95313F,
+ -33.9355F,
+ 107.178F,
+ 49.8047F,
+ -42.9688F,
+ -141.113F,
+ 5.61523F,
+ 31.9824F,
+ -65.6738F,
+ -184.814F,
+ -46.6309F,
+ 59.8145F,
+ -26.6113F,
+ -82.5195F,
+ 27.3438F,
+ 77.1484F,
+ 29.2969F,
+ -99.1211F,
+ -28.8086F,
+ 149.170F,
+ -43.9453F,
+ -45.4102F,
+ -157.471F,
+ 28.0762F,
+ -42.2363F,
+ 8.30078F,
+ -126.465F,
+ -119.385F,
+ -36.8652F,
+ 14.8926F,
+ -142.334F,
+ -206.055F,
+ 53.7109F,
+ -33.6914F,
+ -166.260F,
+ -249.023F,
+ 95.4590F,
+ -4.15039F,
+ -145.996F,
+ -78.3691F,
+ 38.3301F,
+ -72.0215F,
+ 31.4941F,
+ 37.8418F,
+ -226.074F,
+ -213.623F,
+ -240.967F,
+ 69.5801F,
+ 58.8379F,
+ -20.2637F,
+ -30.5176F,
+ -30.5176F,
+ 151.367F,
+ 145.752F,
+ 105.469F,
+ 22.4609F,
+ 95.9473F,
+ 19.0430F,
+ 99.8535F,
+ 14.8926F,
+ -95.9473F,
+ -180.420F,
+ -100.830F,
+ -182.617F,
+ 20.2637F,
+ 13.1836F,
+ 88.1348F,
+ 6.59180F,
+ -264.648F,
+ 31.7383F,
+ -82.2754F,
+ -169.434F,
+ -382.080F,
+ 72.5098F,
+ 77.6367F,
+ -4.63867F,
+ -457.275F,
+ 8.78906F,
+ 12.4512F,
+ -77.3926F,
+ -567.139F,
+ -60.0586F,
+ 56.3965F,
+ -20.5078F,
+ -562.988F,
+ -191.162F,
+ 9.76563F,
+ -43.7012F,
+ -545.166F,
+ -227.051F,
+ -115.723F,
+ -112.793F,
+ -184.082F,
+ -20.9961F,
+ -70.3125F,
+ -152.832F,
+ -588.623F,
+ -111.084F,
+ -15.3809F,
+ 41.7480F,
+ -268.311F,
+ -267.090F,
+ -6.34766F,
+ -34.9121F,
+ -291.260F,
+ -111.084F,
+ -99.1211F,
+ -93.0176F,
+ -147.705F,
+ -51.2695F,
+ -23.4375F,
+ -12.4512F,
+ -141.602F,
+ -116.211F,
+ -67.3828F,
+ -3.66211F,
+ -291.748F,
+ -154.785F,
+ -293.701F,
+ -215.088F,
+ -92.2852F,
+ -53.9551F,
+ -163.330F,
+ -232.422F,
+ 145.020F,
+ 43.4570F,
+ -98.3887F,
+ -165.039F,
+ 186.279F,
+ 79.8340F,
+ 146.729F,
+ 70.8008F,
+ 41.9922F,
+ 73.2422F,
+ 49.5605F,
+ 38.3301F,
+ -13.6719F,
+ -82.0313F,
+ 86.9141F,
+ 5.85938F,
+ -55.6641F,
+ -72.2656F,
+ -63.2324F,
+ -7.08008F,
+ -45.4102F,
+ 64.2090F,
+ 101.563F,
+ 3.41797F,
+ -86.1816F,
+ 91.0645F,
+ -2.92969F,
+ -52.7344F,
+ 62.7441F,
+ 23.4375F,
+ 42.4805F,
+ 13.9160F,
+ -372.559F,
+ -150.391F,
+ -232.910F,
+ -121.826F,
+ -121.338F,
+ -37.1094F,
+ -81.2988F,
+ 30.5176F,
+ 25.6348F,
+ 48.8281F,
+ 43.7012F,
+ -23.6816F,
+ -80.8105F,
+ -54.6875F,
+ 186.768F,
+ 170.166F,
+ 185.547F,
+ 62.5000F,
+ 73.4863F,
+ 14.4043F,
+ 111.084F,
+ -20.7520F,
+ 49.8047F,
+ 70.3125F,
+ -125.488F,
+ 58.5938F,
+ 61.2793F,
+ -26.6113F,
+ 62.5000F,
+ 101.807F,
+ -8.30078F,
+ -100.830F,
+ 24.6582F,
+ 104.980F,
+ 93.7500F,
+ 38.0859F,
+ -7.56836F,
+ -2.44141F,
+ 50.2930F,
+ 104.004F,
+ 143.799F,
+ 35.4004F,
+ 34.9121F,
+ 17.3340F,
+ 197.266F,
+ 221.191F,
+ 81.2988F,
+ 85.2051F,
+ 240.723F,
+ 229.004F,
+ 143.799F,
+ 80.8105F,
+ 317.383F,
+ 201.172F,
+ 45.6543F,
+ 124.268F,
+ 259.277F,
+ 159.424F,
+ 92.5293F,
+ 113.770F,
+ 356.934F,
+ 228.760F,
+ 97.9004F,
+ 66.8945F,
+ 192.139F,
+ 210.205F,
+ 64.6973F,
+ 0.488281F,
+ 148.682F,
+ 135.010F,
+ 6.83594F,
+ 74.4629F,
+ 226.074F,
+ 83.0078F,
+ 25.8789F,
+ 94.2383F,
+ 58.8379F,
+ -65.1855F,
+ -35.8887F,
+ 54.9316F,
+ -43.4570F,
+ -130.371F,
+ 84.7168F,
+ 122.559F,
+ -156.982F,
+ -93.0176F,
+ 96.9238F,
+ 7.32422F,
+ -158.936F,
+ -178.955F,
+ -106.201F,
+ 97.1680F,
+ -99.3652F,
+ -177.246F,
+ -118.164F,
+ -60.5469F,
+ -192.627F,
+ -223.145F,
+ -106.934F,
+ -116.211F,
+ -121.582F,
+ -95.2148F,
+ 18.3105F,
+ -72.0215F,
+ -235.352F,
+ -144.043F,
+ -147.949F,
+ 36.6211F,
+ -29.5410F,
+ -11.9629F,
+ -37.8418F,
+ -19.0430F,
+ 228.271F,
+ 134.277F,
+ 94.9707F,
+ 9.27734F,
+ -78.3691F,
+ 31.0059F,
+ 103.516F,
+ 76.9043F,
+ -69.5801F,
+ -27.5879F,
+ 69.0918F,
+ 63.2324F,
+ 160.645F,
+ 49.5605F,
+ 78.6133F,
+ 118.652F,
+ 220.459F,
+ 123.291F,
+ 182.617F,
+ 101.807F,
+ 149.170F,
+ 103.271F,
+ 135.498F,
+ 125.000F,
+ 58.3496F,
+ -20.2637F,
+ -141.113F,
+ -4.63867F,
+ -82.7637F,
+ -178.467F,
+ 85.2051F,
+ 3.17383F,
+ -228.027F,
+ -341.553F,
+ -27.8320F,
+ -87.8906F,
+ 26.1230F,
+ 168.945F,
+ 44.4336F,
+ 21.9727F,
+ -303.467F,
+ -375.488F,
+ -378.662F,
+ -177.002F,
+ -138.672F,
+ -220.459F,
+ -332.764F,
+ -128.174F,
+ -126.221F,
+ -208.252F,
+ -210.205F,
+ -245.117F,
+ -41.0156F,
+ -168.457F,
+ -203.857F,
+ 15.3809F,
+ -33.4473F,
+ -135.742F,
+ -133.545F,
+ 35.1563F,
+ -69.8242F,
+ -199.463F,
+ 118.408F,
+ 77.8809F,
+ -35.8887F,
+ -99.6094F,
+ 128.418F,
+ 60.0586F,
+ -84.7168F,
+ -105.957F,
+ 72.5098F,
+ -6.83594F,
+ -70.8008F,
+ -114.990F,
+ -270.996F,
+ -313.721F,
+ -112.305F,
+ -87.6465F,
+ -241.211F,
+ -193.848F,
+ 328.857F,
+ 317.139F,
+ 168.457F,
+ 127.686F,
+ 296.875F,
+ 260.742F,
+ 267.090F,
+ 184.814F,
+ 201.416F,
+ 278.320F,
+ 183.594F,
+ 120.605F,
+ 305.664F,
+ 333.252F,
+ 291.748F,
+ 219.238F,
+ 127.197F,
+ 257.080F,
+ 129.883F,
+ 105.469F,
+ -81.5430F,
+ -52.7344F,
+ -76.4160F,
+ -64.2090F,
+ -39.0625F,
+ 12.6953F,
+ -115.234F,
+ -37.8418F,
+ 31.0059F,
+ 33.2031F,
+ -92.7734F,
+ 10.7422F,
+ 207.764F,
+ 100.098F,
+ -39.5508F,
+ -119.385F,
+ 30.0293F,
+ -62.2559F,
+ -194.336F,
+ -162.842F,
+ 266.113F,
+ 223.877F,
+ 192.627F,
+ 120.361F,
+ 341.064F,
+ 292.236F,
+ 136.230F,
+ 49.3164F,
+ -12.4512F,
+ -28.8086F,
+ -83.4961F,
+ -171.143F,
+ 20.2637F,
+ 26.3672F,
+ -10.2539F,
+ -107.666F,
+ 14.8926F,
+ 23.1934F,
+ 70.0684F,
+ 62.5000F,
+ -6.59180F,
+ 21.7285F,
+ 127.930F,
+ 129.639F,
+ 85.6934F,
+ 55.4199F,
+ 144.531F,
+ 133.057F,
+ 170.166F,
+ 37.8418F,
+ -40.0391F,
+ 74.9512F,
+ 155.762F,
+ 66.8945F,
+ -119.385F,
+ -12.2070F,
+ 184.082F,
+ 58.5938F,
+ -40.5273F,
+ -30.2734F,
+ -28.3203F,
+ -141.357F,
+ -295.898F,
+ -15.3809F,
+ 46.3867F,
+ -72.0215F,
+ -253.906F,
+ -316.406F,
+ 35.8887F,
+ -91.7969F,
+ -43.2129F,
+ -27.5879F,
+ 205.322F,
+ 302.979F,
+ 256.592F,
+ 163.086F,
+ 0.488281F,
+ 71.5332F,
+ 134.521F,
+ 74.2188F,
+ -267.578F,
+ -232.666F,
+ -60.5469F,
+ 91.7969F,
+ -183.105F,
+ -235.596F,
+ 21.2402F,
+ 125.977F,
+ -67.1387F,
+ -125.977F,
+ 168.213F,
+ 95.4590F,
+ -92.5293F,
+ -156.982F,
+ 213.867F,
+ 145.020F,
+ -95.2148F,
+ -247.314F,
+ -157.471F,
+ 139.893F,
+ -26.1230F,
+ -138.672F,
+ -168.213F,
+ -201.660F,
+ -250.244F,
+ -6.59180F,
+ -80.0781F,
+ -49.5605F,
+ 210.205F,
+ 182.861F,
+ 133.789F,
+ 56.8848F,
+ -405.273F,
+ -254.639F,
+ 110.107F,
+ 26.3672F,
+ -161.133F,
+ -151.367F,
+ 104.980F,
+ 57.6172F,
+ 5.12695F,
+ -96.6797F,
+ -282.715F,
+ -154.053F,
+ 334.961F,
+ 316.895F,
+ 236.084F,
+ 140.869F,
+ 274.658F,
+ 274.658F,
+ 143.799F,
+ 110.840F,
+ -78.8574F,
+ -211.182F,
+ -114.014F,
+ 37.3535F,
+ -114.258F,
+ -170.654F,
+ -196.289F,
+ -124.268F,
+ -95.7031F,
+ -175.293F,
+ -49.8047F,
+ -8.54492F,
+ -147.217F,
+ -266.846F,
+ -138.428F,
+ -39.5508F,
+ -123.291F,
+ -245.117F,
+ -24.9023F,
+ 85.4492F,
+ 53.4668F,
+ 54.6875F,
+ 103.271F,
+ 61.5234F,
+ 96.4355F,
+ 144.287F,
+ 148.438F,
+ 88.6230F,
+ -182.129F,
+ -23.4375F,
+ 91.0645F,
+ 41.9922F,
+ 41.7480F,
+ 72.0215F,
+ 174.316F,
+ 82.7637F,
+ 56.8848F,
+ 18.7988F,
+ 26.1230F,
+ 67.6270F,
+ 38.3301F,
+ 37.3535F,
+ -121.826F,
+ -86.9141F,
+ 377.686F,
+ 261.963F,
+ 140.625F,
+ 120.605F,
+ -71.2891F,
+ -82.7637F,
+ -123.047F,
+ -144.531F,
+ -220.459F,
+ -17.5781F,
+ -151.123F,
+ -117.432F,
+ -389.160F,
+ -272.705F,
+ -138.428F,
+ -62.0117F,
+ -193.604F,
+ -123.779F,
+ -137.695F,
+ -71.0449F,
+ -120.117F,
+ -129.883F,
+ 122.559F,
+ 136.719F,
+ -93.2617F,
+ 104.248F,
+ 146.484F,
+ 56.1523F,
+ -55.4199F,
+ 116.455F,
+ 61.2793F,
+ 18.3105F,
+ 69.5801F,
+ 205.566F,
+ 198.486F,
+ 116.211F,
+ -319.824F,
+ -325.439F,
+ 45.4102F,
+ 92.0410F,
+ -143.311F,
+ -223.877F,
+ 156.982F,
+ 93.0176F,
+ -289.551F,
+ -135.010F,
+ 100.342F,
+ 20.0195F,
+ -275.146F,
+ -200.195F,
+ -42.4805F,
+ -131.836F,
+ -147.461F,
+ 29.0527F,
+ 132.568F,
+ 50.0488F,
+ -92.7734F,
+ 160.400F,
+ 221.924F,
+ 138.428F,
+ 27.3438F,
+ -72.7539F,
+ -91.3086F,
+ 27.8320F,
+ -209.229F,
+ -61.2793F,
+ 13.6719F,
+ 38.8184F,
+ 97.9004F,
+ 84.2285F,
+ -8.30078F,
+ -34.1797F,
+ -27.0996F,
+ -148.193F,
+ 10.0098F,
+ 149.902F,
+ 86.6699F,
+ -27.8320F,
+ -18.7988F,
+ 115.723F,
+ 141.113F,
+ 13.6719F,
+ 354.004F,
+ 225.586F,
+ 268.066F,
+ 346.680F,
+ 180.908F,
+ 97.6563F,
+ 60.0586F,
+ 5.37109F,
+ 143.555F,
+ 76.4160F,
+ -29.5410F,
+ 79.8340F,
+ 202.881F,
+ 115.234F,
+ -277.832F,
+ -148.438F,
+ 208.984F,
+ 134.766F,
+ -302.979F,
+ -261.719F,
+ 155.762F,
+ 146.484F,
+ -87.4023F,
+ 62.0117F,
+ -81.2988F,
+ -73.9746F,
+ -157.715F,
+ 180.420F,
+ 87.4023F,
+ 18.0664F,
+ 299.316F,
+ 407.959F,
+ 298.096F,
+ 207.275F,
+ 547.119F,
+ 396.484F,
+ 239.990F,
+ 155.273F,
+ 449.463F,
+ 360.596F,
+ 182.861F,
+ 93.7500F,
+ 85.4492F,
+ 64.2090F,
+ 21.2402F,
+ 31.2500F,
+ -464.355F,
+ -229.736F,
+ -35.1563F,
+ -15.6250F,
+ -423.340F,
+ -62.2559F,
+ 70.3125F,
+ -7.56836F,
+ -645.508F,
+ -302.246F,
+ 89.3555F,
+ 57.3730F,
+ -401.123F,
+ -266.602F,
+ -328.125F,
+ -74.2188F,
+ -132.080F,
+ -262.451F,
+ -272.461F,
+ 30.0293F,
+ -287.598F,
+ -61.5234F,
+ -199.219F,
+ -43.9453F,
+ -248.047F,
+ 130.127F,
+ 137.939F,
+ 56.8848F,
+ -118.896F,
+ -104.980F,
+ -45.8984F,
+ 81.5430F,
+ 211.670F,
+ 301.758F,
+ 130.371F,
+ 41.7480F,
+ -388.184F,
+ -392.334F,
+ 155.029F,
+ 153.809F,
+ -536.133F,
+ 75.6836F,
+ 225.586F,
+ 100.586F,
+ -575.684F,
+ -80.0781F,
+ 233.398F,
+ 129.150F,
+ -644.287F,
+ -92.0410F,
+ 153.809F,
+ 67.8711F,
+ -635.254F,
+ 77.3926F,
+ 195.068F,
+ 72.9980F,
+ -587.402F,
+ 32.4707F,
+ 83.0078F,
+ 7.56836F,
+ -526.367F,
+ -358.398F,
+ 31.9824F,
+ 30.5176F,
+ -289.063F,
+ -119.629F,
+ -33.9355F,
+ 11.2305F,
+ -181.641F,
+ 109.131F,
+ 217.529F,
+ 137.695F,
+ 16.3574F,
+ -110.107F,
+ 157.715F,
+ 147.461F,
+ -135.010F,
+ -104.736F,
+ -213.867F,
+ 96.6797F,
+ 39.5508F,
+ -16.1133F,
+ 318.604F,
+ 223.389F,
+ 116.943F,
+ 141.357F,
+ 265.625F,
+ 193.848F,
+ 109.863F,
+ 67.8711F,
+ 138.184F,
+ 79.1016F,
+ -258.057F,
+ -37.5977F,
+ 36.1328F,
+ -43.2129F,
+ -621.338F,
+ 41.0156F,
+ 261.230F,
+ 144.531F,
+ -573.975F,
+ -10.2539F,
+ 199.951F,
+ 84.2285F,
+ -572.266F,
+ -172.607F,
+ 176.025F,
+ 61.0352F,
+ -531.006F,
+ -365.479F,
+ -75.4395F,
+ 29.7852F,
+ -19.0430F,
+ -17.8223F,
+ 29.2969F,
+ 42.2363F,
+ -0.976563F,
+ 63.9648F,
+ -64.2090F,
+ -63.7207F,
+ -105.225F,
+ -15.6250F,
+ -98.8770F,
+ -178.711F,
+ -636.963F,
+ 28.3203F,
+ -20.2637F,
+ -47.1191F,
+ -372.314F,
+ -230.469F,
+ -116.455F,
+ -177.002F,
+ -124.023F,
+ 74.9512F,
+ 41.5039F,
+ 41.9922F,
+ 203.125F,
+ 101.807F,
+ 203.125F,
+ 167.480F,
+ -54.9316F,
+ 43.2129F,
+ 218.262F,
+ 199.707F,
+ -117.676F,
+ -94.9707F,
+ 312.256F,
+ 253.662F,
+ -93.5059F,
+ 49.0723F,
+ -85.4492F,
+ 9.76563F,
+ 178.223F,
+ 155.029F,
+ 55.1758F,
+ 128.418F,
+ 122.803F,
+ 112.793F,
+ 82.5195F,
+ 97.1680F,
+ 130.615F,
+ 174.316F,
+ 9.76563F,
+ -68.8477F,
+ 361.816F,
+ 359.131F,
+ 264.893F,
+ 178.467F,
+ 381.104F,
+ 261.719F,
+ 221.924F,
+ 169.189F,
+ 346.436F,
+ 312.988F,
+ 217.041F,
+ 214.600F,
+ 281.494F,
+ 177.734F,
+ 289.551F,
+ 205.078F,
+ -55.1758F,
+ 275.879F,
+ 231.689F,
+ 168.213F,
+ -120.605F,
+ -240.723F,
+ -379.883F,
+ -31.2500F,
+ -138.672F,
+ -176.025F,
+ -174.072F,
+ -6.34766F,
+ 77.3926F,
+ 127.930F,
+ 17.0898F,
+ 32.9590F,
+ -98.8770F,
+ -211.182F,
+ -431.152F,
+ -159.180F,
+ -42.4805F,
+ -195.557F,
+ 216.064F,
+ 188.721F,
+ -37.3535F,
+ -22.2168F,
+ 268.311F,
+ 183.350F,
+ -123.535F,
+ -280.518F,
+ 208.252F,
+ 157.715F,
+ 58.8379F,
+ 190.918F,
+ 126.709F,
+ 131.592F,
+ 452.393F,
+ 415.039F,
+ 268.799F,
+ 166.992F,
+ -304.932F,
+ -362.793F,
+ -113.281F,
+ 45.8984F,
+ -218.018F,
+ -343.994F,
+ -320.313F,
+ -83.2520F,
+ -32.9590F,
+ 106.934F,
+ -42.7246F,
+ 4.39453F,
+ 271.240F,
+ 238.281F,
+ 77.8809F,
+ 50.7813F,
+ -349.121F,
+ -431.641F,
+ 20.2637F,
+ 111.816F,
+ -129.395F,
+ -244.141F,
+ 74.9512F,
+ 31.4941F,
+ -205.078F,
+ -3.66211F,
+ -7.08008F,
+ -86.9141F,
+ -222.412F,
+ -225.586F,
+ -280.029F,
+ -59.0820F,
+ -29.0527F,
+ -128.906F,
+ 31.0059F,
+ -32.4707F,
+ -185.791F,
+ -186.768F,
+ 46.3867F,
+ -20.2637F,
+ -76.9043F,
+ 218.506F,
+ 127.441F,
+ 56.3965F,
+ -54.1992F,
+ 24.9023F,
+ -15.3809F,
+ -104.492F,
+ 77.1484F,
+ 170.654F,
+ 92.5293F,
+ 17.0898F,
+ 6.10352F,
+ 174.805F,
+ 76.6602F,
+ -26.3672F,
+ 123.779F,
+ 213.379F,
+ 138.184F,
+ 58.1055F,
+ 26.3672F,
+ 229.736F,
+ 126.709F,
+ 47.6074F,
+ 103.760F,
+ -14.6484F,
+ -104.248F,
+ 62.7441F,
+ 33.9355F,
+ -25.1465F,
+ -153.809F,
+ 108.887F,
+ 81.5430F,
+ 90.3320F,
+ 100.586F,
+ 11.7188F,
+ -41.9922F,
+ -168.457F,
+ -69.0918F,
+ 135.986F,
+ 45.6543F,
+ -69.8242F,
+ 38.5742F,
+ 117.920F,
+ 34.1797F,
+ 65.9180F,
+ -83.9844F,
+ -154.053F,
+ 225.586F,
+ 141.357F,
+ -28.3203F,
+ 32.2266F,
+ 34.6680F,
+ 113.770F,
+ -16.6016F,
+ -15.6250F,
+ 56.1523F,
+ -35.4004F,
+ -73.7305F,
+ -132.324F,
+ -196.045F,
+ -222.656F,
+ 248.535F,
+ 179.932F,
+ -188.721F,
+ 247.803F,
+ 153.809F,
+ 72.5098F,
+ -633.789F,
+ 23.1934F,
+ 108.643F,
+ 82.0313F,
+ -518.066F,
+ 119.873F,
+ 124.512F,
+ 46.6309F,
+ -305.908F,
+ 39.3066F,
+ -0.488281F,
+ -79.1016F,
+ -354.004F,
+ -154.541F,
+ -173.828F,
+ -25.6348F,
+ -205.566F,
+ -62.0117F,
+ -100.342F,
+ 24.4141F,
+ -156.250F,
+ -70.8008F,
+ 246.582F,
+ 186.279F,
+ -158.691F,
+ 76.4160F,
+ 285.400F,
+ 178.223F,
+ 34.1797F,
+ 123.291F,
+ 251.465F,
+ 187.012F,
+ 188.477F,
+ 70.0684F,
+ 260.498F,
+ 200.928F,
+ 120.850F,
+ 182.861F,
+ 74.4629F,
+ 78.8574F,
+ -40.0391F,
+ 112.793F,
+ 19.0430F,
+ 97.4121F,
+ -83.4961F,
+ -213.379F,
+ 16.8457F,
+ 145.752F,
+ -3.90625F,
+ 151.367F,
+ 151.611F,
+ 82.2754F,
+ -33.6914F,
+ -108.398F,
+ -64.6973F,
+ 53.2227F,
+ 20.5078F,
+ -109.863F,
+ 232.666F,
+ 162.598F,
+ -54.1992F,
+ -196.045F,
+ 132.080F,
+ 147.461F,
+ -224.854F,
+ -335.938F,
+ 59.5703F,
+ 28.3203F,
+ -205.322F,
+ -176.514F,
+ 153.809F,
+ 143.555F,
+ 34.1797F,
+ 161.865F,
+ 71.7773F,
+ 89.8438F,
+ 228.271F,
+ 255.371F,
+ 215.088F,
+ 185.303F,
+ 426.270F,
+ 357.422F,
+ 223.633F,
+ 153.320F,
+ 106.445F,
+ 235.107F,
+ 68.6035F,
+ 0.244141F,
+ -29.0527F,
+ 18.0664F,
+ 132.324F,
+ 52.0020F,
+ 0.244141F,
+ -138.428F,
+ 73.4863F,
+ 58.8379F,
+ 63.4766F,
+ 106.201F,
+ 54.1992F,
+ 96.6797F,
+ 228.516F,
+ 233.643F,
+ 270.508F,
+ 171.631F,
+ 124.512F,
+ 123.535F,
+ 197.266F,
+ 116.699F,
+ 146.729F,
+ 169.434F,
+ 234.375F,
+ 151.367F,
+ 237.305F,
+ 180.908F,
+ 239.258F,
+ 146.484F,
+ 203.613F,
+ 175.049F,
+ 187.256F,
+ 166.992F,
+ 156.982F,
+ 237.305F,
+ 228.271F,
+ 155.762F,
+ 122.314F,
+ 161.377F,
+ 175.781F,
+ 207.764F,
+ -25.6348F,
+ -154.297F,
+ -73.9746F,
+ -28.5645F,
+ -104.736F,
+ 31.7383F,
+ 192.627F,
+ 107.910F,
+ -127.441F,
+ -45.8984F,
+ 171.875F,
+ 91.0645F,
+ -185.303F,
+ 10.2539F,
+ 198.730F,
+ 127.686F,
+ -129.639F,
+ -277.588F,
+ 91.0645F,
+ 141.113F,
+ -166.504F,
+ -293.701F,
+ -111.084F,
+ 69.5801F,
+ -283.936F,
+ -385.010F,
+ -268.066F,
+ 10.7422F,
+ 19.7754F,
+ -20.0195F,
+ 173.828F,
+ 88.6230F,
+ 116.455F,
+ 60.0586F,
+ 232.910F,
+ 151.855F,
+ 391.602F,
+ 395.996F,
+ 311.768F,
+ 217.529F,
+ 343.994F,
+ 209.717F,
+ 225.586F,
+ 217.773F,
+ 188.965F,
+ 254.150F,
+ 231.201F,
+ 278.809F,
+ 9.76563F,
+ -133.301F,
+ -18.3105F,
+ 70.3125F,
+ -150.391F,
+ -25.8789F,
+ -170.166F,
+ -6.34766F,
+ -41.2598F,
+ -39.0625F,
+ -217.529F,
+ -180.420F,
+ -68.1152F,
+ -93.7500F,
+ -251.221F,
+ -85.4492F,
+ 434.814F,
+ 319.336F,
+ 255.371F,
+ 199.219F,
+ 385.742F,
+ 374.268F,
+ 359.375F,
+ 287.598F,
+ 367.432F,
+ 262.695F,
+ 296.875F,
+ 219.482F,
+ 217.285F,
+ 220.703F,
+ 137.695F,
+ 159.668F,
+ 224.609F,
+ 168.945F,
+ 249.268F,
+ 208.984F,
+ -120.361F,
+ 32.2266F,
+ 43.2129F,
+ 123.291F,
+ 17.3340F,
+ 47.6074F,
+ -6.83594F,
+ 23.6816F,
+ 111.328F,
+ 85.6934F,
+ -40.0391F,
+ 21.4844F,
+ 107.178F,
+ 67.8711F,
+ -9.76563F,
+ 85.4492F,
+ 340.576F,
+ 231.689F,
+ 57.1289F,
+ -23.1934F,
+ -196.533F,
+ -115.234F,
+ 9.27734F,
+ -39.7949F,
+ 89.5996F,
+ -23.9258F,
+ 119.385F,
+ 127.686F,
+ 250.244F,
+ 287.598F,
+ 295.898F,
+ 221.191F,
+ 77.8809F,
+ 320.801F,
+ 198.730F,
+ 112.549F,
+ -30.0293F,
+ -132.568F,
+ -196.289F,
+ 109.131F,
+ -182.617F,
+ -79.1016F,
+ -218.994F,
+ -275.146F,
+ -179.932F,
+ -122.314F,
+ -192.627F,
+ -174.072F,
+ 174.561F,
+ 189.697F,
+ 302.490F,
+ 225.098F,
+ 475.830F,
+ 473.389F,
+ 333.984F,
+ 211.182F,
+ 178.223F,
+ 214.844F,
+ 185.059F,
+ 94.7266F,
+ -212.646F,
+ 110.840F,
+ 4.15039F,
+ -61.2793F,
+ -93.0176F,
+ -197.754F,
+ -386.475F,
+ 58.3496F,
+ -127.197F,
+ -235.840F,
+ -193.359F,
+ 63.2324F,
+ -217.285F,
+ -331.543F,
+ -187.988F,
+ -17.8223F,
+ 40.5273F,
+ 85.2051F,
+ -51.7578F,
+ 78.8574F,
+ -205.078F,
+ -73.4863F,
+ 115.479F,
+ 106.201F,
+ -165.771F,
+ -113.281F,
+ 177.734F,
+ 85.6934F,
+ -38.0859F,
+ -48.5840F,
+ 162.842F,
+ 105.469F,
+ 7.08008F,
+ -61.5234F,
+ 101.318F,
+ 117.188F,
+ -178.467F,
+ -92.5293F,
+ 35.4004F,
+ 136.475F,
+ -128.906F,
+ -154.053F,
+ -282.715F,
+ -38.8184F,
+ 108.643F,
+ 66.6504F,
+ 30.0293F,
+ 156.006F,
+ 91.0645F,
+ -30.7617F,
+ 195.313F,
+ 138.672F,
+ 20.5078F,
+ -39.5508F,
+ 175.781F,
+ 173.828F,
+ -202.637F,
+ -130.859F,
+ -45.1660F,
+ 54.1992F,
+ 99.6094F,
+ 110.352F,
+ 122.314F,
+ 188.232F,
+ -218.994F,
+ -330.811F,
+ -16.3574F,
+ 107.910F,
+ -193.359F,
+ -343.262F,
+ 138.184F,
+ 146.973F,
+ 40.7715F,
+ -79.5898F,
+ 124.268F,
+ 80.5664F,
+ -23.1934F,
+ -152.832F,
+ -178.223F,
+ -83.9844F,
+ 407.227F,
+ 297.119F,
+ 190.186F,
+ 111.084F,
+ 321.289F,
+ 202.148F,
+ 142.578F,
+ 175.537F,
+ 98.6328F,
+ -7.56836F,
+ 247.314F,
+ 192.627F,
+ 21.7285F,
+ 26.1230F,
+ 217.529F,
+ 134.033F,
+ 212.646F,
+ 385.986F,
+ 223.877F,
+ 163.818F,
+ 211.426F,
+ 361.084F,
+ 314.697F,
+ 208.496F,
+ 95.4590F,
+ 260.742F,
+ 273.926F,
+ 198.242F,
+ 19.0430F,
+ -137.207F,
+ 84.2285F,
+ 137.451F,
+ 104.736F,
+ -25.1465F,
+ 101.807F,
+ 192.139F,
+ -29.7852F,
+ -106.689F,
+ 100.342F,
+ 192.383F,
+ -222.900F,
+ -101.807F,
+ 146.973F,
+ 184.082F,
+ -55.1758F,
+ -3.90625F,
+ 36.8652F,
+ 185.547F,
+ -170.898F,
+ 28.8086F,
+ -25.3906F,
+ -3.41797F,
+ -275.391F,
+ 11.7188F,
+ 69.3359F,
+ 95.9473F,
+ -95.2148F,
+ -102.295F,
+ -156.006F,
+ -28.3203F,
+ -222.168F,
+ 74.7070F,
+ 77.1484F,
+ -3.17383F,
+ 294.678F,
+ 240.234F,
+ 200.439F,
+ 163.330F,
+ -291.748F,
+ -169.189F,
+ 34.1797F,
+ -52.0020F,
+ -215.820F,
+ -101.563F,
+ -48.5840F,
+ -136.230F,
+ -150.391F,
+ 59.8145F,
+ -98.6328F,
+ -162.109F,
+ 63.9648F,
+ 13.6719F,
+ -150.635F,
+ -176.758F,
+ -20.7520F,
+ -119.873F,
+ -78.1250F,
+ -160.156F,
+ -139.160F,
+ -202.881F,
+ -31.4941F,
+ -128.906F,
+ -367.676F,
+ -15.3809F,
+ -89.5996F,
+ -93.9941F,
+ -87.4023F,
+ -78.3691F,
+ 0.976563F,
+ 12.4512F,
+ -89.3555F,
+ -52.2461F,
+ 77.8809F,
+ 124.756F,
+ 35.6445F,
+ 163.818F,
+ -4.15039F,
+ -71.0449F,
+ -26.8555F,
+ 113.281F,
+ -33.9355F,
+ -121.094F,
+ -49.3164F,
+ 53.7109F,
+ -76.1719F,
+ -154.053F,
+ -161.133F,
+ -17.8223F,
+ -159.912F,
+ -200.195F,
+ -161.621F,
+ -159.424F,
+ -314.453F,
+ -209.229F,
+ -104.980F,
+ -232.666F,
+ -234.131F,
+ -64.4531F,
+ -11.9629F,
+ -114.258F,
+ -17.5781F,
+ -93.0176F,
+ -85.4492F,
+ -137.451F,
+ -47.1191F,
+ -99.3652F,
+ 13.4277F,
+ -99.6094F,
+ -196.045F,
+ 2.68555F,
+ -75.4395F,
+ 158.447F,
+ 45.8984F,
+ -48.3398F,
+ -125.000F,
+ 112.549F,
+ -19.2871F,
+ -111.816F,
+ -321.777F,
+ -64.2090F,
+ -32.7148F,
+ -127.686F,
+ -404.541F,
+ -106.201F,
+ -120.850F,
+ -186.768F,
+ 13.9160F,
+ -84.7168F,
+ -101.074F,
+ 105.957F,
+ -278.564F,
+ -59.0820F,
+ -162.109F,
+ -209.229F,
+ 8.30078F,
+ -16.6016F,
+ -172.607F,
+ -82.5195F
+
+};
+#define MR515_3_SIZE 128
+
+/* third codebook for MR475, MR515 */
+static const Float32 mr515_3_lsf[] =
+{
+ 102.295F,
+ 39.7949F,
+ -7.32422F,
+ -63.9648F,
+ -111.084F,
+ -192.627F,
+ -349.121F,
+ -176.025F,
+ 245.605F,
+ 162.109F,
+ 65.6738F,
+ 6.10352F,
+ 151.123F,
+ 63.4766F,
+ 44.6777F,
+ 23.4375F,
+ -236.328F,
+ -331.543F,
+ -94.7266F,
+ 32.9590F,
+ -169.189F,
+ 203.857F,
+ 111.328F,
+ 37.5977F,
+ 269.775F,
+ 171.631F,
+ 138.916F,
+ 88.6230F,
+ 396.729F,
+ 323.730F,
+ 240.479F,
+ 182.617F,
+ -53.7109F,
+ 53.4668F,
+ 18.5547F,
+ -50.7813F,
+ -355.225F,
+ -405.762F,
+ 11.9629F,
+ 36.3770F,
+ -235.352F,
+ -41.9922F,
+ -183.594F,
+ -82.0313F,
+ 152.588F,
+ 51.0254F,
+ -61.0352F,
+ -16.1133F,
+ -248.291F,
+ -204.590F,
+ -0.488281F,
+ 77.3926F,
+ -529.297F,
+ -362.549F,
+ -33.6914F,
+ 30.0293F,
+ -458.008F,
+ -512.451F,
+ -127.197F,
+ 20.7520F,
+ -236.084F,
+ -89.3555F,
+ -169.678F,
+ -215.088F,
+ -224.854F,
+ -246.826F,
+ -186.279F,
+ -231.689F,
+ -30.2734F,
+ -62.5000F,
+ -85.9375F,
+ -161.133F,
+ 43.4570F,
+ 113.037F,
+ 86.4258F,
+ 74.2188F,
+ -425.781F,
+ -144.287F,
+ -68.8477F,
+ 19.2871F,
+ -549.072F,
+ 42.7246F,
+ 211.670F,
+ 121.826F,
+ -33.6914F,
+ -43.9453F,
+ -44.1895F,
+ -5.12695F,
+ -559.326F,
+ -302.979F,
+ -112.305F,
+ -126.953F,
+ -188.232F,
+ 110.107F,
+ -2.44141F,
+ -75.1953F,
+ 66.1621F,
+ -15.8691F,
+ 0.976563F,
+ 52.2461F,
+ -68.1152F,
+ -106.201F,
+ -10.4980F,
+ -84.9609F,
+ -163.574F,
+ 8.54492F,
+ -15.8691F,
+ -51.5137F,
+ 196.777F,
+ 130.615F,
+ 20.7520F,
+ 72.5098F,
+ 13.9160F,
+ 58.3496F,
+ 176.270F,
+ 120.361F,
+ 54.9316F,
+ 161.377F,
+ 205.078F,
+ 133.545F,
+ -131.836F,
+ -91.7969F,
+ 3.41797F,
+ 85.2051F,
+ 114.502F,
+ 176.025F,
+ 80.8105F,
+ 39.5508F,
+ -132.813F,
+ -183.594F,
+ -15.1367F,
+ -2.44141F,
+ 97.1680F,
+ -21.4844F,
+ 176.758F,
+ 171.143F,
+ -4.63867F,
+ -130.127F,
+ -22.9492F,
+ 146.729F,
+ 33.2031F,
+ -17.3340F,
+ -166.260F,
+ -182.373F,
+ -40.5273F,
+ -83.9844F,
+ 63.7207F,
+ -12.2070F,
+ 39.3066F,
+ -12.6953F,
+ 118.408F,
+ 82.2754F,
+ -408.936F,
+ 12.2070F,
+ 46.3867F,
+ -22.7051F,
+ -557.129F,
+ -56.3965F,
+ -47.3633F,
+ -20.0195F,
+ -23.1934F,
+ -145.264F,
+ -37.5977F,
+ 31.2500F,
+ 218.262F,
+ 122.314F,
+ 143.555F,
+ 111.572F,
+ -84.2285F,
+ 50.2930F,
+ 29.7852F,
+ 26.8555F,
+ -154.053F,
+ -55.4199F,
+ -138.916F,
+ 0.732422F,
+ 99.6094F,
+ 58.3496F,
+ 96.9238F,
+ 55.1758F,
+ -48.0957F,
+ -0.488281F,
+ 31.2500F,
+ 119.873F,
+ 312.744F,
+ 220.703F,
+ 71.2891F,
+ 52.4902F,
+ 131.348F,
+ 74.7070F,
+ 63.2324F,
+ 124.268F,
+ -165.283F,
+ -255.615F,
+ 3.17383F,
+ 78.3691F,
+ -165.771F,
+ -143.555F,
+ -87.4023F,
+ -51.7578F,
+ -136.230F,
+ 59.3262F,
+ 157.715F,
+ 116.943F,
+ 118.652F,
+ 83.4961F,
+ 154.785F,
+ 129.883F,
+ 26.1230F,
+ 195.801F,
+ 80.8105F,
+ 33.2031F,
+ -27.3438F,
+ -97.1680F,
+ -251.709F,
+ -69.8242F,
+ -79.5898F,
+ -172.119F,
+ 70.3125F,
+ 66.4063F,
+ 317.139F,
+ 279.297F,
+ 287.598F,
+ 209.961F,
+ -103.271F,
+ 29.5410F,
+ -93.9941F,
+ -36.1328F,
+ -72.0215F,
+ -73.7305F,
+ -203.613F,
+ -199.951F,
+ 3.90625F,
+ -5.85938F,
+ -49.0723F,
+ -116.211F,
+ 135.498F,
+ 22.2168F,
+ -59.8145F,
+ 71.7773F,
+ -9.27734F,
+ -92.5293F,
+ -234.863F,
+ -298.096F,
+ -290.771F,
+ -370.605F,
+ -66.6504F,
+ -96.4355F,
+ -95.2148F,
+ -247.314F,
+ -157.471F,
+ 139.893F,
+ -449.951F,
+ -251.465F,
+ 123.291F,
+ 114.258F,
+ 181.641F,
+ 231.201F,
+ 148.682F,
+ 120.361F,
+ -168.213F,
+ -286.133F,
+ -153.320F,
+ -32.9590F,
+ -250.488F,
+ 47.6074F,
+ 100.342F,
+ 47.8516F,
+ 386.230F,
+ 280.029F,
+ 140.381F,
+ 82.2754F,
+ -302.490F,
+ -189.697F,
+ -158.203F,
+ -34.6680F,
+ 145.264F,
+ 201.416F,
+ 236.084F,
+ 179.443F,
+ -294.434F,
+ -236.816F,
+ -19.7754F,
+ -83.4961F,
+ -181.885F,
+ 3.17383F,
+ -17.5781F,
+ 91.5527F,
+ 110.840F,
+ 4.63867F,
+ 343.506F,
+ 224.854F,
+ -402.100F,
+ -41.9922F,
+ 210.205F,
+ 137.207F,
+ 226.563F,
+ 375.244F,
+ 259.521F,
+ 180.664F,
+ -603.516F,
+ -232.422F,
+ 64.4531F,
+ 20.0195F,
+ -122.559F,
+ -235.596F,
+ -325.684F,
+ 30.0293F,
+ 211.670F,
+ 301.758F,
+ 130.371F,
+ 41.7480F,
+ -566.406F,
+ -112.305F,
+ 190.430F,
+ 88.6230F,
+ -290.527F,
+ -150.635F,
+ 61.5234F,
+ -14.8926F,
+ -42.4805F,
+ 8.30078F,
+ 246.826F,
+ 192.383F,
+ -569.580F,
+ 60.3027F,
+ 103.271F,
+ 37.3535F,
+ -3.90625F,
+ -86.6699F,
+ 63.9648F,
+ 109.619F,
+ -384.766F,
+ -261.963F,
+ -132.813F,
+ -90.5762F,
+ -150.146F,
+ -74.4629F,
+ 256.592F,
+ 196.533F,
+ 167.725F,
+ 128.906F,
+ 1.46484F,
+ -44.4336F,
+ 228.271F,
+ 213.623F,
+ 244.629F,
+ 197.510F,
+ 48.5840F,
+ 62.7441F,
+ 30.7617F,
+ 18.5547F,
+ -142.578F,
+ -277.832F,
+ 146.240F,
+ 135.742F,
+ -269.775F,
+ -339.600F,
+ -388.428F,
+ -126.709F,
+ -238.525F,
+ -323.486F,
+ 26.3672F,
+ 84.7168F,
+ -176.270F,
+ -238.037F,
+ 89.1113F,
+ 24.6582F,
+ -35.4004F,
+ 166.260F,
+ 60.7910F,
+ -37.3535F,
+ 0.000000F,
+ -81.5430F,
+ -139.160F,
+ 38.8184F,
+ 100.586F,
+ 69.5801F,
+ -82.0313F,
+ -150.635F,
+ -232.666F,
+ -235.840F,
+ 216.553F,
+ 168.213F,
+ -305.420F,
+ 20.5078F,
+ -45.1660F,
+ -97.1680F,
+ -144.531F,
+ 105.713F,
+ 254.883F,
+ 159.424F,
+ 20.7520F,
+ 80.3223F,
+ -9.76563F,
+ 88.1348F,
+ -105.713F,
+ -172.119F,
+ 113.770F,
+ 140.137F,
+ -37.5977F,
+ 159.668F,
+ 144.531F,
+ 70.8008F,
+ -40.7715F,
+ 17.5781F,
+ 85.2051F,
+ 42.7246F,
+ 164.551F,
+ 72.5098F,
+ 238.525F,
+ 175.781F,
+ 301.514F,
+ 293.945F,
+ 184.814F,
+ 119.141F,
+ -97.6563F,
+ -65.6738F,
+ 131.348F,
+ 90.8203F,
+ -329.590F,
+ -338.623F,
+ -291.504F,
+ -22.2168F,
+ 308.105F,
+ 213.867F,
+ 189.209F,
+ 170.898F,
+ -146.240F,
+ -9.27734F,
+ -104.980F,
+ -176.270F,
+ 482.422F,
+ 397.949F,
+ 241.943F,
+ 148.438F,
+ 27.0996F,
+ 67.3828F,
+ -55.1758F,
+ -23.4375F,
+ -231.201F,
+ -94.7266F,
+ -2.68555F,
+ -1.70898F,
+ -73.9746F,
+ -129.639F,
+ -204.834F,
+ 82.5195F,
+ 423.340F,
+ 417.480F,
+ 343.018F,
+ 247.314F,
+ -125.977F,
+ -208.740F,
+ -157.471F,
+ 51.2695F,
+ -167.969F,
+ -101.563F,
+ 125.244F,
+ 56.1523F,
+ -200.684F,
+ -155.518F,
+ -279.785F,
+ -78.1250F,
+ -232.422F,
+ -160.645F,
+ -169.434F,
+ 44.6777F,
+ -27.8320F,
+ -152.100F,
+ 199.707F,
+ 164.551F,
+ -46.6309F,
+ -49.8047F,
+ 178.467F,
+ 155.029F,
+ 12.4512F,
+ 298.096F,
+ 215.576F,
+ 140.625F,
+ -232.910F,
+ -105.225F,
+ 201.660F,
+ 145.996F,
+ -83.4961F,
+ -184.326F,
+ -219.727F,
+ -99.3652F,
+ -274.902F,
+ -86.4258F,
+ -50.2930F,
+ -125.000F,
+ -133.545F,
+ -197.754F,
+ -87.1582F,
+ -151.367F,
+ 16.1133F,
+ 125.732F,
+ -17.8223F,
+ -100.098F,
+ -212.891F,
+ -230.713F,
+ -352.539F,
+ -299.561F,
+ 46.6309F,
+ -4.15039F,
+ -132.813F,
+ -56.3965F,
+ -375.977F,
+ -132.813F,
+ -219.971F,
+ -216.309F
+
+};
+#define MR795_1_SIZE 512
+
+/* first codebook for MR795 */
+static const Float32 mr795_1_lsf[] =
+{
+ -217.285F,
+ -378.418F,
+ -620.361F,
+ -199.951F,
+ -236.816F,
+ 42.7246F,
+ -201.660F,
+ -301.270F,
+ -186.035F,
+ -146.240F,
+ -5.37109F,
+ 154.785F,
+ -197.998F,
+ -240.967F,
+ -220.215F,
+ -78.8574F,
+ 49.5605F,
+ 6.34766F,
+ -93.5059F,
+ -57.3730F,
+ -190.674F,
+ -97.4121F,
+ 308.105F,
+ 221.191F,
+ -227.539F,
+ -341.553F,
+ -336.914F,
+ -152.344F,
+ 22.7051F,
+ 21.2402F,
+ -101.074F,
+ -131.592F,
+ -168.701F,
+ 9.03320F,
+ 154.541F,
+ 124.512F,
+ -94.4824F,
+ -116.211F,
+ -324.707F,
+ 97.4121F,
+ 16.1133F,
+ 64.2090F,
+ -99.3652F,
+ -11.9629F,
+ -81.7871F,
+ -101.807F,
+ 254.150F,
+ 455.322F,
+ -190.186F,
+ -265.869F,
+ -351.563F,
+ -182.129F,
+ -209.473F,
+ 203.125F,
+ -141.846F,
+ -185.303F,
+ -90.5762F,
+ -164.307F,
+ -123.535F,
+ 509.766F,
+ -136.719F,
+ -154.785F,
+ -287.842F,
+ 66.1621F,
+ 58.8379F,
+ 3.41797F,
+ -106.934F,
+ -59.5703F,
+ -96.9238F,
+ 113.037F,
+ 293.457F,
+ 255.615F,
+ -147.949F,
+ -194.580F,
+ -351.074F,
+ -12.4512F,
+ -78.8574F,
+ 117.432F,
+ -54.6875F,
+ -142.578F,
+ -128.662F,
+ 120.605F,
+ 215.088F,
+ 166.504F,
+ -105.713F,
+ -74.7070F,
+ -244.629F,
+ 135.254F,
+ 160.889F,
+ 54.1992F,
+ 41.7480F,
+ -39.0625F,
+ -86.1816F,
+ 166.260F,
+ 438.965F,
+ 382.080F,
+ -208.008F,
+ -288.330F,
+ -413.818F,
+ -82.0313F,
+ -162.598F,
+ 27.8320F,
+ -141.846F,
+ -184.570F,
+ -181.641F,
+ -47.6074F,
+ 91.5527F,
+ 121.338F,
+ -113.525F,
+ -196.289F,
+ -268.066F,
+ 37.5977F,
+ 68.8477F,
+ -31.9824F,
+ -12.2070F,
+ -46.6309F,
+ -175.537F,
+ 78.8574F,
+ 178.711F,
+ 376.465F,
+ -176.270F,
+ -199.951F,
+ -342.773F,
+ 25.6348F,
+ -61.0352F,
+ 45.1660F,
+ -43.4570F,
+ -122.559F,
+ -181.152F,
+ 78.3691F,
+ 124.512F,
+ 271.240F,
+ -78.8574F,
+ -138.428F,
+ -235.840F,
+ 31.0059F,
+ 118.164F,
+ 82.5195F,
+ -39.0625F,
+ 12.6953F,
+ -82.5195F,
+ 178.711F,
+ 333.740F,
+ 379.395F,
+ -152.832F,
+ -195.801F,
+ -414.063F,
+ -69.8242F,
+ -143.066F,
+ 165.039F,
+ -169.678F,
+ -83.7402F,
+ -90.3320F,
+ -119.629F,
+ 72.0215F,
+ 462.158F,
+ -153.809F,
+ -140.137F,
+ -247.559F,
+ -19.5313F,
+ 157.471F,
+ -16.8457F,
+ -1.46484F,
+ -77.6367F,
+ -88.8672F,
+ 190.918F,
+ 354.004F,
+ 253.418F,
+ -76.4160F,
+ -178.955F,
+ -340.576F,
+ 29.2969F,
+ 14.6484F,
+ 116.455F,
+ -64.4531F,
+ -142.822F,
+ -30.0293F,
+ 173.584F,
+ 303.955F,
+ 154.541F,
+ -22.2168F,
+ -86.6699F,
+ -248.047F,
+ 188.232F,
+ 185.059F,
+ 63.7207F,
+ 61.7676F,
+ 19.7754F,
+ -115.723F,
+ 227.051F,
+ 540.771F,
+ 419.922F,
+ -197.266F,
+ -268.311F,
+ -469.971F,
+ -136.719F,
+ -190.918F,
+ 41.2598F,
+ -196.289F,
+ -262.207F,
+ -45.8984F,
+ -152.832F,
+ -13.4277F,
+ 343.018F,
+ -169.434F,
+ -174.805F,
+ -291.504F,
+ -161.133F,
+ 86.4258F,
+ 80.3223F,
+ -125.488F,
+ -13.4277F,
+ -132.568F,
+ 89.3555F,
+ 252.197F,
+ 288.574F,
+ -160.645F,
+ -234.131F,
+ -331.299F,
+ -13.4277F,
+ -44.9219F,
+ 22.7051F,
+ -147.705F,
+ -69.8242F,
+ -161.621F,
+ 98.6328F,
+ 109.619F,
+ 201.904F,
+ -69.8242F,
+ -85.4492F,
+ -308.350F,
+ 153.320F,
+ 74.7070F,
+ 55.4199F,
+ -3.90625F,
+ 35.8887F,
+ -152.100F,
+ 45.4102F,
+ 225.342F,
+ 523.926F,
+ -164.551F,
+ -217.285F,
+ -392.090F,
+ -108.154F,
+ -55.6641F,
+ 82.7637F,
+ -90.0879F,
+ -192.871F,
+ -99.8535F,
+ 56.3965F,
+ 20.9961F,
+ 358.643F,
+ -109.375F,
+ -141.846F,
+ -259.033F,
+ 145.020F,
+ 109.863F,
+ -43.2129F,
+ -30.2734F,
+ -41.5039F,
+ -109.131F,
+ 163.818F,
+ 282.959F,
+ 342.773F,
+ -116.211F,
+ -162.842F,
+ -368.896F,
+ -18.7988F,
+ -33.6914F,
+ 174.805F,
+ -43.2129F,
+ -90.8203F,
+ -93.0176F,
+ 110.107F,
+ 228.027F,
+ 223.389F,
+ -61.0352F,
+ -105.469F,
+ -200.684F,
+ 66.4063F,
+ 202.148F,
+ 108.887F,
+ 6.34766F,
+ 4.63867F,
+ -7.56836F,
+ 170.410F,
+ 413.086F,
+ 529.297F,
+ -157.715F,
+ -238.525F,
+ -469.727F,
+ -43.7012F,
+ -115.479F,
+ 65.4297F,
+ -92.5293F,
+ -181.885F,
+ -168.701F,
+ 2.68555F,
+ 31.0059F,
+ 252.197F,
+ -119.141F,
+ -223.877F,
+ -201.416F,
+ 14.8926F,
+ 78.8574F,
+ 32.9590F,
+ 35.8887F,
+ -35.4004F,
+ -167.480F,
+ 167.236F,
+ 191.895F,
+ 410.645F,
+ -123.535F,
+ -207.031F,
+ -316.650F,
+ 8.54492F,
+ 21.9727F,
+ 54.1992F,
+ -5.61523F,
+ -84.4727F,
+ -163.574F,
+ 111.084F,
+ 144.287F,
+ 314.209F,
+ -49.5605F,
+ -144.775F,
+ -265.137F,
+ 159.180F,
+ 85.9375F,
+ 106.689F,
+ 9.52148F,
+ 15.3809F,
+ -111.572F,
+ 205.322F,
+ 308.838F,
+ 513.916F,
+ -126.953F,
+ -215.332F,
+ -386.719F,
+ -80.0781F,
+ -173.584F,
+ 346.924F,
+ -145.508F,
+ -83.4961F,
+ -17.0898F,
+ 51.0254F,
+ 42.2363F,
+ 470.703F,
+ -103.271F,
+ -145.996F,
+ -224.854F,
+ 102.783F,
+ 147.705F,
+ -9.27734F,
+ -0.488281F,
+ -59.8145F,
+ -31.0059F,
+ 218.750F,
+ 480.713F,
+ 277.100F,
+ -92.5293F,
+ -126.465F,
+ -385.498F,
+ 42.2363F,
+ 28.8086F,
+ 183.838F,
+ -13.4277F,
+ -93.0176F,
+ -12.6953F,
+ 240.479F,
+ 249.268F,
+ 183.838F,
+ -0.488281F,
+ -71.0449F,
+ -217.529F,
+ 183.838F,
+ 242.188F,
+ 103.271F,
+ 64.4531F,
+ 31.9824F,
+ -47.8516F,
+ 218.506F,
+ 555.176F,
+ 620.850F,
+ -155.029F,
+ -265.625F,
+ -610.107F,
+ -129.150F,
+ -239.746F,
+ 128.418F,
+ -186.523F,
+ -202.637F,
+ -133.789F,
+ -106.445F,
+ 77.1484F,
+ 146.240F,
+ -164.795F,
+ -229.492F,
+ -182.129F,
+ -13.9160F,
+ 57.6172F,
+ -2.68555F,
+ -49.0723F,
+ -19.7754F,
+ -194.824F,
+ 3.90625F,
+ 206.299F,
+ 380.371F,
+ -179.932F,
+ -240.479F,
+ -295.898F,
+ -114.258F,
+ 4.15039F,
+ 70.8008F,
+ -68.1152F,
+ -142.578F,
+ -170.898F,
+ 44.6777F,
+ 200.684F,
+ 172.119F,
+ -64.6973F,
+ -120.117F,
+ -289.795F,
+ 102.783F,
+ 37.1094F,
+ 114.258F,
+ -95.2148F,
+ 40.5273F,
+ -65.4297F,
+ 9.52148F,
+ 378.418F,
+ 456.055F,
+ -155.029F,
+ -235.840F,
+ -383.545F,
+ -110.596F,
+ -120.117F,
+ 222.168F,
+ -69.3359F,
+ -250.732F,
+ -18.3105F,
+ -44.1895F,
+ -32.4707F,
+ 452.148F,
+ -108.643F,
+ -152.344F,
+ -286.621F,
+ 102.539F,
+ 89.5996F,
+ -11.9629F,
+ -94.9707F,
+ -51.7578F,
+ -41.2598F,
+ 172.607F,
+ 261.963F,
+ 294.922F,
+ -131.592F,
+ -173.340F,
+ -353.760F,
+ 20.2637F,
+ -39.7949F,
+ 118.164F,
+ -57.6172F,
+ -132.568F,
+ -86.6699F,
+ 82.5195F,
+ 286.865F,
+ 198.730F,
+ -60.0586F,
+ -75.4395F,
+ -233.887F,
+ 147.949F,
+ 185.547F,
+ 14.6484F,
+ 40.5273F,
+ -1.95313F,
+ -39.7949F,
+ -74.7070F,
+ 451.416F,
+ 625.732F,
+ -182.373F,
+ -250.244F,
+ -435.303F,
+ -102.295F,
+ -108.887F,
+ 51.0254F,
+ -175.293F,
+ -138.184F,
+ -130.371F,
+ -123.535F,
+ 169.189F,
+ 209.229F,
+ -113.037F,
+ -170.166F,
+ -264.160F,
+ 79.3457F,
+ 105.225F,
+ -50.2930F,
+ -3.66211F,
+ -1.95313F,
+ -186.279F,
+ 133.057F,
+ 224.365F,
+ 370.605F,
+ -149.170F,
+ -191.162F,
+ -320.557F,
+ 62.5000F,
+ -13.4277F,
+ 50.7813F,
+ -40.2832F,
+ -84.9609F,
+ -161.621F,
+ 78.3691F,
+ 166.016F,
+ 227.051F,
+ -79.5898F,
+ -104.736F,
+ -232.178F,
+ 118.164F,
+ 108.887F,
+ 139.160F,
+ -48.0957F,
+ 17.5781F,
+ -17.8223F,
+ 221.924F,
+ 355.225F,
+ 425.049F,
+ -137.451F,
+ -179.932F,
+ -481.934F,
+ -30.2734F,
+ -101.563F,
+ 175.293F,
+ -116.699F,
+ -98.6328F,
+ -76.6602F,
+ -3.90625F,
+ 108.887F,
+ 399.414F,
+ -134.521F,
+ -131.104F,
+ -183.105F,
+ -14.1602F,
+ 155.762F,
+ 52.2461F,
+ 13.4277F,
+ -45.1660F,
+ -66.1621F,
+ 280.273F,
+ 317.627F,
+ 295.898F,
+ -117.920F,
+ -163.818F,
+ -308.594F,
+ 28.5645F,
+ 69.5801F,
+ 132.568F,
+ -49.8047F,
+ -95.4590F,
+ -27.0996F,
+ 125.244F,
+ 375.488F,
+ 208.496F,
+ -27.8320F,
+ -46.3867F,
+ -238.770F,
+ 214.111F,
+ 145.264F,
+ 113.281F,
+ 63.4766F,
+ 63.4766F,
+ -75.9277F,
+ 182.617F,
+ 557.373F,
+ 541.016F,
+ -126.221F,
+ -230.713F,
+ -530.029F,
+ -79.5898F,
+ -172.852F,
+ 92.2852F,
+ -198.242F,
+ -168.701F,
+ -56.6406F,
+ -136.719F,
+ 167.725F,
+ 343.994F,
+ -178.711F,
+ -168.457F,
+ -204.102F,
+ -87.6465F,
+ 157.471F,
+ 94.2383F,
+ -64.6973F,
+ 15.1367F,
+ -165.527F,
+ 35.4004F,
+ 401.367F,
+ 294.922F,
+ -135.498F,
+ -241.211F,
+ -301.025F,
+ -19.0430F,
+ 3.41797F,
+ 27.8320F,
+ -79.8340F,
+ -87.4023F,
+ -119.385F,
+ 95.7031F,
+ 165.283F,
+ 170.166F,
+ -49.0723F,
+ -57.6172F,
+ -278.320F,
+ 169.189F,
+ 109.619F,
+ 43.4570F,
+ -59.3262F,
+ 62.5000F,
+ -105.713F,
+ 149.170F,
+ 338.135F,
+ 599.609F,
+ -149.414F,
+ -219.971F,
+ -357.422F,
+ -74.9512F,
+ -4.15039F,
+ 121.826F,
+ -76.9043F,
+ -162.842F,
+ -62.0117F,
+ 62.5000F,
+ 104.492F,
+ 357.178F,
+ -118.652F,
+ -103.027F,
+ -257.813F,
+ 159.912F,
+ 90.3320F,
+ 4.39453F,
+ -24.9023F,
+ -45.1660F,
+ -67.3828F,
+ 184.326F,
+ 385.254F,
+ 325.928F,
+ -119.141F,
+ -147.217F,
+ -346.191F,
+ 44.4336F,
+ -22.7051F,
+ 212.402F,
+ -17.8223F,
+ -111.816F,
+ -84.9609F,
+ 203.857F,
+ 210.449F,
+ 233.643F,
+ -68.8477F,
+ -81.2988F,
+ -182.129F,
+ 133.545F,
+ 204.834F,
+ 104.492F,
+ 66.6504F,
+ -21.7285F,
+ 3.17383F,
+ 229.492F,
+ 416.992F,
+ 628.906F,
+ -102.051F,
+ -264.648F,
+ -429.199F,
+ -10.7422F,
+ -87.4023F,
+ 63.2324F,
+ -121.338F,
+ -156.982F,
+ -136.719F,
+ 24.1699F,
+ 135.986F,
+ 234.619F,
+ -102.783F,
+ -187.012F,
+ -223.877F,
+ 72.0215F,
+ 79.5898F,
+ 44.9219F,
+ 42.7246F,
+ 3.66211F,
+ -152.832F,
+ 129.883F,
+ 214.355F,
+ 483.643F,
+ -108.154F,
+ -187.500F,
+ -311.279F,
+ 53.9551F,
+ 38.0859F,
+ 65.4297F,
+ 9.52148F,
+ -88.6230F,
+ -123.291F,
+ 169.678F,
+ 188.477F,
+ 278.320F,
+ -39.5508F,
+ -112.061F,
+ -222.656F,
+ 173.096F,
+ 108.398F,
+ 160.645F,
+ 6.10352F,
+ 73.9746F,
+ -76.1719F,
+ 309.570F,
+ 344.238F,
+ 418.701F,
+ -72.5098F,
+ -187.012F,
+ -448.242F,
+ -64.2090F,
+ -26.3672F,
+ 261.230F,
+ -99.1211F,
+ -3.17383F,
+ -31.4941F,
+ 13.9160F,
+ 106.934F,
+ 667.480F,
+ -91.3086F,
+ -118.896F,
+ -203.857F,
+ 74.2188F,
+ 169.922F,
+ 40.0391F,
+ 25.3906F,
+ -57.3730F,
+ 1.22070F,
+ 393.311F,
+ 463.867F,
+ 341.553F,
+ -55.9082F,
+ -142.090F,
+ -323.486F,
+ 98.8770F,
+ 46.8750F,
+ 199.463F,
+ -21.2402F,
+ -106.934F,
+ 27.0996F,
+ 250.977F,
+ 292.725F,
+ 242.432F,
+ 16.6016F,
+ -42.7246F,
+ -228.027F,
+ 252.197F,
+ 272.705F,
+ 110.107F,
+ 116.699F,
+ 48.8281F,
+ -60.5469F,
+ 519.287F,
+ 658.203F,
+ 498.535F,
+ -203.857F,
+ -322.998F,
+ -520.264F,
+ -195.068F,
+ -168.945F,
+ 113.770F,
+ -198.242F,
+ -251.953F,
+ -114.502F,
+ -151.855F,
+ 70.3125F,
+ 224.609F,
+ -171.143F,
+ -205.322F,
+ -261.230F,
+ -100.342F,
+ 125.000F,
+ 1.95313F,
+ -95.2148F,
+ -22.2168F,
+ -181.641F,
+ -7.32422F,
+ 254.639F,
+ 283.447F,
+ -200.684F,
+ -280.273F,
+ -282.227F,
+ -71.7773F,
+ -11.2305F,
+ 26.8555F,
+ -100.342F,
+ -91.3086F,
+ -165.527F,
+ 52.2461F,
+ 129.639F,
+ 163.086F,
+ -99.1211F,
+ -102.539F,
+ -291.504F,
+ 118.896F,
+ 56.6406F,
+ 73.9746F,
+ -77.6367F,
+ 22.2168F,
+ -115.234F,
+ 30.0293F,
+ 300.781F,
+ 596.924F,
+ -176.270F,
+ -232.422F,
+ -364.990F,
+ -180.176F,
+ -164.795F,
+ 325.195F,
+ -132.568F,
+ -147.949F,
+ -51.5137F,
+ -23.1934F,
+ -23.9258F,
+ 368.164F,
+ -134.033F,
+ -125.488F,
+ -291.260F,
+ 115.479F,
+ 51.5137F,
+ 17.8223F,
+ -70.3125F,
+ -27.3438F,
+ -94.9707F,
+ 131.104F,
+ 325.195F,
+ 307.129F,
+ -138.428F,
+ -184.326F,
+ -377.197F,
+ 17.3340F,
+ -69.0918F,
+ 154.297F,
+ -41.5039F,
+ -117.432F,
+ -120.361F,
+ 166.260F,
+ 244.629F,
+ 199.463F,
+ -86.9141F,
+ -80.8105F,
+ -214.111F,
+ 102.295F,
+ 172.363F,
+ 84.4727F,
+ 58.8379F,
+ -8.30078F,
+ -79.5898F,
+ 92.0410F,
+ 476.074F,
+ 459.717F,
+ -177.490F,
+ -262.451F,
+ -396.729F,
+ -56.8848F,
+ -132.568F,
+ 28.3203F,
+ -127.930F,
+ -196.777F,
+ -142.822F,
+ -17.8223F,
+ 116.699F,
+ 177.979F,
+ -70.3125F,
+ -225.830F,
+ -279.053F,
+ 42.2363F,
+ 109.131F,
+ -12.6953F,
+ 16.6016F,
+ -55.9082F,
+ -147.949F,
+ 109.619F,
+ 129.150F,
+ 438.721F,
+ -144.287F,
+ -213.623F,
+ -332.764F,
+ 44.6777F,
+ -35.1563F,
+ 79.1016F,
+ -25.1465F,
+ -110.352F,
+ -162.598F,
+ 152.100F,
+ 119.141F,
+ 287.109F,
+ -58.1055F,
+ -124.756F,
+ -245.117F,
+ 79.5898F,
+ 134.766F,
+ 111.816F,
+ 33.2031F,
+ 26.3672F,
+ -77.8809F,
+ 152.832F,
+ 327.881F,
+ 459.717F,
+ -119.629F,
+ -157.715F,
+ -422.363F,
+ -45.4102F,
+ -109.619F,
+ 240.234F,
+ -180.176F,
+ -18.5547F,
+ -41.5039F,
+ -134.277F,
+ 184.326F,
+ 625.000F,
+ -121.094F,
+ -124.512F,
+ -231.201F,
+ 51.2695F,
+ 169.434F,
+ -12.6953F,
+ 20.5078F,
+ -78.6133F,
+ -48.5840F,
+ 266.113F,
+ 396.729F,
+ 298.828F,
+ -91.7969F,
+ -147.217F,
+ -340.820F,
+ 83.7402F,
+ 18.0664F,
+ 154.297F,
+ -42.7246F,
+ -122.559F,
+ -7.81250F,
+ 237.305F,
+ 325.195F,
+ 179.199F,
+ 12.6953F,
+ -72.0215F,
+ -271.729F,
+ 260.010F,
+ 224.121F,
+ 39.0625F,
+ 95.9473F,
+ 26.1230F,
+ -96.9238F,
+ 296.387F,
+ 646.729F,
+ 425.049F,
+ -154.297F,
+ -293.213F,
+ -461.670F,
+ -175.537F,
+ -67.6270F,
+ 86.1816F,
+ -158.936F,
+ -214.844F,
+ -29.7852F,
+ -51.5137F,
+ 51.0254F,
+ 326.660F,
+ -137.207F,
+ -174.316F,
+ -258.545F,
+ -50.7813F,
+ 94.7266F,
+ 38.8184F,
+ -78.1250F,
+ -14.8926F,
+ -134.521F,
+ 71.5332F,
+ 266.602F,
+ 352.295F,
+ -158.203F,
+ -211.182F,
+ -305.908F,
+ -11.9629F,
+ -34.9121F,
+ 74.4629F,
+ -97.9004F,
+ -55.4199F,
+ -142.822F,
+ 136.963F,
+ 129.883F,
+ 226.318F,
+ -28.5645F,
+ -108.154F,
+ -290.039F,
+ 123.779F,
+ 106.445F,
+ 71.2891F,
+ -19.2871F,
+ 56.8848F,
+ -111.816F,
+ 163.818F,
+ 250.244F,
+ 584.961F,
+ -154.541F,
+ -205.566F,
+ -372.314F,
+ -75.1953F,
+ -69.8242F,
+ 156.250F,
+ -91.0645F,
+ -151.611F,
+ -99.3652F,
+ 102.051F,
+ 61.7676F,
+ 318.604F,
+ -76.9043F,
+ -141.846F,
+ -277.588F,
+ 139.648F,
+ 167.236F,
+ -68.6035F,
+ 14.8926F,
+ -16.6016F,
+ -90.5762F,
+ 241.943F,
+ 268.799F,
+ 365.723F,
+ -120.361F,
+ -166.748F,
+ -332.520F,
+ -11.4746F,
+ 40.0391F,
+ 171.875F,
+ -62.5000F,
+ -76.6602F,
+ -65.4297F,
+ 154.053F,
+ 231.689F,
+ 256.836F,
+ -28.8086F,
+ -84.9609F,
+ -203.369F,
+ 16.6016F,
+ 288.086F,
+ 138.672F,
+ 37.1094F,
+ 28.5645F,
+ 8.30078F,
+ 271.729F,
+ 464.355F,
+ 546.631F,
+ -146.729F,
+ -234.131F,
+ -416.504F,
+ -34.9121F,
+ -119.385F,
+ 117.188F,
+ -81.0547F,
+ -159.912F,
+ -140.137F,
+ 13.1836F,
+ 86.1816F,
+ 291.016F,
+ -112.793F,
+ -159.180F,
+ -194.336F,
+ 36.6211F,
+ 134.033F,
+ 27.3438F,
+ 47.6074F,
+ -27.0996F,
+ -125.732F,
+ 165.771F,
+ 270.508F,
+ 402.100F,
+ -136.230F,
+ -182.861F,
+ -297.119F,
+ -2.19727F,
+ 66.4063F,
+ 83.2520F,
+ -12.9395F,
+ -64.6973F,
+ -130.615F,
+ 119.385F,
+ 205.811F,
+ 316.895F,
+ -29.2969F,
+ -117.676F,
+ -251.953F,
+ 154.297F,
+ 132.568F,
+ 99.6094F,
+ 43.7012F,
+ 74.7070F,
+ -128.418F,
+ 274.414F,
+ 357.422F,
+ 547.852F,
+ -101.807F,
+ -191.895F,
+ -381.348F,
+ -54.6875F,
+ -93.7500F,
+ 333.008F,
+ -92.0410F,
+ -112.061F,
+ -6.10352F,
+ 93.9941F,
+ 119.385F,
+ 530.762F,
+ -81.0547F,
+ -158.936F,
+ -202.393F,
+ 132.813F,
+ 135.010F,
+ 14.8926F,
+ 5.37109F,
+ -27.5879F,
+ -21.7285F,
+ 275.391F,
+ 421.143F,
+ 372.070F,
+ -52.7344F,
+ -91.0645F,
+ -403.564F,
+ 39.3066F,
+ 77.1484F,
+ 221.680F,
+ -40.2832F,
+ -54.1992F,
+ -16.3574F,
+ 332.520F,
+ 286.865F,
+ 192.627F,
+ 17.8223F,
+ -61.5234F,
+ -187.256F,
+ 180.176F,
+ 227.539F,
+ 150.391F,
+ 88.3789F,
+ 60.0586F,
+ -30.7617F,
+ 192.139F,
+ 647.949F,
+ 739.014F,
+ -168.701F,
+ -270.020F,
+ -534.668F,
+ -137.939F,
+ -143.555F,
+ 127.930F,
+ -144.043F,
+ -239.014F,
+ -119.629F,
+ -64.2090F,
+ 96.9238F,
+ 239.746F,
+ -140.869F,
+ -204.346F,
+ -230.713F,
+ -5.37109F,
+ 106.201F,
+ -11.9629F,
+ -46.3867F,
+ -28.8086F,
+ -153.564F,
+ -21.4844F,
+ 302.734F,
+ 369.385F,
+ -155.273F,
+ -256.592F,
+ -248.779F,
+ -71.0449F,
+ 46.1426F,
+ 63.2324F,
+ -62.7441F,
+ -114.746F,
+ -153.564F,
+ 35.4004F,
+ 230.713F,
+ 218.262F,
+ -79.5898F,
+ -88.8672F,
+ -267.090F,
+ 132.568F,
+ 63.4766F,
+ 153.809F,
+ -49.3164F,
+ 46.1426F,
+ -51.0254F,
+ 87.1582F,
+ 336.670F,
+ 510.498F,
+ -138.916F,
+ -262.451F,
+ -353.760F,
+ -174.316F,
+ -58.3496F,
+ 224.365F,
+ -102.539F,
+ -172.119F,
+ -20.5078F,
+ -26.6113F,
+ -27.8320F,
+ 587.646F,
+ -100.830F,
+ -129.150F,
+ -287.354F,
+ 117.676F,
+ 89.8438F,
+ 31.9824F,
+ -45.4102F,
+ -17.5781F,
+ -31.9824F,
+ 210.205F,
+ 306.396F,
+ 297.852F,
+ -149.170F,
+ -160.645F,
+ -327.393F,
+ 55.4199F,
+ -29.5410F,
+ 154.053F,
+ -42.9688F,
+ -119.385F,
+ -53.2227F,
+ 181.885F,
+ 286.865F,
+ 233.643F,
+ -78.3691F,
+ -36.1328F,
+ -228.516F,
+ 163.818F,
+ 235.840F,
+ 52.7344F,
+ 83.0078F,
+ -0.732422F,
+ -34.9121F,
+ 114.502F,
+ 451.172F,
+ 594.971F,
+ -177.979F,
+ -234.619F,
+ -410.889F,
+ -52.0020F,
+ -62.0117F,
+ 78.3691F,
+ -124.756F,
+ -106.934F,
+ -127.197F,
+ -30.7617F,
+ 177.002F,
+ 220.459F,
+ -83.0078F,
+ -167.236F,
+ -251.953F,
+ 77.1484F,
+ 117.188F,
+ 4.88281F,
+ 5.61523F,
+ -21.7285F,
+ -134.521F,
+ 86.1816F,
+ 256.592F,
+ 436.768F,
+ -132.813F,
+ -184.814F,
+ -333.008F,
+ 72.7539F,
+ -6.10352F,
+ 106.445F,
+ -24.4141F,
+ -95.7031F,
+ -126.709F,
+ 114.014F,
+ 184.082F,
+ 263.184F,
+ -51.2695F,
+ -97.1680F,
+ -263.184F,
+ 151.367F,
+ 160.645F,
+ 153.809F,
+ 8.05664F,
+ 35.8887F,
+ -43.4570F,
+ 224.854F,
+ 411.865F,
+ 468.994F,
+ -79.3457F,
+ -128.906F,
+ -482.910F,
+ 0.488281F,
+ -69.5801F,
+ 222.168F,
+ -90.5762F,
+ -119.629F,
+ -56.1523F,
+ 0.000000F,
+ 145.752F,
+ 490.723F,
+ -121.094F,
+ -96.4355F,
+ -203.613F,
+ 9.03320F,
+ 230.713F,
+ 59.8145F,
+ 44.1895F,
+ -39.0625F,
+ -35.1563F,
+ 361.572F,
+ 335.205F,
+ 331.299F,
+ -86.6699F,
+ -146.729F,
+ -310.059F,
+ 72.7539F,
+ 78.6133F,
+ 164.063F,
+ -47.1191F,
+ -82.0313F,
+ 18.7988F,
+ 265.869F,
+ 374.268F,
+ 225.098F,
+ 43.2129F,
+ -9.52148F,
+ -274.658F,
+ 243.164F,
+ 190.674F,
+ 130.859F,
+ 111.328F,
+ 89.3555F,
+ -105.469F,
+ 345.459F,
+ 595.703F,
+ 556.396F,
+ -113.770F,
+ -185.059F,
+ -567.627F,
+ -73.9746F,
+ -124.268F,
+ 94.4824F,
+ -177.490F,
+ -135.986F,
+ 16.1133F,
+ -35.4004F,
+ 156.982F,
+ 304.688F,
+ -132.813F,
+ -165.039F,
+ -223.633F,
+ -54.9316F,
+ 210.449F,
+ 143.555F,
+ -37.1094F,
+ 9.76563F,
+ -130.127F,
+ 103.271F,
+ 347.412F,
+ 380.371F,
+ -139.648F,
+ -205.811F,
+ -279.541F,
+ -31.2500F,
+ 20.7520F,
+ 112.549F,
+ -58.1055F,
+ -62.7441F,
+ -142.578F,
+ 147.705F,
+ 182.617F,
+ 210.205F,
+ 5.85938F,
+ -49.3164F,
+ -343.994F,
+ 194.580F,
+ 118.896F,
+ 73.9746F,
+ -44.1895F,
+ 88.8672F,
+ -44.4336F,
+ 150.391F,
+ 336.426F,
+ 718.262F,
+ -120.605F,
+ -208.008F,
+ -351.807F,
+ -71.2891F,
+ 14.8926F,
+ 198.242F,
+ -20.5078F,
+ -176.514F,
+ -44.4336F,
+ 135.498F,
+ 129.883F,
+ 367.676F,
+ -89.1113F,
+ -120.361F,
+ -258.057F,
+ 200.684F,
+ 143.555F,
+ 2.68555F,
+ -3.41797F,
+ -4.39453F,
+ -56.1523F,
+ 244.385F,
+ 342.041F,
+ 354.248F,
+ -115.723F,
+ -138.916F,
+ -315.430F,
+ 73.7305F,
+ 15.1367F,
+ 259.277F,
+ -17.0898F,
+ -91.7969F,
+ -54.1992F,
+ 239.746F,
+ 237.793F,
+ 280.518F,
+ -47.8516F,
+ -57.1289F,
+ -194.092F,
+ 116.943F,
+ 268.066F,
+ 121.826F,
+ 88.3789F,
+ 14.1602F,
+ 17.0898F,
+ 280.029F,
+ 505.127F,
+ 697.510F,
+ -118.896F,
+ -214.355F,
+ -445.313F,
+ 17.8223F,
+ -70.3125F,
+ 84.9609F,
+ -87.4023F,
+ -122.070F,
+ -124.023F,
+ 48.5840F,
+ 176.025F,
+ 303.223F,
+ -19.0430F,
+ -170.166F,
+ -194.092F,
+ 88.1348F,
+ 130.859F,
+ 47.8516F,
+ 91.3086F,
+ 26.8555F,
+ -179.443F,
+ 206.787F,
+ 256.592F,
+ 462.891F,
+ -89.3555F,
+ -174.072F,
+ -288.574F,
+ 76.9043F,
+ 78.1250F,
+ 104.736F,
+ 17.5781F,
+ -52.4902F,
+ -109.863F,
+ 185.303F,
+ 216.309F,
+ 332.764F,
+ -7.32422F,
+ -104.492F,
+ -203.613F,
+ 210.205F,
+ 153.076F,
+ 194.336F,
+ 28.8086F,
+ 114.258F,
+ -68.1152F,
+ 330.811F,
+ 459.717F,
+ 462.158F,
+ -45.8984F,
+ -156.738F,
+ -393.555F,
+ 15.3809F,
+ -42.7246F,
+ 292.480F,
+ -102.051F,
+ -51.5137F,
+ 12.4512F,
+ 101.074F,
+ 143.311F,
+ 635.010F,
+ -57.1289F,
+ -135.986F,
+ -209.473F,
+ 103.516F,
+ 217.041F,
+ 54.1992F,
+ 33.2031F,
+ -24.6582F,
+ 20.2637F,
+ 344.971F,
+ 556.152F,
+ 337.646F,
+ -20.5078F,
+ -108.643F,
+ -339.111F,
+ 101.074F,
+ 76.4160F,
+ 255.127F,
+ 7.08008F,
+ -83.7402F,
+ 15.8691F,
+ 378.906F,
+ 402.100F,
+ 239.258F,
+ 44.6777F,
+ -22.2168F,
+ -202.393F,
+ 310.791F,
+ 344.971F,
+ 87.8906F,
+ 135.010F,
+ 66.4063F,
+ -26.1230F,
+ 387.451F,
+ 768.799F,
+ 635.498F
+
+};
+
+/*
+ * Quantization tables for split_MQ of 2 sets of LSFs in a 20 ms frame.
+ */
+#define DICO1_SIZE_5 128
+#define DICO2_SIZE_5 256
+#define DICO3_SIZE_5 256
+#define DICO4_SIZE_5 256
+#define DICO5_SIZE_5 64
+static const Float32 dico1_lsf_5[DICO1_SIZE_5 * 4] =
+{
+ -110.107F,
+ -260.010F,
+ -129.150F,
+ -318.604F,
+ -109.863F,
+ -184.570F,
+ -121.338F,
+ -210.693F,
+ -93.7500F,
+ -151.123F,
+ -100.830F,
+ -163.330F,
+ -77.3926F,
+ -131.348F,
+ -80.8105F,
+ -135.742F,
+ -101.074F,
+ -124.023F,
+ -103.516F,
+ -92.2852F,
+ -66.8945F,
+ -79.1016F,
+ -105.957F,
+ -149.902F,
+ -55.1758F,
+ -122.070F,
+ -56.6406F,
+ -125.488F,
+ -64.2090F,
+ -92.0410F,
+ -72.7539F,
+ -100.098F,
+ -36.8652F,
+ -173.340F,
+ -42.4805F,
+ -199.707F,
+ -36.3770F,
+ -100.586F,
+ -38.0859F,
+ -104.736F,
+ -70.3125F,
+ -112.793F,
+ -45.4102F,
+ -49.5605F,
+ -41.5039F,
+ -73.7305F,
+ -46.6309F,
+ -78.3691F,
+ -31.9824F,
+ -35.8887F,
+ -72.5098F,
+ -96.4355F,
+ -55.6641F,
+ -52.2461F,
+ -59.8145F,
+ -46.8750F,
+ -16.3574F,
+ -77.1484F,
+ -17.3340F,
+ -79.8340F,
+ -25.3906F,
+ -50.0488F,
+ -22.9492F,
+ -44.6777F,
+ -34.9121F,
+ -9.27734F,
+ -47.1191F,
+ -23.1934F,
+ 3.90625F,
+ -18.5547F,
+ -30.2734F,
+ -60.5469F,
+ 5.61523F,
+ -57.8613F,
+ 5.85938F,
+ -59.5703F,
+ 4.39453F,
+ -33.2031F,
+ 10.7422F,
+ -27.0996F,
+ -8.05664F,
+ -5.85938F,
+ -6.10352F,
+ 0.000000F,
+ 36.3770F,
+ 4.63867F,
+ 5.61523F,
+ -34.9121F,
+ 38.5742F,
+ -41.2598F,
+ 42.4805F,
+ -44.1895F,
+ 32.4707F,
+ -13.4277F,
+ 40.2832F,
+ -6.34766F,
+ 27.0996F,
+ 20.5078F,
+ 23.9258F,
+ 18.3105F,
+ 21.2402F,
+ 44.6777F,
+ -28.0762F,
+ -2.68555F,
+ -1.95313F,
+ 31.7383F,
+ 2.68555F,
+ 41.5039F,
+ 62.0117F,
+ 18.7988F,
+ 50.0488F,
+ 4.15039F,
+ 44.6777F,
+ 27.3438F,
+ 63.9648F,
+ 47.3633F,
+ 49.3164F,
+ 70.0684F,
+ 23.1934F,
+ 46.1426F,
+ -10.2539F,
+ -25.6348F,
+ 57.1289F,
+ 43.7012F,
+ 9.52148F,
+ 45.4102F,
+ 39.7949F,
+ 84.2285F,
+ 81.0547F,
+ 48.5840F,
+ 72.9980F,
+ 39.3066F,
+ -13.1836F,
+ 69.5801F,
+ -19.0430F,
+ 68.6035F,
+ -32.4707F,
+ 34.4238F,
+ -44.4336F,
+ 27.0996F,
+ 60.7910F,
+ 83.2520F,
+ 66.1621F,
+ 88.8672F,
+ 22.7051F,
+ 98.3887F,
+ 18.3105F,
+ 95.4590F,
+ 22.4609F,
+ 124.512F,
+ -33.6914F,
+ 53.7109F,
+ -45.1660F,
+ -7.08008F,
+ -8.30078F,
+ 88.1348F,
+ -28.0762F,
+ 78.1250F,
+ 0.732422F,
+ 135.254F,
+ 24.1699F,
+ 69.8242F,
+ 53.2227F,
+ 144.287F,
+ -59.8145F,
+ 99.1211F,
+ -65.4297F,
+ 110.596F,
+ 0.000000F,
+ 141.602F,
+ 6.10352F,
+ 147.949F,
+ 67.1387F,
+ 129.883F,
+ 36.1328F,
+ 109.863F,
+ -17.8223F,
+ 180.420F,
+ -69.5801F,
+ 126.465F,
+ -70.3125F,
+ 22.9492F,
+ -49.5605F,
+ 164.551F,
+ -34.1797F,
+ -18.0664F,
+ 50.0488F,
+ 174.316F,
+ -27.8320F,
+ 72.9980F,
+ 42.9688F,
+ 225.342F,
+ 44.4336F,
+ 135.986F,
+ 58.5938F,
+ 172.119F,
+ -3.90625F,
+ 125.244F,
+ 118.408F,
+ 144.775F,
+ 71.5332F,
+ 93.7500F,
+ 110.107F,
+ 150.635F,
+ -9.27734F,
+ 12.2070F,
+ 137.451F,
+ 129.150F,
+ 73.9746F,
+ 51.0254F,
+ 112.061F,
+ 88.6230F,
+ 105.713F,
+ 110.352F,
+ 109.863F,
+ 110.840F,
+ 89.5996F,
+ 147.949F,
+ 116.455F,
+ 180.908F,
+ 105.469F,
+ 86.1816F,
+ 89.8438F,
+ 65.1855F,
+ 88.1348F,
+ 174.805F,
+ 66.6504F,
+ 142.334F,
+ 110.596F,
+ 40.5273F,
+ 124.512F,
+ 41.9922F,
+ 49.0723F,
+ 153.564F,
+ 66.8945F,
+ 46.6309F,
+ 138.672F,
+ 156.006F,
+ 73.7305F,
+ 72.7539F,
+ 154.785F,
+ 94.4824F,
+ 156.982F,
+ 85.4492F,
+ 143.311F,
+ 136.719F,
+ 149.414F,
+ 137.939F,
+ 146.484F,
+ 192.383F,
+ 118.896F,
+ 164.063F,
+ 125.000F,
+ 247.803F,
+ 78.3691F,
+ 81.2988F,
+ 87.1582F,
+ 208.496F,
+ -30.5176F,
+ 100.830F,
+ 115.723F,
+ 173.828F,
+ 4.15039F,
+ -36.8652F,
+ 137.695F,
+ 69.5801F,
+ 65.9180F,
+ -58.8379F,
+ 237.061F,
+ 217.041F,
+ 119.385F,
+ 53.7109F,
+ 124.512F,
+ 218.750F,
+ 134.033F,
+ 225.586F,
+ 79.8340F,
+ 201.416F,
+ 70.8008F,
+ 222.412F,
+ 131.836F,
+ 270.508F,
+ 38.5742F,
+ 196.533F,
+ 48.5840F,
+ 233.643F,
+ 124.756F,
+ 178.223F,
+ 24.4141F,
+ 213.379F,
+ 3.17383F,
+ 193.115F,
+ 106.201F,
+ 154.297F,
+ 165.039F,
+ 237.305F,
+ 60.7910F,
+ 219.727F,
+ 114.014F,
+ 297.363F,
+ 190.674F,
+ 262.207F,
+ 142.822F,
+ 191.650F,
+ -5.61523F,
+ 163.330F,
+ 65.1855F,
+ 254.639F,
+ 151.123F,
+ 264.648F,
+ 150.146F,
+ 279.541F,
+ 151.855F,
+ 220.947F,
+ 223.633F,
+ 256.104F,
+ 19.5313F,
+ 80.8105F,
+ 142.578F,
+ 262.451F,
+ 21.7285F,
+ 156.006F,
+ 241.211F,
+ 234.619F,
+ 187.988F,
+ 175.781F,
+ 194.824F,
+ 170.654F,
+ 120.117F,
+ 109.131F,
+ 219.482F,
+ 153.076F,
+ 66.1621F,
+ 290.039F,
+ 177.002F,
+ 325.439F,
+ 21.2402F,
+ 147.217F,
+ 203.125F,
+ 391.357F,
+ 150.391F,
+ 275.146F,
+ 217.285F,
+ 367.432F,
+ 244.141F,
+ 282.227F,
+ 211.426F,
+ 246.338F,
+ 242.920F,
+ 201.904F,
+ 280.518F,
+ 209.473F,
+ 199.463F,
+ 354.004F,
+ 188.721F,
+ 322.266F,
+ 122.070F,
+ 339.111F,
+ 76.1719F,
+ 281.494F,
+ -4.88281F,
+ 264.648F,
+ 15.6250F,
+ 313.232F,
+ 0.488281F,
+ 286.133F,
+ 97.4121F,
+ 456.299F,
+ 125.488F,
+ 416.504F,
+ 122.559F,
+ 399.414F,
+ 216.309F,
+ 371.582F,
+ 101.563F,
+ 146.484F,
+ 276.123F,
+ 329.590F,
+ 311.279F,
+ 339.355F,
+ 217.041F,
+ 438.232F,
+ 223.145F,
+ 431.152F,
+ 55.4199F,
+ 288.818F,
+ 305.176F,
+ 445.801F,
+ 123.291F,
+ 452.637F,
+ 224.365F,
+ 574.463F,
+ -48.5840F,
+ 105.225F,
+ 37.1094F,
+ 423.584F,
+ -52.0020F,
+ -6.83594F,
+ 95.7031F,
+ 325.684F,
+ -37.3535F,
+ -12.6953F,
+ 238.770F,
+ 281.006F,
+ -78.8574F,
+ -97.6563F,
+ 198.486F,
+ 415.771F,
+ -33.2031F,
+ 20.5078F,
+ 353.760F,
+ 491.943F,
+ -80.8105F,
+ -34.9121F,
+ -33.4473F,
+ 291.016F,
+ -62.5000F,
+ 130.371F,
+ -38.3301F,
+ 251.709F,
+ -74.9512F,
+ -107.178F,
+ 132.324F,
+ 178.467F,
+ -80.3223F,
+ -102.539F,
+ -23.6816F,
+ 150.391F,
+ -88.3789F,
+ -41.0156F,
+ -78.6133F,
+ 89.3555F,
+ -60.3027F,
+ -26.8555F,
+ -51.5137F,
+ 21.7285F,
+ -47.8516F,
+ -75.4395F,
+ 4.88281F,
+ 14.4043F,
+ -88.8672F,
+ -113.037F,
+ -69.8242F,
+ 21.7285F,
+ -82.0313F,
+ 42.7246F,
+ -105.469F,
+ 34.4238F,
+ -92.5293F,
+ -46.3867F,
+ -105.957F,
+ -47.8516F,
+ -19.2871F,
+ 36.6211F,
+ -67.8711F,
+ -55.4199F,
+ -68.3594F,
+ 40.5273F,
+ -135.498F,
+ -103.027F,
+ -37.8418F,
+ 132.080F,
+ -89.3555F,
+ 13.1836F,
+ -7.08008F,
+ -20.2637F,
+ -73.4863F,
+ -188.965F,
+ 45.4102F,
+ 153.320F,
+ -96.9238F,
+ -64.4531F,
+ 59.0820F,
+ 71.5332F,
+ -48.0957F,
+ -142.822F,
+ 30.2734F,
+ 100.098F,
+ 12.9395F,
+ -32.4707F,
+ 2.44141F,
+ 83.0078F,
+ -139.160F,
+ -260.010F,
+ 15.8691F,
+ -108.887F,
+ 16.6016F,
+ -120.361F,
+ 93.5059F,
+ 228.760F,
+ -87.1582F,
+ -173.584F,
+ -87.6465F,
+ -61.0352F,
+ -165.283F,
+ -260.742F,
+ 71.2891F,
+ -6.34766F,
+ 88.6230F,
+ 1.46484F,
+ 148.193F,
+ 320.557F,
+ -31.0059F,
+ -2.44141F,
+ 369.385F,
+ 460.449F,
+ 174.072F,
+ 237.305F,
+ 358.643F,
+ 532.471F,
+ 352.295F,
+ 492.188F
+
+};
+static const Float32 dico2_lsf_5[DICO2_SIZE_5 * 4] =
+{
+ -398.193F,
+ -390.625F,
+ -438.477F,
+ -559.082F,
+ -250.732F,
+ -432.129F,
+ -268.555F,
+ -494.385F,
+ -311.768F,
+ -338.867F,
+ -333.740F,
+ -374.512F,
+ -231.201F,
+ -356.689F,
+ -237.305F,
+ -372.070F,
+ -243.896F,
+ -298.340F,
+ -249.023F,
+ -286.133F,
+ -198.975F,
+ -240.967F,
+ -242.188F,
+ -334.717F,
+ -296.875F,
+ -245.605F,
+ -314.697F,
+ -267.090F,
+ -181.641F,
+ -309.570F,
+ -184.326F,
+ -315.674F,
+ -210.449F,
+ -225.342F,
+ -220.947F,
+ -240.234F,
+ -165.527F,
+ -256.592F,
+ -167.236F,
+ -256.348F,
+ -265.381F,
+ -240.479F,
+ -259.277F,
+ -165.771F,
+ -241.455F,
+ -156.494F,
+ -275.146F,
+ -238.281F,
+ -186.035F,
+ -159.668F,
+ -217.285F,
+ -196.777F,
+ -203.369F,
+ -266.357F,
+ -172.363F,
+ -153.564F,
+ -151.611F,
+ -196.777F,
+ -156.250F,
+ -198.242F,
+ -189.209F,
+ -154.785F,
+ -190.186F,
+ -132.568F,
+ -243.164F,
+ -137.939F,
+ -262.451F,
+ -141.602F,
+ -133.301F,
+ -149.170F,
+ -139.648F,
+ -151.123F,
+ -185.547F,
+ -70.8008F,
+ -214.600F,
+ -128.418F,
+ -200.928F,
+ -112.793F,
+ -194.092F,
+ -61.7676F,
+ -135.010F,
+ -101.318F,
+ -143.799F,
+ -107.178F,
+ -130.127F,
+ -83.0078F,
+ -168.945F,
+ -228.271F,
+ -123.291F,
+ -188.477F,
+ -171.387F,
+ -276.123F,
+ -64.2090F,
+ -74.7070F,
+ -237.061F,
+ -117.920F,
+ -108.643F,
+ -18.0664F,
+ -135.498F,
+ -133.789F,
+ -149.902F,
+ -31.4941F,
+ -169.189F,
+ -57.1289F,
+ -96.6797F,
+ -60.0586F,
+ -115.967F,
+ -61.0352F,
+ -64.6973F,
+ -98.6328F,
+ -91.7969F,
+ -125.488F,
+ -101.807F,
+ -124.512F,
+ -73.2422F,
+ -76.4160F,
+ -81.5430F,
+ -162.109F,
+ -113.037F,
+ -198.730F,
+ -94.2383F,
+ -171.875F,
+ -82.2754F,
+ -150.146F,
+ -57.1289F,
+ -49.0723F,
+ -56.8848F,
+ -58.3496F,
+ -40.7715F,
+ -138.428F,
+ -49.5605F,
+ -151.123F,
+ -35.8887F,
+ -101.318F,
+ -28.0762F,
+ -85.9375F,
+ -40.5273F,
+ -183.105F,
+ -41.7480F,
+ -185.791F,
+ -65.9180F,
+ -214.600F,
+ -64.4531F,
+ -220.459F,
+ -89.5996F,
+ -181.641F,
+ 10.4980F,
+ -115.967F,
+ 3.41797F,
+ -159.424F,
+ 10.4980F,
+ -163.574F,
+ 2.68555F,
+ -109.375F,
+ -14.4043F,
+ -127.197F,
+ -30.7617F,
+ -29.0527F,
+ -37.8418F,
+ -149.658F,
+ -10.2539F,
+ -210.693F,
+ -6.59180F,
+ -227.295F,
+ 33.2031F,
+ -117.920F,
+ 44.6777F,
+ -114.258F,
+ 13.4277F,
+ -72.7539F,
+ 13.4277F,
+ -74.2188F,
+ 76.4160F,
+ -148.682F,
+ 76.4160F,
+ -175.781F,
+ 78.6133F,
+ -40.7715F,
+ 24.4141F,
+ -132.080F,
+ -0.732422F,
+ -29.0527F,
+ -27.0996F,
+ -45.6543F,
+ 56.8848F,
+ -57.6172F,
+ 63.4766F,
+ -57.1289F,
+ 6.34766F,
+ -40.2832F,
+ 32.7148F,
+ -10.9863F,
+ -9.76563F,
+ -134.033F,
+ 87.8906F,
+ -49.5605F,
+ 92.2852F,
+ -94.7266F,
+ 109.863F,
+ -93.5059F,
+ 67.1387F,
+ 4.88281F,
+ 44.4336F,
+ -25.1465F,
+ 60.0586F,
+ -27.0996F,
+ 105.225F,
+ 9.03320F,
+ 112.793F,
+ -35.6445F,
+ 118.896F,
+ -38.3301F,
+ -69.3359F,
+ -14.4043F,
+ 122.803F,
+ -44.9219F,
+ 5.85938F,
+ 12.9395F,
+ -0.732422F,
+ 13.1836F,
+ 29.7852F,
+ 63.2324F,
+ 81.2988F,
+ 16.1133F,
+ 118.164F,
+ 25.3906F,
+ 106.445F,
+ 16.6016F,
+ 47.6074F,
+ 28.3203F,
+ 46.3867F,
+ 50.2930F,
+ 65.6738F,
+ -2.19727F,
+ 117.676F,
+ 85.9375F,
+ 93.2617F,
+ 69.5801F,
+ 97.4121F,
+ 67.6270F,
+ 110.352F,
+ 62.5000F,
+ 16.8457F,
+ 45.4102F,
+ 3.17383F,
+ 72.5098F,
+ -3.17383F,
+ 63.2324F,
+ -23.1934F,
+ 7.32422F,
+ 13.6719F,
+ 96.1914F,
+ 47.8516F,
+ 103.760F,
+ 50.0488F,
+ 111.328F,
+ 68.6035F,
+ 140.869F,
+ 3.66211F,
+ 46.6309F,
+ 91.5527F,
+ 70.8008F,
+ 99.3652F,
+ 140.625F,
+ -13.6719F,
+ 55.4199F,
+ 132.813F,
+ 98.8770F,
+ 0.000000F,
+ 134.033F,
+ -22.4609F,
+ 128.906F,
+ -55.9082F,
+ 85.6934F,
+ -59.8145F,
+ 82.5195F,
+ -88.3789F,
+ 106.201F,
+ 40.7715F,
+ 128.662F,
+ -18.3105F,
+ 73.7305F,
+ 22.2168F,
+ 201.172F,
+ 31.4941F,
+ 146.240F,
+ 121.094F,
+ 165.771F,
+ 45.4102F,
+ 182.861F,
+ 37.3535F,
+ 179.932F,
+ -68.6035F,
+ 146.484F,
+ -84.9609F,
+ 150.146F,
+ -57.6172F,
+ 187.744F,
+ 10.0098F,
+ 215.088F,
+ 9.27734F,
+ 217.285F,
+ -53.7109F,
+ 205.322F,
+ -87.1582F,
+ 215.576F,
+ -95.9473F,
+ 220.459F,
+ -154.785F,
+ 115.723F,
+ -108.398F,
+ 207.520F,
+ -42.7246F,
+ 165.527F,
+ -120.361F,
+ 59.0820F,
+ -126.709F,
+ 191.650F,
+ -174.316F,
+ 142.090F,
+ -132.080F,
+ 89.3555F,
+ -132.568F,
+ 105.957F,
+ -145.752F,
+ 122.070F,
+ -186.768F,
+ 54.1992F,
+ -171.387F,
+ 223.877F,
+ -181.396F,
+ 234.863F,
+ -212.158F,
+ 122.314F,
+ -219.482F,
+ 133.789F,
+ -92.5293F,
+ 48.8281F,
+ -106.201F,
+ 38.3301F,
+ -199.951F,
+ 52.2461F,
+ -210.205F,
+ 38.3301F,
+ -149.902F,
+ 9.76563F,
+ -154.297F,
+ 22.9492F,
+ -215.576F,
+ -13.1836F,
+ -180.908F,
+ 125.977F,
+ -122.314F,
+ 72.7539F,
+ -149.902F,
+ -41.7480F,
+ -212.402F,
+ -39.3066F,
+ -211.182F,
+ -5.61523F,
+ -199.707F,
+ 22.7051F,
+ -247.803F,
+ -65.1855F,
+ -161.621F,
+ -87.6465F,
+ -134.033F,
+ 0.488281F,
+ -107.910F,
+ -29.5410F,
+ -92.0410F,
+ 0.000000F,
+ -55.4199F,
+ 8.05664F,
+ -101.074F,
+ -30.7617F,
+ -31.4941F,
+ 51.7578F,
+ -228.027F,
+ 8.30078F,
+ -264.160F,
+ -68.8477F,
+ -273.193F,
+ -65.4297F,
+ -173.340F,
+ -201.416F,
+ -102.539F,
+ -46.6309F,
+ -262.695F,
+ -226.563F,
+ -223.877F,
+ -22.7051F,
+ -153.320F,
+ -87.4023F,
+ 23.6816F,
+ 1.70898F,
+ -50.2930F,
+ -95.9473F,
+ -24.6582F,
+ 5.85938F,
+ -49.5605F,
+ 9.27734F,
+ -41.0156F,
+ 20.2637F,
+ -146.240F,
+ -103.271F,
+ -68.1152F,
+ 104.004F,
+ -170.898F,
+ 28.8086F,
+ -18.3105F,
+ 50.2930F,
+ -239.502F,
+ -164.307F,
+ -166.016F,
+ 101.807F,
+ -89.5996F,
+ 9.03320F,
+ -68.1152F,
+ 115.723F,
+ -31.4941F,
+ -77.6367F,
+ 77.8809F,
+ 72.2656F,
+ -152.832F,
+ -9.52148F,
+ 83.7402F,
+ 146.973F,
+ -169.922F,
+ -9.52148F,
+ -73.9746F,
+ 229.492F,
+ 25.3906F,
+ 56.8848F,
+ -92.7734F,
+ 33.4473F,
+ -8.78906F,
+ 65.6738F,
+ -18.3105F,
+ -52.2461F,
+ 29.2969F,
+ 10.4980F,
+ -129.150F,
+ -116.455F,
+ 112.061F,
+ 40.0391F,
+ -49.3164F,
+ -55.9082F,
+ -11.9629F,
+ -40.7715F,
+ 148.682F,
+ 193.359F,
+ 23.9258F,
+ -53.7109F,
+ 223.389F,
+ 36.1328F,
+ 71.5332F,
+ 69.0918F,
+ 212.158F,
+ 22.2168F,
+ 140.381F,
+ 96.1914F,
+ 79.5898F,
+ -19.0430F,
+ 175.049F,
+ 16.3574F,
+ 89.1113F,
+ -78.8574F,
+ 150.391F,
+ -8.78906F,
+ 178.467F,
+ 6.59180F,
+ 151.123F,
+ 58.1055F,
+ 154.297F,
+ 66.6504F,
+ 109.375F,
+ 24.1699F,
+ 195.557F,
+ 116.211F,
+ 212.158F,
+ 66.6504F,
+ 167.236F,
+ 15.6250F,
+ 192.627F,
+ 17.5781F,
+ 249.268F,
+ 52.9785F,
+ 193.604F,
+ 112.061F,
+ 179.199F,
+ 87.8906F,
+ 157.715F,
+ 117.188F,
+ 87.8906F,
+ 78.6133F,
+ 104.736F,
+ 113.281F,
+ 155.762F,
+ 104.980F,
+ 184.570F,
+ 88.6230F,
+ 244.141F,
+ 98.6328F,
+ 166.748F,
+ 128.906F,
+ 146.973F,
+ 150.146F,
+ 159.912F,
+ 100.830F,
+ 230.957F,
+ 167.725F,
+ 228.760F,
+ 146.973F,
+ 220.703F,
+ 147.461F,
+ 135.498F,
+ 179.932F,
+ 191.895F,
+ 161.621F,
+ 114.014F,
+ 159.668F,
+ 88.3789F,
+ 143.799F,
+ 226.807F,
+ 173.340F,
+ 121.582F,
+ 116.699F,
+ 101.318F,
+ 102.539F,
+ 169.189F,
+ 215.576F,
+ 198.486F,
+ 166.748F,
+ 190.674F,
+ 225.830F,
+ 222.900F,
+ 229.248F,
+ 177.246F,
+ 178.711F,
+ 119.873F,
+ 208.252F,
+ 129.639F,
+ 231.445F,
+ 179.199F,
+ 235.107F,
+ 76.9043F,
+ 197.266F,
+ 185.791F,
+ 184.326F,
+ 279.297F,
+ 185.547F,
+ 159.912F,
+ 262.695F,
+ 201.660F,
+ 258.057F,
+ 266.357F,
+ 204.590F,
+ 244.873F,
+ 197.266F,
+ 255.615F,
+ 276.611F,
+ 160.889F,
+ 268.799F,
+ 242.188F,
+ 256.348F,
+ 262.207F,
+ 262.451F,
+ 237.061F,
+ 169.434F,
+ 299.316F,
+ 257.324F,
+ 139.404F,
+ 205.322F,
+ 215.820F,
+ 342.773F,
+ 336.670F,
+ 267.578F,
+ 263.672F,
+ 210.205F,
+ 300.537F,
+ 179.443F,
+ 313.477F,
+ 185.547F,
+ 310.547F,
+ 241.943F,
+ 333.740F,
+ 257.080F,
+ 306.885F,
+ 170.898F,
+ 256.348F,
+ 130.371F,
+ 241.211F,
+ 110.596F,
+ 308.594F,
+ 146.240F,
+ 278.320F,
+ 165.771F,
+ 395.752F,
+ 198.975F,
+ 337.891F,
+ 127.197F,
+ 321.533F,
+ 95.9473F,
+ 381.836F,
+ 196.533F,
+ 353.516F,
+ 167.480F,
+ 260.742F,
+ 158.203F,
+ 213.623F,
+ 74.9512F,
+ 264.404F,
+ 88.1348F,
+ 255.615F,
+ 77.3926F,
+ 345.947F,
+ 235.352F,
+ 164.795F,
+ 139.404F,
+ 281.250F,
+ 19.2871F,
+ 271.973F,
+ -11.4746F,
+ 373.535F,
+ 75.9277F,
+ 420.166F,
+ 76.6602F,
+ 284.668F,
+ 168.213F,
+ 125.488F,
+ -22.9492F,
+ 85.2051F,
+ 68.8477F,
+ 344.727F,
+ 80.0781F,
+ 250.244F,
+ 118.896F,
+ -15.8691F,
+ 13.9160F,
+ 196.533F,
+ 236.816F,
+ 8.78906F,
+ 15.1367F,
+ 187.744F,
+ -64.2090F,
+ 193.115F,
+ -84.4727F,
+ 155.518F,
+ 170.654F,
+ -33.4473F,
+ 151.367F,
+ 130.371F,
+ 132.080F,
+ -179.443F,
+ 47.3633F,
+ 173.584F,
+ 73.2422F,
+ -65.4297F,
+ -210.693F,
+ 226.074F,
+ 187.744F,
+ -172.852F,
+ -104.492F,
+ 123.535F,
+ 42.4805F,
+ -217.773F,
+ -153.809F,
+ 106.201F,
+ 133.545F,
+ -350.342F,
+ -62.9883F,
+ 151.611F,
+ 114.990F,
+ -248.535F,
+ -333.984F,
+ -95.9473F,
+ 127.197F,
+ -224.609F,
+ -167.480F,
+ -6.10352F,
+ 4.88281F,
+ -239.746F,
+ -282.227F,
+ 83.0078F,
+ 2.19727F,
+ -380.371F,
+ -277.100F,
+ -85.9375F,
+ 11.7188F,
+ -385.498F,
+ -98.1445F,
+ -216.553F,
+ 1.46484F,
+ -282.227F,
+ -216.797F,
+ -133.789F,
+ -85.9375F,
+ -401.123F,
+ -285.156F,
+ -38.8184F,
+ 148.926F,
+ -494.141F,
+ -235.107F,
+ -54.9316F,
+ 47.1191F,
+ -404.297F,
+ -478.516F,
+ -59.8145F,
+ -120.361F,
+ -235.352F,
+ -410.156F,
+ -228.516F,
+ -155.029F,
+ -317.139F,
+ -425.781F,
+ -338.867F,
+ -147.461F,
+ -375.977F,
+ -203.857F,
+ -341.064F,
+ -32.9590F,
+ -387.695F,
+ -70.8008F,
+ -407.715F,
+ -173.828F,
+ -490.967F,
+ -398.438F,
+ -406.006F,
+ -6.59180F,
+ -551.270F,
+ -197.998F,
+ -282.471F,
+ 44.9219F,
+ -308.838F,
+ 46.1426F,
+ -333.740F,
+ 143.066F,
+ -490.967F,
+ 49.0723F,
+ -192.871F,
+ 173.828F,
+ -295.410F,
+ 0.732422F,
+ -252.197F,
+ 197.266F,
+ -305.420F,
+ 202.637F,
+ -27.0996F,
+ 155.029F,
+ -399.414F,
+ 109.131F,
+ -113.037F,
+ -231.689F,
+ -108.643F,
+ -226.563F,
+ -123.047F,
+ -283.691F,
+ -122.314F,
+ -295.654F,
+ 35.1563F,
+ -85.6934F,
+ -90.8203F,
+ -256.836F,
+ -69.0918F,
+ -258.545F,
+ -68.1152F,
+ -274.170F,
+ -140.381F,
+ -351.074F,
+ -143.311F,
+ -394.043F,
+ -228.271F,
+ -240.234F,
+ 55.9082F,
+ 168.457F,
+ -224.854F,
+ -175.537F,
+ -98.3887F,
+ 332.520F,
+ -167.236F,
+ -113.525F,
+ 213.379F,
+ 96.9238F,
+ -124.268F,
+ -11.2305F,
+ 77.3926F,
+ 325.684F,
+ -118.408F,
+ 111.328F,
+ 198.486F,
+ 107.178F,
+ -100.342F,
+ 82.7637F,
+ 219.238F,
+ 260.498F,
+ -103.760F,
+ 11.2305F,
+ 351.807F,
+ 121.338F,
+ -221.924F,
+ -195.313F,
+ 357.666F,
+ 255.371F,
+ -62.0117F,
+ -78.3691F,
+ 349.121F,
+ 284.424F,
+ 16.6016F,
+ 85.4492F,
+ 252.441F,
+ 162.598F,
+ 90.3320F,
+ 2.68555F,
+ 320.068F,
+ 192.871F,
+ 34.9121F,
+ 56.6406F,
+ 254.150F,
+ 381.348F,
+ -27.8320F,
+ 161.865F,
+ 394.531F,
+ 263.184F,
+ 110.840F,
+ 141.357F,
+ 311.279F,
+ 253.906F,
+ -18.5547F,
+ 221.924F,
+ 183.594F,
+ 260.498F,
+ 37.3535F,
+ 125.000F,
+ 84.9609F,
+ 296.387F,
+ 149.902F,
+ 93.9941F,
+ 449.951F,
+ 197.266F,
+ 65.6738F,
+ 252.441F,
+ 49.5605F,
+ 265.137F,
+ 159.180F,
+ 248.291F,
+ 435.303F,
+ 275.879F,
+ 104.736F,
+ 323.975F,
+ 94.4824F,
+ 337.891F,
+ -11.9629F,
+ 288.818F,
+ -17.5781F,
+ 296.631F,
+ -101.563F,
+ 244.385F,
+ 132.813F,
+ 427.002F,
+ -85.9375F,
+ 298.584F,
+ -122.559F,
+ 292.725F,
+ -143.799F,
+ 138.916F,
+ -55.4199F,
+ 397.949F,
+ -34.6680F,
+ 385.254F,
+ -56.1523F,
+ 418.701F,
+ -174.316F,
+ 314.453F,
+ -204.590F,
+ 341.309F,
+ 276.123F,
+ 331.299F,
+ -50.7813F,
+ 300.781F,
+ 106.689F,
+ 235.596F,
+ -226.807F,
+ 199.707F,
+ 197.998F,
+ 344.238F,
+ 209.717F,
+ 367.920F,
+ 40.0391F,
+ 295.898F,
+ 338.623F,
+ 437.744F,
+ 118.164F,
+ 457.520F,
+ 111.328F,
+ 503.662F,
+ 243.164F,
+ 285.645F,
+ 323.730F,
+ 342.285F,
+ 321.289F,
+ 332.031F,
+ 277.100F,
+ 308.105F,
+ 301.270F,
+ 395.020F,
+ 332.275F,
+ 431.641F,
+ 346.924F,
+ 299.561F,
+ 386.719F,
+ 328.857F,
+ 208.496F,
+ 164.063F,
+ 411.377F,
+ 382.324F,
+ 278.076F,
+ 310.059F,
+ 492.188F,
+ 445.557F,
+ 432.861F,
+ 385.986F,
+ 374.023F,
+ 356.445F,
+ 363.037F,
+ 230.957F,
+ 405.029F,
+ 249.268F,
+ 425.781F,
+ 295.898F,
+ 339.844F,
+ 238.525F,
+ 432.617F,
+ 283.447F,
+ 445.801F,
+ 284.180F,
+ 419.434F,
+ 348.877F,
+ 481.689F,
+ 388.428F,
+ 289.307F,
+ 210.938F,
+ 520.508F,
+ 259.033F,
+ 439.209F,
+ 198.730F,
+ 448.730F,
+ 184.814F,
+ 513.672F,
+ 321.045F,
+ 501.465F,
+ 307.129F,
+ 515.869F,
+ 223.389F,
+ 569.092F,
+ 227.051F,
+ 358.154F,
+ 280.029F,
+ 632.324F,
+ 351.318F,
+ 548.096F,
+ 425.781F,
+ 510.254F,
+ 395.508F,
+ 575.684F,
+ 354.980F,
+ 650.879F,
+ 367.676F,
+ 458.008F,
+ 448.486F,
+ 505.371F,
+ 482.178F,
+ 424.561F,
+ 385.010F,
+ 166.504F,
+ 314.697F,
+ 386.719F,
+ 499.268F,
+ 354.980F,
+ 512.207F,
+ 609.863F,
+ 489.258F,
+ 661.865F,
+ 504.395F,
+ 177.246F,
+ 387.695F,
+ 672.852F,
+ 570.313F,
+ 55.6641F,
+ 206.787F,
+ 599.609F,
+ 405.029F,
+ 8.78906F,
+ 73.4863F,
+ 474.121F,
+ 477.783F,
+ -108.887F,
+ -23.4375F,
+ 525.879F,
+ 340.820F,
+ 374.268F,
+ 268.799F,
+ 3.41797F,
+ 148.438F,
+ -225.342F,
+ -178.711F,
+ 337.646F,
+ 483.887F,
+ 328.369F,
+ 232.422F,
+ -166.016F,
+ 78.3691F,
+ 312.744F,
+ 309.570F,
+ -389.160F,
+ 89.1113F,
+ 229.736F,
+ 230.957F,
+ -424.072F,
+ -200.684F,
+ 579.590F,
+ 680.420F,
+ 444.580F,
+ 680.664F
+
+};
+static const Float32 dico3_lsf_5[DICO3_SIZE_5 * 4] =
+{
+ -442.383F,
+ -555.420F,
+ -458.740F,
+ -619.385F,
+ -400.391F,
+ -451.172F,
+ -413.818F,
+ -489.258F,
+ -297.852F,
+ -466.797F,
+ -298.096F,
+ -514.160F,
+ -380.615F,
+ -387.695F,
+ -384.033F,
+ -379.883F,
+ -291.748F,
+ -394.287F,
+ -298.828F,
+ -421.631F,
+ -331.787F,
+ -281.006F,
+ -394.531F,
+ -475.586F,
+ -311.035F,
+ -339.600F,
+ -318.604F,
+ -342.529F,
+ -392.334F,
+ -287.842F,
+ -409.180F,
+ -320.068F,
+ -352.295F,
+ -360.840F,
+ -333.740F,
+ -219.238F,
+ -306.641F,
+ -258.545F,
+ -324.951F,
+ -276.855F,
+ -239.746F,
+ -276.611F,
+ -280.518F,
+ -367.188F,
+ -263.672F,
+ -319.336F,
+ -249.023F,
+ -288.818F,
+ -239.258F,
+ -362.793F,
+ -236.084F,
+ -364.990F,
+ -241.211F,
+ -225.098F,
+ -255.615F,
+ -262.939F,
+ -204.590F,
+ -287.842F,
+ -209.473F,
+ -298.340F,
+ -276.123F,
+ -254.150F,
+ -259.766F,
+ -187.256F,
+ -212.891F,
+ -282.471F,
+ -171.143F,
+ -214.844F,
+ -172.363F,
+ -221.191F,
+ -188.965F,
+ -248.047F,
+ -141.113F,
+ -263.672F,
+ -195.557F,
+ -360.840F,
+ -144.287F,
+ -271.240F,
+ -144.531F,
+ -279.785F,
+ -174.072F,
+ -338.867F,
+ -156.250F,
+ -335.938F,
+ -145.752F,
+ -258.545F,
+ -101.563F,
+ -220.459F,
+ -167.480F,
+ -203.125F,
+ -161.377F,
+ -172.852F,
+ -108.398F,
+ -211.914F,
+ -119.629F,
+ -224.854F,
+ -91.3086F,
+ -189.453F,
+ -151.123F,
+ -285.645F,
+ -142.822F,
+ -134.033F,
+ -187.744F,
+ -194.092F,
+ -106.201F,
+ -160.889F,
+ -129.395F,
+ -180.908F,
+ -121.582F,
+ -204.346F,
+ -87.1582F,
+ -145.752F,
+ -68.1152F,
+ -212.646F,
+ -59.3262F,
+ -216.553F,
+ -68.8477F,
+ -162.354F,
+ -68.3594F,
+ -162.842F,
+ -40.2832F,
+ -136.719F,
+ -96.1914F,
+ -220.459F,
+ -88.3789F,
+ -100.098F,
+ -109.375F,
+ -142.334F,
+ -99.8535F,
+ -140.137F,
+ -76.4160F,
+ -87.1582F,
+ -155.518F,
+ -133.789F,
+ -139.160F,
+ -106.445F,
+ -218.750F,
+ -123.047F,
+ -93.2617F,
+ -184.814F,
+ -14.1602F,
+ -117.432F,
+ -40.2832F,
+ -150.879F,
+ -46.6309F,
+ -91.3086F,
+ -57.1289F,
+ -93.2617F,
+ -54.1992F,
+ -166.748F,
+ -6.10352F,
+ -117.188F,
+ -102.051F,
+ -87.6465F,
+ -178.223F,
+ -86.1816F,
+ -79.1016F,
+ -38.3301F,
+ -105.469F,
+ -78.6133F,
+ -96.1914F,
+ -73.9746F,
+ -69.3359F,
+ -25.3906F,
+ -146.729F,
+ -70.5566F,
+ -135.742F,
+ -47.8516F,
+ -143.555F,
+ -36.6211F,
+ -160.889F,
+ -148.438F,
+ -115.479F,
+ -5.85938F,
+ -16.6016F,
+ -109.375F,
+ -115.723F,
+ -1.95313F,
+ -123.535F,
+ -10.9863F,
+ -182.617F,
+ -44.9219F,
+ -206.055F,
+ -61.5234F,
+ -219.971F,
+ -22.2168F,
+ -142.578F,
+ -23.6816F,
+ -159.180F,
+ 33.6914F,
+ -186.523F,
+ -31.9824F,
+ -165.527F,
+ -2.92969F,
+ -163.574F,
+ 40.2832F,
+ -63.2324F,
+ -0.732422F,
+ -205.078F,
+ -26.1230F,
+ -221.924F,
+ 9.03320F,
+ -242.188F,
+ 10.7422F,
+ -208.496F,
+ -101.318F,
+ -204.834F,
+ 3.17383F,
+ -244.385F,
+ -66.1621F,
+ -250.488F,
+ -75.4395F,
+ -194.824F,
+ -116.699F,
+ -203.125F,
+ -119.141F,
+ -230.225F,
+ 41.0156F,
+ -271.484F,
+ -94.4824F,
+ -289.307F,
+ -24.6582F,
+ -288.818F,
+ -9.76563F,
+ -229.736F,
+ -77.1484F,
+ -251.465F,
+ -187.988F,
+ -254.883F,
+ -152.588F,
+ -263.916F,
+ -131.348F,
+ -298.828F,
+ -72.9980F,
+ -320.313F,
+ -106.445F,
+ -292.236F,
+ -161.865F,
+ -284.912F,
+ -39.3066F,
+ -296.875F,
+ -168.457F,
+ -302.002F,
+ -202.881F,
+ -349.609F,
+ -175.781F,
+ -342.529F,
+ -120.361F,
+ -219.238F,
+ -180.664F,
+ -225.098F,
+ -195.557F,
+ -269.043F,
+ -98.1445F,
+ -385.498F,
+ -235.352F,
+ -259.033F,
+ -155.762F,
+ -309.814F,
+ -351.074F,
+ -365.967F,
+ -228.027F,
+ -366.699F,
+ -218.506F,
+ -390.137F,
+ -137.695F,
+ -420.654F,
+ -175.049F,
+ -147.949F,
+ -145.752F,
+ -284.668F,
+ -264.893F,
+ -334.229F,
+ -114.258F,
+ -475.098F,
+ -364.502F,
+ -448.730F,
+ -232.666F,
+ -471.680F,
+ -227.295F,
+ -365.967F,
+ -45.8984F,
+ -399.170F,
+ -102.783F,
+ -355.713F,
+ -82.5195F,
+ -353.516F,
+ -5.37109F,
+ -474.121F,
+ -103.027F,
+ -489.746F,
+ -60.7910F,
+ -121.094F,
+ -27.8320F,
+ -466.309F,
+ -184.326F,
+ -314.697F,
+ 42.4805F,
+ -354.248F,
+ -26.6113F,
+ -117.676F,
+ -62.7441F,
+ -298.096F,
+ -124.023F,
+ -394.775F,
+ 36.8652F,
+ -413.574F,
+ 50.7813F,
+ -159.668F,
+ 26.1230F,
+ -403.076F,
+ 7.08008F,
+ -278.564F,
+ 68.1152F,
+ -296.631F,
+ 74.7070F,
+ -299.805F,
+ -123.535F,
+ -178.223F,
+ -42.7246F,
+ -301.758F,
+ -24.6582F,
+ -236.572F,
+ 134.521F,
+ -212.402F,
+ 67.8711F,
+ -200.928F,
+ 76.9043F,
+ -137.451F,
+ 91.7969F,
+ -256.592F,
+ 55.6641F,
+ -123.779F,
+ 68.3594F,
+ -146.240F,
+ 68.6035F,
+ -185.059F,
+ 61.7676F,
+ -74.4629F,
+ 92.5293F,
+ -184.326F,
+ -32.7148F,
+ -149.170F,
+ 161.133F,
+ -201.172F,
+ 130.859F,
+ -199.463F,
+ 157.715F,
+ -100.830F,
+ 11.9629F,
+ -83.2520F,
+ 43.2129F,
+ -110.596F,
+ 128.418F,
+ -117.676F,
+ 143.799F,
+ -17.3340F,
+ 82.7637F,
+ -160.400F,
+ 64.4531F,
+ -59.5703F,
+ 72.0215F,
+ -57.8613F,
+ 76.9043F,
+ -94.4824F,
+ 138.916F,
+ -123.535F,
+ -2.19727F,
+ -92.0410F,
+ 3.41797F,
+ -39.0625F,
+ 161.377F,
+ -52.7344F,
+ 9.76563F,
+ -75.1953F,
+ -11.2305F,
+ 23.1934F,
+ 52.2461F,
+ -59.0820F,
+ 40.7715F,
+ -20.9961F,
+ 46.8750F,
+ -13.6719F,
+ 6.59180F,
+ -18.5547F,
+ 7.56836F,
+ 8.78906F,
+ 75.4395F,
+ -25.8789F,
+ -44.4336F,
+ -27.5879F,
+ 18.0664F,
+ -107.666F,
+ -5.37109F,
+ 5.61523F,
+ 33.9355F,
+ 19.7754F,
+ -2.68555F,
+ 10.7422F,
+ 3.66211F,
+ -21.2402F,
+ -33.4473F,
+ -28.8086F,
+ -50.5371F,
+ -38.5742F,
+ -14.1602F,
+ 66.4063F,
+ -22.4609F,
+ -38.0859F,
+ -107.666F,
+ 1.95313F,
+ -33.2031F,
+ 31.2500F,
+ -53.9551F,
+ 24.6582F,
+ -53.2227F,
+ 9.76563F,
+ -48.0957F,
+ -18.5547F,
+ -111.328F,
+ 2.19727F,
+ -108.643F,
+ 8.05664F,
+ -103.271F,
+ 55.1758F,
+ 14.6484F,
+ 17.8223F,
+ -54.1992F,
+ 38.0859F,
+ -97.4121F,
+ 68.3594F,
+ -77.6367F,
+ 59.8145F,
+ -83.2520F,
+ 40.5273F,
+ -121.826F,
+ 82.7637F,
+ -46.3867F,
+ 79.8340F,
+ -53.4668F,
+ 79.3457F,
+ -33.4473F,
+ -21.7285F,
+ -145.508F,
+ 24.4141F,
+ -153.076F,
+ 35.1563F,
+ -165.283F,
+ 118.896F,
+ 6.83594F,
+ 61.5234F,
+ -95.4590F,
+ 52.2461F,
+ -10.0098F,
+ 68.8477F,
+ -6.83594F,
+ 24.1699F,
+ -69.8242F,
+ 80.8105F,
+ 11.9629F,
+ 112.061F,
+ -94.7266F,
+ 137.939F,
+ -90.0879F,
+ 106.445F,
+ 6.83594F,
+ 82.0313F,
+ -2.19727F,
+ 96.9238F,
+ -40.7715F,
+ 150.879F,
+ 8.30078F,
+ 145.508F,
+ -4.15039F,
+ 136.963F,
+ -34.1797F,
+ 72.9980F,
+ 19.2871F,
+ 127.441F,
+ 30.5176F,
+ 49.5605F,
+ 0.488281F,
+ 59.5703F,
+ 70.3125F,
+ 62.2559F,
+ 51.5137F,
+ 42.7246F,
+ 20.0195F,
+ 145.508F,
+ 45.6543F,
+ 126.221F,
+ 26.3672F,
+ 93.0176F,
+ 62.2559F,
+ 89.1113F,
+ 72.5098F,
+ 121.338F,
+ 85.9375F,
+ 79.8340F,
+ -20.0195F,
+ 6.10352F,
+ 51.2695F,
+ 90.5762F,
+ 59.8145F,
+ 63.7207F,
+ 0.732422F,
+ 133.057F,
+ 109.619F,
+ 34.1797F,
+ 71.7773F,
+ 10.7422F,
+ 72.0215F,
+ 51.7578F,
+ 84.7168F,
+ 59.5703F,
+ 120.605F,
+ 80.8105F,
+ 128.906F,
+ 49.0723F,
+ 74.9512F,
+ 85.2051F,
+ 100.342F,
+ 149.658F,
+ 69.3359F,
+ 149.902F,
+ 100.830F,
+ 113.281F,
+ 78.6133F,
+ 152.344F,
+ 96.9238F,
+ 23.6816F,
+ 48.8281F,
+ -39.0625F,
+ 93.7500F,
+ 36.3770F,
+ 88.3789F,
+ 120.850F,
+ 128.174F,
+ 65.6738F,
+ 142.822F,
+ 8.05664F,
+ 119.873F,
+ -29.5410F,
+ 105.713F,
+ 104.248F,
+ 149.170F,
+ 121.582F,
+ 125.977F,
+ 41.7480F,
+ 108.154F,
+ 121.338F,
+ 162.598F,
+ 107.422F,
+ 67.1387F,
+ 138.184F,
+ 140.381F,
+ 35.6445F,
+ 156.006F,
+ 37.8418F,
+ 163.574F,
+ -8.05664F,
+ 42.2363F,
+ 51.7578F,
+ 169.922F,
+ -40.5273F,
+ 146.729F,
+ -46.6309F,
+ 169.678F,
+ -119.385F,
+ 122.803F,
+ 42.7246F,
+ 181.152F,
+ 52.2461F,
+ 116.211F,
+ 90.8203F,
+ 264.404F,
+ 141.113F,
+ 129.395F,
+ 143.066F,
+ 189.697F,
+ 103.760F,
+ 213.379F,
+ 76.9043F,
+ 205.322F,
+ 91.3086F,
+ 207.031F,
+ -40.2832F,
+ 137.939F,
+ 8.54492F,
+ 241.943F,
+ -9.52148F,
+ 259.277F,
+ 80.3223F,
+ 173.828F,
+ 191.895F,
+ 205.078F,
+ 157.471F,
+ 194.092F,
+ 161.377F,
+ 165.039F,
+ 139.404F,
+ 224.121F,
+ 154.297F,
+ 263.428F,
+ 164.307F,
+ 199.463F,
+ 77.6367F,
+ 94.7266F,
+ 213.379F,
+ 247.070F,
+ 137.695F,
+ 207.031F,
+ 214.844F,
+ 151.367F,
+ 135.986F,
+ 116.943F,
+ 163.818F,
+ 110.596F,
+ 168.945F,
+ 114.258F,
+ 205.078F,
+ 156.738F,
+ 206.055F,
+ 157.471F,
+ 123.535F,
+ 104.492F,
+ 218.994F,
+ 138.428F,
+ 204.346F,
+ 94.4824F,
+ 234.863F,
+ 121.826F,
+ 168.701F,
+ 136.963F,
+ 229.248F,
+ 226.074F,
+ 191.162F,
+ 72.2656F,
+ 192.871F,
+ 65.4297F,
+ 250.977F,
+ 129.395F,
+ 213.379F,
+ 80.3223F,
+ 133.789F,
+ 34.9121F,
+ 164.795F,
+ 71.0449F,
+ 122.803F,
+ 16.1133F,
+ 254.150F,
+ 87.6465F,
+ 191.895F,
+ 23.6816F,
+ 196.533F,
+ 8.05664F,
+ 204.346F,
+ 114.746F,
+ 124.756F,
+ 11.9629F,
+ 266.602F,
+ 79.8340F,
+ 286.621F,
+ 78.8574F,
+ 0.732422F,
+ 59.0820F,
+ 212.891F,
+ 115.723F,
+ 168.213F,
+ 104.736F,
+ 324.463F,
+ 165.527F,
+ 254.395F,
+ 151.367F,
+ 270.752F,
+ 162.109F,
+ 78.3691F,
+ 47.1191F,
+ 217.041F,
+ 231.934F,
+ 281.494F,
+ 213.379F,
+ 218.018F,
+ 155.029F,
+ 214.111F,
+ 210.449F,
+ 231.445F,
+ 222.900F,
+ 315.674F,
+ 162.354F,
+ 322.266F,
+ 156.006F,
+ 243.408F,
+ 193.604F,
+ 342.285F,
+ 251.465F,
+ 287.109F,
+ 247.070F,
+ 270.996F,
+ 234.131F,
+ 344.238F,
+ 225.830F,
+ 342.529F,
+ 223.389F,
+ 132.568F,
+ 210.449F,
+ 272.461F,
+ 298.340F,
+ 203.857F,
+ 290.527F,
+ 203.857F,
+ 290.527F,
+ 234.131F,
+ 280.273F,
+ 280.029F,
+ 335.938F,
+ 317.383F,
+ 291.260F,
+ 345.459F,
+ 300.537F,
+ 325.928F,
+ 327.393F,
+ 182.129F,
+ 266.602F,
+ 417.725F,
+ 313.232F,
+ 339.111F,
+ 261.963F,
+ 325.684F,
+ 382.324F,
+ 281.494F,
+ 360.107F,
+ 401.611F,
+ 277.588F,
+ 445.557F,
+ 297.852F,
+ 257.813F,
+ 337.402F,
+ 371.338F,
+ 422.363F,
+ 398.438F,
+ 377.197F,
+ 395.508F,
+ 376.465F,
+ 208.740F,
+ 389.648F,
+ 211.182F,
+ 406.982F,
+ 169.189F,
+ 216.064F,
+ 418.945F,
+ 370.850F,
+ 284.912F,
+ 316.406F,
+ 539.307F,
+ 429.688F,
+ 476.563F,
+ 364.502F,
+ 493.164F,
+ 361.816F,
+ 374.512F,
+ 455.566F,
+ 413.574F,
+ 490.234F,
+ 382.324F,
+ 182.617F,
+ 429.932F,
+ 201.416F,
+ 71.7773F,
+ 339.844F,
+ 264.648F,
+ 502.441F,
+ 151.611F,
+ 321.045F,
+ 89.1113F,
+ 314.209F,
+ 48.3398F,
+ 250.977F,
+ 119.141F,
+ 343.750F,
+ 60.7910F,
+ 98.3887F,
+ 247.559F,
+ 381.104F,
+ 79.1016F,
+ 88.6230F,
+ 401.611F,
+ 254.883F,
+ 47.1191F,
+ 89.5996F,
+ 496.582F,
+ 453.857F,
+ -61.2793F,
+ 141.357F,
+ 183.105F,
+ 242.676F,
+ -59.3262F,
+ 7.32422F,
+ 323.486F,
+ 214.600F,
+ -6.83594F,
+ -41.2598F,
+ 152.344F,
+ 223.877F,
+ -110.596F,
+ 38.8184F,
+ 45.4102F,
+ 334.473F,
+ -149.902F,
+ 1.46484F,
+ 131.104F,
+ 95.7031F,
+ -22.9492F,
+ -71.0449F,
+ 190.674F,
+ 55.9082F,
+ -31.2500F,
+ -72.7539F,
+ 59.8145F,
+ 119.873F,
+ -171.143F,
+ -158.203F,
+ 237.305F,
+ 192.627F,
+ -122.314F,
+ -156.250F,
+ 43.4570F,
+ 62.2559F,
+ -89.1113F,
+ -95.2148F,
+ -62.2559F,
+ 77.3926F,
+ -233.887F,
+ -71.7773F,
+ -46.6309F,
+ 55.6641F,
+ -189.209F,
+ -109.131F,
+ 38.3301F,
+ -57.8613F,
+ -160.400F,
+ -175.781F,
+ -99.3652F,
+ 22.4609F,
+ -28.5645F,
+ -149.170F,
+ 81.5430F,
+ -56.1523F,
+ -165.771F,
+ -264.648F,
+ -35.1563F,
+ -77.3926F,
+ -219.971F,
+ -210.205F,
+ -180.176F,
+ -87.8906F,
+ -20.7520F,
+ -177.490F,
+ -21.9727F,
+ -192.139F,
+ 24.4141F,
+ -5.37109F,
+ -95.4590F,
+ -64.2090F,
+ -13.6719F,
+ -17.8223F,
+ -82.2754F,
+ -184.082F,
+ 1.22070F,
+ -46.1426F,
+ -172.363F,
+ -152.344F,
+ 21.7285F,
+ -83.9844F,
+ -32.9590F,
+ -271.729F,
+ -86.1816F,
+ -57.8613F,
+ -166.992F,
+ -277.100F,
+ -67.1387F,
+ -269.043F,
+ -65.6738F,
+ -293.701F,
+ 37.1094F,
+ 35.4004F,
+ -176.270F,
+ -300.781F,
+ 11.9629F,
+ 19.5313F,
+ -304.688F,
+ -189.453F,
+ -60.5469F,
+ 95.4590F,
+ -178.711F,
+ -133.545F,
+ 114.502F,
+ 53.2227F,
+ -62.2559F,
+ -210.938F,
+ 16.8457F,
+ 89.3555F,
+ -40.5273F,
+ -118.408F,
+ -167.969F,
+ 46.6309F,
+ -295.898F,
+ -291.992F,
+ -41.5039F,
+ -41.2598F,
+ -319.336F,
+ -398.193F,
+ 78.3691F,
+ 114.746F,
+ -346.436F,
+ -303.467F,
+ -15.6250F,
+ 66.4063F,
+ -332.275F,
+ -60.5469F,
+ 120.117F,
+ 137.939F,
+ -176.025F,
+ -148.682F,
+ 47.6074F,
+ 118.408F,
+ -139.893F,
+ -32.4707F,
+ 104.248F,
+ 49.3164F,
+ -41.7480F,
+ -28.8086F,
+ 48.5840F,
+ 140.381F,
+ 0.488281F,
+ -7.56836F,
+ 169.434F,
+ 184.326F,
+ -333.496F,
+ -9.52148F,
+ 134.766F,
+ 135.986F,
+ -119.385F,
+ 66.1621F,
+ 166.016F,
+ 131.104F,
+ 3.17383F,
+ -110.596F,
+ 208.740F,
+ 232.910F,
+ -32.4707F,
+ -12.6953F,
+ -19.7754F,
+ 180.176F,
+ -285.400F,
+ 155.518F,
+ 257.568F,
+ 258.545F,
+ -23.1934F,
+ 165.039F,
+ 307.373F,
+ 263.916F,
+ 119.385F,
+ 74.4629F,
+ -109.619F,
+ 232.910F,
+ -130.371F,
+ 243.164F,
+ -236.572F,
+ 211.426F,
+ -258.301F,
+ 258.545F,
+ -315.918F,
+ 150.879F,
+ -345.703F,
+ 150.635F,
+ -111.816F,
+ 333.496F,
+ -38.8184F,
+ 444.580F,
+ -188.965F,
+ -128.906F,
+ -3.41797F,
+ 270.996F,
+ -293.457F,
+ -219.971F,
+ -188.477F,
+ 105.713F,
+ -306.641F,
+ -306.396F,
+ -246.826F,
+ -73.7305F,
+ -146.973F,
+ -142.822F,
+ -185.303F,
+ -395.020F,
+ -185.547F,
+ -378.174F,
+ -205.078F,
+ -468.994F,
+ -199.219F,
+ -131.592F,
+ -431.885F,
+ -545.654F,
+ -55.4199F,
+ -8.78906F,
+ -496.582F,
+ -447.021F,
+ -514.404F,
+ -274.902F,
+ -603.271F,
+ -443.359F,
+ -358.887F,
+ 61.5234F,
+ -659.424F,
+ -101.318F,
+ -139.404F,
+ -114.014F,
+ 368.408F,
+ 379.395F,
+ 532.227F,
+ 482.178F,
+ 567.871F,
+ 493.164F
+
+
+};
+static const Float32 dico4_lsf_5[DICO4_SIZE_5 * 4] =
+{
+ -453.369F,
+ -410.400F,
+ -453.369F,
+ -428.467F,
+ -501.953F,
+ -280.762F,
+ -520.996F,
+ -403.809F,
+ -395.264F,
+ -268.311F,
+ -416.016F,
+ -276.123F,
+ -328.369F,
+ -392.578F,
+ -331.787F,
+ -399.902F,
+ -326.660F,
+ -315.674F,
+ -323.486F,
+ -308.838F,
+ -406.250F,
+ -402.588F,
+ -363.037F,
+ -207.764F,
+ -328.613F,
+ -447.266F,
+ -344.971F,
+ -534.180F,
+ -312.988F,
+ -166.260F,
+ -435.791F,
+ -402.588F,
+ -235.840F,
+ -264.160F,
+ -288.818F,
+ -409.180F,
+ -257.324F,
+ -261.963F,
+ -278.809F,
+ -282.715F,
+ -294.678F,
+ -181.641F,
+ -311.035F,
+ -243.408F,
+ -228.027F,
+ -337.646F,
+ -226.318F,
+ -345.703F,
+ -246.582F,
+ -318.604F,
+ -191.162F,
+ -233.154F,
+ -256.104F,
+ -219.727F,
+ -242.432F,
+ -199.463F,
+ -179.932F,
+ -200.928F,
+ -237.305F,
+ -290.283F,
+ -180.176F,
+ -267.090F,
+ -180.176F,
+ -281.738F,
+ -191.406F,
+ -195.557F,
+ -197.754F,
+ -191.895F,
+ -217.773F,
+ -126.953F,
+ -244.141F,
+ -199.707F,
+ -157.227F,
+ -235.596F,
+ -140.869F,
+ -215.332F,
+ -132.080F,
+ -169.434F,
+ -163.818F,
+ -223.877F,
+ -145.264F,
+ -156.738F,
+ -157.715F,
+ -150.146F,
+ -233.398F,
+ -151.611F,
+ -225.830F,
+ -125.732F,
+ -177.490F,
+ -117.920F,
+ -198.975F,
+ -118.408F,
+ -205.078F,
+ -141.113F,
+ -107.422F,
+ -174.072F,
+ -141.113F,
+ -79.3457F,
+ -160.400F,
+ -163.574F,
+ -94.2383F,
+ -139.160F,
+ -107.666F,
+ -162.598F,
+ -125.488F,
+ -192.139F,
+ -95.7031F,
+ -129.150F,
+ -127.441F,
+ -110.596F,
+ -118.896F,
+ -103.271F,
+ -150.391F,
+ -142.822F,
+ -150.635F,
+ -38.3301F,
+ -161.621F,
+ -65.4297F,
+ -166.016F,
+ -84.9609F,
+ -78.6133F,
+ -78.8574F,
+ -154.297F,
+ -108.398F,
+ -74.2188F,
+ -104.980F,
+ -81.0547F,
+ -111.816F,
+ -67.6270F,
+ -114.258F,
+ -160.889F,
+ -193.604F,
+ -77.8809F,
+ -155.273F,
+ -55.4199F,
+ -135.254F,
+ -91.0645F,
+ -84.7168F,
+ -81.5430F,
+ -51.2695F,
+ -111.328F,
+ -46.8750F,
+ -129.395F,
+ -59.0820F,
+ -52.7344F,
+ -48.3398F,
+ -89.3555F,
+ -90.3320F,
+ -82.5195F,
+ -39.3066F,
+ -99.8535F,
+ -182.617F,
+ -26.1230F,
+ -92.7734F,
+ -71.7773F,
+ -156.982F,
+ -54.4434F,
+ -162.354F,
+ -57.1289F,
+ -180.908F,
+ -34.4238F,
+ -121.094F,
+ -31.7383F,
+ -124.512F,
+ -33.9355F,
+ -79.8340F,
+ -41.9922F,
+ -74.4629F,
+ -74.7070F,
+ -141.602F,
+ -40.0391F,
+ -64.2090F,
+ -63.9648F,
+ -41.9922F,
+ -16.3574F,
+ -98.1445F,
+ 7.56836F,
+ -89.3555F,
+ -2.44141F,
+ -106.445F,
+ -20.9961F,
+ -128.662F,
+ 17.3340F,
+ -92.0410F,
+ -5.37109F,
+ -148.682F,
+ -2.92969F,
+ -165.527F,
+ -16.3574F,
+ -77.8809F,
+ 15.3809F,
+ -46.6309F,
+ 8.54492F,
+ -44.1895F,
+ -9.52148F,
+ -59.0820F,
+ 30.7617F,
+ -40.7715F,
+ -34.1797F,
+ -132.813F,
+ 37.8418F,
+ -72.5098F,
+ 42.4805F,
+ -72.5098F,
+ 9.27734F,
+ -1.95313F,
+ 28.5645F,
+ -92.7734F,
+ 48.0957F,
+ -110.352F,
+ 58.5938F,
+ -127.441F,
+ 54.4434F,
+ -25.1465F,
+ 26.8555F,
+ -45.6543F,
+ 21.2402F,
+ -37.8418F,
+ 41.2598F,
+ -11.4746F,
+ 38.3301F,
+ 6.34766F,
+ -20.2637F,
+ -24.4141F,
+ 31.2500F,
+ 19.5313F,
+ 51.0254F,
+ -15.1367F,
+ 1.46484F,
+ 1.70898F,
+ 5.37109F,
+ 1.22070F,
+ 77.6367F,
+ -4.88281F,
+ 60.5469F,
+ -10.9863F,
+ -48.8281F,
+ -15.3809F,
+ 38.0859F,
+ -16.8457F,
+ 61.0352F,
+ -44.6777F,
+ 90.0879F,
+ -30.7617F,
+ -27.5879F,
+ -18.5547F,
+ -34.6680F,
+ -29.7852F,
+ -15.6250F,
+ -62.0117F,
+ -7.56836F,
+ 8.54492F,
+ -43.2129F,
+ -17.3340F,
+ -1.70898F,
+ 41.7480F,
+ 22.7051F,
+ 6.59180F,
+ 26.3672F,
+ 51.7578F,
+ -80.5664F,
+ -51.0254F,
+ -30.0293F,
+ -17.0898F,
+ -68.1152F,
+ 23.1934F,
+ -23.4375F,
+ 4.88281F,
+ -45.8984F,
+ -14.8926F,
+ -76.6602F,
+ 21.2402F,
+ -73.2422F,
+ -19.0430F,
+ -86.4258F,
+ -32.7148F,
+ 2.68555F,
+ 29.7852F,
+ -34.1797F,
+ 29.7852F,
+ -67.1387F,
+ 37.1094F,
+ -71.5332F,
+ 34.1797F,
+ -20.0195F,
+ 33.6914F,
+ -78.3691F,
+ -27.0996F,
+ -117.188F,
+ -38.0859F,
+ -87.6465F,
+ 18.5547F,
+ -62.0117F,
+ -9.76563F,
+ -155.029F,
+ -23.4375F,
+ -127.441F,
+ 19.2871F,
+ -123.779F,
+ 1.95313F,
+ -65.4297F,
+ 73.9746F,
+ -131.592F,
+ 16.6016F,
+ -108.887F,
+ 14.8926F,
+ -127.441F,
+ 74.7070F,
+ 27.0996F,
+ 46.1426F,
+ -106.201F,
+ 29.7852F,
+ -92.5293F,
+ 40.5273F,
+ -139.404F,
+ -97.1680F,
+ -154.297F,
+ -18.0664F,
+ -182.373F,
+ -23.1934F,
+ -111.084F,
+ 47.3633F,
+ -232.422F,
+ 20.2637F,
+ -194.824F,
+ 46.8750F,
+ -184.326F,
+ 46.8750F,
+ -190.674F,
+ -39.5508F,
+ -151.123F,
+ 57.1289F,
+ -161.865F,
+ -72.5098F,
+ -119.141F,
+ -26.6113F,
+ -235.352F,
+ -32.2266F,
+ -204.590F,
+ -16.6016F,
+ -205.811F,
+ 14.1602F,
+ -271.484F,
+ -20.9961F,
+ -196.533F,
+ -72.9980F,
+ -230.469F,
+ -61.7676F,
+ -189.941F,
+ -12.2070F,
+ -235.596F,
+ -134.033F,
+ -85.9375F,
+ -23.9258F,
+ -242.188F,
+ -83.7402F,
+ -272.705F,
+ -76.9043F,
+ -272.705F,
+ -74.9512F,
+ -281.982F,
+ -91.3086F,
+ -155.518F,
+ -56.1523F,
+ -284.668F,
+ -10.4980F,
+ -317.139F,
+ -24.4141F,
+ -225.830F,
+ -95.9473F,
+ -311.035F,
+ -146.484F,
+ -168.213F,
+ -31.7383F,
+ -361.084F,
+ -76.1719F,
+ -322.510F,
+ -62.0117F,
+ -357.422F,
+ -107.910F,
+ -315.430F,
+ -149.658F,
+ -307.861F,
+ -122.803F,
+ -366.455F,
+ -89.8438F,
+ -322.754F,
+ 6.34766F,
+ -349.609F,
+ -16.1133F,
+ -425.537F,
+ -39.3066F,
+ -401.367F,
+ -114.014F,
+ -429.688F,
+ -133.789F,
+ -340.088F,
+ -138.672F,
+ -379.883F,
+ -212.646F,
+ -364.990F,
+ -252.441F,
+ -338.623F,
+ -139.404F,
+ -468.018F,
+ -128.906F,
+ -435.303F,
+ -30.0293F,
+ -463.135F,
+ -56.3965F,
+ -501.465F,
+ -78.8574F,
+ -500.977F,
+ -221.191F,
+ -482.422F,
+ -138.428F,
+ -468.018F,
+ -151.367F,
+ -499.756F,
+ -241.455F,
+ -262.939F,
+ -90.3320F,
+ -495.850F,
+ -171.875F,
+ -574.951F,
+ -182.861F,
+ -668.945F,
+ -265.869F,
+ -466.064F,
+ 38.8184F,
+ -491.211F,
+ 60.5469F,
+ -152.832F,
+ -30.0293F,
+ -571.045F,
+ -234.863F,
+ -163.330F,
+ -99.6094F,
+ -336.670F,
+ -286.621F,
+ -110.352F,
+ -88.8672F,
+ -254.883F,
+ -179.443F,
+ -32.2266F,
+ 44.6777F,
+ -395.508F,
+ -183.594F,
+ -133.545F,
+ -74.9512F,
+ -189.697F,
+ -307.861F,
+ -23.9258F,
+ 10.0098F,
+ -214.844F,
+ -266.357F,
+ -62.7441F,
+ 23.6816F,
+ -391.113F,
+ -447.510F,
+ 7.56836F,
+ -6.34766F,
+ -157.227F,
+ -136.963F,
+ -43.9453F,
+ -133.301F,
+ -93.9941F,
+ -267.334F,
+ -100.098F,
+ -195.801F,
+ -101.074F,
+ -201.904F,
+ -111.572F,
+ -236.816F,
+ -119.629F,
+ -270.752F,
+ -52.4902F,
+ -223.633F,
+ -35.1563F,
+ -228.760F,
+ -120.361F,
+ -309.814F,
+ -126.221F,
+ -367.920F,
+ 44.1895F,
+ 24.6582F,
+ -81.0547F,
+ -217.041F,
+ -204.102F,
+ -228.760F,
+ -136.475F,
+ -104.736F,
+ -153.564F,
+ -133.545F,
+ -44.6777F,
+ -82.2754F,
+ -133.057F,
+ -20.0195F,
+ -61.0352F,
+ -69.8242F,
+ 1.22070F,
+ -32.2266F,
+ -84.9609F,
+ -61.5234F,
+ -71.5332F,
+ -115.234F,
+ -38.5742F,
+ 24.4141F,
+ -7.08008F,
+ 48.0957F,
+ -57.6172F,
+ -103.516F,
+ -210.205F,
+ -52.0020F,
+ -34.1797F,
+ -1.70898F,
+ -104.248F,
+ -108.154F,
+ 45.6543F,
+ -23.6816F,
+ -166.992F,
+ -179.688F,
+ -71.5332F,
+ 62.9883F,
+ -89.8438F,
+ -37.1094F,
+ -36.6211F,
+ 95.7031F,
+ -148.682F,
+ 42.7246F,
+ -34.6680F,
+ 72.9980F,
+ -33.6914F,
+ 37.1094F,
+ -29.0527F,
+ 80.3223F,
+ -118.652F,
+ -12.6953F,
+ 71.5332F,
+ 48.3398F,
+ -44.6777F,
+ 28.5645F,
+ 42.7246F,
+ 80.8105F,
+ -14.1602F,
+ -66.8945F,
+ 56.3965F,
+ 73.2422F,
+ -70.3125F,
+ 80.5664F,
+ -74.4629F,
+ 90.8203F,
+ -27.0996F,
+ 99.8535F,
+ -2.19727F,
+ 103.271F,
+ 20.2637F,
+ 62.5000F,
+ 16.3574F,
+ 89.5996F,
+ -4.63867F,
+ 60.5469F,
+ 22.2168F,
+ 27.5879F,
+ -8.54492F,
+ 99.1211F,
+ -46.6309F,
+ 37.5977F,
+ 58.1055F,
+ 72.2656F,
+ 1.22070F,
+ 48.0957F,
+ 34.4238F,
+ 53.9551F,
+ 76.4160F,
+ 48.3398F,
+ 51.5137F,
+ 102.783F,
+ 59.5703F,
+ 81.5430F,
+ 21.4844F,
+ 104.004F,
+ -59.3262F,
+ 110.840F,
+ 49.3164F,
+ 134.766F,
+ -1.22070F,
+ 98.3887F,
+ 71.0449F,
+ 45.1660F,
+ 53.4668F,
+ 73.4863F,
+ 61.2793F,
+ 33.6914F,
+ 31.2500F,
+ 16.8457F,
+ 48.0957F,
+ 70.3125F,
+ -34.1797F,
+ -14.8926F,
+ 45.8984F,
+ 88.1348F,
+ 48.0957F,
+ 145.996F,
+ 107.910F,
+ 66.6504F,
+ 70.8008F,
+ 34.9121F,
+ 115.234F,
+ 117.676F,
+ 38.3301F,
+ 90.3320F,
+ 101.318F,
+ 78.3691F,
+ 90.8203F,
+ 93.9941F,
+ 98.1445F,
+ 134.766F,
+ 37.8418F,
+ 5.85938F,
+ 134.277F,
+ 64.2090F,
+ -2.68555F,
+ 5.12695F,
+ 87.8906F,
+ 55.4199F,
+ 35.8887F,
+ -62.0117F,
+ 103.516F,
+ 23.6816F,
+ 89.3555F,
+ -3.17383F,
+ 91.5527F,
+ 34.4238F,
+ 109.619F,
+ 56.6406F,
+ 96.6797F,
+ 123.779F,
+ 115.723F,
+ 66.4063F,
+ 171.143F,
+ 79.1016F,
+ 88.3789F,
+ -11.4746F,
+ 143.311F,
+ 36.1328F,
+ 132.568F,
+ 16.8457F,
+ 97.6563F,
+ -12.4512F,
+ 136.963F,
+ 14.4043F,
+ 53.7109F,
+ -2.44141F,
+ 85.9375F,
+ 35.8887F,
+ 50.2930F,
+ 51.5137F,
+ 159.424F,
+ 45.1660F,
+ 137.451F,
+ 72.5098F,
+ 137.939F,
+ 69.3359F,
+ 145.020F,
+ 29.5410F,
+ 187.012F,
+ 46.8750F,
+ 97.1680F,
+ 28.8086F,
+ 156.738F,
+ 105.957F,
+ 56.8848F,
+ 64.4531F,
+ 117.432F,
+ 114.014F,
+ 31.4941F,
+ -40.2832F,
+ 170.654F,
+ 58.3496F,
+ 21.9727F,
+ 6.34766F,
+ 83.4961F,
+ 115.723F,
+ -13.4277F,
+ 6.59180F,
+ 94.7266F,
+ 22.9492F,
+ -41.9922F,
+ 0.000000F,
+ 177.002F,
+ 92.5293F,
+ -14.6484F,
+ 82.2754F,
+ 90.3320F,
+ 113.525F,
+ 23.1934F,
+ 77.8809F,
+ 196.777F,
+ 145.264F,
+ 19.0430F,
+ 63.4766F,
+ 121.338F,
+ 207.764F,
+ 51.2695F,
+ 136.719F,
+ 111.816F,
+ 140.137F,
+ -113.281F,
+ 49.3164F,
+ 121.338F,
+ 152.588F,
+ -49.3164F,
+ 37.1094F,
+ 11.7188F,
+ 173.828F,
+ -4.88281F,
+ 138.184F,
+ 24.4141F,
+ 174.561F,
+ 111.084F,
+ 114.258F,
+ 100.342F,
+ 147.705F,
+ 77.8809F,
+ 157.715F,
+ 47.6074F,
+ 150.146F,
+ 97.9004F,
+ 131.348F,
+ 166.016F,
+ 180.420F,
+ 49.0723F,
+ 162.842F,
+ 105.957F,
+ 232.910F,
+ 110.840F,
+ 103.760F,
+ 157.715F,
+ 119.873F,
+ 147.949F,
+ 166.260F,
+ 101.563F,
+ 124.023F,
+ 121.338F,
+ 200.684F,
+ 104.004F,
+ 198.975F,
+ 161.133F,
+ 157.959F,
+ 153.320F,
+ 174.805F,
+ 170.166F,
+ 113.770F,
+ 150.879F,
+ 111.572F,
+ 167.236F,
+ 112.305F,
+ 89.1113F,
+ 75.4395F,
+ 176.025F,
+ 138.428F,
+ 204.102F,
+ 146.729F,
+ 148.682F,
+ 73.2422F,
+ 201.416F,
+ 112.061F,
+ 230.225F,
+ 167.725F,
+ 166.260F,
+ 130.127F,
+ 223.389F,
+ 145.996F,
+ 144.287F,
+ 59.3262F,
+ 213.867F,
+ 110.107F,
+ 213.379F,
+ 102.539F,
+ 191.895F,
+ 77.3926F,
+ 178.711F,
+ 53.7109F,
+ 225.098F,
+ 77.3926F,
+ 270.508F,
+ 89.5996F,
+ 129.639F,
+ 113.770F,
+ 250.977F,
+ 158.447F,
+ 257.080F,
+ 150.146F,
+ 252.441F,
+ 135.010F,
+ 202.393F,
+ 146.973F,
+ 249.268F,
+ 195.068F,
+ 226.318F,
+ 196.045F,
+ 214.355F,
+ 186.279F,
+ 195.068F,
+ 121.094F,
+ 335.205F,
+ 188.721F,
+ 142.822F,
+ 187.988F,
+ 196.045F,
+ 227.051F,
+ 268.311F,
+ 193.604F,
+ 298.340F,
+ 210.449F,
+ 295.166F,
+ 218.506F,
+ 250.244F,
+ 177.490F,
+ 188.477F,
+ 206.299F,
+ 286.133F,
+ 272.217F,
+ 211.670F,
+ 249.268F,
+ 202.637F,
+ 247.314F,
+ 205.322F,
+ 222.168F,
+ 123.535F,
+ 171.631F,
+ 302.490F,
+ 262.939F,
+ 151.367F,
+ 199.951F,
+ 291.992F,
+ 264.404F,
+ 281.982F,
+ 263.916F,
+ 278.809F,
+ 221.436F,
+ 377.686F,
+ 273.682F,
+ 319.580F,
+ 158.203F,
+ 327.881F,
+ 149.414F,
+ 362.305F,
+ 241.211F,
+ 361.084F,
+ 228.760F,
+ 240.479F,
+ 324.219F,
+ 233.154F,
+ 327.393F,
+ 104.736F,
+ 222.168F,
+ 205.322F,
+ 326.660F,
+ 137.695F,
+ 287.842F,
+ 100.586F,
+ 282.227F,
+ 348.389F,
+ 322.266F,
+ 350.098F,
+ 324.707F,
+ 156.250F,
+ 185.547F,
+ 421.387F,
+ 344.238F,
+ 46.3867F,
+ 135.498F,
+ 261.963F,
+ 245.361F,
+ 104.004F,
+ 62.7441F,
+ 204.834F,
+ 239.258F,
+ 57.3730F,
+ 56.3965F,
+ 371.094F,
+ 284.912F,
+ 26.6113F,
+ 71.5332F,
+ 247.559F,
+ 383.057F,
+ 74.4629F,
+ 34.6680F,
+ 280.273F,
+ 131.592F,
+ -71.0449F,
+ -26.3672F,
+ 296.143F,
+ 237.305F,
+ 5.37109F,
+ -52.7344F,
+ 162.842F,
+ 202.148F,
+ -117.676F,
+ 106.934F,
+ 110.596F,
+ 349.365F,
+ -141.846F,
+ -103.027F,
+ 192.627F,
+ 94.4824F,
+ -87.4023F,
+ -110.840F,
+ 42.4805F,
+ 190.430F,
+ -8.78906F,
+ -90.8203F,
+ 95.2148F,
+ -32.7148F,
+ -153.564F,
+ 39.0625F,
+ -74.7070F,
+ 183.350F,
+ -307.129F,
+ -80.8105F,
+ 43.2129F,
+ 127.441F,
+ -60.5469F,
+ 140.137F,
+ -61.2793F,
+ 156.006F,
+ -129.639F,
+ 99.3652F,
+ -145.508F,
+ 96.1914F,
+ -102.295F,
+ 192.627F,
+ -150.635F,
+ 195.557F,
+ -240.723F,
+ 97.4121F,
+ -209.229F,
+ 177.490F,
+ -1.70898F,
+ 126.465F,
+ -171.631F,
+ 75.6836F,
+ -279.053F,
+ -5.85938F,
+ -244.629F,
+ 70.0684F,
+ -234.375F,
+ 88.6230F,
+ -317.139F,
+ 76.1719F,
+ -374.512F,
+ 59.8145F,
+ -380.127F,
+ 74.4629F,
+ 6.83594F,
+ 37.3535F,
+ -209.717F,
+ -42.7246F,
+ -8.05664F,
+ 81.0547F,
+ -341.309F,
+ -37.5977F,
+ 51.7578F,
+ 100.098F,
+ -144.775F,
+ -48.0957F,
+ -266.602F,
+ -171.875F,
+ -220.703F,
+ -15.8691F,
+ 68.8477F,
+ 89.5996F,
+ -224.121F,
+ -167.480F,
+ 84.2285F,
+ 22.7051F,
+ -62.9883F,
+ -87.1582F,
+ 169.922F,
+ 157.227F,
+ -169.189F,
+ -6.83594F,
+ 109.375F,
+ 120.361F,
+ -66.6504F,
+ 47.1191F,
+ 128.662F,
+ 133.301F,
+ -59.3262F,
+ -125.244F,
+ 93.7500F,
+ -33.2031F,
+ 66.6504F,
+ -86.1816F,
+ 125.000F,
+ -34.6680F,
+ 131.104F,
+ -48.3398F,
+ 229.736F,
+ 183.105F,
+ 20.2637F,
+ 60.5469F,
+ 141.113F,
+ 210.205F,
+ -13.6719F,
+ 144.531F,
+ 205.566F,
+ 10.7422F,
+ 217.773F,
+ 5.85938F,
+ 8.05664F,
+ 217.285F,
+ -3.90625F,
+ 239.746F,
+ 202.881F,
+ 341.309F,
+ 374.756F,
+ 463.379F,
+ 418.945F,
+ 335.938F,
+ 475.586F,
+ 357.666F
+};
+static const Float32 dico5_lsf_5[DICO5_SIZE_5 * 4] =
+{
+ -244.629F,
+ -226.807F,
+ -267.578F,
+ -293.701F,
+ -156.494F,
+ -227.295F,
+ -147.461F,
+ -234.619F,
+ -190.186F,
+ -164.307F,
+ -203.857F,
+ -192.383F,
+ -101.563F,
+ -162.109F,
+ -111.816F,
+ -187.012F,
+ -159.180F,
+ -127.197F,
+ -161.621F,
+ -120.850F,
+ -249.756F,
+ -124.268F,
+ -249.756F,
+ -104.492F,
+ -108.398F,
+ -134.766F,
+ -89.8438F,
+ -109.619F,
+ -116.943F,
+ -51.5137F,
+ -257.324F,
+ -220.459F,
+ -77.1484F,
+ -60.7910F,
+ -138.916F,
+ -144.287F,
+ -138.916F,
+ -67.1387F,
+ -132.080F,
+ -46.6309F,
+ -174.805F,
+ -45.8984F,
+ -205.566F,
+ -64.4531F,
+ -81.2988F,
+ -60.5469F,
+ -77.6367F,
+ -55.6641F,
+ -67.1387F,
+ 0.244141F,
+ -138.428F,
+ -55.6641F,
+ -28.0762F,
+ -53.9551F,
+ -58.1055F,
+ -91.3086F,
+ -48.0957F,
+ -123.779F,
+ -54.1992F,
+ -141.357F,
+ -62.9883F,
+ -105.469F,
+ -14.8926F,
+ -59.5703F,
+ -84.2285F,
+ 0.488281F,
+ -82.5195F,
+ 9.52148F,
+ -52.4902F,
+ -41.2598F,
+ -14.1602F,
+ 0.000000F,
+ -13.6719F,
+ -1.46484F,
+ -49.5605F,
+ -31.9824F,
+ 0.244141F,
+ -45.4102F,
+ -1.22070F,
+ -51.5137F,
+ 1.46484F,
+ -92.7734F,
+ 2.68555F,
+ -102.051F,
+ -28.3203F,
+ 31.9824F,
+ -32.7148F,
+ 27.5879F,
+ 21.7285F,
+ -0.976563F,
+ 17.3340F,
+ -0.488281F,
+ -4.63867F,
+ -46.8750F,
+ 63.9648F,
+ 5.85938F,
+ 46.1426F,
+ 36.8652F,
+ -32.4707F,
+ -26.6113F,
+ 45.4102F,
+ -37.3535F,
+ 40.5273F,
+ -53.4668F,
+ 9.03320F,
+ 33.9355F,
+ 47.1191F,
+ 41.7480F,
+ 82.2754F,
+ 30.2734F,
+ 38.5742F,
+ -14.8926F,
+ 34.4238F,
+ 55.1758F,
+ -3.17383F,
+ 46.3867F,
+ 56.3965F,
+ 8.30078F,
+ 86.4258F,
+ 26.6113F,
+ 77.1484F,
+ 49.0723F,
+ 59.5703F,
+ 40.0391F,
+ 80.5664F,
+ -20.7520F,
+ 95.2148F,
+ -20.5078F,
+ 62.0117F,
+ 79.8340F,
+ 62.7441F,
+ 81.7871F,
+ 119.873F,
+ 35.8887F,
+ 116.211F,
+ 25.6348F,
+ 13.1836F,
+ 18.7988F,
+ 106.689F,
+ 90.3320F,
+ 102.783F,
+ 76.6602F,
+ 109.619F,
+ 83.4961F,
+ 80.3223F,
+ 30.7617F,
+ 164.307F,
+ 71.2891F,
+ 139.404F,
+ 94.7266F,
+ 59.3262F,
+ 47.1191F,
+ 159.424F,
+ 78.1250F,
+ 151.611F,
+ 68.3594F,
+ 47.3633F,
+ 92.7734F,
+ 126.221F,
+ 141.846F,
+ 10.9863F,
+ 78.8574F,
+ 27.0996F,
+ 103.027F,
+ 119.385F,
+ 96.4355F,
+ 179.199F,
+ 130.371F,
+ 151.855F,
+ 133.301F,
+ 118.652F,
+ 122.559F,
+ 77.6367F,
+ 139.648F,
+ 46.1426F,
+ 134.277F,
+ 93.9941F,
+ 103.027F,
+ -38.3301F,
+ 37.3535F,
+ -30.5176F,
+ 93.2617F,
+ -48.0957F,
+ 94.2383F,
+ -64.2090F,
+ 81.5430F,
+ 55.6641F,
+ 170.166F,
+ -45.8984F,
+ 0.244141F,
+ 12.4512F,
+ 72.5098F,
+ -123.779F,
+ 52.0020F,
+ -91.7969F,
+ 96.9238F,
+ -5.85938F,
+ 62.2559F,
+ -133.545F,
+ 21.7285F,
+ -122.559F,
+ -22.9492F,
+ 94.4824F,
+ 43.7012F,
+ -151.367F,
+ 16.6016F,
+ -166.992F,
+ 27.3438F,
+ -156.738F,
+ -85.4492F,
+ -63.4766F,
+ 41.9922F,
+ -106.934F,
+ -79.1016F,
+ 64.4531F,
+ 158.203F,
+ -235.352F,
+ -0.976563F,
+ -273.682F,
+ 1.70898F,
+ -32.7148F,
+ 32.7148F,
+ -276.611F,
+ -74.7070F,
+ 34.9121F,
+ 23.4375F,
+ -102.539F,
+ -121.338F,
+ -298.096F,
+ -85.4492F,
+ -372.803F,
+ -167.236F,
+ -39.3066F,
+ 17.5781F,
+ 213.135F,
+ 168.701F,
+ 178.711F,
+ 69.0918F,
+ 224.854F,
+ 86.1816F,
+ 81.5430F,
+ 115.967F,
+ 267.334F,
+ 200.439F,
+ 210.938F,
+ 127.930F,
+ 205.811F,
+ 121.338F,
+ 174.316F,
+ 173.584F,
+ 192.383F,
+ 183.105F,
+ 262.695F,
+ 174.316F,
+ 293.945F,
+ 183.838F,
+
+};
+
+/* Table for MR475 gain */
+#define MR475_VQ_SIZE 256
+
+/* The table contains the following data:
+ *
+ * g_pitch(0) // for sub-
+ * g_fac(0) // frame 0 and 2
+ * g_pitch(1) // for sub-
+ * g_fac(1) // frame 1 and 3
+ *
+ */
+static const Float32 table_gain_MR475[MR475_VQ_SIZE * 4] =
+{
+0.049561F, 0.031250F,
+0.033081F, 0.034180F,
+0.175354F, 0.277100F,
+0.138306F, 0.830566F,
+0.126160F, 0.137451F,
+0.773743F, 0.157959F,
+0.252197F, 0.438965F,
+0.341858F, 1.290283F,
+0.469299F, 0.091309F,
+0.227966F, 0.107666F,
+0.666016F, 0.644043F,
+0.720642F, 0.608887F,
+1.250610F, 0.194580F,
+0.318481F, 0.164795F,
+0.410400F, 2.039551F,
+0.322388F, 0.414063F,
+0.090820F, 0.104492F,
+0.359009F, 0.110352F,
+0.325439F, 0.994141F,
+0.218689F, 0.309570F,
+0.150696F, 0.219971F,
+0.970093F, 0.245361F,
+0.914429F, 0.798584F,
+0.630554F, 1.186035F,
+0.221863F, 0.493408F,
+0.158447F, 0.203857F,
+0.754395F, 1.194336F,
+0.744995F, 0.416016F,
+0.819824F, 0.391602F,
+0.556519F, 0.571533F,
+0.242188F, 0.375488F,
+0.334412F, 2.425781F,
+0.231628F, 0.101807F,
+0.082947F, 0.101074F,
+0.222168F, 0.383057F,
+0.487976F, 0.864502F,
+0.696106F, 0.157471F,
+0.521973F, 0.155029F,
+0.247559F, 0.336182F,
+1.013672F, 1.495117F,
+0.697021F, 0.170898F,
+0.122498F, 0.148193F,
+0.757751F, 0.385254F,
+0.678650F, 1.136230F,
+0.834961F, 0.416992F,
+0.731812F, 0.300049F,
+0.488037F, 1.781494F,
+0.807556F, 1.395264F,
+0.148193F, 0.282959F,
+0.126526F, 0.473877F,
+0.379517F, 1.494385F,
+0.216431F, 0.440430F,
+0.544739F, 0.439941F,
+0.529724F, 0.385742F,
+0.850525F, 0.873047F,
+0.812561F, 1.522705F,
+0.374878F, 0.275879F,
+0.365845F, 0.423340F,
+0.863098F, 1.138184F,
+0.687927F, 0.810791F,
+0.746216F, 0.378662F,
+0.850281F, 0.736084F,
+0.310120F, 2.554688F,
+0.576416F, 1.637207F,
+0.103088F, 0.166748F,
+0.087646F, 0.318848F,
+0.440186F, 0.960205F,
+0.249146F, 0.662354F,
+0.475647F, 0.171875F,
+0.919800F, 0.195801F,
+0.384460F, 1.272461F,
+0.264709F, 1.307861F,
+0.407471F, 0.132080F,
+0.369995F, 0.152832F,
+0.833191F, 0.903320F,
+0.701782F, 0.587891F,
+0.986084F, 0.174805F,
+0.743225F, 0.183350F,
+0.492249F, 2.804932F,
+0.385376F, 0.550781F,
+0.272583F, 0.121094F,
+0.445129F, 0.127686F,
+0.623352F, 0.935791F,
+0.512329F, 0.741455F,
+0.512878F, 0.235840F,
+0.868408F, 0.458984F,
+0.531189F, 1.320557F,
+1.000671F, 1.187256F,
+0.452881F, 0.483154F,
+0.371643F, 0.300293F,
+0.571960F, 1.073730F,
+0.888550F, 0.821045F,
+0.827576F, 0.701416F,
+0.803406F, 0.357666F,
+0.337769F, 0.409668F,
+0.801880F, 3.606201F,
+0.447876F, 0.146484F,
+0.080444F, 0.133789F,
+0.259521F, 0.864014F,
+0.613037F, 0.577148F,
+0.646179F, 0.151855F,
+0.798828F, 0.163330F,
+0.862183F, 0.860840F,
+0.307556F, 2.388672F,
+0.936157F, 0.151123F,
+0.190125F, 0.144043F,
+1.003540F, 0.735596F,
+0.948608F, 1.017578F,
+0.948303F, 0.393311F,
+0.940247F, 0.299805F,
+0.977966F, 2.270264F,
+0.459839F, 1.214844F,
+0.121460F, 0.296143F,
+0.698669F, 0.282471F,
+0.763672F, 1.347412F,
+0.578308F, 0.645508F,
+0.470947F, 0.496582F,
+0.810547F, 0.546631F,
+0.977234F, 1.243408F,
+0.492310F, 1.650635F,
+0.615417F, 0.344971F,
+0.305298F, 0.572998F,
+0.764343F, 1.458740F,
+0.923218F, 0.707764F,
+1.114746F, 0.558838F,
+0.966003F, 0.616943F,
+0.992737F, 2.503418F,
+0.894226F, 2.763428F,
+0.109680F, 0.082275F,
+0.190125F, 0.096924F,
+0.214233F, 0.714844F,
+0.280273F, 0.651855F,
+0.458923F, 0.153320F,
+0.696716F, 0.160156F,
+0.362915F, 0.594482F,
+0.399414F, 1.798584F,
+0.502808F, 0.202393F,
+0.244141F, 0.210693F,
+0.612305F, 0.608398F,
+0.980042F, 0.866943F,
+1.111084F, 0.257324F,
+0.372498F, 0.354980F,
+0.359131F, 1.928711F,
+1.144531F, 0.846680F,
+0.113770F, 0.132813F,
+0.561401F, 0.166748F,
+0.709412F, 1.015625F,
+0.280396F, 0.401367F,
+0.192749F, 0.282471F,
+0.973694F, 0.625000F,
+0.753723F, 0.911377F,
+1.063232F, 1.284180F,
+0.372681F, 0.489258F,
+0.178040F, 0.425293F,
+1.005066F, 1.283447F,
+1.024597F, 0.410156F,
+1.050110F, 0.429443F,
+0.291321F, 0.788818F,
+0.450806F, 1.473389F,
+0.875366F, 2.444336F,
+0.246277F, 0.107910F,
+0.255981F, 0.111816F,
+0.562378F, 0.547363F,
+0.453308F, 1.029541F,
+0.784912F, 0.195557F,
+0.682739F, 0.201416F,
+0.771973F, 0.508789F,
+0.790771F, 1.600098F,
+0.580139F, 0.243164F,
+0.404602F, 0.240479F,
+0.643127F, 0.610840F,
+0.933167F, 1.222168F,
+0.769165F, 0.501709F,
+0.945068F, 0.403564F,
+0.988403F, 1.689697F,
+0.868591F, 1.413574F,
+0.160278F, 0.202148F,
+0.342712F, 0.411621F,
+0.833923F, 1.410645F,
+0.223877F, 0.379395F,
+0.690491F, 0.642822F,
+0.596313F, 0.356201F,
+0.854675F, 1.155518F,
+0.970276F, 1.535889F,
+0.383179F, 0.456543F,
+0.482788F, 0.557861F,
+1.036255F, 1.115967F,
+1.011719F, 0.939697F,
+0.930664F, 0.564209F,
+0.977966F, 0.791992F,
+0.882507F, 4.347656F,
+0.723083F, 0.674561F,
+0.120911F, 0.343506F,
+0.085449F, 0.213867F,
+0.264587F, 0.865967F,
+0.268005F, 1.027832F,
+0.329895F, 0.166016F,
+1.065735F, 0.190674F,
+0.396790F, 1.249512F,
+0.493835F, 1.874268F,
+0.448914F, 0.193848F,
+0.508606F, 0.288574F,
+0.918030F, 0.771484F,
+0.911133F, 0.741943F,
+1.246399F, 0.214844F,
+0.887756F, 0.208008F,
+0.752991F, 3.590820F,
+0.421387F, 0.468750F,
+0.257874F, 0.227783F,
+0.501587F, 0.265381F,
+0.650574F, 0.997070F,
+0.615356F, 1.106689F,
+0.166931F, 0.205078F,
+1.260803F, 0.263916F,
+1.019958F, 1.456543F,
+0.968811F, 1.117676F,
+0.663513F, 0.628418F,
+0.230286F, 0.284668F,
+0.886169F, 0.987305F,
+1.263367F, 0.641357F,
+0.928894F, 0.667480F,
+0.932251F, 0.533691F,
+0.381897F, 0.787598F,
+0.801086F, 4.755859F,
+0.439209F, 0.227051F,
+0.150269F, 0.395020F,
+0.275574F, 0.754883F,
+0.845459F, 1.044189F,
+0.638428F, 0.203369F,
+1.058289F, 0.197754F,
+1.030945F, 0.558838F,
+0.948853F, 2.006104F,
+0.830261F, 0.411133F,
+0.195129F, 0.447754F,
+0.973389F, 0.688477F,
+0.965088F, 1.300537F,
+1.037964F, 0.595215F,
+1.024658F, 0.323730F,
+0.956482F, 1.991211F,
+0.715698F, 2.088867F,
+0.229614F, 0.501221F,
+0.583679F, 0.321533F,
+0.827698F, 1.657715F,
+0.746277F, 0.472656F,
+0.499268F, 0.866699F,
+0.810974F, 0.434082F,
+0.994812F, 1.611084F,
+0.994324F, 1.894043F,
+0.520081F, 0.622803F,
+0.440979F, 0.645752F,
+1.115051F, 1.828369F,
+1.030579F, 0.548828F,
+1.091431F, 0.704102F,
+1.053772F, 0.812500F,
+0.574768F, 4.922363F,
+0.673950F, 2.031250F,
+0.078491F, 0.151367F,
+0.087341F, 0.142334F,
+0.365784F, 0.558838F,
+0.242798F, 0.885254F,
+0.313965F, 0.183594F,
+0.818420F, 0.202637F,
+0.338928F, 0.698242F,
+0.718018F, 1.442383F,
+0.655334F, 0.136719F,
+0.332397F, 0.137695F,
+0.813049F, 0.734375F,
+0.729126F, 0.899170F,
+1.213806F, 0.194824F,
+0.599670F, 0.177734F,
+0.833923F, 2.135742F,
+0.451111F, 0.745361F,
+0.153503F, 0.189941F,
+0.369263F, 0.203369F,
+0.394836F, 1.238770F,
+0.506897F, 0.601318F,
+0.374817F, 0.455322F,
+0.934326F, 0.308105F,
+0.879395F, 1.110107F,
+0.833923F, 1.102295F,
+0.191467F, 0.728271F,
+0.151306F, 0.307373F,
+0.920898F, 1.134521F,
+0.938843F, 0.636475F,
+0.884521F, 0.583984F,
+0.760620F, 0.619385F,
+0.460144F, 0.719971F,
+0.787903F, 2.944336F,
+0.333740F, 0.166992F,
+0.191711F, 0.176270F,
+0.310120F, 0.311035F,
+0.777100F, 1.025391F,
+0.933960F, 0.166260F,
+0.477234F, 0.144531F,
+0.398804F, 0.493408F,
+1.005737F, 2.133057F,
+0.815674F, 0.215332F,
+0.329407F, 0.219482F,
+0.894531F, 0.531738F,
+0.899719F, 1.031982F,
+0.870972F, 0.316895F,
+0.850159F, 0.495361F,
+0.944641F, 1.826660F,
+0.965271F, 1.116211F,
+0.153870F, 0.491455F,
+0.308960F, 0.440430F,
+0.314880F, 1.606934F,
+0.435181F, 0.878174F,
+0.666504F, 0.393311F,
+0.715881F, 0.416992F,
+1.031677F, 0.843506F,
+0.992920F, 1.621094F,
+0.567993F, 0.245850F,
+0.571838F, 0.514160F,
+1.170776F, 1.229736F,
+0.759338F, 1.042236F,
+0.971619F, 0.325195F,
+0.937317F, 0.857422F,
+0.726196F, 3.452393F,
+0.982727F, 1.673340F,
+0.122681F, 0.179932F,
+0.230652F, 0.210205F,
+0.699097F, 0.703125F,
+0.217529F, 0.864258F,
+0.552795F, 0.302979F,
+0.756287F, 0.218750F,
+0.521606F, 1.130127F,
+0.705627F, 1.410156F,
+0.496155F, 0.143799F,
+0.501587F, 0.143555F,
+1.143066F, 0.916748F,
+0.791809F, 0.768799F,
+0.960022F, 0.185059F,
+1.015259F, 0.184082F,
+0.929077F, 2.719238F,
+0.968689F, 0.539063F,
+0.285217F, 0.148926F,
+0.623657F, 0.165527F,
+0.931213F, 1.012207F,
+0.349670F, 0.812256F,
+0.511292F, 0.407715F,
+1.212280F, 0.566650F,
+0.942993F, 1.345459F,
+0.857788F, 1.338135F,
+0.349609F, 0.705078F,
+0.462646F, 0.328613F,
+0.877930F, 1.300049F,
+0.990967F, 0.964355F,
+0.922729F, 0.914063F,
+0.934204F, 0.350342F,
+0.890930F, 0.993652F,
+0.750793F, 3.832031F,
+0.464905F, 0.414795F,
+0.132446F, 0.215820F,
+0.272156F, 1.114990F,
+1.104370F, 0.807129F,
+0.777710F, 0.198975F,
+0.911011F, 0.221436F,
+0.916504F, 1.045166F,
+0.947144F, 2.042969F,
+1.098267F, 0.265381F,
+0.143921F, 0.211182F,
+0.993713F, 0.924561F,
+0.956970F, 1.122070F,
+0.998291F, 0.374512F,
+1.012207F, 0.539551F,
+1.027405F, 2.367432F,
+0.972229F, 1.101807F,
+0.200012F, 0.264893F,
+0.588562F, 0.533936F,
+0.730774F, 1.481445F,
+0.561462F, 1.089355F,
+0.546570F, 0.397705F,
+0.627991F, 0.747559F,
+1.005920F, 1.258545F,
+0.943970F, 1.725098F,
+0.834839F, 0.620850F,
+0.321838F, 0.555908F,
+1.022095F, 1.516846F,
+1.016541F, 0.832031F,
+1.239258F, 0.821045F,
+1.140625F, 0.484619F,
+0.864990F, 3.141357F,
+0.924927F, 3.833740F,
+0.273010F, 0.249023F,
+0.102600F, 0.216309F,
+0.263123F, 1.050049F,
+0.546387F, 0.892822F,
+0.359680F, 0.280029F,
+0.710876F, 0.354492F,
+0.969604F, 0.543701F,
+0.279663F, 1.622070F,
+0.422913F, 0.294189F,
+0.379639F, 0.195068F,
+0.757751F, 0.832275F,
+0.974609F, 0.946533F,
+1.212097F, 0.514893F,
+0.591370F, 0.522705F,
+0.899780F, 2.155762F,
+0.883789F, 0.634521F,
+0.110901F, 0.302246F,
+0.474304F, 0.198486F,
+1.164490F, 1.076660F,
+0.338989F, 0.503906F,
+0.225037F, 0.694336F,
+1.064148F, 0.550781F,
+1.019104F, 1.095215F,
+0.988708F, 1.315430F,
+0.489990F, 0.674561F,
+0.207825F, 0.517334F,
+1.063599F, 1.337158F,
+0.836060F, 0.680176F,
+1.213318F, 0.664063F,
+0.555298F, 0.947266F,
+1.109131F, 1.179932F,
+1.058105F, 2.980225F,
+0.312256F, 0.243164F,
+0.301208F, 0.241211F,
+0.603516F, 0.752197F,
+0.367065F, 1.311279F,
+0.969299F, 0.406982F,
+0.513000F, 0.288818F,
+0.920837F, 0.577637F,
+1.207092F, 1.709473F,
+0.730164F, 0.381348F,
+0.444275F, 0.275391F,
+1.028992F, 0.374023F,
+0.962036F, 1.313721F,
+0.897705F, 0.504150F,
+1.227112F, 0.526123F,
+1.047241F, 2.012939F,
+1.093201F, 1.542480F,
+0.333679F, 0.367188F,
+0.250244F, 0.628418F,
+1.063293F, 1.662598F,
+0.346252F, 0.705078F,
+1.015381F, 0.825684F,
+0.547791F, 0.447021F,
+1.230408F, 1.156494F,
+1.193237F, 1.780762F,
+0.406372F, 0.678955F,
+0.700195F, 0.810791F,
+1.183899F, 1.233887F,
+1.152222F, 1.152832F,
+1.003357F, 0.579346F,
+1.246948F, 1.070801F,
+0.692932F, 6.476074F,
+0.707581F, 0.749023F,
+0.174927F, 0.382324F,
+0.311768F, 0.261230F,
+0.586792F, 1.199951F,
+0.301453F, 0.863281F,
+0.460266F, 0.214355F,
+1.264465F, 0.207764F,
+0.423462F, 1.072998F,
+1.025330F, 1.887939F,
+0.618713F, 0.248779F,
+0.600891F, 0.235352F,
+0.945679F, 0.965576F,
+0.943542F, 0.837402F,
+1.151306F, 0.239746F,
+1.228027F, 0.235107F,
+1.030029F, 3.146240F,
+0.874878F, 1.025391F,
+0.402771F, 0.297852F,
+0.562866F, 0.198730F,
+1.034058F, 1.253418F,
+0.345520F, 1.195801F,
+0.334961F, 0.438965F,
+1.236450F, 0.967285F,
+1.037903F, 1.508301F,
+1.094299F, 1.447510F,
+0.571594F, 0.834961F,
+0.456177F, 0.481201F,
+1.192444F, 1.263916F,
+1.159851F, 0.733887F,
+1.004272F, 0.924805F,
+0.980835F, 0.577881F,
+0.528809F, 0.669678F,
+0.576477F, 6.435059F,
+0.662598F, 0.314209F,
+0.216980F, 0.246338F,
+0.342163F, 0.884277F,
+1.187317F, 1.345703F,
+0.760071F, 0.194580F,
+1.259399F, 0.222412F,
+0.941589F, 0.748535F,
+1.039856F, 2.508545F,
+1.152527F, 0.642822F,
+0.238831F, 0.309570F,
+1.191345F, 0.822998F,
+1.101807F, 1.276855F,
+1.177429F, 0.409668F,
+1.190674F, 0.774414F,
+1.103027F, 2.625488F,
+1.014709F, 1.671143F,
+0.191284F, 0.561035F,
+0.663391F, 0.594971F,
+0.950928F, 1.687744F,
+0.768860F, 0.825439F,
+0.678467F, 0.804932F,
+1.023071F, 0.591797F,
+1.150696F, 1.639404F,
+1.048035F, 2.413818F,
+0.777771F, 0.635986F,
+0.545471F, 0.766602F,
+1.161682F, 1.895508F,
+1.119812F, 0.947266F,
+1.249695F, 0.898926F,
+1.196411F, 0.825195F,
+0.796143F, 4.729736F,
+0.642456F, 5.645508F,
+
+};
+
+/*
+ * g_pitch ,
+ * g_fac , (g_code = g_code0*g_fac),
+ */
+/* table used in 'high' rates: MR67 MR74 MR102 */
+#define VQ_SIZE_HIGHRATES 128
+static const Float32 table_highrates[VQ_SIZE_HIGHRATES * 2] =
+{
+ /*g_pit, g_fac, */
+ 0.0352173F, 0.161621F,
+ 0.0491943F, 0.448242F,
+ 0.189758F, 0.256836F,
+ 0.255188F, 0.338623F,
+ 0.144836F, 0.347900F,
+ 0.198242F, 0.484619F,
+ 0.111511F, 0.566406F,
+ 0.0574341F, 0.809082F,
+ 0.143494F, 0.726807F,
+ 0.220703F, 0.590820F,
+ 0.210632F, 0.755859F,
+ 0.180359F, 1.05005F,
+ 0.112793F, 1.09863F,
+ 0.237061F, 1.32227F,
+ 0.0724487F, 1.76025F,
+ 0.188171F, 2.19727F,
+ 0.450684F, 0.215576F,
+ 0.363892F, 0.367676F,
+ 0.314636F, 0.520996F,
+ 0.484863F, 0.490479F,
+ 0.397156F, 0.549316F,
+ 0.468140F, 0.671875F,
+ 0.363281F, 0.736328F,
+ 0.298950F, 0.918945F,
+ 0.426575F, 0.875977F,
+ 0.498901F, 0.971191F,
+ 0.370117F, 1.07520F,
+ 0.470520F, 1.24194F,
+ 0.337097F, 1.46997F,
+ 0.474182F, 1.73975F,
+ 0.369873F, 1.93799F,
+ 0.341431F, 2.80444F,
+ 0.645813F, 0.331055F,
+ 0.552307F, 0.389893F,
+ 0.597778F, 0.496826F,
+ 0.546021F, 0.589600F,
+ 0.628418F, 0.630859F,
+ 0.574158F, 0.667480F,
+ 0.531006F, 0.785645F,
+ 0.595520F, 0.828857F,
+ 0.621155F, 0.950195F,
+ 0.559692F, 1.10547F,
+ 0.619629F, 1.22168F,
+ 0.556274F, 1.40015F,
+ 0.640869F, 1.52979F,
+ 0.617065F, 1.86304F,
+ 0.539795F, 2.13062F,
+ 0.546631F, 3.05078F,
+ 0.788818F, 0.238281F,
+ 0.697937F, 0.428467F,
+ 0.740845F, 0.568359F,
+ 0.695068F, 0.578125F,
+ 0.653076F, 0.748047F,
+ 0.752686F, 0.698486F,
+ 0.715454F, 0.812256F,
+ 0.687866F, 0.903320F,
+ 0.662903F, 1.07739F,
+ 0.737427F, 1.10669F,
+ 0.688660F, 1.27075F,
+ 0.729980F, 1.53931F,
+ 0.681580F, 1.83936F,
+ 0.740234F, 2.03345F,
+ 0.669495F, 2.63110F,
+ 0.628662F, 4.24219F,
+ 0.848328F, 0.410400F,
+ 0.767822F, 0.499268F,
+ 0.809631F, 0.595459F,
+ 0.856506F, 0.729736F,
+ 0.821045F, 0.756348F,
+ 0.756592F, 0.893066F,
+ 0.824585F, 0.922852F,
+ 0.786133F, 1.04297F,
+ 0.825989F, 1.18677F,
+ 0.773132F, 1.33228F,
+ 0.845581F, 1.49072F,
+ 0.795349F, 1.58276F,
+ 0.827454F, 1.88501F,
+ 0.790833F, 2.27319F,
+ 0.837036F, 2.82007F,
+ 0.768494F, 3.71240F,
+ 0.922424F, 0.375977F,
+ 0.919922F, 0.569580F,
+ 0.886658F, 0.613037F,
+ 0.896729F, 0.781006F,
+ 0.938843F, 0.869141F,
+ 0.862610F, 0.966797F,
+ 0.921753F, 1.03418F,
+ 0.874756F, 1.17773F,
+ 0.906128F, 1.33081F,
+ 0.934204F, 1.48511F,
+ 0.874573F, 1.68164F,
+ 0.919189F, 1.87720F,
+ 0.879272F, 2.30127F,
+ 0.939148F, 2.37817F,
+ 0.904785F, 3.48413F,
+ 0.830078F, 6.08862F,
+ 1.00073F, 0.480713F,
+ 1.02643F, 0.691406F,
+ 0.959045F, 0.694092F,
+ 0.982910F, 0.814453F,
+ 1.00000F, 0.967529F,
+ 1.03394F, 1.11792F,
+ 0.958923F, 1.12280F,
+ 0.990112F, 1.33008F,
+ 1.02734F, 1.55811F,
+ 0.960999F, 1.74341F,
+ 0.996460F, 1.82349F,
+ 1.01385F, 2.10547F,
+ 1.03931F, 2.54346F,
+ 0.970764F, 2.88501F,
+ 1.03015F, 3.58643F,
+ 1.00800F, 5.09521F,
+ 1.10730F, 0.508545F,
+ 1.18414F, 0.775879F,
+ 1.06860F, 0.836426F,
+ 1.22400F, 0.983154F,
+ 1.10284F, 1.03735F,
+ 1.15674F, 1.23682F,
+ 1.08099F, 1.31885F,
+ 1.21063F, 1.51172F,
+ 1.09558F, 1.71240F,
+ 1.30115F, 1.92310F,
+ 1.09314F, 2.26782F,
+ 1.16846F, 2.26807F,
+ 1.25226F, 2.77856F,
+ 1.10321F, 3.53638F,
+ 1.22064F, 4.36572F,
+ 1.15002F, 7.99902F
+};
+
+
+/* table used in 'low' rates: MR475, MR515, MR59 */
+#define VQ_SIZE_LOWRATES 64
+static const Float32 table_lowrates[VQ_SIZE_LOWRATES * 2] =
+{
+ /*g_pit, g_fac */
+ 0.659973F, 7.01978F,
+ 1.25000F, 0.679932F,
+ 1.14996F, 1.60986F,
+ 0.379944F, 1.80981F,
+ 1.04999F, 2.54980F,
+ 1.31995F, 0.309814F,
+ 1.28998F, 1.07983F,
+ 0.689941F, 0.379883F,
+ 1.15997F, 3.12988F,
+ 1.06000F, 0.609863F,
+ 1.08997F, 1.17993F,
+ 0.609985F, 0.609863F,
+ 1.06995F, 1.91992F,
+ 0.869995F, 0.459961F,
+ 0.969971F, 0.769775F,
+ 0.409973F, 0.439941F,
+ 1.10999F, 4.92993F,
+ 1.09998F, 0.739990F,
+ 1.01996F, 1.42993F,
+ 0.539978F, 0.979980F,
+ 0.969971F, 2.18994F,
+ 1.09998F, 0.339844F,
+ 1.01996F, 1.00000F,
+ 0.500000F, 0.159912F,
+ 0.929993F, 3.39990F,
+ 0.869995F, 0.759766F,
+ 0.859985F, 1.13989F,
+ 0.329956F, 0.659912F,
+ 0.819946F, 1.59985F,
+ 0.759949F, 0.219971F,
+ 0.759949F, 0.649902F,
+ 0.229980F, 0.159912F,
+ 0.899963F, 5.73999F,
+ 1.16998F, 0.599854F,
+ 1.22998F, 1.23999F,
+ 0.419983F, 1.00000F,
+ 1.25000F, 2.08984F,
+ 1.19995F, 0.179932F,
+ 1.15997F, 1.03979F,
+ 0.479980F, 0.509766F,
+ 0.699951F, 3.00000F,
+ 0.969971F, 0.359863F,
+ 0.959961F, 1.12988F,
+ 0.559998F, 0.349854F,
+ 0.979980F, 1.70996F,
+ 0.904968F, 0.179932F,
+ 0.919983F, 0.549805F,
+ 0.309998F, 0.299805F,
+ 0.809998F, 4.22998F,
+ 1.00995F, 0.569824F,
+ 0.919983F, 1.41992F,
+ 0.239990F, 0.899902F,
+ 0.869995F, 2.09985F,
+ 1.02997F, 0.189941F,
+ 0.919983F, 0.929932F,
+ 0.369995F, 0.149902F,
+ 0.569946F, 2.25977F,
+ 0.809998F, 0.429932F,
+ 0.809998F, 0.859863F,
+ 0.149963F, 0.479980F,
+ 0.699951F, 1.34985F,
+ 0.639954F, 0.179932F,
+ 0.709961F, 0.779785F,
+ 0.0899658F, 0.189941F
+};
+
+
+#define DTX_VQ_SIZE 47
+static const Word32 qua_gain_code_MR122[NB_QUA_CODE+VQ_SIZE_HIGHRATES+VQ_SIZE_LOWRATES+(MR475_VQ_SIZE*2)+DTX_VQ_SIZE+1] =
+{
+ - 3776,
+ - 3394,
+ - 3005,
+ - 2615,
+ - 2345,
+ - 2138,
+ - 1932,
+ - 1726,
+ - 1518,
+ - 1314,
+ - 1106,
+ - 900,
+ - 694,
+ - 487,
+ - 281,
+ - 75,
+ 133,
+ 339,
+ 545,
+ 752,
+ 958,
+ 1165,
+ 1371,
+ 1577,
+ 1784,
+ 1991,
+ 2197,
+ 2404,
+ 2673,
+ 3060,
+ 3448,
+ 3836,
+ /* high_rates */
+ - 2692,
+ - 1185,
+ - 2008,
+ - 1600,
+ - 1560,
+ - 1070,
+ - 840,
+ - 313,
+ - 471,
+ - 777,
+ - 414,
+ 72,
+ 139,
+ 413,
+ 835,
+ 1163,
+ - 2267,
+ - 1478,
+ - 963,
+ - 1052,
+ - 885,
+ - 588,
+ - 452,
+ - 125,
+ - 196,
+ - 43,
+ 107,
+ 320,
+ 569,
+ 818,
+ 977,
+ 1523,
+ - 1633,
+ - 1391,
+ - 1033,
+ - 780,
+ - 681,
+ - 597,
+ - 356,
+ - 277,
+ - 75,
+ 148,
+ 296,
+ 497,
+ 628,
+ 919,
+ 1117,
+ 1648,
+ - 2119,
+ - 1252,
+ - 835,
+ - 810,
+ - 429,
+ - 530,
+ - 307,
+ - 150,
+ 110,
+ 150,
+ 354,
+ 637,
+ 900,
+ 1049,
+ 1429,
+ 2135,
+ - 1316,
+ - 1026,
+ - 766,
+ - 465,
+ - 413,
+ - 167,
+ - 119,
+ 62,
+ 253,
+ 424,
+ 590,
+ 678,
+ 937,
+ 1213,
+ 1532,
+ 1938,
+ - 1445,
+ - 832,
+ - 723,
+ - 365,
+ - 207,
+ - 50,
+ 50,
+ 242,
+ 422,
+ 584,
+ 768,
+ 930,
+ 1231,
+ 1280,
+ 1844,
+ 2669,
+ - 1082,
+ - 545,
+ - 539,
+ - 303,
+ - 49,
+ 165,
+ 171,
+ 421,
+ 655,
+ 821,
+ 888,
+ 1100,
+ 1379,
+ 1565,
+ 1887,
+ 2406,
+ - 999,
+ - 375,
+ - 264,
+ - 25,
+ 54,
+ 314,
+ 409,
+ 610,
+ 795,
+ 966,
+ 1210,
+ 1210,
+ 1510,
+ 1866,
+ 2177,
+ 3072,
+ /* low_rates */
+ 2879,
+ - 570,
+ 703,
+ 876,
+ 1383,
+ - 1731,
+ 113,
+ - 1430,
+ 1686,
+ - 731,
+ 244,
+ - 731,
+ 964,
+ - 1147,
+ - 387,
+ - 1213,
+ 2357,
+ - 445,
+ 528,
+ - 30,
+ 1158,
+ - 1594,
+ 0,
+ - 2708,
+ 1808,
+ - 406,
+ 193,
+ - 614,
+ 694,
+ - 2237,
+ - 637,
+ - 2708,
+ 2582,
+ - 755,
+ 318,
+ 0,
+ 1089,
+ - 2534,
+ 58,
+ - 995,
+ 1623,
+ - 1510,
+ 180,
+ - 1552,
+ 793,
+ - 2534,
+ - 884,
+ - 1780,
+ 2131,
+ - 831,
+ 518,
+ - 156,
+ 1096,
+ - 2454,
+ - 107,
+ - 2804,
+ 1204,
+ - 1247,
+ - 223,
+ - 1084,
+ 443,
+ - 2534,
+ - 367,
+ - 2454,
+ /* MR475 */
+ - 5120,
+ - 4988,
+ - 1896,
+ - 274,
+ - 2932,
+ - 2726,
+ - 1216,
+ 376,
+ - 3536,
+ - 3293,
+ - 650,
+ - 733,
+ - 2418,
+ - 2664,
+ 1053,
+ - 1303,
+ - 3337,
+ - 3256,
+ - 9,
+ - 1732,
+ - 2237,
+ - 2076,
+ - 332,
+ 252,
+ - 1044,
+ - 2350,
+ 262,
+ - 1296,
+ - 1385,
+ - 827,
+ - 1447,
+ 1309,
+ - 3375,
+ - 3386,
+ - 1418,
+ - 215,
+ - 2731,
+ - 2754,
+ - 1610,
+ 594,
+ - 2610,
+ - 2821,
+ - 1409,
+ 189,
+ - 1292,
+ - 1779,
+ 853,
+ 492,
+ - 1865,
+ - 1103,
+ 593,
+ - 1211,
+ - 1213,
+ - 1407,
+ - 201,
+ 621,
+ - 1903,
+ - 1270,
+ 191,
+ - 310,
+ - 1435,
+ - 453,
+ 1386,
+ 728,
+ - 2646,
+ - 1689,
+ - 60,
+ - 609,
+ - 2602,
+ - 2409,
+ 356,
+ 396,
+ - 2991,
+ - 2775,
+ - 150,
+ - 785,
+ - 2577,
+ - 2506,
+ 1524,
+ - 881,
+ - 3119,
+ - 3041,
+ - 98,
+ - 442,
+ - 2134,
+ - 1151,
+ 411,
+ 254,
+ - 1075,
+ - 1777,
+ 105,
+ - 291,
+ - 524,
+ - 1519,
+ - 1318,
+ 1895,
+ - 2838,
+ - 2972,
+ - 216,
+ - 812,
+ - 2785,
+ - 2677,
+ - 221,
+ 1286,
+ - 2792,
+ - 2863,
+ - 454,
+ 26,
+ - 1379,
+ - 1780,
+ 1211,
+ 287,
+ - 1798,
+ - 1868,
+ 440,
+ - 647,
+ - 1034,
+ - 892,
+ 322,
+ 740,
+ - 1572,
+ - 823,
+ 558,
+ - 511,
+ - 860,
+ - 714,
+ 1356,
+ 1502,
+ - 3690,
+ - 3448,
+ - 496,
+ - 632,
+ - 2770,
+ - 2706,
+ - 768,
+ 867,
+ - 2360,
+ - 2301,
+ - 734,
+ - 211,
+ - 2005,
+ - 1530,
+ 970,
+ - 246,
+ - 2982,
+ - 2646,
+ 23,
+ - 1349,
+ - 1868,
+ - 694,
+ - 137,
+ 369,
+ - 1056,
+ - 1263,
+ 369,
+ - 1317,
+ - 1249,
+ - 351,
+ 572,
+ 1320,
+ - 3289,
+ - 3237,
+ - 890,
+ 43,
+ - 2411,
+ - 2367,
+ - 998,
+ 694,
+ - 2089,
+ - 2105,
+ - 728,
+ 296,
+ - 1019,
+ - 1341,
+ 775,
+ 511,
+ - 2362,
+ - 1311,
+ 508,
+ - 1432,
+ - 653,
+ - 1525,
+ 214,
+ 634,
+ - 1158,
+ - 862,
+ 162,
+ - 92,
+ - 846,
+ - 345,
+ 2171,
+ - 582,
+ - 1579,
+ - 2279,
+ - 213,
+ 40,
+ - 2653,
+ - 2448,
+ 329,
+ 928,
+ - 2424,
+ - 1836,
+ - 383,
+ - 441,
+ - 2272,
+ - 2320,
+ 1888,
+ - 1119,
+ - 2186,
+ - 1960,
+ - 4,
+ 150,
+ - 2341,
+ - 1968,
+ 555,
+ 164,
+ - 686,
+ - 1856,
+ - 19,
+ - 656,
+ - 597,
+ - 928,
+ - 353,
+ 2304,
+ - 2190,
+ - 1372,
+ - 416,
+ 64,
+ - 2353,
+ - 2394,
+ - 860,
+ 1028,
+ - 1313,
+ - 1187,
+ - 551,
+ 388,
+ - 767,
+ - 1666,
+ 1017,
+ 1088,
+ - 1020,
+ - 1676,
+ 747,
+ - 1107,
+ - 211,
+ - 1233,
+ 704,
+ 943,
+ - 700,
+ - 646,
+ 891,
+ - 886,
+ - 518,
+ - 307,
+ 2354,
+ 1047,
+ - 2789,
+ - 2880,
+ - 860,
+ - 180,
+ - 2504,
+ - 2358,
+ - 531,
+ 541,
+ - 2940,
+ - 2929,
+ - 456,
+ - 157,
+ - 2416,
+ - 2552,
+ 1121,
+ - 434,
+ - 2454,
+ - 2353,
+ 316,
+ - 752,
+ - 1162,
+ - 1739,
+ 154,
+ 144,
+ - 469,
+ - 1743,
+ 186,
+ - 668,
+ - 795,
+ - 708,
+ - 485,
+ 1595,
+ - 2644,
+ - 2564,
+ - 1725,
+ 37,
+ - 2651,
+ - 2858,
+ - 1044,
+ 1119,
+ - 2269,
+ - 2240,
+ - 933,
+ 47,
+ - 1698,
+ - 1038,
+ 890,
+ 162,
+ - 1049,
+ - 1211,
+ 701,
+ - 192,
+ - 1379,
+ - 1292,
+ - 251,
+ 714,
+ - 2073,
+ - 983,
+ 305,
+ 61,
+ - 1660,
+ - 227,
+ 1830,
+ 760,
+ - 2534,
+ - 2304,
+ - 520,
+ - 216,
+ - 1764,
+ - 2245,
+ 181,
+ 508,
+ - 2865,
+ - 2868,
+ - 128,
+ - 389,
+ - 2492,
+ - 2500,
+ 1478,
+ - 913,
+ - 2813,
+ - 2657,
+ 18,
+ - 307,
+ - 1326,
+ - 839,
+ 438,
+ 430,
+ - 516,
+ - 1644,
+ 388,
+ - 54,
+ - 133,
+ - 1550,
+ - 9,
+ 1985,
+ - 1300,
+ - 2265,
+ 161,
+ - 317,
+ - 2385,
+ - 2227,
+ 65,
+ 1055,
+ - 1960,
+ - 2297,
+ - 116,
+ 170,
+ - 1451,
+ - 912,
+ 1273,
+ 143,
+ - 1963,
+ - 927,
+ 581,
+ 126,
+ - 1362,
+ - 430,
+ 340,
+ 806,
+ - 704,
+ - 868,
+ 615,
+ - 272,
+ - 291,
+ - 1070,
+ 1691,
+ 1985,
+ - 2054,
+ - 2262,
+ 72,
+ - 168,
+ - 1881,
+ - 1532,
+ - 900,
+ 715,
+ - 1808,
+ - 2415,
+ - 271,
+ - 81,
+ - 981,
+ - 959,
+ 1135,
+ - 672,
+ - 1768,
+ - 2389,
+ 109,
+ - 1013,
+ - 539,
+ - 881,
+ 134,
+ 405,
+ - 582,
+ - 974,
+ 429,
+ - 569,
+ - 605,
+ - 80,
+ 244,
+ 1613,
+ - 2089,
+ - 2101,
+ - 421,
+ 400,
+ - 1328,
+ - 1835,
+ - 811,
+ 792,
+ - 1424,
+ - 1905,
+ - 1453,
+ 403,
+ - 1012,
+ - 949,
+ 1033,
+ 640,
+ - 1480,
+ - 686,
+ 751,
+ - 516,
+ - 283,
+ - 1190,
+ 215,
+ 852,
+ - 572,
+ - 310,
+ 310,
+ 210,
+ - 806,
+ 101,
+ 2760,
+ - 427,
+ - 1420,
+ - 1983,
+ 269,
+ - 217,
+ - 2275,
+ - 2321,
+ 104,
+ 939,
+ - 2055,
+ - 2137,
+ - 52,
+ - 262,
+ - 2110,
+ - 2139,
+ 1693,
+ 37,
+ - 1789,
+ - 2387,
+ 334,
+ 264,
+ - 1216,
+ - 49,
+ 607,
+ 546,
+ - 267,
+ - 1081,
+ 346,
+ - 457,
+ - 116,
+ - 810,
+ - 592,
+ 2750,
+ - 1710,
+ - 2070,
+ - 182,
+ 439,
+ - 2418,
+ - 2221,
+ - 428,
+ 1359,
+ - 653,
+ - 1732,
+ - 288,
+ 361,
+ - 1318,
+ - 378,
+ 1426,
+ 759,
+ - 854,
+ - 767,
+ 773,
+ - 283,
+ - 321,
+ - 775,
+ 730,
+ 1302,
+ - 669,
+ - 393,
+ 945,
+ - 80,
+ - 158,
+ - 284,
+ 2295,
+ 2557,
+ /* dtx */
+ - 1921,
+ - 1878,
+ - 1836,
+ - 1793,
+ - 1751,
+ - 1708,
+ - 1666,
+ - 1623,
+ - 1581,
+ - 1538,
+ - 1495,
+ - 1453,
+ - 1410,
+ - 1368,
+ - 1325,
+ - 1283,
+ - 1240,
+ - 1198,
+ - 1155,
+ - 1113,
+ - 1070,
+ - 1028,
+ - 985,
+ - 943,
+ - 900,
+ - 858,
+ - 815,
+ - 773,
+ - 730,
+ - 688,
+ - 645,
+ - 602,
+ - 560,
+ - 517,
+ - 475,
+ - 432,
+ - 390,
+ - 347,
+ - 305,
+ - 262,
+ - 220,
+ - 177,
+ - 135,
+ - 92,
+ - 50,
+ - 7,
+ 0,
+ /* init value */
+ - 2381
+};
+
+
+static const Word32 qua_gain_code[NB_QUA_CODE+VQ_SIZE_HIGHRATES+VQ_SIZE_LOWRATES+(MR475_VQ_SIZE*2)+DTX_VQ_SIZE+3] =
+{
+ - 22731,
+ - 20428,
+ - 18088,
+ - 15739,
+ - 14113,
+ - 12867,
+ - 11629,
+ - 10387,
+ - 9139,
+ - 7906,
+ - 6656,
+ - 5416,
+ - 4173,
+ - 2931,
+ - 1688,
+ - 445,
+ 801,
+ 2044,
+ 3285,
+ 4530,
+ 5772,
+ 7016,
+ 8259,
+ 9501,
+ 10745,
+ 11988,
+ 13231,
+ 14474,
+ 16096,
+ 18429,
+ 20763,
+ 23097,
+ /* high rates */
+ - 16214,
+ - 7135,
+ - 12086,
+ - 9629,
+ - 9394,
+ - 6442,
+ - 5056,
+ - 1885,
+ - 2838,
+ - 4681,
+ - 2490,
+ 434,
+ 836,
+ 2484,
+ 5030,
+ 7002,
+ - 13647,
+ - 8900,
+ - 5800,
+ - 6335,
+ - 5327,
+ - 3537,
+ - 2724,
+ - 751,
+ - 1177,
+ - 260,
+ 645,
+ 1928,
+ 3426,
+ 4926,
+ 5885,
+ 9172,
+ - 9831,
+ - 8380,
+ - 6220,
+ - 4700,
+ - 4099,
+ - 3595,
+ - 2144,
+ - 1669,
+ - 454,
+ 891,
+ 1781,
+ 2993,
+ 3782,
+ 5534,
+ 6728,
+ 9921,
+ - 12753,
+ - 7539,
+ - 5024,
+ - 4872,
+ - 2580,
+ - 3192,
+ - 1848,
+ - 904,
+ 663,
+ 902,
+ 2132,
+ 3837,
+ 5420,
+ 6312,
+ 8604,
+ 12853,
+ - 7921,
+ - 6179,
+ - 4610,
+ - 2802,
+ - 2482,
+ - 1006,
+ - 713,
+ 374,
+ 1523,
+ 2552,
+ 3551,
+ 4084,
+ 5639,
+ 7304,
+ 9221,
+ 11667,
+ - 8700,
+ - 5007,
+ - 4352,
+ - 2197,
+ - 1247,
+ - 300,
+ 298,
+ 1454,
+ 2542,
+ 3518,
+ 4623,
+ 5602,
+ 7413,
+ 7706,
+ 11102,
+ 16067,
+ - 6517,
+ - 3283,
+ - 3248,
+ - 1825,
+ - 294,
+ 992,
+ 1030,
+ 2537,
+ 3945,
+ 4944,
+ 5343,
+ 6622,
+ 8303,
+ 9423,
+ 11360,
+ 14483,
+ - 6013,
+ - 2257,
+ - 1589,
+ - 151,
+ 326,
+ 1890,
+ 2461,
+ 3676,
+ 4784,
+ 5816,
+ 7283,
+ 7284,
+ 9089,
+ 11234,
+ 13108,
+ 18494,
+ /* low_rates */
+ 17333,
+ - 3431,
+ 4235,
+ 5276,
+ 8325,
+ - 10422,
+ 683,
+ - 8609,
+ 10148,
+ - 4398,
+ 1472,
+ - 4398,
+ 5802,
+ - 6907,
+ - 2327,
+ - 7303,
+ 14189,
+ - 2678,
+ 3181,
+ - 180,
+ 6972,
+ - 9599,
+ 0,
+ - 16305,
+ 10884,
+ - 2444,
+ 1165,
+ - 3697,
+ 4180,
+ - 13468,
+ - 3833,
+ - 16305,
+ 15543,
+ - 4546,
+ 1913,
+ 0,
+ 6556,
+ - 15255,
+ 347,
+ - 5993,
+ 9771,
+ - 9090,
+ 1086,
+ - 9341,
+ 4772,
+ - 15255,
+ - 5321,
+ - 10714,
+ 12827,
+ - 5002,
+ 3118,
+ - 938,
+ 6598,
+ - 14774,
+ - 646,
+ - 16879,
+ 7251,
+ - 7508,
+ - 1343,
+ - 6529,
+ 2668,
+ - 15255,
+ - 2212,
+ - 14774,
+ /* MR475 */
+ - 30825,
+ - 30028,
+ - 11416,
+ - 1652,
+ - 17651,
+ - 16414,
+ - 7323,
+ 2266,
+ - 21289,
+ - 19823,
+ - 3914,
+ - 4413,
+ - 14560,
+ - 16037,
+ 6338,
+ - 7842,
+ - 20089,
+ - 19604,
+ - 53,
+ - 10430,
+ - 13469,
+ - 12497,
+ - 2001,
+ 1517,
+ - 6283,
+ - 14145,
+ 1579,
+ - 7801,
+ - 8339,
+ - 4977,
+ - 8713,
+ 7881,
+ - 20321,
+ - 20385,
+ - 8535,
+ - 1296,
+ - 16442,
+ - 16581,
+ - 9696,
+ 3577,
+ - 15714,
+ - 16981,
+ - 8484,
+ 1135,
+ - 7780,
+ - 10708,
+ 5136,
+ 2962,
+ - 11229,
+ - 6643,
+ 3572,
+ - 7294,
+ - 7304,
+ - 8473,
+ - 1208,
+ 3739,
+ - 11455,
+ - 7646,
+ 1150,
+ - 1866,
+ - 8638,
+ - 2726,
+ 8342,
+ 4384,
+ - 15933,
+ - 10167,
+ - 362,
+ - 3665,
+ - 15663,
+ - 14504,
+ 2142,
+ 2387,
+ - 18006,
+ - 16707,
+ - 905,
+ - 4726,
+ - 15513,
+ - 15088,
+ 9173,
+ - 5305,
+ - 18778,
+ - 18307,
+ - 591,
+ - 2661,
+ - 12849,
+ - 6927,
+ 2472,
+ 1527,
+ - 6470,
+ - 10701,
+ 632,
+ - 1754,
+ - 3155,
+ - 9145,
+ - 7938,
+ 11408,
+ - 17085,
+ - 17891,
+ - 1301,
+ - 4889,
+ - 16764,
+ - 16117,
+ - 1333,
+ 7744,
+ - 16808,
+ - 17234,
+ - 2732,
+ 154,
+ - 8300,
+ - 10715,
+ 7291,
+ 1731,
+ - 10824,
+ - 11244,
+ 2652,
+ - 3894,
+ - 6227,
+ - 5372,
+ 1937,
+ 4457,
+ - 9466,
+ - 4954,
+ 3358,
+ - 3075,
+ - 5176,
+ - 4297,
+ 8162,
+ 9040,
+ - 22215,
+ - 20758,
+ - 2986,
+ - 3807,
+ - 16679,
+ - 16291,
+ - 4626,
+ 5220,
+ - 14210,
+ - 13852,
+ - 4420,
+ - 1271,
+ - 12073,
+ - 9212,
+ 5842,
+ - 1481,
+ - 17956,
+ - 15933,
+ 137,
+ - 8120,
+ - 11244,
+ - 4180,
+ - 826,
+ 2224,
+ - 6359,
+ - 7605,
+ 2219,
+ - 7927,
+ - 7518,
+ - 2111,
+ 3447,
+ 7949,
+ - 19803,
+ - 19487,
+ - 5360,
+ 259,
+ - 14515,
+ - 14253,
+ - 6011,
+ 4180,
+ - 12577,
+ - 12676,
+ - 4384,
+ 1784,
+ - 6135,
+ - 8071,
+ 4665,
+ 3078,
+ - 14220,
+ - 7896,
+ 3060,
+ - 8621,
+ - 3931,
+ - 9182,
+ 1285,
+ 3816,
+ - 6974,
+ - 5192,
+ 975,
+ - 554,
+ - 5091,
+ - 2075,
+ 13071,
+ - 3502,
+ - 9504,
+ - 13719,
+ - 1280,
+ 244,
+ - 15972,
+ - 14740,
+ 1981,
+ 5587,
+ - 14593,
+ - 11054,
+ - 2308,
+ - 2656,
+ - 13678,
+ - 13966,
+ 11370,
+ - 6739,
+ - 13158,
+ - 11799,
+ - 27,
+ 901,
+ - 14092,
+ - 11849,
+ 3344,
+ 989,
+ - 4132,
+ - 11176,
+ - 114,
+ - 3951,
+ - 3596,
+ - 5586,
+ - 2124,
+ 13869,
+ - 13187,
+ - 8262,
+ - 2502,
+ 384,
+ - 14166,
+ - 14416,
+ - 5176,
+ 6192,
+ - 7906,
+ - 7147,
+ - 3320,
+ 2336,
+ - 4615,
+ - 10032,
+ 6125,
+ 6551,
+ - 6144,
+ - 10092,
+ 4495,
+ - 6666,
+ - 1273,
+ - 7423,
+ 4241,
+ 5680,
+ - 4212,
+ - 3891,
+ 5366,
+ - 5337,
+ - 3121,
+ - 1847,
+ 14175,
+ 6302,
+ - 16793,
+ - 17341,
+ - 5176,
+ - 1085,
+ - 15076,
+ - 14199,
+ - 3195,
+ 3257,
+ - 17698,
+ - 17635,
+ - 2746,
+ - 946,
+ - 14548,
+ - 15365,
+ 6748,
+ - 2615,
+ - 14774,
+ - 14166,
+ 1904,
+ - 4525,
+ - 6998,
+ - 10472,
+ 928,
+ 865,
+ - 2821,
+ - 10493,
+ 1122,
+ - 4019,
+ - 4785,
+ - 4261,
+ - 2922,
+ 9604,
+ - 15920,
+ - 15438,
+ - 10388,
+ 222,
+ - 15959,
+ - 17204,
+ - 6283,
+ 6737,
+ - 13658,
+ - 13488,
+ - 5618,
+ 280,
+ - 10222,
+ - 6248,
+ 5358,
+ 977,
+ - 6319,
+ - 7294,
+ 4218,
+ - 1156,
+ - 8300,
+ - 7780,
+ - 1514,
+ 4296,
+ - 12479,
+ - 5917,
+ 1839,
+ 367,
+ - 9992,
+ - 1369,
+ 11020,
+ 4578,
+ - 15255,
+ - 13873,
+ - 3133,
+ - 1298,
+ - 10621,
+ - 13518,
+ 1087,
+ 3057,
+ - 17250,
+ - 17265,
+ - 774,
+ - 2339,
+ - 15006,
+ - 15053,
+ 8896,
+ - 5497,
+ - 16938,
+ - 15998,
+ 107,
+ - 1850,
+ - 7980,
+ - 5053,
+ 2639,
+ 2590,
+ - 3108,
+ - 9898,
+ 2333,
+ - 323,
+ - 800,
+ - 9329,
+ - 57,
+ 11948,
+ - 7827,
+ - 13638,
+ 967,
+ - 1906,
+ - 14361,
+ - 13410,
+ 392,
+ 6353,
+ - 11799,
+ - 13831,
+ - 698,
+ 1024,
+ - 8736,
+ - 5489,
+ 7665,
+ 861,
+ - 11816,
+ - 5582,
+ 3495,
+ 761,
+ - 8201,
+ - 2588,
+ 2045,
+ 4850,
+ - 4240,
+ - 5223,
+ 3705,
+ - 1636,
+ - 1754,
+ - 6443,
+ 10180,
+ 11952,
+ - 12365,
+ - 13618,
+ 433,
+ - 1009,
+ - 11322,
+ - 9225,
+ - 5421,
+ 4302,
+ - 10883,
+ - 14537,
+ - 1633,
+ - 489,
+ - 5904,
+ - 5771,
+ 6831,
+ - 4047,
+ - 10643,
+ - 14383,
+ 656,
+ - 6097,
+ - 3245,
+ - 5305,
+ 809,
+ 2438,
+ - 3502,
+ - 5862,
+ 2584,
+ - 3429,
+ - 3642,
+ - 482,
+ 1471,
+ 9712,
+ - 12577,
+ - 12649,
+ - 2533,
+ 2410,
+ - 7996,
+ - 11047,
+ - 4882,
+ 4768,
+ - 8575,
+ - 11470,
+ - 8747,
+ 2427,
+ - 6092,
+ - 5713,
+ 6222,
+ 3854,
+ - 8911,
+ - 4132,
+ 4521,
+ - 3108,
+ - 1704,
+ - 7162,
+ 1293,
+ 5132,
+ - 3445,
+ - 1866,
+ 1868,
+ 1264,
+ - 4855,
+ 608,
+ 16615,
+ - 2571,
+ - 8552,
+ - 11940,
+ 1620,
+ - 1308,
+ - 13699,
+ - 13976,
+ 626,
+ 5652,
+ - 12374,
+ - 12868,
+ - 312,
+ - 1579,
+ - 12703,
+ - 12877,
+ 10194,
+ 222,
+ - 10773,
+ - 14372,
+ 2009,
+ 1590,
+ - 7323,
+ - 296,
+ 3655,
+ 3289,
+ - 1605,
+ - 6506,
+ 2082,
+ - 2752,
+ - 696,
+ - 4878,
+ - 3567,
+ 16558,
+ - 10297,
+ - 12462,
+ - 1094,
+ 2640,
+ - 14560,
+ - 13370,
+ - 2577,
+ 8180,
+ - 3931,
+ - 10430,
+ - 1733,
+ 2173,
+ - 7938,
+ - 2274,
+ 8585,
+ 4567,
+ - 5141,
+ - 4619,
+ 4655,
+ - 1707,
+ - 1931,
+ - 4666,
+ 4396,
+ 7837,
+ - 4026,
+ - 2364,
+ 5687,
+ - 482,
+ - 948,
+ - 1709,
+ 13820,
+ 15394,
+ /* dtx */
+ - 11560,
+ - 11304,
+ - 11048,
+ - 10792,
+ - 10536,
+ - 10280,
+ - 10024,
+ - 9768,
+ - 9512,
+ - 9256,
+ - 9000,
+ - 8744,
+ - 8488,
+ - 8232,
+ - 7976,
+ - 7720,
+ - 7464,
+ - 7208,
+ - 6952,
+ - 6696,
+ - 6440,
+ - 6184,
+ - 5928,
+ - 5672,
+ - 5416,
+ - 5160,
+ - 4904,
+ - 4648,
+ - 4392,
+ - 4136,
+ - 3880,
+ - 3624,
+ - 3368,
+ - 3112,
+ - 2856,
+ - 2600,
+ - 2344,
+ - 2088,
+ - 1832,
+ - 1576,
+ - 1320,
+ - 1064,
+ - 808,
+ - 552,
+ - 296,
+ - 40,
+ 0,
+ /* init value */
+ - 14336,
+ /* min */
+ - 32767,
+ /* max */
+ 18284
+
+};
+/*
+ * LP analysis is performed twice per frame using two different asymmetric windows.
+ * The second window has its weight concentrated at the fourth subframe
+ * and it consists of two parts:
+ * the first part is half a Hamming window and
+ * the second part is a quarter of a cosine function cycle.
+ */
+static const Float32 window_200_40[240] =
+{
+ 0.0800000F,
+ 0.0800570F,
+ 0.0802281F,
+ 0.0805132F,
+ 0.0809123F,
+ 0.0814251F,
+ 0.0820517F,
+ 0.0827919F,
+ 0.0836454F,
+ 0.0846121F,
+ 0.0856917F,
+ 0.0868840F,
+ 0.0881886F,
+ 0.0896053F,
+ 0.0911337F,
+ 0.0927733F,
+ 0.0945239F,
+ 0.0963849F,
+ 0.0983560F,
+ 0.100437F,
+ 0.102626F,
+ 0.104924F,
+ 0.107330F,
+ 0.109843F,
+ 0.112463F,
+ 0.115189F,
+ 0.118020F,
+ 0.120956F,
+ 0.123996F,
+ 0.127139F,
+ 0.130384F,
+ 0.133731F,
+ 0.137178F,
+ 0.140726F,
+ 0.144372F,
+ 0.148117F,
+ 0.151959F,
+ 0.155897F,
+ 0.159930F,
+ 0.164058F,
+ 0.168278F,
+ 0.172591F,
+ 0.176995F,
+ 0.181489F,
+ 0.186072F,
+ 0.190743F,
+ 0.195500F,
+ 0.200343F,
+ 0.205270F,
+ 0.210280F,
+ 0.215372F,
+ 0.220544F,
+ 0.225795F,
+ 0.231125F,
+ 0.236531F,
+ 0.242012F,
+ 0.247567F,
+ 0.253195F,
+ 0.258893F,
+ 0.264662F,
+ 0.270499F,
+ 0.276402F,
+ 0.282371F,
+ 0.288404F,
+ 0.294499F,
+ 0.300655F,
+ 0.306871F,
+ 0.313144F,
+ 0.319473F,
+ 0.325857F,
+ 0.332295F,
+ 0.338783F,
+ 0.345322F,
+ 0.351909F,
+ 0.358543F,
+ 0.365221F,
+ 0.371943F,
+ 0.378707F,
+ 0.385510F,
+ 0.392352F,
+ 0.399231F,
+ 0.406144F,
+ 0.413091F,
+ 0.420069F,
+ 0.427077F,
+ 0.434112F,
+ 0.441175F,
+ 0.448261F,
+ 0.455371F,
+ 0.462501F,
+ 0.469650F,
+ 0.476817F,
+ 0.484000F,
+ 0.491197F,
+ 0.498405F,
+ 0.505624F,
+ 0.512852F,
+ 0.520086F,
+ 0.527325F,
+ 0.534567F,
+ 0.541811F,
+ 0.549054F,
+ 0.556295F,
+ 0.563532F,
+ 0.570763F,
+ 0.577986F,
+ 0.585201F,
+ 0.592403F,
+ 0.599593F,
+ 0.606768F,
+ 0.613927F,
+ 0.621067F,
+ 0.628187F,
+ 0.635285F,
+ 0.642360F,
+ 0.649409F,
+ 0.656431F,
+ 0.663424F,
+ 0.670387F,
+ 0.677317F,
+ 0.684213F,
+ 0.691073F,
+ 0.697896F,
+ 0.704680F,
+ 0.711423F,
+ 0.718124F,
+ 0.724780F,
+ 0.731390F,
+ 0.737953F,
+ 0.744467F,
+ 0.750930F,
+ 0.757341F,
+ 0.763698F,
+ 0.770000F,
+ 0.776245F,
+ 0.782430F,
+ 0.788556F,
+ 0.794620F,
+ 0.800622F,
+ 0.806558F,
+ 0.812428F,
+ 0.818231F,
+ 0.823965F,
+ 0.829628F,
+ 0.835220F,
+ 0.840738F,
+ 0.846182F,
+ 0.851550F,
+ 0.856840F,
+ 0.862052F,
+ 0.867184F,
+ 0.872235F,
+ 0.877204F,
+ 0.882089F,
+ 0.886889F,
+ 0.891603F,
+ 0.896230F,
+ 0.900769F,
+ 0.905218F,
+ 0.909577F,
+ 0.913844F,
+ 0.918018F,
+ 0.922098F,
+ 0.926084F,
+ 0.929974F,
+ 0.933767F,
+ 0.937463F,
+ 0.941060F,
+ 0.944558F,
+ 0.947955F,
+ 0.951251F,
+ 0.954446F,
+ 0.957537F,
+ 0.960525F,
+ 0.963409F,
+ 0.966187F,
+ 0.968860F,
+ 0.971427F,
+ 0.973886F,
+ 0.976238F,
+ 0.978482F,
+ 0.980617F,
+ 0.982643F,
+ 0.984559F,
+ 0.986365F,
+ 0.988060F,
+ 0.989644F,
+ 0.991117F,
+ 0.992478F,
+ 0.993726F,
+ 0.994862F,
+ 0.995885F,
+ 0.996796F,
+ 0.997592F,
+ 0.998276F,
+ 0.998846F,
+ 0.999301F,
+ 0.999644F,
+ 0.999872F,
+ 0.999986F,
+ 1.00000F,
+ 0.999219F,
+ 0.996878F,
+ 0.992981F,
+ 0.987533F,
+ 0.980544F,
+ 0.972023F,
+ 0.961985F,
+ 0.950444F,
+ 0.937420F,
+ 0.922932F,
+ 0.907002F,
+ 0.889657F,
+ 0.870923F,
+ 0.850828F,
+ 0.829406F,
+ 0.806688F,
+ 0.782711F,
+ 0.757511F,
+ 0.731129F,
+ 0.703605F,
+ 0.674983F,
+ 0.645307F,
+ 0.614623F,
+ 0.582980F,
+ 0.550426F,
+ 0.517013F,
+ 0.482792F,
+ 0.447818F,
+ 0.412145F,
+ 0.375828F,
+ 0.338924F,
+ 0.301491F,
+ 0.263587F,
+ 0.225272F,
+ 0.186605F,
+ 0.147647F,
+ 0.108458F,
+ 0.0690994F,
+ 0.0296333F
+};
+
+/*
+ * LP analysis is performed twice per frame using two different asymmetric windows.
+ * The second window has its weight concentrated at the fourth subframe
+ * and it consists of two parts:
+ * the first part is half a Hamming window and
+ * the second part is a quarter of a cosine function cycle.
+ */
+static const Float32 window_232_8[240] =
+{
+ 0.0800000F,
+ 0.0800424F,
+ 0.0801694F,
+ 0.0803812F,
+ 0.0806775F,
+ 0.0810585F,
+ 0.0815240F,
+ 0.0820739F,
+ 0.0827082F,
+ 0.0834267F,
+ 0.0842292F,
+ 0.0851157F,
+ 0.0860859F,
+ 0.0871398F,
+ 0.0882770F,
+ 0.0894975F,
+ 0.0908009F,
+ 0.0921870F,
+ 0.0936556F,
+ 0.0952064F,
+ 0.0968391F,
+ 0.0985534F,
+ 0.100349F,
+ 0.102226F,
+ 0.104183F,
+ 0.106220F,
+ 0.108338F,
+ 0.110534F,
+ 0.112810F,
+ 0.115165F,
+ 0.117598F,
+ 0.120108F,
+ 0.122696F,
+ 0.125361F,
+ 0.128102F,
+ 0.130919F,
+ 0.133812F,
+ 0.136779F,
+ 0.139820F,
+ 0.142935F,
+ 0.146123F,
+ 0.149384F,
+ 0.152717F,
+ 0.156121F,
+ 0.159596F,
+ 0.163140F,
+ 0.166754F,
+ 0.170437F,
+ 0.174188F,
+ 0.178007F,
+ 0.181892F,
+ 0.185843F,
+ 0.189859F,
+ 0.193939F,
+ 0.198084F,
+ 0.202291F,
+ 0.206561F,
+ 0.210892F,
+ 0.215283F,
+ 0.219734F,
+ 0.224245F,
+ 0.228813F,
+ 0.233439F,
+ 0.238121F,
+ 0.242859F,
+ 0.247652F,
+ 0.252498F,
+ 0.257397F,
+ 0.262349F,
+ 0.267351F,
+ 0.272404F,
+ 0.277506F,
+ 0.282656F,
+ 0.287854F,
+ 0.293098F,
+ 0.298388F,
+ 0.303722F,
+ 0.309100F,
+ 0.314520F,
+ 0.319981F,
+ 0.325484F,
+ 0.331025F,
+ 0.336606F,
+ 0.342223F,
+ 0.347877F,
+ 0.353567F,
+ 0.359290F,
+ 0.365048F,
+ 0.370837F,
+ 0.376657F,
+ 0.382508F,
+ 0.388387F,
+ 0.394295F,
+ 0.400229F,
+ 0.406189F,
+ 0.412174F,
+ 0.418182F,
+ 0.424213F,
+ 0.430265F,
+ 0.436337F,
+ 0.442428F,
+ 0.448537F,
+ 0.454663F,
+ 0.460805F,
+ 0.466961F,
+ 0.473131F,
+ 0.479313F,
+ 0.485507F,
+ 0.491710F,
+ 0.497922F,
+ 0.504142F,
+ 0.510369F,
+ 0.516601F,
+ 0.522837F,
+ 0.529077F,
+ 0.535318F,
+ 0.541561F,
+ 0.547803F,
+ 0.554043F,
+ 0.560281F,
+ 0.566516F,
+ 0.572745F,
+ 0.578969F,
+ 0.585185F,
+ 0.591393F,
+ 0.597591F,
+ 0.603779F,
+ 0.609955F,
+ 0.616119F,
+ 0.622268F,
+ 0.628402F,
+ 0.634520F,
+ 0.640620F,
+ 0.646702F,
+ 0.652764F,
+ 0.658805F,
+ 0.664825F,
+ 0.670822F,
+ 0.676794F,
+ 0.682741F,
+ 0.688662F,
+ 0.694556F,
+ 0.700421F,
+ 0.706257F,
+ 0.712062F,
+ 0.717835F,
+ 0.723576F,
+ 0.729282F,
+ 0.734954F,
+ 0.740590F,
+ 0.746189F,
+ 0.751750F,
+ 0.757272F,
+ 0.762755F,
+ 0.768196F,
+ 0.773595F,
+ 0.778951F,
+ 0.784263F,
+ 0.789530F,
+ 0.794751F,
+ 0.799925F,
+ 0.805051F,
+ 0.810129F,
+ 0.815156F,
+ 0.820133F,
+ 0.825059F,
+ 0.829932F,
+ 0.834751F,
+ 0.839517F,
+ 0.844227F,
+ 0.848881F,
+ 0.853478F,
+ 0.858018F,
+ 0.862499F,
+ 0.866920F,
+ 0.871282F,
+ 0.875582F,
+ 0.879820F,
+ 0.883996F,
+ 0.888109F,
+ 0.892157F,
+ 0.896141F,
+ 0.900059F,
+ 0.903911F,
+ 0.907696F,
+ 0.911413F,
+ 0.915061F,
+ 0.918641F,
+ 0.922151F,
+ 0.925590F,
+ 0.928958F,
+ 0.932255F,
+ 0.935480F,
+ 0.938632F,
+ 0.941710F,
+ 0.944714F,
+ 0.947644F,
+ 0.950499F,
+ 0.953278F,
+ 0.955981F,
+ 0.958607F,
+ 0.961157F,
+ 0.963628F,
+ 0.966022F,
+ 0.968338F,
+ 0.970574F,
+ 0.972731F,
+ 0.974809F,
+ 0.976806F,
+ 0.978723F,
+ 0.980559F,
+ 0.982314F,
+ 0.983988F,
+ 0.985579F,
+ 0.987089F,
+ 0.988516F,
+ 0.989861F,
+ 0.991123F,
+ 0.992302F,
+ 0.993398F,
+ 0.994410F,
+ 0.995338F,
+ 0.996183F,
+ 0.996943F,
+ 0.997619F,
+ 0.998212F,
+ 0.998719F,
+ 0.999143F,
+ 0.999481F,
+ 0.999735F,
+ 0.999905F,
+ 0.999989F,
+ 1.00000F,
+ 0.979530F,
+ 0.918958F,
+ 0.820763F,
+ 0.688967F,
+ 0.528964F,
+ 0.347305F,
+ 0.151428F
+};
+
+/*
+ * LP analysis is performed twice per frame using two different asymmetric windows.
+ * The first window has its weight concentrated at the second subframe
+ * and it consists of two halves of Hamming windows with different sizes
+ */
+static const Float32 window_160_80[240] =
+{
+ 0.0800000F,
+ 0.0800898F,
+ 0.0803591F,
+ 0.0808079F,
+ 0.0814359F,
+ 0.0822430F,
+ 0.0832287F,
+ 0.0843928F,
+ 0.0857347F,
+ 0.0872539F,
+ 0.0889499F,
+ 0.0908220F,
+ 0.0928695F,
+ 0.0950914F,
+ 0.0974871F,
+ 0.100056F,
+ 0.102796F,
+ 0.105707F,
+ 0.108787F,
+ 0.112036F,
+ 0.115451F,
+ 0.119033F,
+ 0.122779F,
+ 0.126688F,
+ 0.130758F,
+ 0.134988F,
+ 0.139376F,
+ 0.143920F,
+ 0.148619F,
+ 0.153471F,
+ 0.158473F,
+ 0.163625F,
+ 0.168924F,
+ 0.174367F,
+ 0.179953F,
+ 0.185680F,
+ 0.191545F,
+ 0.197546F,
+ 0.203681F,
+ 0.209947F,
+ 0.216342F,
+ 0.222863F,
+ 0.229508F,
+ 0.236274F,
+ 0.243159F,
+ 0.250160F,
+ 0.257273F,
+ 0.264498F,
+ 0.271829F,
+ 0.279266F,
+ 0.286804F,
+ 0.294441F,
+ 0.302174F,
+ 0.310000F,
+ 0.317916F,
+ 0.325918F,
+ 0.334004F,
+ 0.342170F,
+ 0.350414F,
+ 0.358731F,
+ 0.367119F,
+ 0.375575F,
+ 0.384095F,
+ 0.392676F,
+ 0.401314F,
+ 0.410007F,
+ 0.418750F,
+ 0.427540F,
+ 0.436375F,
+ 0.445250F,
+ 0.454162F,
+ 0.463107F,
+ 0.472083F,
+ 0.481085F,
+ 0.490109F,
+ 0.499154F,
+ 0.508214F,
+ 0.517287F,
+ 0.526369F,
+ 0.535456F,
+ 0.544544F,
+ 0.553631F,
+ 0.562713F,
+ 0.571786F,
+ 0.580846F,
+ 0.589891F,
+ 0.598915F,
+ 0.607917F,
+ 0.616893F,
+ 0.625838F,
+ 0.634750F,
+ 0.643625F,
+ 0.652460F,
+ 0.661250F,
+ 0.669993F,
+ 0.678686F,
+ 0.687324F,
+ 0.695905F,
+ 0.704425F,
+ 0.712881F,
+ 0.721269F,
+ 0.729586F,
+ 0.737830F,
+ 0.745996F,
+ 0.754082F,
+ 0.762084F,
+ 0.770000F,
+ 0.777826F,
+ 0.785559F,
+ 0.793196F,
+ 0.800734F,
+ 0.808171F,
+ 0.815502F,
+ 0.822727F,
+ 0.829840F,
+ 0.836841F,
+ 0.843726F,
+ 0.850492F,
+ 0.857137F,
+ 0.863658F,
+ 0.870053F,
+ 0.876319F,
+ 0.882454F,
+ 0.888455F,
+ 0.894320F,
+ 0.900047F,
+ 0.905633F,
+ 0.911076F,
+ 0.916375F,
+ 0.921527F,
+ 0.926529F,
+ 0.931381F,
+ 0.936080F,
+ 0.940624F,
+ 0.945012F,
+ 0.949242F,
+ 0.953312F,
+ 0.957221F,
+ 0.960967F,
+ 0.964549F,
+ 0.967964F,
+ 0.971213F,
+ 0.974293F,
+ 0.977204F,
+ 0.979944F,
+ 0.982513F,
+ 0.984909F,
+ 0.987131F,
+ 0.989178F,
+ 0.991050F,
+ 0.992746F,
+ 0.994265F,
+ 0.995607F,
+ 0.996771F,
+ 0.997757F,
+ 0.998564F,
+ 0.999192F,
+ 0.999641F,
+ 0.999910F,
+ 1.00000F,
+ 1.00000F,
+ 0.999636F,
+ 0.998546F,
+ 0.996730F,
+ 0.994193F,
+ 0.990937F,
+ 0.986968F,
+ 0.982292F,
+ 0.976917F,
+ 0.970851F,
+ 0.964104F,
+ 0.956687F,
+ 0.948610F,
+ 0.939887F,
+ 0.930532F,
+ 0.920560F,
+ 0.909986F,
+ 0.898826F,
+ 0.887100F,
+ 0.874824F,
+ 0.862019F,
+ 0.848705F,
+ 0.834903F,
+ 0.820635F,
+ 0.805922F,
+ 0.790790F,
+ 0.775260F,
+ 0.759359F,
+ 0.743111F,
+ 0.726542F,
+ 0.709677F,
+ 0.692545F,
+ 0.675171F,
+ 0.657584F,
+ 0.639810F,
+ 0.621879F,
+ 0.603818F,
+ 0.585657F,
+ 0.567423F,
+ 0.549146F,
+ 0.530854F,
+ 0.512577F,
+ 0.494343F,
+ 0.476182F,
+ 0.458121F,
+ 0.440190F,
+ 0.422416F,
+ 0.404829F,
+ 0.387455F,
+ 0.370323F,
+ 0.353458F,
+ 0.336889F,
+ 0.320641F,
+ 0.304740F,
+ 0.289210F,
+ 0.274078F,
+ 0.259365F,
+ 0.245097F,
+ 0.231295F,
+ 0.217981F,
+ 0.205176F,
+ 0.192900F,
+ 0.181174F,
+ 0.170014F,
+ 0.159440F,
+ 0.149468F,
+ 0.140113F,
+ 0.131390F,
+ 0.123313F,
+ 0.115896F,
+ 0.109149F,
+ 0.103083F,
+ 0.0977077F,
+ 0.0930321F,
+ 0.0890632F,
+ 0.0858073F,
+ 0.0832696F,
+ 0.0814541F,
+ 0.0803637F,
+ 0.0800000F
+};
+
+/* correlation weights */
+static const Float32 corrweight[251] =
+{
+ 0.624805F,
+ 0.625813F,
+ 0.626820F,
+ 0.627827F,
+ 0.628834F,
+ 0.630024F,
+ 0.631031F,
+ 0.632221F,
+ 0.633229F,
+ 0.634419F,
+ 0.635426F,
+ 0.636616F,
+ 0.637623F,
+ 0.638813F,
+ 0.640034F,
+ 0.641224F,
+ 0.642415F,
+ 0.643605F,
+ 0.644826F,
+ 0.646016F,
+ 0.647206F,
+ 0.648427F,
+ 0.649617F,
+ 0.651021F,
+ 0.652211F,
+ 0.653615F,
+ 0.654805F,
+ 0.656209F,
+ 0.657430F,
+ 0.658834F,
+ 0.660207F,
+ 0.661611F,
+ 0.663015F,
+ 0.664418F,
+ 0.665822F,
+ 0.667226F,
+ 0.668630F,
+ 0.670217F,
+ 0.671621F,
+ 0.673208F,
+ 0.674612F,
+ 0.676229F,
+ 0.677816F,
+ 0.679434F,
+ 0.681021F,
+ 0.682607F,
+ 0.684225F,
+ 0.685812F,
+ 0.687613F,
+ 0.689230F,
+ 0.691031F,
+ 0.692831F,
+ 0.694632F,
+ 0.696432F,
+ 0.698233F,
+ 0.700034F,
+ 0.702017F,
+ 0.703818F,
+ 0.705832F,
+ 0.707816F,
+ 0.709616F,
+ 0.711814F,
+ 0.713828F,
+ 0.715812F,
+ 0.718009F,
+ 0.720237F,
+ 0.722221F,
+ 0.724631F,
+ 0.726829F,
+ 0.729026F,
+ 0.731437F,
+ 0.733818F,
+ 0.736229F,
+ 0.738609F,
+ 0.741234F,
+ 0.743614F,
+ 0.746208F,
+ 0.748833F,
+ 0.751610F,
+ 0.754234F,
+ 0.757012F,
+ 0.760033F,
+ 0.762810F,
+ 0.765831F,
+ 0.768822F,
+ 0.772027F,
+ 0.775018F,
+ 0.778222F,
+ 0.781610F,
+ 0.785028F,
+ 0.788415F,
+ 0.792016F,
+ 0.795618F,
+ 0.799219F,
+ 0.803034F,
+ 0.807031F,
+ 0.811029F,
+ 0.815027F,
+ 0.819239F,
+ 0.823634F,
+ 0.828028F,
+ 0.832636F,
+ 0.837428F,
+ 0.842219F,
+ 0.847224F,
+ 0.852412F,
+ 0.857814F,
+ 0.863216F,
+ 0.869015F,
+ 0.874813F,
+ 0.881039F,
+ 0.887417F,
+ 0.894040F,
+ 0.901028F,
+ 0.908231F,
+ 0.915616F,
+ 0.923429F,
+ 0.931639F,
+ 0.940214F,
+ 0.960021F,
+ 1.00000F,
+ 1.00000F,
+ 1.00000F,
+ 1.00000F,
+ 1.00000F,
+ 1.00000F,
+ 1.00000F,
+ 0.960021F,
+ 0.940214F,
+ 0.931639F,
+ 0.923429F,
+ 0.915616F,
+ 0.908231F,
+ 0.901028F,
+ 0.894040F,
+ 0.887417F,
+ 0.881039F,
+ 0.874813F,
+ 0.869015F,
+ 0.863216F,
+ 0.857814F,
+ 0.852412F,
+ 0.847224F,
+ 0.842219F,
+ 0.837428F,
+ 0.832636F,
+ 0.828028F,
+ 0.823634F,
+ 0.819239F,
+ 0.815027F,
+ 0.811029F,
+ 0.807031F,
+ 0.803034F,
+ 0.799219F,
+ 0.795618F,
+ 0.792016F,
+ 0.788415F,
+ 0.785028F,
+ 0.781610F,
+ 0.778222F,
+ 0.775018F,
+ 0.772027F,
+ 0.768822F,
+ 0.765831F,
+ 0.762810F,
+ 0.760033F,
+ 0.757012F,
+ 0.754234F,
+ 0.751610F,
+ 0.748833F,
+ 0.746208F,
+ 0.743614F,
+ 0.741234F,
+ 0.738609F,
+ 0.736229F,
+ 0.733818F,
+ 0.731437F,
+ 0.729026F,
+ 0.726829F,
+ 0.724631F,
+ 0.722221F,
+ 0.720237F,
+ 0.718009F,
+ 0.715812F,
+ 0.713828F,
+ 0.711814F,
+ 0.709616F,
+ 0.707816F,
+ 0.705832F,
+ 0.703818F,
+ 0.702017F,
+ 0.700034F,
+ 0.698233F,
+ 0.696432F,
+ 0.694632F,
+ 0.692831F,
+ 0.691031F,
+ 0.689230F,
+ 0.687613F,
+ 0.685812F,
+ 0.684225F,
+ 0.682607F,
+ 0.681021F,
+ 0.679434F,
+ 0.677816F,
+ 0.676229F,
+ 0.674612F,
+ 0.673208F,
+ 0.671621F,
+ 0.670217F,
+ 0.668630F,
+ 0.667226F,
+ 0.665822F,
+ 0.664418F,
+ 0.663015F,
+ 0.661611F,
+ 0.660207F,
+ 0.658834F,
+ 0.657430F,
+ 0.656209F,
+ 0.654805F,
+ 0.653615F,
+ 0.652211F,
+ 0.651021F,
+ 0.649617F,
+ 0.648427F,
+ 0.647206F,
+ 0.646016F,
+ 0.644826F,
+ 0.643605F,
+ 0.642415F,
+ 0.641224F,
+ 0.640034F,
+ 0.638813F,
+ 0.637623F,
+ 0.636616F,
+ 0.635426F,
+ 0.634419F,
+ 0.633229F,
+ 0.632221F,
+ 0.631031F,
+ 0.630024F,
+ 0.628834F,
+ 0.627827F,
+ 0.626820F,
+ 0.625813F,
+ 0.624805F,
+ 0.623615F,
+ 0.622608F,
+ 0.621632F,
+ 0.620624F
+};
+
+
+const struct
+{
+ Word8 max_frac_lag; /* lag up to which fractional lags are used */
+ Word8 flag3; /* enable 1/3 instead of 1/6 fract. resolution */
+ Word8 first_frac; /* first fractional to check */
+ Word8 last_frac; /* last fractional to check */
+ Word8 delta_int_low; /* integer lag below TO to start search from */
+ Word8 delta_int_range; /* integer range around T0 */
+ Word8 delta_frc_low; /* fractional below T0 */
+ Word8 delta_frc_range; /* fractional range around T0 */
+ Word8 pit_min; /* minimum pitch */
+
+} static mode_dep_parm[8] =
+{
+ /*
+ * MR475
+ */
+ {
+ 84, 1, - 2, 2, 5, 10, 5, 9, PIT_MIN
+ },
+ /*
+ * MR515
+ */
+ {
+ 84, 1, - 2, 2, 5, 10, 5, 9, PIT_MIN
+ },
+ /*
+ * MR59
+ */
+ {
+ 84, 1, - 2, 2, 3, 6, 5, 9, PIT_MIN
+ },
+ /*
+ * MR67
+ */
+ {
+ 84, 1, - 2, 2, 3, 6, 5, 9, PIT_MIN
+ },
+ /*
+ * MR74
+ */
+ {
+ 84, 1, - 2, 2, 3, 6, 5, 9, PIT_MIN
+ },
+ /*
+ * MR795
+ */
+ {
+ 84, 1, - 2, 2, 3, 6, 10, 19, PIT_MIN
+ },
+ /*
+ * MR102
+ */
+ {
+ 84, 1, - 2, 2, 3, 6, 5, 9, PIT_MIN
+ },
+ /*
+ * MR122
+ */
+ {
+ 94, 0, - 3, 3, 3, 6, 5, 9, PIT_MIN_MR122
+ }
+};
+
+/* table used inbase 2 logharithm computation */
+static const Word32 log2_table[33] =
+{
+ 0,
+ 1455,
+ 2866,
+ 4236,
+ 5568,
+ 6863,
+ 8124,
+ 9352,
+ 10549,
+ 11716,
+ 12855,
+ 13967,
+ 15054,
+ 16117,
+ 17156,
+ 18172,
+ 19167,
+ 20142,
+ 21097,
+ 22033,
+ 22951,
+ 23852,
+ 24735,
+ 25603,
+ 26455,
+ 27291,
+ 28113,
+ 28922,
+ 29716,
+ 30497,
+ 31266,
+ 32023,
+ 32767
+};
+
+/* table used in 2 to the power computation */
+static const Word32 pow2_table[33] =
+{
+ 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,
+ 32767
+};
+
+
+#endif
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/sp_dec.c b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/sp_dec.c
new file mode 100644
index 000000000..126178e76
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/sp_dec.c
@@ -0,0 +1,6122 @@
+/*
+ * ===================================================================
+ * TS 26.104
+ * REL-5 V5.4.0 2004-03
+ * REL-6 V6.1.0 2004-03
+ * 3GPP AMR Floating-point Speech Codec
+ * ===================================================================
+ *
+ */
+
+/*
+ * sp_dec.c
+ *
+ *
+ * Project:
+ * AMR Floating-Point Codec
+ *
+ * Contains:
+ * This module contains all the functions needed decoding AMR
+ * encoder parameters to 16-bit speech samples
+ *
+ */
+/*
+ * include files
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <memory.h>
+#include <math.h>
+#include "sp_dec.h"
+#include "rom_dec.h"
+
+/*
+ * Declare structure types
+ */
+enum DTXStateType
+{
+ SPEECH = 0, DTX, DTX_MUTE
+};
+
+/*
+ * Decoder memory structure
+ */
+typedef struct
+{
+ /* history vector of past synthesis speech energy */
+ Word32 frameEnergyHist[L_ENERGYHIST];
+
+
+ /* state flags */
+ Word16 bgHangover; /* counter; number of frames after last speech frame */
+
+
+}Bgn_scdState;
+typedef struct
+{
+ Word32 hangCount; /* counter; */
+ /* history vector of past synthesis speech energy */
+ Word32 cbGainHistory[L_CBGAINHIST];
+ Word16 hangVar; /* counter; */
+
+}Cb_gain_averageState;
+typedef struct
+{
+ Word32 lsp_meanSave[M]; /* Averaged LSPs saved for efficiency */
+
+
+}lsp_avgState;
+typedef struct
+{
+ Word32 past_r_q[M]; /* Past quantized prediction error, Q15 */
+ Word32 past_lsf_q[M]; /* Past dequantized lsfs, Q15 */
+
+
+}D_plsfState;
+typedef struct
+{
+ Word32 pbuf[5];
+ Word32 past_gain_pit;
+ Word32 prev_gp;
+
+
+}ec_gain_pitchState;
+typedef struct
+{
+ Word32 gbuf[5];
+ Word32 past_gain_code;
+ Word32 prev_gc;
+
+
+}ec_gain_codeState;
+typedef struct
+{
+ /*
+ * normal MA predictor memory, Q10
+ * (contains 20*log10(quaErr))
+ */
+ Word32 past_qua_en[4];
+
+
+ /*
+ * MA predictor memory for MR122 mode, Q10
+ * (contains log2(quaErr))
+ */
+ Word32 past_qua_en_MR122[4];
+
+
+}gc_predState;
+typedef struct
+{
+ Word32 gainMem[PHDGAINMEMSIZE];
+ Word32 prevCbGain;
+ Word32 prevState;
+ Word16 lockFull;
+ Word16 onset;
+
+
+}ph_dispState;
+typedef struct
+{
+ enum DTXStateType dtxGlobalState; /* contains previous state */
+
+ Word32 log_en;
+ Word32 old_log_en;
+ Word32 pn_seed_rx;
+ Word32 lsp[M];
+ Word32 lsp_old[M];
+ Word32 lsf_hist[M * DTX_HIST_SIZE];
+ Word32 lsf_hist_mean[M * DTX_HIST_SIZE];
+ Word32 log_en_hist[DTX_HIST_SIZE];
+ Word32 true_sid_period_inv;
+ Word16 since_last_sid;
+ Word16 lsf_hist_ptr;
+ Word16 log_pg_mean;
+ Word16 log_en_hist_ptr;
+ Word16 log_en_adjust;
+ Word16 dtxHangoverCount;
+ Word16 decAnaElapsedCount;
+ Word16 sid_frame;
+ Word16 valid_data;
+ Word16 dtxHangoverAdded;
+
+
+ /* updated in main decoder */
+ Word16 data_updated; /* marker to know if CNI data is ever renewed */
+
+
+}dtx_decState;
+typedef struct
+{
+ Word32 past_gain;
+
+
+}agcState;
+typedef struct
+{
+ /* Excitation vector */
+ Word32 old_exc[L_SUBFR + PIT_MAX + L_INTERPOL];
+ Word32 *exc;
+ Word32 lsp_old[M];
+
+
+ /* Filter's memory */
+ Word32 mem_syn[M];
+
+
+ /* pitch sharpening */
+ Word32 sharp;
+ Word32 old_T0;
+
+
+ /* Variable holding received ltpLag, used in background noise and BFI */
+ Word32 T0_lagBuff;
+
+
+ /* Variables for the source characteristic detector (SCD) */
+ Word32 inBackgroundNoise;
+ Word32 voicedHangover;
+ Word32 ltpGainHistory[9];
+
+
+ /* Memories for bad frame handling */
+ Word32 excEnergyHist[9];
+ Word16 prev_bf;
+ Word16 prev_pdf;
+ Word16 state;
+ Word16 nodataSeed;
+
+
+ Bgn_scdState * background_state;
+ Cb_gain_averageState * Cb_gain_averState;
+ lsp_avgState * lsp_avg_st;
+ D_plsfState * lsfState;
+ ec_gain_pitchState * ec_gain_p_st;
+ ec_gain_codeState * ec_gain_c_st;
+ gc_predState * pred_state;
+ ph_dispState * ph_disp_st;
+ dtx_decState * dtxDecoderState;
+}Decoder_amrState;
+typedef struct
+{
+ Word32 res2[L_SUBFR];
+ Word32 mem_syn_pst[M];
+ Word32 synth_buf[M + L_FRAME];
+ Word32 preemph_state_mem_pre;
+ agcState * agc_state;
+}Post_FilterState;
+typedef struct
+{
+ Word32 y2_hi;
+ Word32 y2_lo;
+ Word32 y1_hi;
+ Word32 y1_lo;
+ Word32 x0;
+ Word32 x1;
+
+
+}Post_ProcessState;
+typedef struct
+{
+ Decoder_amrState * decoder_amrState;
+ Post_FilterState * post_state;
+ Post_ProcessState * postHP_state;
+}Speech_Decode_FrameState;
+
+
+/*
+ * CodAmrReset
+ *
+ *
+ * Parameters:
+ * state B: state structure
+ * mode I: AMR mode
+ *
+ * Function:
+ * Resets state memory
+ *
+ * Returns:
+ * void
+ */
+static void Decoder_amr_reset( Decoder_amrState *state, enum Mode mode )
+{
+ Word32 i;
+
+ /* Cb_gain_average_reset */
+ memset(state->Cb_gain_averState->cbGainHistory, 0, L_CBGAINHIST << 2);
+ state->Cb_gain_averState->hangVar = 0;
+ state->Cb_gain_averState->hangCount= 0;
+
+ /* Initialize static pointer */
+ state->exc = state->old_exc + PIT_MAX + L_INTERPOL;
+
+ /* Static vectors to zero */
+ memset( state->old_exc, 0, ( PIT_MAX + L_INTERPOL )<<2 );
+
+ if ( mode != MRDTX )
+ memset( state->mem_syn, 0, M <<2 );
+
+ /* initialize pitch sharpening */
+ state->sharp = SHARPMIN;
+ state->old_T0 = 40;
+
+ /* Initialize state->lsp_old [] */
+ if ( mode != MRDTX ) {
+ state->lsp_old[0] = 30000;
+ state->lsp_old[1] = 26000;
+ state->lsp_old[2] = 21000;
+ state->lsp_old[3] = 15000;
+ state->lsp_old[4] = 8000;
+ state->lsp_old[5] = 0;
+ state->lsp_old[6] = -8000;
+ state->lsp_old[7] = -15000;
+ state->lsp_old[8] = -21000;
+ state->lsp_old[9] = -26000;
+ }
+
+ /* Initialize memories of bad frame handling */
+ state->prev_bf = 0;
+ state->prev_pdf = 0;
+ state->state = 0;
+ state->T0_lagBuff = 40;
+ state->inBackgroundNoise = 0;
+ state->voicedHangover = 0;
+
+ if ( mode != MRDTX )
+ memset( state->excEnergyHist, 0, 9 <<2 );
+ memset( state->ltpGainHistory, 0, 9 <<2 );
+
+ if ( mode != MRDTX ) {
+ state->lsp_avg_st->lsp_meanSave[0] = 1384;
+ state->lsp_avg_st->lsp_meanSave[1] = 2077;
+ state->lsp_avg_st->lsp_meanSave[2] = 3420;
+ state->lsp_avg_st->lsp_meanSave[3] = 5108;
+ state->lsp_avg_st->lsp_meanSave[4] = 6742;
+ state->lsp_avg_st->lsp_meanSave[5] = 8122;
+ state->lsp_avg_st->lsp_meanSave[6] = 9863;
+ state->lsp_avg_st->lsp_meanSave[7] = 11092;
+ state->lsp_avg_st->lsp_meanSave[8] = 12714;
+ state->lsp_avg_st->lsp_meanSave[9] = 13701;
+ }
+ memset( state->lsfState->past_r_q, 0, M <<2 );
+
+ /* Past dequantized lsfs */
+ state->lsfState->past_lsf_q[0] = 1384;
+ state->lsfState->past_lsf_q[1] = 2077;
+ state->lsfState->past_lsf_q[2] = 3420;
+ state->lsfState->past_lsf_q[3] = 5108;
+ state->lsfState->past_lsf_q[4] = 6742;
+ state->lsfState->past_lsf_q[5] = 8122;
+ state->lsfState->past_lsf_q[6] = 9863;
+ state->lsfState->past_lsf_q[7] = 11092;
+ state->lsfState->past_lsf_q[8] = 12714;
+ state->lsfState->past_lsf_q[9] = 13701;
+
+ for ( i = 0; i < 5; i++ )
+ state->ec_gain_p_st->pbuf[i] = 1640;
+ state->ec_gain_p_st->past_gain_pit = 0;
+ state->ec_gain_p_st->prev_gp = 16384;
+
+ for ( i = 0; i < 5; i++ )
+ state->ec_gain_c_st->gbuf[i] = 1;
+ state->ec_gain_c_st->past_gain_code = 0;
+ state->ec_gain_c_st->prev_gc = 1;
+
+ if ( mode != MRDTX ) {
+ for ( i = 0; i < NPRED; i++ ) {
+ state->pred_state->past_qua_en[i] = MIN_ENERGY;
+ state->pred_state->past_qua_en_MR122[i] = MIN_ENERGY_MR122;
+ }
+ }
+ state->nodataSeed = 21845;
+
+ /* Static vectors to zero */
+ memset( state->background_state->frameEnergyHist, 0, L_ENERGYHIST <<2 );
+
+ /* Initialize hangover handling */
+ state->background_state->bgHangover = 0;
+
+ /* phDispReset */
+ memset( state->ph_disp_st->gainMem, 0, PHDGAINMEMSIZE <<2 );
+ state->ph_disp_st->prevState = 0;
+ state->ph_disp_st->prevCbGain = 0;
+ state->ph_disp_st->lockFull = 0;
+ state->ph_disp_st->onset = 0; /* assume no onset in start */
+
+ if ( mode != MRDTX ) {
+ state->dtxDecoderState->since_last_sid = 0;
+ state->dtxDecoderState->true_sid_period_inv = 8192;
+ state->dtxDecoderState->log_en = 3500;
+ state->dtxDecoderState->old_log_en = 3500;
+
+ /* low level noise for better performance in DTX handover cases*/
+ state->dtxDecoderState->pn_seed_rx = PN_INITIAL_SEED;
+
+ /* Initialize state->lsp [] */
+ state->dtxDecoderState->lsp[0] = 30000;
+ state->dtxDecoderState->lsp[1] = 26000;
+ state->dtxDecoderState->lsp[2] = 21000;
+ state->dtxDecoderState->lsp[3] = 15000;
+ state->dtxDecoderState->lsp[4] = 8000;
+ state->dtxDecoderState->lsp[5] = 0;
+ state->dtxDecoderState->lsp[6] = -8000;
+ state->dtxDecoderState->lsp[7] = -15000;
+ state->dtxDecoderState->lsp[8] = -21000;
+ state->dtxDecoderState->lsp[9] = -26000;
+
+ /* Initialize state->lsp_old [] */
+ state->dtxDecoderState->lsp_old[0] = 30000;
+ state->dtxDecoderState->lsp_old[1] = 26000;
+ state->dtxDecoderState->lsp_old[2] = 21000;
+ state->dtxDecoderState->lsp_old[3] = 15000;
+ state->dtxDecoderState->lsp_old[4] = 8000;
+ state->dtxDecoderState->lsp_old[5] = 0;
+ state->dtxDecoderState->lsp_old[6] = -8000;
+ state->dtxDecoderState->lsp_old[7] = -15000;
+ state->dtxDecoderState->lsp_old[8] = -21000;
+ state->dtxDecoderState->lsp_old[9] = -26000;
+ state->dtxDecoderState->lsf_hist_ptr = 0;
+ state->dtxDecoderState->log_pg_mean = 0;
+ state->dtxDecoderState->log_en_hist_ptr = 0;
+
+ /* initialize decoder lsf history */
+ state->dtxDecoderState->lsf_hist[0] = 1384;
+ state->dtxDecoderState->lsf_hist[1] = 2077;
+ state->dtxDecoderState->lsf_hist[2] = 3420;
+ state->dtxDecoderState->lsf_hist[3] = 5108;
+ state->dtxDecoderState->lsf_hist[4] = 6742;
+ state->dtxDecoderState->lsf_hist[5] = 8122;
+ state->dtxDecoderState->lsf_hist[6] = 9863;
+ state->dtxDecoderState->lsf_hist[7] = 11092;
+ state->dtxDecoderState->lsf_hist[8] = 12714;
+ state->dtxDecoderState->lsf_hist[9] = 13701;
+
+ for ( i = 1; i < DTX_HIST_SIZE; i++ ) {
+ memcpy( &state->dtxDecoderState->lsf_hist[M * i], &state->
+ dtxDecoderState->lsf_hist[0], M <<2 );
+ }
+ memset( state->dtxDecoderState->lsf_hist_mean, 0, M * DTX_HIST_SIZE <<2 );
+
+ /* initialize decoder log frame energy */
+ for ( i = 0; i < DTX_HIST_SIZE; i++ ) {
+ state->dtxDecoderState->log_en_hist[i] = state->dtxDecoderState->log_en
+ ;
+ }
+ state->dtxDecoderState->log_en_adjust = 0;
+ state->dtxDecoderState->dtxHangoverCount = DTX_HANG_CONST;
+ state->dtxDecoderState->decAnaElapsedCount = 31;
+ state->dtxDecoderState->sid_frame = 0;
+ state->dtxDecoderState->valid_data = 0;
+ state->dtxDecoderState->dtxHangoverAdded = 0;
+ state->dtxDecoderState->dtxGlobalState = DTX;
+ state->dtxDecoderState->data_updated = 0;
+ }
+ return;
+}
+
+
+/*
+ * rx_dtx_handler
+ *
+ *
+ * Parameters:
+ * st->dtxGlobalState I: DTX state
+ * st->since_last_sid B: Frames after last SID frame
+ * st->data_updated I: SID update flag
+ * st->decAnaElapsedCount B: state machine that synch with the GSMEFR txDtx machine
+ * st->dtxHangoverAdded B: DTX hangover
+ * st->sid_frame O: SID frame indicator
+ * st->valid_data O: Vaild data indicator
+ * frame_type O: Frame type
+ *
+ * Function:
+ * Find the new DTX state
+ *
+ * Returns:
+ * DTXStateType DTX, DTX_MUTE or SPEECH
+ */
+static enum DTXStateType rx_dtx_handler( dtx_decState *st, enum RXFrameType frame_type )
+{
+ enum DTXStateType newState;
+ enum DTXStateType encState;
+
+ /* DTX if SID frame or previously in DTX{_MUTE} and (NO_RX OR BAD_SPEECH) */
+ if ( table_SID[frame_type] | ( ( st->dtxGlobalState != SPEECH ) &
+ table_speech_bad[frame_type] ) ) {
+ newState = DTX;
+
+ /* stay in mute for these input types */
+ if ( ( st->dtxGlobalState == DTX_MUTE ) & table_mute[frame_type] ) {
+ newState = DTX_MUTE;
+ }
+
+ /*
+ * evaluate if noise parameters are too old
+ * since_last_sid is reset when CN parameters have been updated
+ */
+ st->since_last_sid += 1;
+
+ /* no update of sid parameters in DTX for a long while */
+ if ((frame_type != RX_SID_UPDATE) & ( st->since_last_sid > DTX_MAX_EMPTY_THRESH )) {
+ newState = DTX_MUTE;
+ }
+ }
+ else {
+ newState = SPEECH;
+ st->since_last_sid = 0;
+ }
+
+ /*
+ * reset the decAnaElapsed Counter when receiving CNI data the first
+ * time, to robustify counter missmatch after handover
+ * this might delay the bwd CNI analysis in the new decoder slightly.
+ */
+ if ( ( st->data_updated == 0 ) & ( frame_type == RX_SID_UPDATE ) ) {
+ st->decAnaElapsedCount = 0;
+ }
+
+ /*
+ * update the SPE-SPD DTX hangover synchronization
+ * to know when SPE has added dtx hangover
+ */
+ st->decAnaElapsedCount += 1;
+ st->dtxHangoverAdded = 0;
+ encState = SPEECH;
+
+ if ( table_DTX[frame_type] ) {
+ encState = DTX;
+ if( ( frame_type == RX_NO_DATA ) & ( newState == SPEECH ) ) {
+ encState = SPEECH;
+ }
+ }
+
+ if ( encState == SPEECH ) {
+ st->dtxHangoverCount = DTX_HANG_CONST;
+ }
+ else {
+ if ( st->decAnaElapsedCount > DTX_ELAPSED_FRAMES_THRESH ) {
+ st->dtxHangoverAdded = 1;
+ st->decAnaElapsedCount = 0;
+ st->dtxHangoverCount = 0;
+ }
+ else if ( st->dtxHangoverCount == 0 ) {
+ st->decAnaElapsedCount = 0;
+ }
+ else {
+ st->dtxHangoverCount -= 1;
+ }
+ }
+
+ if ( newState != SPEECH ) {
+ /*
+ * DTX or DTX_MUTE
+ * CN data is not in a first SID, first SIDs are marked as SID_BAD
+ * but will do backwards analysis if a hangover period has been added
+ * according to the state machine above
+ */
+ st->sid_frame = 0;
+ st->valid_data = 0;
+
+ if ( frame_type == RX_SID_FIRST ) {
+ st->sid_frame = 1;
+ }
+ else if ( frame_type == RX_SID_UPDATE ) {
+ st->sid_frame = 1;
+ st->valid_data = 1;
+ }
+ else if ( frame_type == RX_SID_BAD ) {
+ st->sid_frame = 1;
+
+ /* use old data */
+ st->dtxHangoverAdded = 0;
+ }
+ }
+
+ /* newState is used by both SPEECH AND DTX synthesis routines */
+ return newState;
+}
+
+
+/*
+ * Lsf_lsp
+ *
+ *
+ * Parameters:
+ * lsf I: vector of LSFs
+ * lsp O: vector of LSPs
+ *
+ * Function:
+ * Transformation lsf to lsp, order M
+ *
+ * Returns:
+ * void
+ */
+static void Lsf_lsp( Word32 lsf[], Word32 lsp[] )
+{
+ Word32 i, ind, offset, tmp;
+
+
+ for ( i = 0; i < M; i++ ) {
+ /* ind = b8-b15 of lsf[i] */
+ ind = lsf[i] >> 8;
+
+ /* offset = b0-b7 of lsf[i] */
+ offset = lsf[i] & 0x00ff;
+
+ /* lsp[i] = table[ind]+ ((table[ind+1]-table[ind])*offset) / 256 */
+ tmp = ( ( cos_table[ind+1]-cos_table[ind] )*offset ) << 1;
+ lsp[i] = cos_table[ind] + ( tmp >> 9 );
+ }
+ return;
+}
+
+
+/*
+ * D_plsf_3
+ *
+ *
+ * Parameters:
+ * st->past_lsf_q I: Past dequantized LFSs
+ * st->past_r_q B: past quantized residual
+ * mode I: AMR mode
+ * bfi B: bad frame indicator
+ * indice I: quantization indices of 3 submatrices, Q0
+ * lsp1_q O: quantized 1st LSP vector
+ *
+ * Function:
+ * Decodes the LSP parameters using the received quantization indices.
+ * 1st order MA prediction and split by 3 vector quantization (split-VQ)
+ *
+ * Returns:
+ * void
+ */
+static void D_plsf_3( D_plsfState *st, enum Mode mode, Word16 bfi, Word16 *
+ indice, Word32 *lsp1_q )
+{
+ Word32 lsf1_r[M], lsf1_q[M];
+ Word32 i, index, temp;
+ const Word32 *p_cb1, *p_cb2, *p_cb3, *p_dico;
+
+
+ /* if bad frame */
+ if ( bfi != 0 ) {
+ /* use the past LSFs slightly shifted towards their mean */
+ for ( i = 0; i < M; i++ ) {
+ /* lsfi_q[i] = ALPHA*past_lsf_q[i] + ONE_ALPHA*meanLsf[i]; */
+ lsf1_q[i] = ( ( st->past_lsf_q[i] * ALPHA ) >> 15 ) + ( ( mean_lsf_3[i]
+ * ONE_ALPHA ) >> 15 );
+ }
+
+ /* estimate past quantized residual to be used in next frame */
+ if ( mode != MRDTX ) {
+ for ( i = 0; i < M; i++ ) {
+ /* temp = meanLsf[i] + pastR2_q[i] * pred_fac; */
+ temp = mean_lsf_3[i] + ( ( st->past_r_q[i] * pred_fac[i] ) >> 15 );
+ st->past_r_q[i] = lsf1_q[i] - temp;
+ }
+ }
+ else {
+ for ( i = 0; i < M; i++ ) {
+ /* temp = meanLsf[i] + pastR2_q[i]; */
+ temp = mean_lsf_3[i] + st->past_r_q[i];
+ st->past_r_q[i] = lsf1_q[i] - temp;
+ }
+ }
+ }
+
+ /* if good LSFs received */
+ else {
+ if ( ( mode == MR475 ) | ( mode == MR515 ) ) {
+ /* MR475, MR515 */
+ p_cb1 = dico1_lsf_3;
+ p_cb2 = dico2_lsf_3;
+ p_cb3 = mr515_3_lsf;
+ }
+ else if ( mode == MR795 ) {
+ /* MR795 */
+ p_cb1 = mr795_1_lsf;
+ p_cb2 = dico2_lsf_3;
+ p_cb3 = dico3_lsf_3;
+ }
+ else {
+ /* MR59, MR67, MR74, MR102, MRDTX */
+ p_cb1 = dico1_lsf_3;
+ p_cb2 = dico2_lsf_3;
+ p_cb3 = dico3_lsf_3;
+ }
+
+ /* decode prediction residuals from 3 received indices */
+ index = *indice++;
+ p_dico = &p_cb1[index + index + index];
+ index = *indice++;
+ lsf1_r[0] = *p_dico++;
+ lsf1_r[1] = *p_dico++;
+ lsf1_r[2] = *p_dico++;
+
+ if ( ( mode == MR475 ) | ( mode == MR515 ) ) {
+ /* MR475, MR515 only using every second entry */
+ index = index << 1;
+ }
+ p_dico = &p_cb2[index + index + index];
+ index = *indice++;
+ lsf1_r[3] = *p_dico++;
+ lsf1_r[4] = *p_dico++;
+ lsf1_r[5] = *p_dico++;
+ p_dico = &p_cb3[index << 2];
+ lsf1_r[6] = *p_dico++;
+ lsf1_r[7] = *p_dico++;
+ lsf1_r[8] = *p_dico++;
+ lsf1_r[9] = *p_dico++;
+
+ /* Compute quantized LSFs and update the past quantized residual */
+ if ( mode != MRDTX ) {
+ for ( i = 0; i < M; i++ ) {
+ lsf1_q[i] = lsf1_r[i] + ( mean_lsf_3[i] + ( ( st->past_r_q[i] *
+ pred_fac[i] ) >> 15 ) );
+ }
+ memcpy( st->past_r_q, lsf1_r, M <<2 );
+ }
+ else {
+ for ( i = 0; i < M; i++ ) {
+ lsf1_q[i] = lsf1_r[i] + ( mean_lsf_3[i] + st->past_r_q[i] );
+ }
+ memcpy( st->past_r_q, lsf1_r, M <<2 );
+ }
+ }
+
+ /* verification that LSFs has minimum distance of LSF_GAP Hz */
+ temp = LSF_GAP;
+
+ for ( i = 0; i < M; i++ ) {
+ if ( lsf1_q[i] < temp ) {
+ lsf1_q[i] = temp;
+ }
+ temp = lsf1_q[i] + LSF_GAP;
+ }
+ memcpy( st->past_lsf_q, lsf1_q, M <<2 );
+
+ /* convert LSFs to the cosine domain */
+ Lsf_lsp( lsf1_q, lsp1_q );
+ return;
+}
+
+
+/*
+ * pseudonoise
+ *
+ *
+ * Parameters:
+ * shift_reg B: Old CN generator shift register state
+ * no_bits I: Number of bits
+ *
+ * Function:
+ * pseudonoise
+ *
+ * Returns:
+ * noise_bits
+ */
+static Word32 pseudonoise( Word32 *shift_reg, Word32 no_bits )
+{
+ Word32 noise_bits, Sn, i;
+ Word32 s_reg;
+
+
+ s_reg = *shift_reg;
+ noise_bits = 0;
+
+ for ( i = 0; i < no_bits; i++ ) {
+ /* State n == 31 */
+ Sn = s_reg & 0x00000001L;
+
+ /* State n == 3 */
+ if ( s_reg & 0x10000000L ) {
+ Sn = Sn ^ 0x1L;
+ }
+ else {
+ Sn = Sn ^ 0x0L;
+ }
+ noise_bits = ( noise_bits << 1 ) | ( s_reg & 1 );
+ s_reg = s_reg >> 1;
+
+ if ( Sn & 1 ) {
+ s_reg = s_reg | 0x40000000L;
+ }
+ }
+ *shift_reg = s_reg;
+ return noise_bits;
+}
+
+
+/*
+ * Lsp_lsf
+ *
+ *
+ * Parameters:
+ * lsp I: LSP vector (range: -1<=val<1)
+ * lsf O: LSF vector Old CN generator shift register state
+ *
+ * Function:
+ * Transformation lsp to lsf, LPC order M
+ * lsf[i] = arccos(lsp[i])/(2*pi)
+ *
+ * Returns:
+ * void
+ */
+static void Lsp_lsf( Word32 lsp[], Word32 lsf[] )
+{
+ Word32 i, ind = 63; /* begin at end of table -1 */
+
+
+ for ( i = M - 1; i >= 0; i-- ) {
+ /* find value in table that is just greater than lsp[i] */
+ while ( cos_table[ind] < lsp[i] ) {
+ ind--;
+ }
+ lsf[i] = ( ( ( ( lsp[i] - cos_table[ind] ) * acos_slope[ind] ) + 0x800 )
+ >> 12 ) + ( ind << 8 );
+ }
+ return;
+}
+
+
+/*
+ * Reorder_lsf
+ *
+ *
+ * Parameters:
+ * lsf B: vector of LSFs (range: 0<=val<=0.5)
+ * min_dist I: minimum required distance
+ *
+ * Function:
+ * Make sure that the LSFs are properly ordered and to keep a certain minimum
+ * distance between adjacent LSFs. LPC order = M.
+ *
+ * Returns:
+ * void
+ */
+static void Reorder_lsf( Word32 *lsf, Word32 min_dist )
+{
+ Word32 lsf_min, i;
+
+
+ lsf_min = min_dist;
+
+ for ( i = 0; i < M; i++ ) {
+ if ( lsf[i] < lsf_min ) {
+ lsf[i] = lsf_min;
+ }
+ lsf_min = lsf[i] + min_dist;
+ }
+}
+
+/* VC5.0 Global optimization does not work with this function */
+#if _MSC_VER == 1100
+#pragma optimize( "g", off )
+#endif
+/*
+ * Get_lsp_pol
+ *
+ *
+ * Parameters:
+ * lsp I: line spectral frequencies
+ * f O: polynomial F1(z) or F2(z)
+ *
+ * Function:
+ * Find the polynomial F1(z) or F2(z) from the LSPs.
+ *
+ * F1(z) = product ( 1 - 2 lsp[i] z^-1 + z^-2 )
+ * i=0,2,4,6,8
+ * F2(z) = product ( 1 - 2 lsp[i] z^-1 + z^-2 )
+ * i=1,3,5,7,9
+ *
+ * where lsp[] is the LSP vector in the cosine domain.
+ *
+ * The expansion is performed using the following recursion:
+ *
+ * f[0] = 1
+ * b = -2.0 * lsp[0]
+ * f[1] = b
+ * for i=2 to 5 do
+ * b = -2.0 * lsp[2*i-2];
+ * f[i] = b*f[i-1] + 2.0*f[i-2];
+ * for j=i-1 down to 2 do
+ * f[j] = f[j] + b*f[j-1] + f[j-2];
+ * f[1] = f[1] + b;
+ *
+ * Returns:
+ * void
+ */
+static void Get_lsp_pol( Word32 *lsp, Word32 *f )
+{
+ volatile Word32 f0, f1, f2, f3, f4, f5;
+ Word32 l1, l2, l3, l4;
+
+
+ /* f[0] = 1.0; */
+ f0 = 16777216L;
+
+ /* f1 = *lsp * -1024; */
+ f1 = -lsp[0] << 10;
+ l1 = lsp[2];
+ l2 = lsp[4];
+ l3 = lsp[6];
+ l4 = lsp[8];
+ f2 = f0 << 1;
+ f2 -= ( ( ( f1 >> 16 ) * l1 ) + ( ( ( f1 & 0xFFFE ) * l1 ) >> 16 ) ) << 2;
+ f1 -= l1 << 10;
+ f3 = f1 << 1;
+ f3 -= ( ( ( f2 >> 16 ) * l2 ) + ( ( ( f2 & 0xFFFE ) * l2 ) >> 16 ) ) << 2;
+ f2 += f0;
+ f2 -= ( ( ( f1 >> 16 ) * l2 ) + ( ( ( f1 & 0xFFFE ) * l2 ) >> 16 ) ) << 2;
+ f1 -= l2 << 10;
+ f4 = f2 << 1;
+ f4 -= ( ( ( f3 >> 16 ) * l3 ) + ( ( ( f3 & 0xFFFE ) * l3 ) >> 16 ) ) << 2;
+ f3 += f1;
+ f3 -= ( ( ( f2 >> 16 ) * l3 ) + ( ( ( f2 & 0xFFFE ) * l3 ) >> 16 ) ) << 2;
+ f2 += f0;
+ f2 -= ( ( ( f1 >> 16 ) * l3 ) + ( ( ( f1 & 0xFFFE ) * l3 ) >> 16 ) ) << 2;
+ f1 -= l3 << 10;
+ f5 = f3 << 1;
+ f5 -= ( ( ( f4 >> 16 ) * l4 ) + ( ( ( f4 & 0xFFFE ) * l4 ) >> 16 ) ) << 2;
+ f4 += f2;
+ f4 -= ( ( ( f3 >> 16 ) * l4 ) + ( ( ( f3 & 0xFFFE ) * l4 ) >> 16 ) ) << 2;
+ f3 += f1;
+ f3 -= ( ( ( f2 >> 16 ) * l4 ) + ( ( ( f2 & 0xFFFE ) * l4 ) >> 16 ) ) << 2;
+ f2 += f0;
+ f2 -= ( ( ( f1 >> 16 ) * l4 ) + ( ( ( f1 & 0xFFFE ) * l4 ) >> 16 ) ) << 2;
+ f1 -= l4 << 10;
+ f[0] = f0;
+ f[1] = f1;
+ f[2] = f2;
+ f[3] = f3;
+ f[4] = f4;
+ f[5] = f5;
+ return;
+}
+#if _MSC_VER == 1100
+#pragma optimize( "", on )
+#endif
+
+
+/*
+ * Lsp_Az
+ *
+ *
+ * Parameters:
+ * lsp I: Line spectral frequencies
+ * a O: Predictor coefficients
+ *
+ * Function:
+ * Converts from the line spectral pairs (LSP) to LP coefficients,
+ * for a 10th order filter.
+ *
+ * Find the coefficients of F1(z) and F2(z)
+ * Multiply F1(z) by 1+z^{-1} and F2(z) by 1-z^{-1}
+ * A(z) = ( F1(z) + F2(z) ) / 2
+ *
+ * Returns:
+ * void
+ */
+static void Lsp_Az( Word32 lsp[], Word32 a[] )
+{
+ Word32 f1[6], f2[6];
+ Word32 T0, i, j;
+
+
+ Get_lsp_pol( &lsp[0], f1 );
+ Get_lsp_pol( &lsp[1], f2 );
+
+ for ( i = 5; i > 0; i-- ) {
+ f1[i] += f1[i - 1];
+ f2[i] -= f2[i - 1];
+ }
+ a[0] = 4096;
+
+ for ( i = 1, j = 10; i <= 5; i++, j-- ) {
+ T0 = f1[i] + f2[i];
+ a[i] = (Word16)(T0 >> 13); /* emulate fixed point bug */
+ if ( ( T0 & 4096 ) != 0 ) {
+ a[i]++;
+ }
+ T0 = f1[i] - f2[i];
+ a[j] = (Word16)(T0 >> 13); /* emulate fixed point bug */
+
+ if ( ( T0 & 4096 ) != 0 ) {
+ a[j]++;
+ }
+ }
+ return;
+}
+
+
+/*
+ * A_Refl
+ *
+ *
+ * Parameters:
+ * a I: Directform coefficients
+ * refl O: Reflection coefficients
+ *
+ * Function:
+ * Converts from the directform coefficients to reflection coefficients
+ *
+ * Returns:
+ * void
+ */
+static void A_Refl( Word32 a[], Word32 refl[] )
+{
+ /* local variables */
+ int normShift;
+ Word32 aState[M], bState[M];
+ Word32 normProd, acc, temp, mult, scale, i, j;
+
+
+ /* initialize states */
+ memcpy( aState, a, M <<2 );
+
+ /* backward Levinson recursion */
+ for ( i = M - 1; i >= 0; i-- ) {
+ if ( labs( aState[i] ) >= 4096 ) {
+ goto ExitRefl;
+ }
+ refl[i] = aState[i] << 3;
+ temp = ( refl[i] * refl[i] ) << 1;
+ acc = ( MAX_32 - temp );
+ normShift=0;
+ if (acc != 0){
+ temp = acc;
+ while (!(temp & 0x40000000))
+ {
+ normShift++;
+ temp = temp << 1;
+ }
+ }
+ else{
+ normShift = 0;
+ }
+ scale = 15 - normShift;
+ acc = ( acc << normShift );
+ temp = ( acc + ( Word32 )0x00008000L );
+
+ if ( temp > 0 ) {
+ normProd = temp >> 16;
+ mult = 0x20000000L / normProd;
+ }
+ else
+ mult = 16384;
+
+ for ( j = 0; j < i; j++ ) {
+ acc = aState[j] << 16;
+ acc -= ( refl[i] * aState[i - j - 1] ) << 1;
+ temp = ( acc + ( Word32 )0x00008000L ) >> 16;
+ temp = ( mult * temp ) << 1;
+
+ if ( scale > 0 ) {
+ if ( ( temp & ( ( Word32 )1 << ( scale - 1 ) ) ) != 0 ) {
+ temp = ( temp >> scale ) + 1;
+ }
+ else
+ temp = ( temp >> scale );
+ }
+ else
+ temp = ( temp >> scale );
+
+ if ( labs( temp ) > 32767 ) {
+ goto ExitRefl;
+ }
+ bState[j] = temp;
+ }
+ memcpy( aState, bState, i <<2 );
+ }
+ return;
+ExitRefl:
+ memset( refl, 0, M <<2 );
+}
+
+
+/*
+ * Log2_norm
+ *
+ *
+ * Parameters:
+ * x I: input value
+ * exp I: exponent
+ * exponent O: Integer part of Log2. (range: 0<=val<=30)
+ * fraction O: Fractional part of Log2. (range: 0<=val<1)
+ *
+ * Function:
+ * Computes log2
+ *
+ * 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.
+ *
+ * The function Log2(L_x) is approximated by a table and linear
+ * interpolation. The following steps are used to compute Log2(L_x)
+ *
+ * exponent = 30-normExponent
+ * i = bit25-b31 of L_x; 32<=i<=63 (because of normalization).
+ * a = bit10-b24
+ * i -=32
+ * fraction = table[i]<<16 - (table[i] - table[i+1]) * a * 2
+ *
+ * Returns:
+ * void
+ */
+static void Log2_norm( Word32 x, Word32 exp, Word32 *exponent, Word32 *
+ fraction )
+{
+ Word32 y, i, a;
+
+
+ if ( x <= 0 ) {
+ *exponent = 0;
+ *fraction = 0;
+ return;
+ }
+
+ /* Extract b25-b31 */
+ i = x >> 25;
+ i = i - 32;
+
+ /* Extract b10-b24 of fraction */
+ a = x >> 9;
+ a = a & 0xFFFE; /* 2a */
+
+ /* fraction */
+ y = ( log2_table[i] << 16 ) - a * ( log2_table[i] - log2_table[i + 1] );
+ *fraction = y >> 16;
+ *exponent = 30 - exp;
+ return;
+}
+
+
+/*
+ * Log2
+ *
+ *
+ * Parameters:
+ * x I: input value
+ * exponent O: Integer part of Log2. (range: 0<=val<=30)
+ * fraction O: Fractional part of Log2. (range: 0<=val<1)
+ *
+ * Function:
+ * Computes log2(L_x)
+ * If x is negative or zero, the result is 0.
+ *
+ * Returns:
+ * void
+ */
+static void Log2( Word32 x, Word32 *exponent, Word32 *fraction )
+{
+ int tmp, exp=0;
+
+ if (x != 0){
+ tmp = x;
+ while (!((tmp & 0x80000000) ^ ((tmp & 0x40000000) << 1)))
+ {
+ exp++;
+ tmp = tmp << 1;
+ }
+ }
+ Log2_norm( x <<exp, exp, exponent, fraction );
+}
+
+
+/*
+ * Pow2
+ *
+ *
+ * Parameters:
+ * exponent I: Integer part. (range: 0<=val<=30)
+ * fraction O: Fractional part. (range: 0.0<=val<1.0)
+ *
+ * Function:
+ * pow(2.0, exponent.fraction)
+ *
+ * The function Pow2(L_x) is approximated by a table and linear interpolation.
+ *
+ * i = bit10-b15 of fraction, 0 <= i <= 31
+ * a = biT0-b9 of fraction
+ * x = table[i]<<16 - (table[i] - table[i+1]) * a * 2
+ * x = L_x >> (30-exponent) (with rounding)
+ *
+ * Returns:
+ * result (range: 0<=val<=0x7fffffff)
+ */
+static Word32 Pow2( Word32 exponent, Word32 fraction )
+{
+ Word32 i, a, tmp, x, exp;
+
+
+ /* Extract b10-b16 of fraction */
+ i = fraction >> 10;
+
+ /* Extract b0-b9 of fraction */
+ a = ( fraction << 5 ) & 0x7fff;
+
+ /* table[i] << 16 */
+ x = pow2_table[i] << 16;
+
+ /* table[i] - table[i+1] */
+ tmp = pow2_table[i] - pow2_table[i + 1];
+
+ /* L_x -= tmp*a*2 */
+ x -= ( tmp * a ) << 1;
+
+ if ( exponent >= -1 ) {
+ exp = ( 30 - exponent );
+
+ /* Rounding */
+ if ( ( x & ( ( Word32 )1 << ( exp - 1 ) ) ) != 0 ) {
+ x = ( x >> exp ) + 1;
+ }
+ else
+ x = x >> exp;
+ }
+ else
+ x = 0;
+ return( x );
+}
+
+
+/*
+ * Build_CN_code
+ *
+ *
+ * Parameters:
+ * seed B: Old CN generator shift register state
+ * cod O: Generated CN fixed codebook vector
+ *
+ * Function:
+ * Generate CN fixed codebook vector
+ *
+ * Returns:
+ * void
+ */
+static void Build_CN_code( Word32 *seed, Word32 cod[] )
+{
+ Word32 i, j, k;
+
+
+ memset( cod, 0, L_SUBFR <<2 );
+
+ for ( k = 0; k < 10; k++ ) {
+ i = pseudonoise( seed, 2 ); /* generate pulse position */
+ i = ( i * 20 ) >> 1;
+ i = ( i + k );
+ j = pseudonoise( seed, 1 ); /* generate sign */
+
+ if ( j > 0 ) {
+ cod[i] = 4096;
+ }
+ else {
+ cod[i] = -4096;
+ }
+ }
+ return;
+}
+
+
+/*
+ * Build_CN_param
+ *
+ *
+ * Parameters:
+ * seed B: Old CN generator shift register state
+ * nParam I: number of params
+ * paramSizeTable I: size of params
+ * parm O: CN Generated params
+ *
+ * Function:
+ * Generate parameters for comfort noise generation
+ *
+ * Returns:
+ * void
+ */
+static void Build_CN_param( Word16 *seed, enum Mode mode, Word16 parm[] )
+{
+ Word32 i;
+ const Word32 *p;
+
+
+ *seed = ( Word16 )( ( *seed * 31821 ) + 13849L );
+ p = &window_200_40[ * seed & 0x7F];
+
+ switch ( mode ) {
+ case MR122:
+ for ( i = 0; i < PRMNO_MR122; i++ ) {
+ parm[i] = ( Word16 )( *p++ & ~( 0xFFFF << bitno_MR122[i] ) );
+ }
+ break;
+
+ case MR102:
+ for ( i = 0; i < PRMNO_MR102; i++ ) {
+ parm[i] = ( Word16 )( *p++ & ~( 0xFFFF << bitno_MR102[i] ) );
+ }
+ break;
+
+ case MR795:
+ for ( i = 0; i < PRMNO_MR795; i++ ) {
+ parm[i] = ( Word16 )( *p++ & ~( 0xFFFF << bitno_MR795[i] ) );
+ }
+ break;
+
+ case MR74:
+ for ( i = 0; i < PRMNO_MR74; i++ ) {
+ parm[i] = ( Word16 )( *p++ & ~( 0xFFFF << bitno_MR74[i] ) );
+ }
+ break;
+
+ case MR67:
+ for ( i = 0; i < PRMNO_MR67; i++ ) {
+ parm[i] = ( Word16 )( *p++ & ~( 0xFFFF << bitno_MR67[i] ) );
+ }
+ break;
+
+ case MR59:
+ for ( i = 0; i < PRMNO_MR59; i++ ) {
+ parm[i] = ( Word16 )( *p++ & ~( 0xFFFF << bitno_MR59[i] ) );
+ }
+ break;
+
+ case MR515:
+ for ( i = 0; i < PRMNO_MR515; i++ ) {
+ parm[i] = ( Word16 )( *p++ & ~( 0xFFFF << bitno_MR515[i] ) );
+ }
+ break;
+
+ case MR475:
+ for ( i = 0; i < PRMNO_MR475; i++ ) {
+ parm[i] = ( Word16 )( *p++ & ~( 0xFFFF << bitno_MR475[i] ) );
+ }
+ break;
+ }
+}
+
+
+/*
+ * Syn_filt
+ *
+ *
+ * Parameters:
+ * a I: prediction coefficients [M+1]
+ * x I: input signal
+ * y O: output signal
+ * lg I: size of filtering
+ * mem B: memory associated with this filtering
+ * update I: 0=no update, 1=update of memory.
+ *
+ * Function:
+ * Perform synthesis filtering through 1/A(z).
+ *
+ * Returns:
+ * void
+ */
+static Word32 Syn_filt( Word32 a[], Word32 x[], Word32 y[], Word32 lg, Word32 mem[]
+ , Word32 update )
+{
+ Word32 tmp[50]; /* malloc is slow */
+ Word32 s, a0, overflow = 0;
+ Word32 *yy, *yy_limit;
+
+
+ /* Copy mem[] to yy[] */
+ memcpy( tmp, mem, 40 );
+ yy = tmp + M;
+ yy_limit = yy + lg;
+ a0 = a[0];
+
+ /* Do the filtering. */
+ while ( yy < yy_limit ) {
+
+ s = *x++ * a0;
+ s -= yy[-1] * a[1];
+ s -= yy[-2] * a[2];
+ s -= yy[-3] * a[3];
+ s -= yy[-4] * a[4];
+ s -= yy[-5] * a[5];
+ s -= yy[-6] * a[6];
+ s -= yy[-7] * a[7];
+ s -= yy[-8] * a[8];
+ s -= yy[-9] * a[9];
+ s -= yy[-10] * a[10];
+ if ( labs( s ) < 0x7ffffff )
+ *yy = ( s + 0x800L ) >> 12;
+ else if ( s > 0 ) {
+ *yy = 32767;
+ overflow = 1;
+ }
+ else {
+ *yy = -32768;
+ overflow = 1;
+ }
+ yy++;
+ }
+ memcpy( y, &tmp[M], lg <<2 );
+
+ /* Update of memory if update==1 */
+ if ( update ) {
+ memcpy( mem, &y[lg - M], 40 );
+ }
+ return overflow;
+}
+
+/*
+ * Syn_filt_overflow
+ *
+ *
+ * Parameters:
+ * a I: prediction coefficients [M+1]
+ * x I: input signal
+ * y O: output signal
+ * lg I: size of filtering
+ * mem B: memory associated with this filtering
+ * update I: 0=no update, 1=update of memory.
+ *
+ * Function:
+ * Perform synthesis filtering through 1/A(z).
+ * Saturate after every multiplication.
+ * Returns:
+ * void
+ */
+static void Syn_filt_overflow( Word32 a[], Word32 x[], Word32 y[], Word32 lg, Word32 mem[]
+ , Word32 update )
+{
+ Word32 tmp[50]; /* malloc is slow */
+ Word32 i, j, s, a0;
+ Word32 *yy;
+
+
+ /* Copy mem[] to yy[] */
+ memcpy( tmp, mem, 40 );
+ yy = tmp + M;
+ a0 = a[0];
+
+ /* Do the filtering. */
+ for ( i = 0; i < lg; i++ ) {
+ s = x[i] * a0;
+
+ for ( j = 1; j <= M; j++ ) {
+ s -= a[j] * yy[ - j];
+ if (s > 1073741823){
+ s = 1073741823;
+ }
+ else if ( s < -1073741824) {
+ s = -1073741824;
+ }
+ }
+
+ if ( labs( s ) < 0x7FFE800 )
+ *yy = ( s + 0x800L ) >> 12;
+ else if ( s > 0 ) {
+ *yy = 32767;
+ }
+ else {
+ *yy = -32768;
+ }
+ yy++;
+ }
+ memcpy( y, &tmp[M], lg <<2 );
+
+ /* Update of memory if update==1 */
+ if ( update ) {
+ memcpy( mem, &y[lg - M], 40 );
+ }
+ return;
+}
+
+/*
+ * dtx_dec
+ *
+ *
+ * Parameters:
+ * st B: DTX state struct
+ * mem_syn I: AMR decoder state
+ * lsfState B: LSF state struct
+ * pred_state->past_qua_en O: table of past quantized energies
+ * pred_state->past_qua_en_MR122 O: table of past quantized energies MR122
+ * averState->hangVar O:
+ * averState->hangCount O: hangover variable
+ * new_state I: new DTX state
+ * mode I: AMR mode
+ * parm I: vector of synthesis parameters
+ * synth O: synthesised speech
+ * A_t O: decoded LP filter in 4 subframes
+ *
+ * Function:
+ * DTX
+ *
+ * Returns:
+ * void
+ */
+static void dtx_dec( dtx_decState *st, Word32 *mem_syn, D_plsfState *lsfState,
+ gc_predState *pred_state, Cb_gain_averageState *averState, enum
+ DTXStateType new_state, enum Mode mode, Word16 parm[], Word32 synth[],
+ Word32 A_t[] )
+{
+ Word32 ex[L_SUBFR], acoeff[11], acoeff_variab[M + 1], lsp_int[M];
+ Word32 refl[M], lsf[M], lsf_int[M], lsf_int_variab[M], lsp_int_variab[M];
+ Word32 i, j, int_fac, log_en_int, pred_err, log_pg_e, log_pg_m, log_pg;
+ Word32 negative, lsf_mean, lsf_variab_index, lsf_variab_factor, ptr;
+ Word16 log_en_index, log_en_int_e, log_en_int_m, level, ma_pred_init,
+ tmp_int_length;
+
+
+ if ( ( st->dtxHangoverAdded != 0 ) & ( st->sid_frame != 0 ) ) {
+ /*
+ * sidFirst after dtx hangover period
+ * or sidUpd after dtxhangover
+ */
+ /* set log_en_adjust to correct value */
+ st->log_en_adjust = dtx_log_en_adjust[mode];
+ ptr = st->lsf_hist_ptr + M;
+
+ if ( ptr == 80 ) {
+ ptr = 0;
+ }
+ memcpy( &st->lsf_hist[ptr], &st->lsf_hist[st->lsf_hist_ptr], M <<2 );
+ ptr = st->log_en_hist_ptr + 1;
+
+ if ( ptr == DTX_HIST_SIZE ) {
+ ptr = 0;
+ }
+ st->log_en_hist[ptr] = st->log_en_hist[st->log_en_hist_ptr]; /* Q11 */
+
+ /*
+ * compute mean log energy and lsp
+ * from decoded signal (SID_FIRST)
+ */
+ st->log_en = 0;
+ memset( lsf, 0, M <<2 );
+
+ /* average energy and lsp */
+ for ( i = 0; i < DTX_HIST_SIZE; i++ ) {
+ st->log_en = st->log_en + ( st->log_en_hist[i] >> 3 );
+
+ for ( j = 0; j < M; j++ ) {
+ lsf[j] += st->lsf_hist[i * M + j];
+ }
+ }
+
+ for ( j = 0; j < M; j++ ) {
+ lsf[j] = lsf[j] >> 3; /* divide by 8 */
+ }
+ Lsf_lsp( lsf, st->lsp );
+
+ /*
+ * make log_en speech coder mode independent
+ * added again later before synthesis
+ */
+ st->log_en = st->log_en - st->log_en_adjust;
+
+ /* compute lsf variability vector */
+ memcpy( st->lsf_hist_mean, st->lsf_hist, 80 <<2 );
+
+ for ( i = 0; i < M; i++ ) {
+ lsf_mean = 0;
+
+ /* compute mean lsf */
+ for ( j = 0; j < 8; j++ ) {
+ lsf_mean += st->lsf_hist_mean[i + j * M];
+ }
+ lsf_mean = lsf_mean >> 3;
+
+ /*
+ * subtract mean and limit to within reasonable limits
+ * moreover the upper lsf's are attenuated
+ */
+ for ( j = 0; j < 8; j++ ) {
+ /* subtract mean */
+ st->lsf_hist_mean[i + j * M] = st->lsf_hist_mean[i + j * M] -
+ lsf_mean;
+
+ /* attenuate deviation from mean, especially for upper lsf's */
+ st->lsf_hist_mean[i + j * M] = ( st->lsf_hist_mean[i + j * M] *
+ lsf_hist_mean_scale[i] ) >> 15;
+
+ /* limit the deviation */
+ if ( st->lsf_hist_mean[i + j * M] < 0 ) {
+ negative = 1;
+ }
+ else {
+ negative = 0;
+ }
+ st->lsf_hist_mean[i + j * M] = labs( st->lsf_hist_mean[i + j * M] );
+
+ /* apply soft limit */
+ if ( st->lsf_hist_mean[i + j * M] > 655 ) {
+ st->lsf_hist_mean[i + j * M] = 655 + ( ( st->lsf_hist_mean[i + j
+ * M] - 655 ) >> 2 );
+ }
+
+ /* apply hard limit */
+ if ( st->lsf_hist_mean[i + j * M] > 1310 ) {
+ st->lsf_hist_mean[i + j * M] = 1310;
+ }
+
+ if ( negative != 0 ) {
+ st->lsf_hist_mean[i + j * M] = -st->lsf_hist_mean[i + j * M];
+ }
+ }
+ }
+ }
+
+ if ( st->sid_frame != 0 ) {
+ /*
+ * Set old SID parameters, always shift
+ * even if there is no new valid_data
+ */
+ memcpy( st->lsp_old, st->lsp, M <<2 );
+ st->old_log_en = st->log_en;
+
+ if ( st->valid_data != 0 ) /* new data available (no CRC) */ {
+ /* Compute interpolation factor, since the division only works
+ * for values of since_last_sid < 32 we have to limit the
+ * interpolation to 32 frames
+ */
+ tmp_int_length = st->since_last_sid;
+ st->since_last_sid = 0;
+
+ if ( tmp_int_length > 32 ) {
+ tmp_int_length = 32;
+ }
+
+ if ( tmp_int_length >= 2 ) {
+ st->true_sid_period_inv = 0x2000000 / ( tmp_int_length
+ << 10 );
+ }
+ else {
+ st->true_sid_period_inv = 16384; /* 0.5 it Q15 */
+ }
+ memcpy( lsfState->past_r_q, &past_rq_init[parm[0] * M], M <<2 );
+ D_plsf_3( lsfState, MRDTX, 0, &parm[1], st->lsp );
+
+ /* reset for next speech frame */
+ memset( lsfState->past_r_q, 0, M <<2 );
+ log_en_index = parm[4];
+
+ /* Q11 and divide by 4 */
+ st->log_en = ( Word16 )( log_en_index << 9 );
+
+ /* Subtract 2.5 in Q11 */
+ st->log_en = ( Word16 )( st->log_en - 5120 );
+
+ /* Index 0 is reserved for silence */
+ if ( log_en_index == 0 ) {
+ st->log_en = MIN_16;
+ }
+
+ /*
+ * no interpolation at startup after coder reset
+ * or when SID_UPD has been received right after SPEECH
+ */
+ if ( ( st->data_updated == 0 ) || ( st->dtxGlobalState == SPEECH ) ) {
+ memcpy( st->lsp_old, st->lsp, M <<2 );
+ st->old_log_en = st->log_en;
+ }
+ } /* endif valid_data */
+
+ /* initialize gain predictor memory of other modes */
+ ma_pred_init = ( Word16 )( ( st->log_en >> 1 ) - 9000 );
+
+ if ( ma_pred_init > 0 ) {
+ ma_pred_init = 0;
+ }
+
+ if ( ma_pred_init < - 14436 ) {
+ ma_pred_init = -14436;
+ }
+ pred_state->past_qua_en[0] = ma_pred_init;
+ pred_state->past_qua_en[1] = ma_pred_init;
+ pred_state->past_qua_en[2] = ma_pred_init;
+ pred_state->past_qua_en[3] = ma_pred_init;
+
+ /* past_qua_en for other modes than MR122 */
+ ma_pred_init = ( Word16 )( ( 5443*ma_pred_init ) >> 15 );
+
+ /* scale down by factor 20*log10(2) in Q15 */
+ pred_state->past_qua_en_MR122[0] = ma_pred_init;
+ pred_state->past_qua_en_MR122[1] = ma_pred_init;
+ pred_state->past_qua_en_MR122[2] = ma_pred_init;
+ pred_state->past_qua_en_MR122[3] = ma_pred_init;
+ } /* endif sid_frame */
+
+ /*
+ * CN generation
+ * recompute level adjustment factor Q11
+ * st->log_en_adjust = 0.9*st->log_en_adjust +
+ * 0.1*dtx_log_en_adjust[mode]);
+ */
+ st->log_en_adjust = ( Word16 )( ( ( st->log_en_adjust * 29491 ) >> 15 ) + ( (
+ ( dtx_log_en_adjust[mode] << 5 ) * 3277 ) >> 20 ) );
+
+ /* Interpolate SID info */
+ /* Q10 */
+ if ( st->since_last_sid > 30 )
+ int_fac = 32767;
+ else
+ int_fac = ( Word16 )( (st->since_last_sid + 1) << 10 );
+
+ /* Q10 * Q15 -> Q10 */
+ int_fac = ( int_fac * st->true_sid_period_inv ) >> 15;
+
+ /* Maximize to 1.0 in Q10 */
+ if ( int_fac > 1024 ) {
+ int_fac = 1024;
+ }
+
+ /* Q10 -> Q14 */
+ int_fac = ( Word16 )( int_fac << 4 );
+
+ /* Q14 * Q11->Q26 */
+ log_en_int = ( int_fac * st->log_en ) << 1;
+
+ for ( i = 0; i < M; i++ ) {
+ /* Q14 * Q15 -> Q14 */
+ lsp_int[i] = ( int_fac * st->lsp[i] ) >> 15;
+ }
+
+ /* 1-k in Q14 */
+ int_fac = 16384 - int_fac;
+
+ /* (Q14 * Q11 -> Q26) + Q26 -> Q26 */
+ log_en_int += ( int_fac * st->old_log_en ) << 1;
+
+ for ( i = 0; i < M; i++ ) {
+ /* Q14 + (Q14 * Q15 -> Q14) -> Q14 */
+ lsp_int[i] = lsp_int[i] + ( ( int_fac * st->lsp_old[i] ) >> 15 );
+
+ /* Q14 -> Q15 */
+ lsp_int[i] = lsp_int[i] << 1;
+ }
+
+ /* compute the amount of lsf variability */
+ /* -0.6 in Q12 */
+ lsf_variab_factor = st->log_pg_mean - 2457;
+
+ /* *0.3 Q12*Q15 -> Q12 */
+ lsf_variab_factor = 4096 - ( ( lsf_variab_factor * 9830 ) >> 15 );
+
+ /* limit to values between 0..1 in Q12 */
+ if ( lsf_variab_factor >= 4096 ) {
+ lsf_variab_factor = 32767;
+ }
+ else if ( lsf_variab_factor < 0 ) {
+ lsf_variab_factor = 0;
+ }
+ else
+ lsf_variab_factor = lsf_variab_factor << 3; /* -> Q15 */
+
+ /* get index of vector to do variability with */
+ lsf_variab_index = pseudonoise( &st->pn_seed_rx, 3 );
+
+ /* convert to lsf */
+ Lsp_lsf( lsp_int, lsf_int );
+
+ /* apply lsf variability */
+ memcpy( lsf_int_variab, lsf_int, M <<2 );
+
+ for ( i = 0; i < M; i++ ) {
+ lsf_int_variab[i] = lsf_int_variab[i] + ( ( lsf_variab_factor * st->
+ lsf_hist_mean[i + lsf_variab_index * M] ) >> 15 );
+ }
+
+ /* make sure that LSP's are ordered */
+ Reorder_lsf( lsf_int, LSF_GAP );
+ Reorder_lsf( lsf_int_variab, LSF_GAP );
+
+ /* copy lsf to speech decoders lsf state */
+ memcpy( lsfState->past_lsf_q, lsf_int, M <<2 );
+
+ /* convert to lsp */
+ Lsf_lsp( lsf_int, lsp_int );
+ Lsf_lsp( lsf_int_variab, lsp_int_variab );
+
+ /* Compute acoeffs Q12 acoeff is used for level
+ * normalization and Post_Filter, acoeff_variab is
+ * used for synthesis filter
+ * by doing this we make sure that the level
+ * in high frequenncies does not jump up and down
+ */
+ Lsp_Az( lsp_int, acoeff );
+ Lsp_Az( lsp_int_variab, acoeff_variab );
+
+ /* For use in Post_Filter */
+ memcpy( &A_t[0], acoeff, MP1 <<2 );
+ memcpy( &A_t[MP1], acoeff, MP1 <<2 );
+ memcpy( &A_t[MP1 <<1], acoeff, MP1 <<2 );
+ memcpy( &A_t[MP1 + MP1 + MP1], acoeff, MP1 <<2 );
+
+ /* Compute reflection coefficients Q15 */
+ A_Refl( &acoeff[1], refl );
+
+ /* Compute prediction error in Q15 */
+ /* 0.99997 in Q15 */
+ pred_err = MAX_16;
+
+ for ( i = 0; i < M; i++ ) {
+ pred_err = ( pred_err * ( MAX_16 - ( ( refl[i] * refl[i] ) >> 15 ) ) ) >>
+ 15;
+ }
+
+ /* compute logarithm of prediction gain */
+ Log2( pred_err, &log_pg_e, &log_pg_m );
+
+ /* convert exponent and mantissa to Word16 Q12 */
+ /* Q12 */
+ log_pg = ( log_pg_e - 15 ) << 12;
+ /* saturate */
+ if (log_pg < -32768) {
+ log_pg = -32768;
+ }
+ log_pg = ( -( log_pg + ( log_pg_m >> 3 ) ) ) >> 1;
+ st->log_pg_mean = ( Word16 )( ( ( 29491*st->log_pg_mean ) >> 15 ) + ( ( 3277
+ * log_pg ) >> 15 ) );
+
+ /* Compute interpolated log energy */
+ /* Q26 -> Q16 */
+ log_en_int = log_en_int >> 10;
+
+ /* Add 4 in Q16 */
+ log_en_int += 262144L;
+
+ /* subtract prediction gain */
+ log_en_int = log_en_int - ( log_pg << 4 );
+
+ /* adjust level to speech coder mode */
+ log_en_int += st->log_en_adjust << 5;
+ log_en_int_e = ( Word16 )( log_en_int >> 16 );
+ log_en_int_m = ( Word16 )( ( log_en_int - ( log_en_int_e << 16 ) ) >> 1 );
+
+ /* Q4 */
+ level = ( Word16 )( Pow2( log_en_int_e, log_en_int_m ) );
+
+ for ( i = 0; i < 4; i++ ) {
+ /* Compute innovation vector */
+ Build_CN_code( &st->pn_seed_rx, ex );
+
+ for ( j = 0; j < L_SUBFR; j++ ) {
+ ex[j] = ( level * ex[j] ) >> 15;
+ }
+
+ /* Synthesize */
+ Syn_filt( acoeff_variab, ex, &synth[i * L_SUBFR], L_SUBFR, mem_syn, 1 );
+ } /* next i */
+
+ /* reset codebook averaging variables */
+ averState->hangVar = 20;
+ averState->hangCount = 0;
+
+ if ( new_state == DTX_MUTE ) {
+ /*
+ * mute comfort noise as it has been quite a long time since
+ * last SID update was performed
+ */
+ Word32 num, denom;
+
+
+ tmp_int_length = st->since_last_sid;
+
+ if ( tmp_int_length > 32 ) {
+ tmp_int_length = 32;
+ }
+
+ if ( tmp_int_length == 1 ) {
+ st->true_sid_period_inv = MAX_16;
+ }
+ else {
+ num = 1024;
+ denom = ( tmp_int_length << 10 );
+ st->true_sid_period_inv = 0;
+
+ for ( i = 0; i < 15; i++ ) {
+ st->true_sid_period_inv <<= 1;
+ num <<= 1;
+
+ if ( num >= denom ) {
+ num = num - denom;
+ st->true_sid_period_inv += 1;
+ }
+ }
+ }
+ st->since_last_sid = 0;
+ memcpy( st->lsp_old, st->lsp, M << 2 );
+ st->old_log_en = st->log_en;
+
+ /* subtract 1/8 in Q11 i.e -6/8 dB */
+ st->log_en = st->log_en - 256;
+ if (st->log_en < -32768) st->log_en = -32768;
+ }
+
+ /*
+ * reset interpolation length timer
+ * if data has been updated.
+ */
+ if ( ( st->sid_frame != 0 ) & ( ( st->valid_data != 0 ) || ( ( st->valid_data
+ == 0 ) & ( st->dtxHangoverAdded != 0 ) ) ) ) {
+ st->since_last_sid = 0;
+ st->data_updated = 1;
+ }
+ return;
+}
+
+
+/*
+ * lsp_avg
+ *
+ *
+ * Parameters:
+ * st->lsp_meanSave B: LSP averages
+ * lsp I: LSPs
+ *
+ * Function:
+ * Calculate the LSP averages
+ *
+ * Returns:
+ * void
+ */
+static void lsp_avg( lsp_avgState *st, Word32 *lsp )
+{
+ Word32 i, tmp;
+
+
+ for ( i = 0; i < M; i++ ) {
+ /* mean = 0.84*mean */
+ tmp = ( st->lsp_meanSave[i] << 16 );
+ tmp -= ( EXPCONST * st->lsp_meanSave[i] ) << 1;
+
+ /* Add 0.16 of newest LSPs to mean */
+ tmp += ( EXPCONST * lsp[i] ) << 1;
+
+ /* Save means */
+ tmp += 0x00008000L;
+ st->lsp_meanSave[i] = tmp >> 16;
+ }
+ return;
+}
+
+
+/*
+ * Int_lpc_1and3
+ *
+ *
+ * Parameters:
+ * lsp_old I: LSP vector at the 4th subfr. of past frame [M]
+ * lsp_mid I: LSP vector at the 2nd subframe of present frame [M]
+ * lsp_new I: LSP vector at the 4th subframe of present frame [M]
+ * Az O: interpolated LP parameters in subframes 1 and 3
+ * [AZ_SIZE]
+ *
+ * Function:
+ * Interpolates the LSPs and converts to LPC parameters
+ * to get a different LP filter in each subframe.
+ *
+ * The 20 ms speech frame is divided into 4 subframes.
+ * The LSPs are quantized and transmitted at the 2nd and
+ * 4th subframes (twice per frame) and interpolated at the
+ * 1st and 3rd subframe.
+ *
+ * Returns:
+ * void
+ */
+static void Int_lpc_1and3( Word32 lsp_old[], Word32 lsp_mid[], Word32 lsp_new[],
+ Word32 Az[] )
+{
+ Word32 lsp[M];
+ Word32 i;
+
+
+ /* lsp[i] = lsp_mid[i] * 0.5 + lsp_old[i] * 0.5 */
+ for ( i = 0; i < 10; i++ ) {
+ lsp[i] = ( lsp_mid[i] >> 1 ) + ( lsp_old[i] >> 1 );
+ }
+
+ /* Subframe 1 */
+ Lsp_Az( lsp, Az );
+ Az += MP1;
+
+ /* Subframe 2 */
+ Lsp_Az( lsp_mid, Az );
+ Az += MP1;
+
+ for ( i = 0; i < 10; i++ ) {
+ lsp[i] = ( lsp_mid[i] >> 1 ) + ( lsp_new[i] >> 1 );
+ }
+
+ /* Subframe 3 */
+ Lsp_Az( lsp, Az );
+ Az += MP1;
+
+ /* Subframe 4 */
+ Lsp_Az( lsp_new, Az );
+ return;
+}
+
+
+/*
+ * Int_lpc_1to3
+ *
+ *
+ * Parameters:
+ * lsp_old I: LSP vector at the 4th subframe of past frame [M]
+ * lsp_new I: LSP vector at the 4th subframe of present frame [M]
+ * Az O: interpolated LP parameters in all subframes
+ * [AZ_SIZE]
+ *
+ * Function:
+ * Interpolates the LSPs and converts to LPC parameters to get a different
+ * LP filter in each subframe.
+ *
+ * The 20 ms speech frame is divided into 4 subframes.
+ * The LSPs are quantized and transmitted at the 4th
+ * subframes (once per frame) and interpolated at the
+ * 1st, 2nd and 3rd subframe.
+ *
+ * Returns:
+ * void
+ */
+static void Int_lpc_1to3( Word32 lsp_old[], Word32 lsp_new[], Word32 Az[] )
+{
+ Word32 lsp[M];
+ Word32 i;
+
+
+ for ( i = 0; i < 10; i++ ) {
+ lsp[i] = ( lsp_new[i] >> 2 ) + ( lsp_old[i] - ( lsp_old[i] >> 2 ) );
+ }
+
+ /* Subframe 1 */
+ Lsp_Az( lsp, Az );
+ Az += MP1;
+
+ for ( i = 0; i < 10; i++ ) {
+ lsp[i] = ( lsp_old[i] >> 1 ) + ( lsp_new[i] >> 1 );
+ }
+
+ /* Subframe 2 */
+ Lsp_Az( lsp, Az );
+ Az += MP1;
+
+ for ( i = 0; i < 10; i++ ) {
+ lsp[i] = ( lsp_old[i] >> 2 ) + ( lsp_new[i] - ( lsp_new[i] >> 2 ) );
+ }
+
+ /* Subframe 3 */
+ Lsp_Az( lsp, Az );
+ Az += MP1;
+
+ /* Subframe 4 */
+ Lsp_Az( lsp_new, Az );
+ return;
+}
+
+
+/*
+ * D_plsf_5
+ *
+ *
+ * Parameters:
+ * st->past_lsf_q I: Past dequantized LFSs
+ * st->past_r_q B: past quantized residual
+ * bfi B: bad frame indicator
+ * indice I: quantization indices of 3 submatrices, Q0
+ * lsp1_q O: quantized 1st LSP vector
+ * lsp2_q O: quantized 2nd LSP vector
+ *
+ * Function:
+ * Decodes the 2 sets of LSP parameters in a frame
+ * using the received quantization indices.
+ *
+ * Returns:
+ * void
+ */
+static void D_plsf_5( D_plsfState *st, Word16 bfi, Word16 *indice, Word32 *lsp1_q
+ , Word32 *lsp2_q )
+{
+ Word32 lsf1_r[M], lsf2_r[M], lsf1_q[M], lsf2_q[M];
+ Word32 i, temp1, temp2, sign;
+ const Word32 *p_dico;
+
+
+ /* if bad frame */
+ if ( bfi != 0 ) {
+ /* use the past LSFs slightly shifted towards their mean */
+ for ( i = 0; i < M; i += 2 ) {
+ /* lsfi_q[i] = ALPHA*st->past_lsf_q[i] + ONE_ALPHA*meanLsf[i]; */
+ lsf1_q[i] = ( ( st->past_lsf_q[i] * ALPHA_122 ) >> 15 ) + ( ( mean_lsf_5[i]
+ * ONE_ALPHA_122 ) >> 15 );
+ lsf1_q[i + 1] = ( ( st->past_lsf_q[i + 1] * ALPHA_122 ) >> 15 ) + ( (
+ mean_lsf_5[i + 1] * ONE_ALPHA_122 ) >> 15 );
+ }
+ memcpy( lsf2_q, lsf1_q, M <<2 );
+
+ /* estimate past quantized residual to be used in next frame */
+ for ( i = 0; i < M; i += 2 ) {
+ /* temp = meanLsf[i] + st->past_r_q[i] * LSPPpred_facMR122; */
+ temp1 = mean_lsf_5[i] + ( ( st->past_r_q[i] * LSP_PRED_FAC_MR122 ) >>
+ 15 );
+ temp2 = mean_lsf_5[i + 1] +( ( st->past_r_q[i + 1] *LSP_PRED_FAC_MR122
+ ) >> 15 );
+ st->past_r_q[i] = lsf2_q[i] - temp1;
+ st->past_r_q[i + 1] = lsf2_q[i + 1] -temp2;
+ }
+ }
+
+ /* if good LSFs received */
+ else {
+ /* decode prediction residuals from 5 received indices */
+ p_dico = &dico1_lsf_5[indice[0] << 2];
+ lsf1_r[0] = *p_dico++;
+ lsf1_r[1] = *p_dico++;
+ lsf2_r[0] = *p_dico++;
+ lsf2_r[1] = *p_dico++;
+ p_dico = &dico2_lsf_5[indice[1] << 2];
+ lsf1_r[2] = *p_dico++;
+ lsf1_r[3] = *p_dico++;
+ lsf2_r[2] = *p_dico++;
+ lsf2_r[3] = *p_dico++;
+ sign = ( Word16 )( indice[2] & 1 );
+ i = indice[2] >> 1;
+ p_dico = &dico3_lsf_5[i << 2];
+
+ if ( sign == 0 ) {
+ lsf1_r[4] = *p_dico++;
+ lsf1_r[5] = *p_dico++;
+ lsf2_r[4] = *p_dico++;
+ lsf2_r[5] = *p_dico++;
+ }
+ else {
+ lsf1_r[4] = ( Word16 )( -( *p_dico++ ) );
+ lsf1_r[5] = ( Word16 )( -( *p_dico++ ) );
+ lsf2_r[4] = ( Word16 )( -( *p_dico++ ) );
+ lsf2_r[5] = ( Word16 )( -( *p_dico++ ) );
+ }
+ p_dico = &dico4_lsf_5[( indice[3]<<2 )];
+ lsf1_r[6] = *p_dico++;
+ lsf1_r[7] = *p_dico++;
+ lsf2_r[6] = *p_dico++;
+ lsf2_r[7] = *p_dico++;
+ p_dico = &dico5_lsf_5[( indice[4]<<2 )];
+ lsf1_r[8] = *p_dico++;
+ lsf1_r[9] = *p_dico++;
+ lsf2_r[8] = *p_dico++;
+ lsf2_r[9] = *p_dico++;
+
+ /* Compute quantized LSFs and update the past quantized residual */
+ for ( i = 0; i < M; i++ ) {
+ temp1 = mean_lsf_5[i] + ( ( st->past_r_q[i] * LSP_PRED_FAC_MR122 ) >>
+ 15 );
+ lsf1_q[i] = lsf1_r[i] + temp1;
+ lsf2_q[i] = lsf2_r[i] + temp1;
+ st->past_r_q[i] = lsf2_r[i];
+ }
+ }
+
+ /* verification that LSFs have minimum distance of LSF_GAP Hz */
+ Reorder_lsf( lsf1_q, LSF_GAP );
+ Reorder_lsf( lsf2_q, LSF_GAP );
+ memcpy( st->past_lsf_q, lsf2_q, M <<2 );
+
+ /* convert LSFs to the cosine domain */
+ Lsf_lsp( lsf1_q, lsp1_q );
+ Lsf_lsp( lsf2_q, lsp2_q );
+ return;
+}
+
+
+/*
+ * Dec_lag3
+ *
+ *
+ * Parameters:
+ * index I: received pitch index
+ * t0_min I: minimum of search range
+ * t0_max I: maximum of search range
+ * i_subfr I: subframe flag
+ * T0_prev I: integer pitch delay of last subframe used
+ * in 2nd and 4th subframes
+ * T0 O: integer part of pitch lag
+ * T0_frac O : fractional part of pitch lag
+ * flag4 I : flag for encoding with 4 bits
+ * Function:
+ * Decoding of fractional pitch lag with 1/3 resolution.
+ * Extract the integer and fraction parts of the pitch lag from
+ * the received adaptive codebook index.
+ *
+ * The fractional lag in 1st and 3rd subframes is encoded with 8 bits
+ * while that in 2nd and 4th subframes is relatively encoded with 4, 5
+ * and 6 bits depending on the mode.
+ *
+ * Returns:
+ * void
+ */
+static void Dec_lag3( Word32 index, Word32 t0_min, Word32 t0_max, Word32 i_subfr
+ , Word32 T0_prev, Word32 *T0, Word32 *T0_frac, Word32 flag4 )
+{
+ Word32 i, tmp_lag;
+
+
+ /* if 1st or 3rd subframe */
+ if ( i_subfr == 0 ) {
+ if ( index < 197 ) {
+ *T0 = ( ( ( index + 2 ) * 10923 ) >> 15 ) + 19;
+ i = *T0 + *T0 + *T0;
+ *T0_frac = ( index - i ) + 58;
+ }
+ else {
+ *T0 = index - 112;
+ *T0_frac = 0;
+ }
+ }
+
+ /* 2nd or 4th subframe */
+ else {
+ if ( flag4 == 0 ) {
+ /* 'normal' decoding: either with 5 or 6 bit resolution */
+ i = ( ( ( index + 2 ) * 10923 ) >> 15 ) - 1;
+ *T0 = i + t0_min;
+ i = i + i + i;
+ *T0_frac = ( index - 2 ) - i;
+ }
+ else {
+ /* decoding with 4 bit resolution */
+ tmp_lag = T0_prev;
+
+ if ( ( tmp_lag - t0_min ) > 5 )
+ tmp_lag = t0_min + 5;
+
+ if ( ( t0_max - tmp_lag ) > 4 )
+ tmp_lag = t0_max - 4;
+
+ if ( index < 4 ) {
+ i = ( tmp_lag - 5 );
+ *T0 = i + index;
+ *T0_frac = 0;
+ }
+ else {
+ if ( index < 12 ) {
+ i = ( ( ( index - 5 ) * 10923 ) >> 15 ) - 1;
+ *T0 = i + tmp_lag;
+ i = i + i + i;
+ *T0_frac = ( index - 9 ) - i;
+ }
+ else {
+ i = ( index - 12 ) + tmp_lag;
+ *T0 = i + 1;
+ *T0_frac = 0;
+ }
+ }
+ } /* end if (decoding with 4 bit resolution) */
+ }
+ return;
+}
+
+
+/*
+ * Pred_lt_3or6_40
+ *
+ *
+ * Parameters:
+ * exc B: excitation buffer
+ * T0 I: integer pitch lag
+ * frac I: fraction of lag
+ * flag3 I: if set, upsampling rate = 3 (6 otherwise)
+ *
+ * Function:
+ * Compute the result of long term prediction with fractional
+ * interpolation of resolution 1/3 or 1/6. (Interpolated past excitation).
+ *
+ * Once the fractional pitch lag is determined,
+ * the adaptive codebook vector v(n) is computed by interpolating
+ * the past excitation signal u(n) at the given integer delay k
+ * and phase (fraction) :
+ *
+ * 9 9
+ * v(n) = SUM[ u(n-k-i) * b60(t+i*6) ] + SUM[ u(n-k+1+i) * b60(6-t+i*6) ],
+ * i=0 i=0
+ * n = 0, ...,39, t = 0, ...,5.
+ *
+ * The interpolation filter b60 is based on a Hamming windowed sin(x)/x
+ * function truncated at ± 59 and padded with zeros at ± 60 (b60(60)=0)).
+ * The filter has a cut-off frequency (-3 dB) at 3 600 Hz in
+ * the over-sampled domain.
+ *
+ * Returns:
+ * void
+ */
+static void Pred_lt_3or6_40( Word32 exc[], Word32 T0, Word32 frac, Word32 flag3 )
+{
+ Word32 s, i;
+ Word32 *x0, *x1, *x2;
+ const Word32 *c1, *c2;
+
+
+ x0 = &exc[ - T0];
+ frac = -frac;
+
+ if ( flag3 != 0 ) {
+ frac <<= 1; /* inter_3l[k] = inter6[2*k] -> k' = 2*k */
+ }
+
+ if ( frac < 0 ) {
+ frac += 6;
+ x0--;
+ }
+ c1 = &inter6[frac];
+ c2 = &inter6[6 - frac];
+
+ for ( i = 0; i < 40; i++ ) {
+ x1 = x0++;
+ x2 = x0;
+ s = x1[0] * c1[0];
+ s += x1[ - 1] * c1[6];
+ s += x1[ - 2] * c1[12];
+ s += x1[ - 3] * c1[18];
+ s += x1[ - 4] * c1[24];
+ s += x1[ - 5] * c1[30];
+ s += x1[ - 6] * c1[36];
+ s += x1[ - 7] * c1[42];
+ s += x1[ - 8] * c1[48];
+ s += x1[ - 9] * c1[54];
+ s += x2[0] * c2[0];
+ s += x2[1] * c2[6];
+ s += x2[2] * c2[12];
+ s += x2[3] * c2[18];
+ s += x2[4] * c2[24];
+ s += x2[5] * c2[30];
+ s += x2[6] * c2[36];
+ s += x2[7] * c2[42];
+ s += x2[8] * c2[48];
+ s += x2[9] * c2[54];
+ exc[i] = ( s + 0x4000 ) >> 15;
+
+ }
+}
+
+
+/*
+ * Dec_lag6
+ *
+ *
+ * Parameters:
+ * index I: received pitch index
+ * pit_min I: minimum pitch lag
+ * pit_max I: maximum pitch lag
+ * i_subfr I: subframe flag
+ * T0 B: integer part of pitch lag
+ * T0_frac O : fractional part of pitch lag
+ *
+ * Function:
+ * Decoding of fractional pitch lag with 1/6 resolution.
+ * Extract the integer and fraction parts of the pitch lag from
+ * the received adaptive codebook index.
+ *
+ * The fractional lag in 1st and 3rd subframes is encoded with 9 bits
+ * while that in 2nd and 4th subframes is relatively encoded with 6 bits.
+ * Note that in relative encoding only 61 values are used. If the
+ * decoder receives 61, 62, or 63 as the relative pitch index, it means
+ * that a transmission error occurred. In this case, the pitch lag from
+ * previous subframe (actually from previous frame) is used.
+ *
+ * Returns:
+ * void
+ */
+static void Dec_lag6( Word32 index, Word32 pit_min, Word32 pit_max, Word32
+ i_subfr, Word32 *T0, Word32 *T0_frac )
+{
+ Word32 t0_min, t0_max, i;
+
+
+ /* if 1st or 3rd subframe */
+ if ( i_subfr == 0 ) {
+ if ( index < 463 ) {
+ /* T0 = (index+5)/6 + 17 */
+ *T0 = ( index + 5 ) / 6 + 17;
+ i = *T0 + *T0 + *T0;
+
+ /* *T0_frac = index - T0*6 + 105 */
+ *T0_frac = ( index - ( i + i ) ) + 105;
+ }
+ else {
+ *T0 = index - 368;
+ *T0_frac = 0;
+ }
+ }
+
+ /* second or fourth subframe */
+ else {
+ /* find t0_min and t0_max for 2nd (or 4th) subframe */
+ t0_min = *T0 - 5;
+
+ if ( t0_min < pit_min ) {
+ t0_min = pit_min;
+ }
+ t0_max = t0_min + 9;
+
+ if ( t0_max > pit_max ) {
+ t0_max = pit_max;
+ t0_min = t0_max - 9;
+ }
+
+ /* i = (index+5)/6 - 1 */
+ i = ( index + 5 ) / 6 - 1;
+ *T0 = i + t0_min;
+ i = i + i + i;
+ *T0_frac = ( index - 3 ) - ( i + i );
+ }
+}
+
+
+/*
+ * decompress10
+ *
+ *
+ * Parameters:
+ * MSBs I: MSB part of the index
+ * LSBs I: LSB part of the index
+ * index1 I: index for first pos in posIndex
+ * index2 I: index for second pos in posIndex
+ * index3 I: index for third pos in posIndex
+ * pos_indx O: position of 3 pulses (decompressed)
+ * Function:
+ * Decompression of the linear codeword
+ *
+ * Returns:
+ * void
+ */
+static void decompress10( Word32 MSBs, Word32 LSBs, Word32 index1, Word32 index2
+ , Word32 index3, Word32 pos_indx[] )
+{
+ Word32 divMSB;
+
+ if (MSBs > 124)
+ {
+ MSBs = 124;
+ }
+ /*
+ * pos_indx[index1] = ((MSBs-25*(MSBs/25))%5)*2 + (LSBs-4*(LSBs/4))%2;
+ * pos_indx[index2] = ((MSBs-25*(MSBs/25))/5)*2 + (LSBs-4*(LSBs/4))/2;
+ * pos_indx[index3] = (MSBs/25)*2 + LSBs/4;
+ */
+ divMSB = MSBs / 25;
+ pos_indx[index1] = ( ( ( MSBs - 25 * ( divMSB ) ) % 5 ) << 1 ) + ( LSBs & 0x1
+ );
+ pos_indx[index2] = ( ( ( MSBs - 25 * ( divMSB ) ) / 5 ) << 1 ) + ( ( LSBs &
+ 0x2 ) >> 1 );
+ pos_indx[index3] = ( divMSB << 1 ) + ( LSBs >> 2 );
+ return;
+}
+
+
+/*
+ * decompress_codewords
+ *
+ *
+ * Parameters:
+ * indx I: position of 8 pulses (compressed)
+ * pos_indx O: position index of 8 pulses (position only)
+ *
+ * Function:
+ * Decompression of the linear codewords to 4+three indeces
+ * one bit from each pulse is made robust to errors by
+ * minimizing the phase shift of a bit error.
+ *
+ * i0,i4,i1 => one index (7+3) bits, 3 LSBs more robust
+ * i2,i6,i5 => one index (7+3) bits, 3 LSBs more robust
+ * i3,i7 => one index (5+2) bits, 2-3 LSbs more robust
+ *
+ * Returns:
+ * void
+ */
+static void decompress_codewords( Word16 indx[], Word32 pos_indx[] )
+{
+ Word32 ia, ib, MSBs, LSBs, MSBs0_24, tmp;
+
+
+ /*
+ * First index: 10x10x10 -> 2x5x2x5x2x5-> 125x2x2x2 -> 7+1x3 bits
+ * MSBs = indx[NB_TRACK]/8;
+ * LSBs = indx[NB_TRACK]%8;
+ */
+ MSBs = *indx >> 3;
+ LSBs = *indx & 0x7;
+ decompress10( MSBs, LSBs, 0, 4, 1, pos_indx );
+
+ /*
+ * Second index: 10x10x10 -> 2x5x2x5x2x5-> 125x2x2x2 -> 7+1x3 bits
+ * MSBs = indx[NB_TRACK+1]/8;
+ * LSBs = indx[NB_TRACK+1]%8;
+ */
+ MSBs = indx[1] >> 3;
+ LSBs = indx[1] & 0x7;
+ decompress10( MSBs, LSBs, 2, 6, 5, pos_indx );
+
+ /*
+ * Third index: 10x10 -> 2x5x2x5-> 25x2x2 -> 5+1x2 bits
+ * MSBs = indx[NB_TRACK+2]/4;
+ * LSBs = indx[NB_TRACK+2]%4;
+ * MSBs0_24 = (MSBs*25+12)/32;
+ * if ((MSBs0_24/5)%2==1)
+ * pos_indx[3] = (4-(MSBs0_24%5))*2 + LSBs%2;
+ * else
+ * pos_indx[3] = (MSBs0_24%5)*2 + LSBs%2;
+ * pos_indx[7] = (MSBs0_24/5)*2 + LSBs/2;
+ */
+ MSBs = indx[2] >> 2;
+ LSBs = indx[2] & 0x3;
+ MSBs0_24 = ( ( ( MSBs * 25 ) + 12 ) >> 5 );
+ tmp = ( MSBs0_24 * 6554 ) >> 15;
+ ia = tmp & 0x1;
+ ib = ( MSBs0_24 - ( tmp * 5 ) );
+
+ if ( ia == 1 ) {
+ ib = 4 - ib;
+ }
+ pos_indx[3] = ( ib << 1 ) + ( LSBs & 0x1 );
+ pos_indx[7] = ( tmp << 1 ) + ( LSBs >> 1 );
+}
+
+
+/*
+ * decode_2i40_9bits
+ *
+ *
+ * Parameters:
+ * subNr I: subframe number
+ * sign I: signs of 2 pulses
+ * index I: Positions of the 2 pulses
+ * cod O: algebraic (fixed) codebook excitation
+ *
+ * Function:
+ * Algebraic codebook decoder
+ *
+ * Returns:
+ * void
+ */
+static void decode_2i40_9bits( Word32 subNr, Word32 sign, Word32 index, Word32
+ cod[] )
+{
+ Word32 pos[2];
+ Word32 i, j, k;
+
+
+ /* Decode the positions */
+ /* table bit is the MSB */
+ j = ( index & 64 ) >> 6;
+ i = index & 7;
+
+ /* pos0 =i*5+startPos[j*8+subNr*2] */
+ i = ( i + ( i << 2 ) );
+ k = startPos[( j <<3 )+( subNr << 1 )];
+ pos[0] = i + k;
+ index = index >> 3;
+ i = index & 7;
+
+ /* pos1 =i*5+startPos[j*8+subNr*2+1] */
+ i = ( i + ( i << 2 ) );
+ k = startPos[( ( j <<3 )+ ( subNr <<1 ) ) + 1];
+ pos[1] = ( Word16 )( i + k );
+
+ /* decode the signs and build the codeword */
+ memset( cod, 0, L_SUBFR <<2 );
+
+ for ( j = 0; j < 2; j++ ) {
+ i = sign & 1;
+ sign = sign >> 1;
+
+ if ( i != 0 ) {
+ cod[pos[j]] = 8191; /* +1.0 */
+ }
+ else {
+ cod[pos[j]] = -8192; /* -1.0 */
+ }
+ }
+ return;
+}
+
+
+/*
+ * decode_2i40_11bits
+ *
+ *
+ * Parameters:
+ * sign I: signs of 2 pulses
+ * index I: Positions of the 2 pulses
+ * cod O: algebraic (fixed) codebook excitation
+ *
+ * Function:
+ * Algebraic codebook decoder
+ *
+ * Returns:
+ * void
+ */
+static void decode_2i40_11bits( Word32 sign, Word32 index, Word32 cod[] )
+{
+ Word32 pos[2];
+ Word32 i, j;
+
+
+ /* Decode the positions */
+ j = index & 1;
+ index = index >> 1;
+ i = index & 7;
+
+ /* pos0 =i*5+1+j*2 */
+ i = ( i + ( i << 2 ) );
+ i = ( i + 1 );
+ j = ( j << 1 );
+ pos[0] = i + j;
+ index = index >> 3;
+ j = index & 3;
+ index = index >> 2;
+ i = index & 7;
+
+ if ( j == 3 ) {
+ /* pos1 =i*5+4 */
+ i = ( i + ( i << 2 ) );
+ pos[1] = i + 4;
+ }
+ else {
+ /* pos1 =i*5+j */
+ i = ( i + ( i << 2 ) );
+ pos[1] = i + j;
+ }
+
+ /* decode the signs and build the codeword */
+ memset( cod, 0, L_SUBFR <<2 );
+
+ for ( j = 0; j < 2; j++ ) {
+ i = sign & 1;
+ sign = sign >> 1;
+
+ if ( i != 0 ) {
+ cod[pos[j]] = 8191; /* +1.0 */
+ }
+ else {
+ cod[pos[j]] = -8192; /* -1.0 */
+ }
+ }
+ return;
+}
+
+
+/*
+ * decode_3i40_14bits
+ *
+ *
+ * Parameters:
+ * sign I: signs of 3 pulses
+ * index I: Positions of the 3 pulses
+ * cod O: algebraic (fixed) codebook excitation
+ *
+ * Function:
+ * Algebraic codebook decoder
+ *
+ * Returns:
+ * void
+ */
+static void decode_3i40_14bits( Word32 sign, Word32 index, Word32 cod[] )
+{
+ Word32 pos[3];
+ Word32 i, j;
+
+
+ /* Decode the positions */
+ i = index & 7;
+
+ /* pos0 =i*5 */
+ pos[0] = i + ( i << 2 );
+ index = index >> 3;
+ j = index & 1;
+ index = index >> 1;
+ i = index & 7;
+
+ /* pos1 =i*5+1+j*2 */
+ i = ( i + ( i << 2 ) );
+ i = ( i + 1 );
+ j = ( j << 1 );
+ pos[1] = i + j;
+ index = index >> 3;
+ j = index & 1;
+ index = index >> 1;
+ i = index & 7;
+
+ /* pos2 =i*5+2+j*2 */
+ i = ( i + ( i << 2 ) );
+ i = ( i + 2 );
+ j = ( j << 1 );
+ pos[2] = i + j;
+
+ /* decode the signs and build the codeword */
+ memset( cod, 0, L_SUBFR <<2 );
+
+ for ( j = 0; j < 3; j++ ) {
+ i = sign & 1;
+ sign = sign >> 1;
+
+ if ( i > 0 ) {
+ cod[pos[j]] = 8191; /* +1.0 */
+ }
+ else {
+ cod[pos[j]] = -8192; /* -1.0 */
+ }
+ }
+ return;
+}
+
+
+/*
+ * decode_3i40_14bits
+ *
+ *
+ * Parameters:
+ * sign I: signs of 4 pulses
+ * index I: Positions of the 4 pulses
+ * cod O: algebraic (fixed) codebook excitation
+ *
+ * Function:
+ * Algebraic codebook decoder
+ *
+ * Returns:
+ * void
+ */
+static void decode_4i40_17bits( Word32 sign, Word32 index, Word32 cod[] )
+{
+ Word32 pos[4];
+ Word32 i, j;
+
+
+ /* Decode the positions */
+ i = index & 7;
+ i = dgray[i];
+
+ /* pos0 =i*5 */
+ pos[0] = i + ( i << 2 );
+ index = index >> 3;
+ i = index & 7;
+ i = dgray[i];
+
+ /* pos1 =i*5+1 */
+ i = ( i + ( i << 2 ) );
+ pos[1] = i + 1;
+ index = index >> 3;
+ i = index & 7;
+ i = dgray[i];
+
+ /* pos2 =i*5+1 */
+ i = ( i + ( i << 2 ) );
+ pos[2] = i + 2;
+ index = index >> 3;
+ j = index & 1;
+ index = index >> 1;
+ i = index & 7;
+ i = dgray[i];
+
+ /* pos3 =i*5+3+j */
+ i = ( i + ( i << 2 ) );
+ i = ( i + 3 );
+ pos[3] = i + j;
+
+ /* decode the signs and build the codeword */
+ memset( cod, 0, L_SUBFR <<2 );
+
+ for ( j = 0; j < 4; j++ ) {
+ i = sign & 1;
+ sign = sign >> 1;
+
+ if ( i != 0 ) {
+ cod[pos[j]] = 8191;
+ }
+ else {
+ cod[pos[j]] = -8192;
+ }
+ }
+ return;
+}
+
+
+/*
+ * decode_8i40_31bits
+ *
+ *
+ * Parameters:
+ * index I: index of 8 pulses (sign+position)
+ * cod O: algebraic (fixed) codebook excitation
+ *
+ * Function:
+ * Algebraic codebook decoder
+ *
+ * Returns:
+ * void
+ */
+static void decode_8i40_31bits( Word16 index[], Word32 cod[] )
+{
+ Word32 linear_codewords[8];
+ Word32 i, j, pos1, pos2, sign;
+
+
+ memset( cod, 0, L_CODE <<2 );
+ decompress_codewords( &index[NB_TRACK_MR102], linear_codewords );
+
+ /* decode the positions and signs of pulses and build the codeword */
+ for ( j = 0; j < NB_TRACK_MR102; j++ ) {
+ /* compute index i */
+ i = linear_codewords[j];
+ i <<= 2;
+
+ /* position of pulse "j" */
+ pos1 = i + j;
+
+ if ( index[j] == 0 ) {
+ sign = POS_CODE; /* +1.0 */
+ }
+ else {
+ sign = -NEG_CODE; /* -1.0 */
+ }
+
+ /* compute index i */
+ i = linear_codewords[j + 4];
+ i = i << 2;
+
+ /* position of pulse "j+4" */
+ pos2 = i + j;
+ cod[pos1] = sign;
+
+ if ( pos2 < pos1 ) {
+ sign = -( sign );
+ }
+ cod[pos2] = cod[pos2] + sign;
+ }
+ return;
+}
+
+
+/*
+ * decode_10i40_35bits
+ *
+ *
+ * Parameters:
+ * index I: index of 10 pulses (sign+position)
+ * cod O: algebraic (fixed) codebook excitation
+ *
+ * Function:
+ * Algebraic codebook decoder
+ *
+ * Returns:
+ * void
+ */
+static void decode_10i40_35bits( Word16 index[], Word32 cod[] )
+{
+ Word32 i, j, pos1, pos2, sign, tmp;
+
+
+ memset( cod, 0, L_CODE <<2 );
+
+ /* decode the positions and signs of pulses and build the codeword */
+ for ( j = 0; j < 5; j++ ) {
+ /* compute index i */
+ tmp = index[j];
+ i = tmp & 7;
+ i = dgray[i];
+ i = ( i * 5 );
+
+ /* position of pulse "j" */
+ pos1 = ( i + j );
+ i = ( tmp >> 3 ) & 1;
+
+ if ( i == 0 ) {
+ sign = 4096; /* +1.0 */
+ }
+ else {
+ sign = -4096; /* -1.0 */
+ }
+
+ /* compute index i */
+ i = index[j + 5] & 7;
+ i = dgray[i];
+ i = i * 5;
+
+ /* position of pulse "j+5" */
+ pos2 = ( i + j );
+ cod[pos1] = sign;
+
+ if ( pos2 < pos1 ) {
+ sign = -( sign );
+ }
+ cod[pos2] = cod[pos2] + sign;
+ }
+ return;
+}
+
+
+/*
+ * gmed_n
+ *
+ *
+ * Parameters:
+ * ind I: values
+ * n I: The number of gains (odd)
+ *
+ * Function:
+ * Calculates N-point median.
+ *
+ * Returns:
+ * index of the median value
+ */
+static Word32 gmed_n( Word32 ind[], Word32 n )
+{
+ Word32 tmp[NMAX], tmp2[NMAX];
+ Word32 max, medianIndex, i, j, ix = 0;
+
+
+ for ( i = 0; i < n; i++ ) {
+ tmp2[i] = ind[i];
+ }
+
+ for ( i = 0; i < n; i++ ) {
+ max = -32767;
+
+ for ( j = 0; j < n; j++ ) {
+ if ( tmp2[j] >= max ) {
+ max = tmp2[j];
+ ix = j;
+ }
+ }
+ tmp2[ix] = -32768;
+ tmp[i] = ix;
+ }
+ medianIndex = tmp[( n >>1 )];
+ return( ind[medianIndex] );
+}
+
+
+/*
+ * ec_gain_pitch
+ *
+ *
+ * Parameters:
+ * st->pbuf I: last five gains
+ * st->past_gain_pit I: past gain
+ * state I: state of the state machine
+ * gain_pitch O: pitch gain
+ *
+ * Function:
+ * Calculates pitch from previous values.
+ *
+ * Returns:
+ * void
+ */
+static void ec_gain_pitch( ec_gain_pitchState *st, Word16 state, Word32 *
+ gain_pitch )
+{
+ Word32 tmp;
+
+
+ /* calculate median of last five gains */
+ tmp = gmed_n( st->pbuf, 5 );
+
+ /* new gain = minimum(median, past_gain) * pdown[state] */
+ if ( tmp > st->past_gain_pit ) {
+ tmp = st->past_gain_pit;
+ }
+ *gain_pitch = ( tmp * pdown[state] ) >> 15;
+}
+
+
+/*
+ * d_gain_pitch
+ *
+ *
+ * Parameters:
+ * mode I: AMR mode
+ * index I: index of quantization
+ *
+ * Function:
+ * Decodes the pitch gain using the received index
+ *
+ * Returns:
+ * gain
+ */
+static Word32 d_gain_pitch( enum Mode mode, Word32 index )
+{
+ Word32 gain;
+
+
+ if ( mode == MR122 ) {
+ /* clear 2 LSBits */
+ gain = ( qua_gain_pitch[index] >> 2 ) << 2;
+ }
+ else {
+ gain = qua_gain_pitch[index];
+ }
+ return gain;
+}
+
+
+/*
+ * ec_gain_pitch_update
+ *
+ *
+ * Parameters:
+ * st->prev_gp B: previous pitch gain
+ * st->past_gain_pit O: past gain
+ * st->pbuf B: past gain buffer
+ * bfi I: bad frame indicator
+ * prev_bf I: previous frame was bad
+ * gain_pitch B: pitch gain
+ *
+ * Function:
+ * Update the pitch gain concealment state
+ * Limit gain_pitch if the previous frame was bad
+ *
+ * Returns:
+ * gain
+ */
+static void ec_gain_pitch_update( ec_gain_pitchState *st, Word32 bfi,
+ Word32 prev_bf, Word32 *gain_pitch )
+{
+ if ( bfi == 0 ) {
+ if ( prev_bf != 0 ) {
+ if ( *gain_pitch > st->prev_gp ) {
+ *gain_pitch = st->prev_gp;
+ }
+ }
+ st->prev_gp = *gain_pitch;
+ }
+ st->past_gain_pit = *gain_pitch;
+
+ /* if (st->past_gain_pit > 1.0) */
+ if ( st->past_gain_pit > 16384 ) {
+ st->past_gain_pit = 16384;
+ }
+ st->pbuf[0] = st->pbuf[1];
+ st->pbuf[1] = st->pbuf[2];
+ st->pbuf[2] = st->pbuf[3];
+ st->pbuf[3] = st->pbuf[4];
+ st->pbuf[4] = st->past_gain_pit;
+}
+
+
+/*
+ * gc_pred (366)
+ *
+ *
+ * Parameters:
+ * st->past_qua_en I: MA predictor
+ * st->past_qua_en_MR122 I: MA predictor MR122
+ * mode I: AMR mode
+ * code I: innovative codebook vector
+ * exp_gcode0 O: predicted gain factor (exponent)
+ * frac_gcode0 O: predicted gain factor (fraction)
+ * exp_en I: innovation energy (MR795) (exponent)
+ * frac_en I: innovation energy (MR795) (fraction)
+ *
+ * Function:
+ * MA prediction of the innovation energy
+ *
+ * Mean removed innovation energy (dB) in subframe n
+ * N-1
+ * E(n) = 10*log(gc*gc * SUM[(code(i) * code(i)]/N) - EMean
+ * i=0
+ * N=40
+ *
+ * Mean innovation energy (dB)
+ * N-1
+ * Ei(n) = 10*log(SUM[(code(i) * code(i)]/N)
+ * i=0
+ *
+ * Predicted energy
+ * 4
+ * Ep(n) = SUM[b(i) * R(n-i)]
+ * i=1
+ * b = [0.68 0.58 0.34 0.19]
+ * R(k) is quantified prediction error at subframe k
+ *
+ * E_Mean = 36 dB (MR122)
+ *
+ * Predicted gain gc is found by
+ *
+ * gc = POW[10, 0.05 * (Ep(n) + EMean - Ei)]
+ *
+ * Returns:
+ * void
+ */
+static void gc_pred( gc_predState *st, enum Mode mode, Word32 *code, Word32 *
+ exp_gcode0, Word32 *frac_gcode0, Word32 *exp_en, Word32 *frac_en )
+{
+ Word32 exp, frac, ener_code = 0, i = 0;
+
+
+ /* energy of code:
+ * ener_code = sum(code[i]^2)
+ */
+ while ( i < L_SUBFR ) {
+ ener_code += code[i] * code[i];
+ i++;
+ }
+
+ if ( ( 0x3fffffff <= ener_code ) | ( ener_code < 0 ) )
+ ener_code = MAX_32;
+ else
+ ener_code <<= 1;
+
+ if ( mode == MR122 ) {
+ Word32 ener;
+
+
+ /* ener_code = ener_code / lcode; lcode = 40; 1/40 = 26214 Q20 */
+ ener_code = ( ( ener_code + 0x00008000L ) >> 16 ) * 52428;
+
+ /* Q9 * Q20 -> Q30 */
+ /* energy of code:
+ * ener_code(Q17) = 10 * Log10(energy) / constant
+ * = 1/2 * Log2(energy)
+ * constant = 20*Log10(2)
+ */
+ /* ener_code = 1/2 * Log2(ener_code); Note: Log2=log2+30 */
+ Log2( ener_code, &exp, &frac );
+ ener_code = ( ( exp - 30 ) << 16 ) + ( frac << 1 );
+
+ /* Q16 for log(), ->Q17 for 1/2 log() */
+ /*
+ * predicted energy:
+ * ener(Q24) = (Emean + sum{pred[i]*pastEn[i]})/constant
+ * = MEAN_ENER + sum(pred[i]*past_qua_en[i])
+ * constant = 20*Log10(2)
+ */
+ ener = 0;
+ i = 0;
+
+ while ( i < 4 ) {
+ ener += st->past_qua_en_MR122[i] * pred_MR122[i];
+ i++;
+ }
+ ener <<= 1;
+ ener += MEAN_ENER_MR122;
+
+ /*
+ * predicted codebook gain
+
+ * gc0 = Pow10( (ener*constant - ener_code*constant) / 20 )
+ * = Pow2(ener-ener_code)
+ * = Pow2(int(d)+frac(d))
+ */
+ ener = ( ener - ener_code ) >> 1; /* Q16 */
+ *exp_gcode0 = ener >> 16;
+ *frac_gcode0 = ( ener >> 1 ) - ( *exp_gcode0 << 15 );
+ }
+
+ /* all modes except 12.2 */
+ else {
+ Word32 tmp, gcode0;
+ int exp_code;
+
+
+ /*
+ * Compute: meansEner - 10log10(ener_code/ LSufr)
+ */
+ exp_code=0;
+ if (ener_code != 0){
+ while (!(ener_code & 0x40000000))
+ {
+ exp_code++;
+ ener_code = ener_code << 1;
+ }
+ }
+
+ /* Log2 = log2 + 27 */
+ Log2_norm( ener_code, exp_code, &exp, &frac );
+
+ /* fact = 10/log2(10) = 3.01 = 24660 Q13 */
+ /* Q0.Q15 * Q13 -> Q14 */
+ tmp = ( exp * ( -49320 ) ) + ( ( ( frac * ( -24660 ) ) >> 15 ) << 1 );
+
+ /*
+ * tmp = meansEner - 10log10(ener_code/L_SUBFR)
+ * = meansEner - 10log10(ener_code) + 10log10(L_SUBFR)
+ * = K - fact * Log2(ener_code)
+ * = K - fact * log2(ener_code) - fact*27
+ *
+ * ==> K = meansEner + fact*27 + 10log10(L_SUBFR)
+ *
+ * meansEner = 33 = 540672 Q14 (MR475, MR515, MR59)
+ * meansEner = 28.75 = 471040 Q14 (MR67)
+ * meansEner = 30 = 491520 Q14 (MR74)
+ * meansEner = 36 = 589824 Q14 (MR795)
+ * meansEner = 33 = 540672 Q14 (MR102)
+ * 10log10(L_SUBFR) = 16.02 = 262481.51 Q14
+ * fact * 27 = 1331640 Q14
+ * -----------------------------------------
+ * (MR475, MR515, MR59) K = 2134793.51 Q14 ~= 16678 * 64 * 2
+ * (MR67) K = 2065161.51 Q14 ~= 32268 * 32 * 2
+ * (MR74) K = 2085641.51 Q14 ~= 32588 * 32 * 2
+ * (MR795) K = 2183945.51 Q14 ~= 17062 * 64 * 2
+ * (MR102) K = 2134793.51 Q14 ~= 16678 * 64 * 2
+ */
+ if ( mode == MR102 ) {
+ /* mean = 33 dB */
+ tmp += 2134784; /* Q14 */
+ }
+ else if ( mode == MR795 ) {
+ /* mean = 36 dB */
+ tmp += 2183936; /* Q14 */
+
+ /*
+ * ener_code = <xn xn> * 2^27*2^exp_code
+ * frac_en = ener_code / 2^16
+ * = <xn xn> * 2^11*2^exp_code
+ * <xn xn> = <xn xn>*2^11*2^exp * 2^exp_en
+ * := frac_en * 2^exp_en
+ *
+ * ==> exp_en = -11-exp_code;
+ */
+ *frac_en = ener_code >> 16;
+ *exp_en = -11 - exp_code;
+ }
+ else if ( mode == MR74 ) {
+ /* mean = 30 dB */
+ tmp += 2085632; /* Q14 */
+ }
+ else if ( mode == MR67 ) {
+ /* mean = 28.75 dB */
+ tmp += 2065152; /* Q14 */
+ }
+ else /* MR59, MR515, MR475 */ {
+ /* mean = 33 dB */
+ tmp += 2134784; /* Q14 */
+ }
+
+ /*
+ * Compute gcode0
+ * = Sum(i=0,3) pred[i]*past_qua_en[i] - ener_code + meanEner
+ */
+ tmp = tmp << 9; /* Q23 */
+
+ /* Q13 * Q10 -> Q23 */
+ i = 0;
+
+ while ( i < 4 ) {
+ tmp += pred[i] * st->past_qua_en[i];
+ i++;
+ }
+ gcode0 = tmp >> 15; /* Q8 */
+
+ /*
+ * gcode0 = pow(10.0, gcode0/20)
+ * = pow(2, 3.3219*gcode0/20)
+ * = pow(2, 0.166*gcode0)
+ */
+ /* 5439 Q15 = 0.165985 */
+ /* (correct: 1/(20*log10(2)) 0.166096 = 5443 Q15) */
+ /* For IS641 bitexactness */
+ if ( mode == MR74 ) {
+ /* Q8 * Q15 -> Q24 */
+ tmp = gcode0 * 10878;
+ }
+ else {
+ /* Q8 * Q15 -> Q24 */
+ tmp = gcode0 * 10886;
+ }
+ tmp = tmp >> 9; /* -> Q15 */
+
+ /* -> Q0.Q15 */
+ *exp_gcode0 = tmp >> 15;
+ *frac_gcode0 = tmp - ( *exp_gcode0 * 32768 );
+ }
+}
+
+
+/*
+ * gc_pred_update
+ *
+ *
+ * Parameters:
+ * st->past_qua_en B: MA predictor
+ * st->past_qua_en_MR122 B: MA predictor MR122
+ * qua_ener_MR122 I: quantized energy for update (log2(quaErr))
+ * qua_ener I: quantized energy for update (20*log10(quaErr))
+ *
+ * Function:
+ * Update MA predictor with last quantized energy
+ *
+ * Returns:
+ * void
+ */
+static void gc_pred_update( gc_predState *st, Word32 qua_ener_MR122,
+ Word32 qua_ener )
+{
+ Word32 i;
+
+
+ for ( i = 3; i > 0; i-- ) {
+ st->past_qua_en[i] = st->past_qua_en[i - 1];
+ st->past_qua_en_MR122[i] = st->past_qua_en_MR122[i - 1];
+ }
+ st->past_qua_en_MR122[0] = qua_ener_MR122; /* log2 (quaErr), Q10 */
+ st->past_qua_en[0] = qua_ener; /* 20*log10(quaErr), Q10 */
+}
+
+
+/*
+ * Dec_gain
+ *
+ *
+ * Parameters:
+ * pred_state->past_qua_en B: MA predictor
+ * pred_state->past_qua_en_MR122 B: MA predictor MR122
+ * mode I: AMR mode
+ * index I: index of quantization
+ * code I: Innovative vector
+ * evenSubfr I: Flag for even subframes
+ * gain_pit O: Pitch gain
+ * gain_cod O: Code gain
+ *
+ * Function:
+ * Decode the pitch and codebook gains
+ *
+ * Returns:
+ * void
+ */
+static void Dec_gain( gc_predState *pred_state, enum Mode mode, Word32 index,
+ Word32 code[], Word32 evenSubfr, Word32 *gain_pit, Word32 *gain_cod )
+{
+ Word32 frac, gcode0, exp, qua_ener, qua_ener_MR122, g_code, tmp;
+ const Word32 *p;
+
+
+ /* Read the quantized gains (table depends on mode) */
+ index = index << 2;
+
+ if ( ( mode == MR102 ) || ( mode == MR74 ) || ( mode == MR67 ) ) {
+ p = &table_gain_highrates[index];
+ *gain_pit = *p++;
+ g_code = *p++;
+ qua_ener_MR122 = *p++;
+ qua_ener = *p;
+ }
+ else {
+ if ( mode == MR475 ) {
+ index = index + ( ( 1 - evenSubfr ) << 1 );
+ p = &table_gain_MR475[index];
+ *gain_pit = *p++;
+ g_code = *p++;
+
+ /*
+ * calculate predictor update values (not stored in 4.75
+ * quantizer table to save space):
+ * qua_ener = log2(g)
+ * qua_ener_MR122 = 20*log10(g)
+ */
+ /* Log2(x Q12) = log2(x) + 12 */
+ Log2( g_code, &exp, &frac );
+ exp = exp - 12;
+ tmp = frac >> 5;
+
+ if ( ( frac & ( ( Word16 )1 << 4 ) ) != 0 ) {
+ tmp++;
+ }
+ qua_ener_MR122 = tmp + ( exp << 10 );
+
+ /* 24660 Q12 ~= 6.0206 = 20*log10(2) */
+ tmp = exp * 49320;
+ tmp += ( ( ( frac * 24660 ) >> 15 ) << 1 );
+
+ /* Q12 * Q0 = Q13 -> Q10 */
+ qua_ener = ( ( tmp << 13 ) + 0x00008000L ) >> 16;
+ }
+ else {
+ p = &table_gain_lowrates[index];
+ *gain_pit = *p++;
+ g_code = *p++;
+ qua_ener_MR122 = *p++;
+ qua_ener = *p;
+ }
+ }
+
+ /*
+ * predict codebook gain
+ * gc0 = Pow2(int(d)+frac(d))
+ * = 2^exp + 2^frac
+ * gcode0 (Q14) = 2^14*2^frac = gc0 * 2^(14-exp)
+ */
+ gc_pred( pred_state, mode, code, &exp, &frac, NULL, NULL );
+ gcode0 = Pow2( 14, frac );
+
+ /*
+ * read quantized gains, update table of past quantized energies
+ * st->past_qua_en(Q10) = 20 * Log10(gFac) / constant
+ * = Log2(gFac)
+ * = qua_ener
+ * constant = 20*Log10(2)
+ */
+ if ( exp < 11 ) {
+ *gain_cod = ( g_code * gcode0 ) >> ( 25 - exp );
+ }
+ else {
+ tmp = ( ( g_code * gcode0 ) << ( exp - 9 ) );
+
+ if ( ( tmp >> ( exp - 9 ) ) != ( g_code * gcode0 ) ) {
+ *gain_cod = 0x7FFF;
+ }
+ else {
+ *gain_cod = tmp >> 16;
+ }
+ }
+
+ /* update table of past quantized energies */
+ gc_pred_update( pred_state, qua_ener_MR122, qua_ener );
+ return;
+}
+
+
+/*
+ * gc_pred_average_limited
+ *
+ *
+ * Parameters:
+ * st->past_qua_en I: MA predictor
+ * st->past_qua_en_MR122 I: MA predictor MR122
+ * ener_avg_MR122 O: everaged quantized energy (log2(quaErr))
+ * ener_avg O: averaged quantized energy (20*log10(quaErr))
+ *
+ * Function:
+ * Compute average limited quantized energy
+ * Returns:
+ * void
+ */
+static void gc_pred_average_limited( gc_predState *st, Word32 *ener_avg_MR122,
+ Word32 *ener_avg )
+{
+ Word32 av_pred_en, i;
+
+
+ /* do average in MR122 mode (log2() domain) */
+ av_pred_en = 0;
+
+ for ( i = 0; i < NPRED; i++ ) {
+ av_pred_en = ( av_pred_en + st->past_qua_en_MR122[i] );
+ }
+
+ /* av_pred_en = 0.25*av_pred_en */
+ av_pred_en = ( av_pred_en * 8192 ) >> 15;
+
+ /* if (av_pred_en < -14/(20Log10(2))) av_pred_en = .. */
+ if ( av_pred_en < MIN_ENERGY_MR122 ) {
+ av_pred_en = MIN_ENERGY_MR122;
+ }
+ *ener_avg_MR122 = ( Word16 )av_pred_en;
+
+ /* do average for other modes (20*log10() domain) */
+ av_pred_en = 0;
+
+ for ( i = 0; i < NPRED; i++ ) {
+ av_pred_en = ( av_pred_en + st->past_qua_en[i] );
+ if (av_pred_en < -32768)
+ av_pred_en = -32768;
+ else if (av_pred_en > 32767)
+ av_pred_en = 32767;
+ }
+
+ /* av_pred_en = 0.25*av_pred_en */
+ av_pred_en = ( av_pred_en * 8192 ) >> 15;
+
+ *ener_avg = av_pred_en;
+}
+
+
+/*
+ * ec_gain_code
+ *
+ *
+ * Parameters:
+ * st->gbuf I: last five gains
+ * st->past_gain_code I: past gain
+ * pred_state B: MA predictor state
+ * state I: state of the state machine
+ * gain_code O: decoded innovation gain
+ *
+ * Function:
+ * Conceal the codebook gain
+ *
+ * Returns:
+ * void
+ */
+static void ec_gain_code( ec_gain_codeState *st, gc_predState *pred_state,
+ Word16 state, Word32 *gain_code )
+{
+ Word32 tmp, qua_ener_MR122, qua_ener;
+
+
+ /* calculate median of last five gain values */
+ tmp = gmed_n( st->gbuf, 5 );
+
+ /* new gain = minimum(median, past_gain) * cdown[state] */
+ if ( tmp > st->past_gain_code ) {
+ tmp = st->past_gain_code;
+ }
+ tmp = ( tmp * cdown[state] ) >> 15;
+ *gain_code = tmp;
+
+ /*
+ * update table of past quantized energies with average of
+ * current values
+ */
+ gc_pred_average_limited( pred_state, &qua_ener_MR122, &qua_ener );
+ gc_pred_update( pred_state, qua_ener_MR122, qua_ener );
+}
+
+
+/*
+ * ec_gain_code_update
+ *
+ *
+ * Parameters:
+ * st->gbuf B: last five gains
+ * st->past_gain_code O: past gain
+ * st->prev_gc B previous gain
+ * bfi I: bad indicator
+ * prev_bf I: previous frame bad indicator
+ * gain_code O: decoded innovation gain
+ *
+ * Function:
+ * Update the codebook gain concealment state
+ *
+ * Returns:
+ * void
+ */
+static void ec_gain_code_update( ec_gain_codeState *st, Word16 bfi,
+ Word16 prev_bf, Word32 *gain_code )
+{
+ /* limit gain_code by previous good gain if previous frame was bad */
+ if ( bfi == 0 ) {
+ if ( prev_bf != 0 ) {
+ if ( *gain_code > st->prev_gc ) {
+ *gain_code = st->prev_gc;
+ }
+ }
+ st->prev_gc = *gain_code;
+ }
+
+ /* update EC states: previous gain, gain buffer */
+ st->past_gain_code = *gain_code;
+ st->gbuf[0] = st->gbuf[1];
+ st->gbuf[1] = st->gbuf[2];
+ st->gbuf[2] = st->gbuf[3];
+ st->gbuf[3] = st->gbuf[4];
+ st->gbuf[4] = *gain_code;
+ return;
+}
+
+
+/*
+ * d_gain_code
+ *
+ *
+ * Parameters:
+ * pred_state B: MA predictor state
+ * mode I: AMR mode (MR795 or MR122)
+ * index I: received quantization index
+ * code I: innovation codevector
+ * gain_code O: decoded innovation gain
+ *
+ * Function:
+ * Decode the fixed codebook gain using the received index
+ *
+ * Returns:
+ * void
+ */
+static void d_gain_code( gc_predState *pred_state, enum Mode mode, Word32 index,
+ Word32 code[], Word32 *gain_code )
+{
+ Word32 g_code0, exp, frac, qua_ener_MR122, qua_ener;
+ Word32 exp_inn_en, frac_inn_en, tmp, tmp2, i;
+ const Word32 *p;
+
+
+ /*
+ * Decode codebook gain
+ */
+ gc_pred( pred_state, mode, code, &exp, &frac, &exp_inn_en, &frac_inn_en );
+ p = &qua_gain_code[( ( index + index )+ index )];
+
+ /* Different scalings between MR122 and the other modes */
+ if ( mode == MR122 ) {
+ /* predicted gain */
+ g_code0 = Pow2( exp, frac );
+
+ if ( g_code0 <= 2047 )
+ g_code0 = g_code0 << 4;
+ else
+ g_code0 = 32767;
+ *gain_code = ( ( g_code0 * *p++ ) >> 15 ) << 1;
+ if (*gain_code & 0xFFFF8000)
+ *gain_code = 32767;
+
+ }
+ else {
+ g_code0 = Pow2( 14, frac );
+ tmp = ( *p++ * g_code0 ) << 1;
+ exp = 9 - exp;
+
+ if ( exp > 0 ) {
+ tmp = tmp >> exp;
+ }
+ else {
+ for (i = exp; i < 0; i++) {
+ tmp2 = tmp << 1;
+ if ((tmp ^ tmp2) & 0x80000000) {
+ tmp = (tmp & 0x80000000) ? 0x80000000 : 0x7FFFFFFF;
+ break;
+ }
+ else {
+ tmp = tmp2;
+ }
+ }
+ }
+ *gain_code = tmp >> 16;
+ if (*gain_code & 0xFFFF8000)
+ *gain_code = 32767;
+ }
+
+ /*
+ * update table of past quantized energies
+ */
+ qua_ener_MR122 = *p++;
+ qua_ener = *p++;
+ gc_pred_update( pred_state, qua_ener_MR122, qua_ener );
+ return;
+}
+
+
+/*
+ * Int_lsf
+ *
+ *
+ * Parameters:
+ * lsf_old I: LSF vector at the 4th subframe of past frame
+ * lsf_new I: LSF vector at the 4th subframe of present frame
+ * i_subfr I: current subframe
+ * lsf_out O: interpolated LSF parameters for current subframe
+ *
+ * Function:
+ * Interpolates the LSFs for selected subframe
+ *
+ * The LSFs are interpolated at the 1st, 2nd and 3rd
+ * ubframe and only forwarded at the 4th subframe.
+ *
+ * sf1: 3/4 F0 + 1/4 F1
+ * sf2: 1/2 F0 + 1/2 F1
+ * sf3: 1/4 F0 + 3/4 F1
+ * sf4: F1
+ *
+ * Returns:
+ * void
+ */
+static void Int_lsf( Word32 lsf_old[], Word32 lsf_new[], int i_subfr, Word32
+ lsf_out[] )
+{
+ Word32 i;
+
+
+ switch ( i_subfr ) {
+ case 0:
+ for ( i = 0; i < 10; i++ ) {
+ lsf_out[i] = lsf_old[i] - ( lsf_old[i] >> 2 ) + ( lsf_new[i] >> 2 );
+ }
+ break;
+
+ case 40:
+ for ( i = 0; i < 10; i++ ) {
+ lsf_out[i] = ( lsf_old[i] >> 1 ) + ( lsf_new[i] >> 1 );
+ }
+ break;
+
+ case 80:
+ for ( i = 0; i < 10; i++ ) {
+ lsf_out[i] = ( lsf_old[i] >> 2 ) - ( lsf_new[i] >> 2 ) +
+ lsf_new[i];
+ }
+ break;
+
+ case 120:
+ memcpy( lsf_out, lsf_new, M <<2 );
+ break;
+ }
+}
+
+
+/*
+ * Cb_gain_average
+ *
+ *
+ * Parameters:
+ * st->cbGainHistory B: codebook gain history
+ * st->hangCount B: hangover counter
+ * mode I: AMR mode
+ * gain_code I: codebook gain
+ * lsp I: The LSP for the current frame
+ * lspAver I: The average of LSP for 8 frames
+ * bfi I: bad frame indication
+ * prev_bf I: previous bad frame indication
+ * pdfi I: potential degraded bad frame indication
+ * prev_pdf I: previous potential degraded bad frame indication
+ * inBackgroundNoise I: background noise decision
+ * voicedHangover I: number of frames after last voiced frame
+ *
+ * Function:
+ * The mixed codebook gain, used to make codebook gain more smooth in background
+ *
+ *
+ * Returns:
+ * void
+ */
+static Word32 Cb_gain_average( Cb_gain_averageState *st, enum Mode mode, Word32
+ gain_code, Word32 lsp[], Word32 lspAver[], Word16 bfi, Word16 prev_bf,
+ Word16 pdfi, Word16 prev_pdf, Word32 inBackgroundNoise, Word32
+ voicedHangover )
+{
+ Word32 tmp[M];
+ Word32 i, cbGainMix, tmp_diff, bgMix, cbGainMean, sum, diff, tmp1, tmp2;
+ int shift1, shift2, shift;
+
+
+ /* set correct cbGainMix for MR74, MR795, MR122 */
+ cbGainMix = gain_code;
+
+ /*
+ * Store list of CB gain needed in the CB gain averaging *
+ */
+ st->cbGainHistory[0] = st->cbGainHistory[1];
+ st->cbGainHistory[1] = st->cbGainHistory[2];
+ st->cbGainHistory[2] = st->cbGainHistory[3];
+ st->cbGainHistory[3] = st->cbGainHistory[4];
+ st->cbGainHistory[4] = st->cbGainHistory[5];
+ st->cbGainHistory[5] = st->cbGainHistory[6];
+ st->cbGainHistory[6] = gain_code;
+
+ /* compute lsp difference */
+ for ( i = 0; i < M; i++ ) {
+ tmp1 = labs( lspAver[i]- lsp[i] );
+ shift1 = 0;
+ if (tmp1 != 0){
+ while (!(tmp1 & 0x2000))
+ {
+ shift1++;
+ tmp1 = tmp1 << 1;
+ }
+ }
+ tmp2 = lspAver[i];
+ shift2 = 0;
+ if (tmp2 != 0){
+ while (!(tmp2 & 0x4000))
+ {
+ shift2++;
+ tmp2 = tmp2 << 1;
+ }
+ }
+ tmp[i] = ( tmp1 << 15 ) / tmp2;
+ shift = 2 + shift1 - shift2;
+
+ if ( shift >= 0 ) {
+ tmp[i] = tmp[i] >> shift;
+ }
+ else {
+ tmp[i] = tmp[i] << -( shift );
+ }
+ }
+ diff = *tmp + tmp[1] + tmp[2] + tmp[3] + tmp[4] + tmp[5] + tmp[6] + tmp[7] +
+ tmp[8] + tmp[9];
+
+ /* saturate */
+ if ( diff > 32767 ) {
+ diff = 32767;
+ }
+
+ /* Compute hangover */
+ st->hangVar += 1;
+
+ if ( diff <= 5325 ) {
+ st->hangVar = 0;
+ }
+
+ if ( st->hangVar > 10 ) {
+ /* Speech period, reset hangover variable */
+ st->hangCount = 0;
+ }
+
+ /* Compute mix constant (bgMix) */
+ bgMix = 8192;
+
+ /* MR475, MR515, MR59, MR67, MR102 */
+ if ( ( mode <= MR67 ) | ( mode == MR102 ) ) {
+ /* disable mix if too short time since */
+ if ( ( st->hangCount >= 40 ) & ( diff <= 5325 ) ) /* 0.65 in Q13 */ {
+ /* if errors and presumed noise make smoothing probability stronger */
+ if ( ( ( ( ( pdfi != 0 ) & ( prev_pdf != 0 ) ) | ( bfi != 0 ) | (
+ prev_bf != 0 ) ) & ( ( voicedHangover > 1 ) ) & (
+ inBackgroundNoise != 0 ) & ( mode < MR67 ) ) ) {
+ /* bgMix = min(0.25, max(0.0, diff-0.55)) / 0.25; */
+ tmp_diff = diff - 4506; /* 0.55 in Q13 */
+
+ /* max(0.0, diff-0.55) */
+ tmp1 = 0;
+
+ if ( tmp_diff > 0 ) {
+ tmp1 = tmp_diff;
+ }
+
+ /* min(0.25, tmp1) */
+ if ( 2048 >= tmp1 ) {
+ bgMix = tmp1 << 2;
+ }
+ }
+ else {
+ /* bgMix = min(0.25, max(0.0, diff-0.40)) / 0.25; */
+ tmp_diff = diff - 3277; /* 0.4 in Q13 */
+
+ /* max(0.0, diff-0.40) */
+ tmp1 = 0;
+
+ if ( tmp_diff > 0 ) {
+ tmp1 = tmp_diff;
+ }
+
+ /* min(0.25, tmp1) */
+ if ( 2048 >= tmp1 ) {
+ bgMix = tmp1 << 2;
+ }
+ }
+ }
+
+ /*
+ * Smoothen the cb gain trajectory
+ * smoothing depends on mix constant bgMix
+ */
+ sum = st->cbGainHistory[2] + st->cbGainHistory[3] + st->cbGainHistory[4] +
+ st->cbGainHistory[5] + st->cbGainHistory[6];
+
+ if ( sum > 163822 ) {
+ cbGainMean = 32767;
+ }
+ else {
+ cbGainMean = ( 3277 * sum + 0x00002000L ) >> 14; /* Q1 */
+ }
+
+ /* more smoothing in error and bg noise (NB no DFI used here) */
+ if ( ( ( bfi != 0 ) | ( prev_bf != 0 ) ) & ( inBackgroundNoise != 0 ) & (
+ mode < MR67 ) ) {
+ sum = 9362 * ( st->cbGainHistory[0] + st->cbGainHistory[1] + st->
+ cbGainHistory[2] + st->cbGainHistory[3] + st->cbGainHistory[4] +
+ st->cbGainHistory[5] + st->cbGainHistory[6] );
+ cbGainMean = ( sum + 0x00008000L ) >> 16; /* Q1 */
+ }
+
+ /* cbGainMix = bgMix*cbGainMix + (1-bgMix)*cbGainMean; */
+ sum = bgMix * cbGainMix; /* sum in Q14 */
+ sum += cbGainMean << 13;
+ sum -= bgMix * cbGainMean;
+ cbGainMix = ( sum + 0x00001000L ) >> 13;
+
+ /* Q1 */
+ }
+ st->hangCount += 1;
+ if (st->hangCount & 0x80000000)
+ st->hangCount = 40;
+ return cbGainMix;
+}
+
+
+/*
+ * ph_disp
+ *
+ *
+ * Parameters:
+ * state->gainMem B: LTP gain memory
+ * state->prevCbGain B: Codebook gain memory
+ * mode I: AMR mode
+ * x B: LTP excitation signal -> total excitation signal
+ * cbGain I: Codebook gain
+ * ltpGain I: LTP gain
+ * inno B: Innovation vector
+ * pitch_fac I: pitch factor used to scale the LTP excitation
+ * tmp_shift I: shift factor applied to sum of scaled LTP ex & innov.
+ * before rounding
+ *
+ * Function:
+ * Adaptive phase dispersion; forming of total excitation
+ *
+ *
+ * Returns:
+ * void
+ */
+static void ph_disp( ph_dispState *state, enum Mode mode, Word32 x[],
+ Word32 cbGain, Word32 ltpGain, Word32 inno[],
+ Word32 pitch_fac, Word32 tmp_shift)
+{
+ Word32 inno_sav[L_SUBFR], ps_poss[L_SUBFR];
+ Word32 i, i1, impNr, temp1, temp2, j, nze, nPulse, ppos;
+ const Word32 *ph_imp; /* Pointer to phase dispersion filter */
+
+
+ /* Update LTP gain memory */
+ state->gainMem[4] = state->gainMem[3];
+ state->gainMem[3] = state->gainMem[2];
+ state->gainMem[2] = state->gainMem[1];
+ state->gainMem[1] = state->gainMem[0];
+ state->gainMem[0] = ltpGain;
+
+ /* basic adaption of phase dispersion */
+ /* no dispersion */
+ impNr = 2;
+
+ /* if (ltpGain < 0.9) */
+ if ( ltpGain < PHDTHR2LTP ) {
+ /* maximum dispersion */
+ impNr = 0;
+
+ /* if (ltpGain > 0.6 */
+ if ( ltpGain > PHDTHR1LTP ) {
+ /* medium dispersion */
+ impNr = 1;
+ }
+ }
+
+ /* onset indicator */
+ /* onset = (cbGain > onFact * cbGainMem[0]) */
+ temp1 = ( ( state->prevCbGain * ONFACTPLUS1 ) + 0x1000 ) >> 13;
+
+ if ( cbGain > temp1 ) {
+ state->onset = ONLENGTH;
+ }
+ else {
+ if ( state->onset > 0 ) {
+ state->onset--;
+ }
+ }
+
+ /*
+ * if not onset, check ltpGain buffer and use max phase dispersion if
+ * half or more of the ltpGain-parameters say so
+ */
+ if ( state->onset == 0 ) {
+ /* Check LTP gain memory and set filter accordingly */
+ i1 = 0;
+
+ for ( i = 0; i < PHDGAINMEMSIZE; i++ ) {
+ if ( state->gainMem[i] < PHDTHR1LTP ) {
+ i1++;
+ }
+ }
+
+ if ( i1 > 2 ) {
+ impNr = 0;
+ }
+ }
+
+ /* Restrict decrease in phase dispersion to one step if not onset */
+ if ( ( impNr > ( state->prevState + 1 ) ) & ( state->onset == 0 ) ) {
+ impNr--;
+ }
+
+ /* if onset, use one step less phase dispersion */
+ if ( ( impNr<2 )&( state->onset>0 ) ) {
+ impNr++;
+ }
+
+ /* disable for very low levels */
+ if ( cbGain < 10 ) {
+ impNr = 2;
+ }
+
+ if ( state->lockFull == 1 ) {
+ impNr = 0;
+ }
+
+ /* update static memory */
+ state->prevState = impNr;
+ state->prevCbGain = cbGain;
+
+ /*
+ * do phase dispersion for all modes but 12.2 and 7.4;
+ * don't modify the innovation if impNr >=2 (= no phase disp)
+ */
+ if ( ( mode != MR122 ) & ( mode != MR102 ) & ( mode != MR74 ) & ( impNr < 2 )
+ ) {
+ /*
+ * track pulse positions, save innovation,
+ * and initialize new innovation
+ */
+ nze = 0;
+
+ for ( i = 0; i < L_SUBFR; i++ ) {
+ if ( inno[i] != 0 ) {
+ ps_poss[nze] = i;
+ nze++;
+ }
+ }
+ memcpy( inno_sav, inno, L_SUBFR <<2 );
+ memset( inno, 0, L_SUBFR <<2 );
+
+ /* Choose filter corresponding to codec mode and dispersion criterium */
+ ph_imp = ph_imp_mid;
+
+ if ( impNr == 0 ) {
+ ph_imp = ph_imp_low;
+ }
+
+ if ( mode == MR795 ) {
+ ph_imp = ph_imp_mid_MR795;
+
+ if ( impNr == 0 ) {
+ ph_imp = ph_imp_low_MR795;
+ }
+ }
+
+ /* Do phase dispersion of innovation */
+ for ( nPulse = 0; nPulse < nze; nPulse++ ) {
+ ppos = ps_poss[nPulse];
+
+ /* circular convolution with impulse response */
+ j = 0;
+
+ for ( i = ppos; i < L_SUBFR; i++ ) {
+ /* inno[i1] += inno_sav[ppos] * ph_imp[i1-ppos] */
+ temp1 = ( inno_sav[ppos] * ph_imp[j++] ) >> 15;
+ inno[i] = inno[i] + temp1;
+ }
+
+ for ( i = 0; i < ppos; i++ ) {
+ /* inno[i] += inno_sav[ppos] * ph_imp[L_SUBFR-ppos+i] */
+ temp1 = ( inno_sav[ppos] * ph_imp[j++] ) >> 15;
+ inno[i] = inno[i] + temp1;
+ }
+ }
+ }
+
+ /*
+ * compute total excitation for synthesis part of decoder
+ * (using modified innovation if phase dispersion is active)
+ */
+ for ( i = 0; i < L_SUBFR; i++ ) {
+ /* x[i] = gain_pit*x[i] + cbGain*code[i]; */
+ temp1 = x[i] * pitch_fac + inno[i] * cbGain;
+ temp2 = temp1 << tmp_shift;
+ x[i] = ( temp2 + 0x4000 ) >> 15;
+ if (labs(x[i]) > 32767)
+ {
+ if ((temp1 ^ temp2) & 0x80000000) {
+ x[i] = (temp1 & 0x80000000) ? -32768: 32767;
+ }
+ else {
+ x[i] = (temp2 & 0x80000000) ? -32768: 32767;
+ }
+ }
+ }
+ return;
+}
+
+
+/*
+ * sqrt_l_exp
+ *
+ *
+ * Parameters:
+ * x I: input value
+ * exp O: right shift to be applied to result
+ *
+ * Function:
+ * Sqrt with exponent value.
+ *
+ * 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)
+ *
+ *
+ * Returns:
+ * y output value
+ */
+static Word32 sqrt_l_exp( Word32 x, Word32 *exp )
+{
+ Word32 y, a, i, tmp;
+ int e;
+
+
+ if ( x <= ( Word32 )0 ) {
+ *exp = 0;
+ return( Word32 )0;
+ }
+ e=0;
+ if (x != 0){
+ tmp = x;
+ while (!(tmp & 0x40000000))
+ {
+ e++;
+ tmp = tmp << 1;
+ }
+ }
+ e = e & 0xFFFE;
+ x = ( x << e );
+ *exp = ( Word16 )e;
+ x = ( x >> 9 );
+ i = ( Word16 )( x >> 16 );
+ x = ( x >> 1 );
+ a = x & ( Word16 )0x7fff;
+ i = ( i - 16 );
+ y = ( sqrt_table[i] << 16 );
+ tmp = ( sqrt_table[i] - sqrt_table[i + 1] );
+ y -= ( tmp * a ) << 1;
+ return( y );
+}
+
+
+/*
+ * Ex_ctrl
+ *
+ *
+ * Parameters:
+ * excitation B: Current subframe excitation
+ * excEnergy I: Exc. Energy, sqrt(totEx*totEx)
+ * exEnergyHist I: History of subframe energies
+ * voicedHangover I: number of frames after last voiced frame
+ * prevBFI I: Set i previous bad frame indicators
+ * carefulFlag I: Restrict dymamic in scaling
+ *
+ * Function:
+ * Charaterice synthesis speech and detect background noise
+ *
+ * Returns:
+ * background noise decision; 0 = no bgn, 1 = bgn
+ */
+static Word16 Ex_ctrl( Word32 excitation[], Word32 excEnergy, Word32
+ exEnergyHist[], Word32 voicedHangover, Word16 prevBFI, Word16 carefulFlag
+ )
+{
+ Word32 i, testEnergy, scaleFactor, avgEnergy, prevEnergy, T0;
+ int exp;
+
+
+ /* get target level */
+ avgEnergy = gmed_n( exEnergyHist, 9 );
+ prevEnergy = ( exEnergyHist[7] + exEnergyHist[8] ) >> 1;
+
+ if ( exEnergyHist[8] < prevEnergy ) {
+ prevEnergy = exEnergyHist[8];
+ }
+
+ /* upscaling to avoid too rapid energy rises for some cases */
+ if ( ( excEnergy<avgEnergy )&( excEnergy>5 ) ) {
+ /* testEnergy = 4*prevEnergy; */
+ testEnergy = prevEnergy << 2;
+
+ if ( ( voicedHangover < 7 ) || prevBFI != 0 ) {
+ /* testEnergy = 3*prevEnergy */
+ testEnergy = testEnergy - prevEnergy;
+ }
+
+ if ( avgEnergy > testEnergy ) {
+ avgEnergy = testEnergy;
+ }
+
+ /* scaleFactor=avgEnergy/excEnergy in Q0 */
+ exp=0;
+ if (excEnergy != 0){
+ while (!(excEnergy & 0x4000))
+ {
+ exp++;
+ excEnergy = excEnergy << 1;
+ }
+ }
+ excEnergy = 536838144 / excEnergy;
+ T0 = ( avgEnergy * excEnergy ) << 1;
+ T0 = ( T0 >> ( 20 - exp ) );
+
+ if ( T0 > 32767 ) {
+ /* saturate */
+ T0 = 32767;
+ }
+ scaleFactor = T0;
+
+ /* test if scaleFactor > 3.0 */
+ if ( ( carefulFlag != 0 ) & ( scaleFactor > 3072 ) ) {
+ scaleFactor = 3072;
+ }
+
+ /* scale the excitation by scaleFactor */
+ for ( i = 0; i < L_SUBFR; i++ ) {
+ T0 = ( scaleFactor * excitation[i] ) << 1;
+ T0 = ( T0 >> 11 );
+ excitation[i] = T0;
+ }
+ }
+ return 0;
+}
+
+
+/*
+ * Inv_sqrt
+ *
+ *
+ * Parameters:
+ * x I: input value
+ *
+ * Function:
+ * 1/sqrt(x)
+ *
+ * Returns:
+ * y 1/sqrt(x)
+ */
+static Word32 Inv_sqrt( Word32 x )
+{
+ int i, a, tmp, exp;
+ Word32 y;
+
+
+ if ( x <= ( Word32 )0 )
+ return( ( Word32 )0x3fffffffL );
+ exp=0;
+ while (!(x & 0x40000000))
+ {
+ exp++;
+ x = x << 1;
+ }
+
+ /* x is normalized */
+ exp = ( 30 - exp );
+
+ /* If exponent even -> shift right */
+ if ( ( exp & 1 ) == 0 ) {
+ x = ( x >> 1 );
+ }
+ exp = ( exp >> 1 );
+ exp = ( exp + 1 );
+ x = ( x >> 9 );
+
+ /* Extract b25-b31 */
+ i = ( Word16 )( x >> 16 );
+
+ /* Extract b10-b24 */
+ x = ( x >> 1 );
+ a = x & ( Word16 )0x7fff;
+ i = ( i - 16 );
+
+ /* table[i] << 16 */
+ y = inv_sqrt_table[i] << 16;
+
+ /* table[i] - table[i+1]) */
+ tmp = ( inv_sqrt_table[i] - inv_sqrt_table[i + 1] );
+
+ /* y -= tmp*a*2 */
+ y -= ( tmp * a ) << 1;
+
+ /* denormalization */
+ y = ( y >> exp );
+ return( y );
+}
+
+
+/*
+ * energy_old
+ *
+ *
+ * Parameters:
+ * in I: input value
+ *
+ * Function:
+ * Energy of signal
+ *
+ * Returns:
+ * Energy
+ */
+static Word32 energy_old( Word32 in[] )
+{
+ Word32 temp, i, sum = 0;
+
+
+ for ( i = 0; i < L_SUBFR; i += 8 ) {
+ temp = in[i] >> 2;
+ sum += temp * temp;
+ temp = in[i + 1] >> 2;
+ sum += temp * temp;
+ temp = in[i + 2] >> 2;
+ sum += temp * temp;
+ temp = in[i + 3] >> 2;
+ sum += temp * temp;
+ temp = in[i + 4] >> 2;
+ sum += temp * temp;
+ temp = in[i + 5] >> 2;
+ sum += temp * temp;
+ temp = in[i + 6] >> 2;
+ sum += temp * temp;
+ temp = in[i + 7] >> 2;
+ sum += temp * temp;
+ }
+
+ if ( sum & 0xC0000000 ) {
+ return 0x7FFFFFFF;
+ }
+ return( sum << 1 );
+}
+
+
+/*
+ * energy_new
+ *
+ *
+ * Parameters:
+ * in I: input value
+ *
+ * Function:
+ * Energy of signal
+ *
+ * Returns:
+ * Energy
+ */
+static Word32 energy_new( Word32 in[] )
+{
+ Word32 i, s = 0, overflow = 0;
+
+ s += in[0] * in[0];
+ for ( i = 1; i < L_SUBFR; i += 3 ) {
+ s += in[i] * in[i];
+ s += in[i + 1] *in[i + 1];
+ s += in[i + 2] * in[i + 2];
+
+
+ if ( s & 0xC0000000 ) {
+ overflow = 1;
+ break;
+ }
+ }
+
+ /* check for overflow */
+ if ( overflow ) {
+ s = energy_old( in );
+ }
+ else {
+ s = ( s >> 3 );
+ }
+ return s;
+}
+
+
+/*
+ * agc2
+ *
+ *
+ * Parameters:
+ * sig_in I: Post_Filter input signal
+ * sig_out B: Post_Filter output signal
+ *
+ * Function:
+ * Scales the excitation on a subframe basis
+ *
+ * Returns:
+ * Energy
+ */
+static void agc2( Word32 *sig_in, Word32 *sig_out )
+{
+ Word32 s;
+ int i, exp;
+ Word16 gain_in, gain_out, g0;
+
+
+ /* calculate gain_out with exponent */
+ s = energy_new( sig_out );
+
+ if ( s == 0 ) {
+ return;
+ }
+ exp=0;
+ while (!(s & 0x20000000))
+ {
+ exp++;
+ s = s << 1;
+ }
+
+ gain_out = ( Word16 )( ( s + 0x00008000L ) >> 16 );
+
+ /* calculate gain_in with exponent */
+ s = energy_new( sig_in );
+
+ if ( s == 0 ) {
+ g0 = 0;
+ }
+ else {
+ i = 0;
+ while (!(s & 0x40000000))
+ {
+ i++;
+ s = s << 1;
+ }
+
+ if ( s < 0x7fff7fff )
+ gain_in = ( Word16 )( ( s + 0x00008000L ) >> 16 );
+ else
+ gain_in = 32767;
+ exp = ( exp - i );
+
+ /*
+ * g0 = sqrt(gain_in/gain_out);
+ */
+ /* s = gain_out / gain_in */
+ s = ( gain_out << 15 ) / gain_in;
+ s = ( s << 7 );
+
+ if ( exp > 0 )
+ s = ( s >> exp );
+ else
+ s = ( s << ( -exp ) );
+ s = Inv_sqrt( s );
+ g0 = ( Word16 )( ( ( s << 9 ) + 0x00008000L ) >> 16 );
+ }
+
+ /* sig_out(n) = gain(n) * sig_out(n) */
+ for ( i = 0; i < L_SUBFR; i++ ) {
+ sig_out[i] = ( sig_out[i] * g0 ) >> 12;
+ }
+ return;
+}
+
+
+/*
+ * Bgn_scd
+ *
+ *
+ * Parameters:
+ * st->frameEnergyHist B: Frame Energy memory
+ * st->bgHangover B: Background hangover counter
+ * ltpGainHist I: LTP gain history
+ * speech I: synthesis speech frame
+ * voicedHangover O: number of frames after last voiced frame
+ *
+ * Function:
+ * Charaterice synthesis speech and detect background noise
+ *
+ * Returns:
+ * inbgNoise background noise decision; 0 = no bgn, 1 = bgn
+ */
+static Word16 Bgn_scd( Bgn_scdState *st, Word32 ltpGainHist[], Word32 speech[],
+ Word32 *voicedHangover )
+{
+ Word32 temp, ltpLimit, frame_energyMin, currEnergy, noiseFloor, maxEnergy,
+ maxEnergyLastPart, s, i;
+ Word16 prevVoiced, inbgNoise;
+
+
+ /*
+ * Update the inBackgroundNoise flag (valid for use in next frame if BFI)
+ * it now works as a energy detector floating on top
+ * not as good as a VAD.
+ */
+ s = 0;
+
+ for ( i = 0; i < L_FRAME; i++ ) {
+ s += speech[i] * speech[i];
+ }
+
+ if ( (s < 0xFFFFFFF) & (s >= 0) )
+ currEnergy = s >> 13;
+ else
+ currEnergy = 32767;
+ frame_energyMin = 32767;
+
+ for ( i = 0; i < L_ENERGYHIST; i++ ) {
+ if ( st->frameEnergyHist[i] < frame_energyMin )
+ frame_energyMin = st->frameEnergyHist[i];
+ }
+
+ /* Frame Energy Margin of 16 */
+ noiseFloor = frame_energyMin << 4;
+ maxEnergy = st->frameEnergyHist[0];
+
+ for ( i = 1; i < L_ENERGYHIST - 4; i++ ) {
+ if ( maxEnergy < st->frameEnergyHist[i] ) {
+ maxEnergy = st->frameEnergyHist[i];
+ }
+ }
+ maxEnergyLastPart = st->frameEnergyHist[2 * L_ENERGYHIST / 3];
+
+ for ( i = 2 * L_ENERGYHIST / 3 + 1; i < L_ENERGYHIST; i++ ) {
+ if ( maxEnergyLastPart < st->frameEnergyHist[i] ) {
+ maxEnergyLastPart = st->frameEnergyHist[i];
+ }
+ }
+
+ /* false */
+ inbgNoise = 0;
+
+ /*
+ * Do not consider silence as noise
+ * Do not consider continuous high volume as noise
+ * Or if the current noise level is very low
+ * Mark as noise if under current noise limit
+ * OR if the maximum energy is below the upper limit
+ */
+ if ( ( maxEnergy> LOWERNOISELIMIT )&( currEnergy<FRAMEENERGYLIMIT )&(
+ currEnergy>LOWERNOISELIMIT ) & ( ( currEnergy < noiseFloor ) || (
+ maxEnergyLastPart < UPPERNOISELIMIT ) ) ) {
+ if ( ( st->bgHangover + 1 ) > 30 ) {
+ st->bgHangover = 30;
+ }
+ else {
+ st->bgHangover += 1;
+ }
+ }
+ else {
+ st->bgHangover = 0;
+ }
+
+ /* make final decision about frame state, act somewhat cautiosly */
+ if ( st->bgHangover > 1 )
+ inbgNoise = 1; /* true */
+
+ for ( i = 0; i < L_ENERGYHIST - 1; i++ ) {
+ st->frameEnergyHist[i] = st->frameEnergyHist[i + 1];
+ }
+ st->frameEnergyHist[L_ENERGYHIST - 1] = currEnergy;
+
+ /*
+ * prepare for voicing decision;
+ * tighten the threshold after some time in noise
+ */
+ ltpLimit = 13926; /* 0.85 Q14 */
+
+ if ( st->bgHangover > 8 ) {
+ ltpLimit = 15565; /* 0.95 Q14 */
+ }
+
+ if ( st->bgHangover > 15 ) {
+ ltpLimit = 16383; /* 1.00 Q14 */
+ }
+
+ /* weak sort of voicing indication. */
+ prevVoiced = 0; /* false */
+
+ if ( gmed_n( &ltpGainHist[4], 5 ) > ltpLimit ) {
+ prevVoiced = 1; /* true */
+ }
+
+ if ( st->bgHangover > 20 ) {
+ if ( gmed_n( ltpGainHist, 9 ) > ltpLimit ) {
+ prevVoiced = 1; /* true */
+ }
+ else {
+ prevVoiced = 0; /* false */
+ }
+ }
+
+ if ( prevVoiced ) {
+ *voicedHangover = 0;
+ }
+ else {
+ temp = *voicedHangover + 1;
+
+ if ( temp > 10 ) {
+ *voicedHangover = 10;
+ }
+ else {
+ *voicedHangover = temp;
+ }
+ }
+ return inbgNoise;
+}
+
+
+/*
+ * dtx_dec_activity_update
+ *
+ *
+ * Parameters:
+ * st->lsf_hist_ptr B: LSF history pointer
+ * st->lsf_hist B: LSF history
+ * lsf I: lsf
+ * frame I: noise frame
+ *
+ * Function:
+ * Update lsp history and compute log energy.
+ *
+ * Returns:
+ * void
+ */
+static void dtx_dec_activity_update( dtx_decState *st, Word32 lsf[], Word32
+ frame[] )
+{
+ Word32 frame_en;
+ Word32 log_en_e, log_en_m, log_en, i;
+
+
+ /* update lsp history */
+ st->lsf_hist_ptr += M;
+
+ if ( st->lsf_hist_ptr == 80 ) {
+ st->lsf_hist_ptr = 0;
+ }
+ memcpy( &st->lsf_hist[st->lsf_hist_ptr], lsf, M <<2 );
+
+ /* compute log energy based on frame energy */
+ frame_en = 0; /* Q0 */
+
+ for ( i = 0; (i < L_FRAME); i ++ ) {
+ frame_en += frame[i] * frame[i];
+ if (frame_en & 0x80000000)
+ break;
+ }
+
+ log_en = (frame_en & 0xC0000000) ? 0x7FFFFFFE: (Word32)frame_en << 1;
+
+ Log2( log_en , &log_en_e, &log_en_m );
+
+ /* convert exponent and mantissa to Word16 Q10 */
+ log_en = log_en_e << 10; /* Q10 */
+ log_en = log_en + ( log_en_m >> 5 );
+
+ /* divide with L_FRAME i.e subtract with log2(L_FRAME) = 7.32193 */
+ log_en = log_en - 8521;
+
+ /*
+ * insert into log energy buffer, no division by two as
+ * log_en in decoder is Q11
+ */
+ st->log_en_hist_ptr += 1;
+
+ if ( st->log_en_hist_ptr == DTX_HIST_SIZE ) {
+ st->log_en_hist_ptr = 0;
+ }
+ st->log_en_hist[st->log_en_hist_ptr] = log_en; /* Q11 */
+}
+
+
+/*
+ * Decoder_amr
+ *
+ *
+ * Parameters:
+ * st B: State variables
+ * mode I: AMR mode
+ * parm I: vector of synthesis parameters
+ * frame_type I: received frame type
+ * synth O: synthesis speech
+ * A_t O: decoded LP filter in 4 subframes
+ *
+ * Function:
+ * Speech decoder routine
+ *
+ * Returns:
+ * void
+ */
+static void Decoder_amr( Decoder_amrState *st, enum Mode mode, Word16 parm[],
+ enum RXFrameType frame_type, Word32 synth[], Word32 A_t[] )
+{
+ /* LSPs */
+ Word32 lsp_new[M];
+ Word32 lsp_mid[M];
+
+
+ /* LSFs */
+ Word32 prev_lsf[M];
+ Word32 lsf_i[M];
+
+
+ /* Algebraic codevector */
+ Word32 code[L_SUBFR];
+
+
+ /* excitation */
+ Word32 excp[L_SUBFR];
+ Word32 exc_enhanced[L_SUBFR];
+
+
+ /* Scalars */
+ Word32 i, i_subfr, overflow, T0_frac, index, temp, temp2, subfrNr, excEnergy;
+ Word32 gain_code, gain_code_mix, pit_sharp, pit_flag, pitch_fac, t0_min, t0_max;
+ Word32 gain_pit = 0, evenSubfr = 0, T0 = 0, index_mr475 = 0;
+ Word32 *Az; /* Pointer on A_t */
+ Word16 flag4, carefulFlag;
+ Word16 delta_frc_low, delta_frc_range, tmp_shift;
+ Word16 bfi = 0, pdfi = 0;
+ /* bad frame indication flag, potential degraded bad frame flag */
+
+
+ enum DTXStateType newDTXState; /* SPEECH , DTX, DTX_MUTE */
+
+ /* find the new DTX state SPEECH OR DTX */
+ newDTXState = rx_dtx_handler( st->dtxDecoderState, frame_type );
+
+ /* DTX actions */
+ if ( newDTXState != SPEECH ) {
+ Decoder_amr_reset( st, MRDTX );
+ dtx_dec( st->dtxDecoderState, st->mem_syn, st->lsfState, st->pred_state,
+ st->Cb_gain_averState, newDTXState, mode, parm, synth, A_t );
+
+ /* update average lsp */
+ Lsf_lsp( st->lsfState->past_lsf_q, st->lsp_old );
+ lsp_avg( st->lsp_avg_st, st->lsfState->past_lsf_q );
+ goto theEnd;
+ }
+
+ /* SPEECH action state machine */
+ if ( table_speech_bad[frame_type] ) {
+ bfi = 1;
+
+ if ( frame_type != RX_SPEECH_BAD ) {
+ Build_CN_param( &st->nodataSeed, mode, parm );
+ }
+ }
+ else if ( frame_type == RX_SPEECH_DEGRADED ) {
+ pdfi = 1;
+ }
+
+ if ( bfi != 0 ) {
+ st->state += 1;
+ }
+ else if ( st->state == 6 ) {
+ st->state = 5;
+ }
+ else {
+ st->state = 0;
+ }
+
+ if ( st->state > 6 ) {
+ st->state = 6;
+ }
+
+ /*
+ * If this frame is the first speech frame after CNI period,
+ * set the BFH state machine to an appropriate state depending
+ * on whether there was DTX muting before start of speech or not
+ * If there was DTX muting, the first speech frame is muted.
+ * If there was no DTX muting, the first speech frame is not
+ * muted. The BFH state machine starts from state 5, however, to
+ * keep the audible noise resulting from a SID frame which is
+ * erroneously interpreted as a good speech frame as small as
+ * possible (the decoder output in this case is quickly muted)
+ */
+ if ( st->dtxDecoderState->dtxGlobalState == DTX ) {
+ st->state = 5;
+ st->prev_bf = 0;
+ }
+ else if ( st->dtxDecoderState->dtxGlobalState == DTX_MUTE ) {
+ st->state = 5;
+ st->prev_bf = 1;
+ }
+
+ /* save old LSFs for CB gain smoothing */
+ memcpy( prev_lsf, st->lsfState->past_lsf_q, M <<2 );
+
+ /*
+ * decode LSF parameters and generate interpolated lpc coefficients
+ * for the 4 subframes
+ */
+ if ( mode != MR122 ) {
+ D_plsf_3( st->lsfState, mode, bfi, parm, lsp_new );
+
+ /* Advance synthesis parameters pointer */
+ parm += 3;
+ Int_lpc_1to3( st->lsp_old, lsp_new, A_t );
+ }
+ else {
+ D_plsf_5( st->lsfState, bfi, parm, lsp_mid, lsp_new );
+
+ /* Advance synthesis parameters pointer */
+ parm += 5;
+ Int_lpc_1and3( st->lsp_old, lsp_mid, lsp_new, A_t );
+ }
+
+ /* update the LSPs for the next frame */
+ memcpy( st->lsp_old, lsp_new, M <<2 );
+
+ /*
+ * Loop for every subframe in the analysis frame
+ *
+ * The subframe size is L_SUBFR and the loop is repeated
+ * L_FRAME/L_SUBFR times *
+ * - decode the pitch delay
+ * - decode algebraic code
+ * - decode pitch and codebook gains
+ * - find the excitation and compute synthesis speech
+ */
+ /* pointer to interpolated LPC parameters */
+ Az = A_t;
+ evenSubfr = 0;
+ subfrNr = -1;
+
+ for ( i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR ) {
+ subfrNr += 1;
+ evenSubfr = 1 - evenSubfr;
+
+ /* flag for first and 3th subframe */
+ pit_flag = i_subfr;
+
+ if ( i_subfr == L_FRAME_BY2 ) {
+ if ( ( mode != MR475 ) & ( mode != MR515 ) ) {
+ pit_flag = 0;
+ }
+ }
+
+ /* pitch index */
+ index = *parm++;
+
+ /*
+ * decode pitch lag and find adaptive codebook vector.
+ */
+ if ( mode != MR122 ) {
+ /*
+ * flag4 indicates encoding with 4 bit resolution;
+ * this is needed for mode MR475, MR515, MR59 and MR67
+ */
+ flag4 = 0;
+
+ if ( ( mode == MR475 ) || ( mode == MR515 ) || ( mode == MR59 ) || (
+ mode == MR67 ) ) {
+ flag4 = 1;
+ }
+
+ /*
+ * get ranges for the t0_min and t0_max
+ * only needed in delta decoding
+ */
+ delta_frc_low = 5;
+ delta_frc_range = 9;
+
+ if ( mode == MR795 ) {
+ delta_frc_low = 10;
+ delta_frc_range = 19;
+ }
+ t0_min = st->old_T0 - delta_frc_low;
+
+ if ( t0_min < PIT_MIN ) {
+ t0_min = PIT_MIN;
+ }
+ t0_max = t0_min + delta_frc_range;
+
+ if ( t0_max > PIT_MAX ) {
+ t0_max = PIT_MAX;
+ t0_min = t0_max - delta_frc_range;
+ }
+ Dec_lag3( index, t0_min, t0_max, pit_flag, st->old_T0, &T0, &T0_frac,
+ flag4 );
+ st->T0_lagBuff = T0;
+
+ if ( bfi != 0 ) {
+ if ( st->old_T0 < PIT_MAX ) {
+ /* Graceful pitch degradation */
+ st->old_T0 += 1;
+ }
+ T0 = st->old_T0;
+ T0_frac = 0;
+
+ if ( ( st->inBackgroundNoise != 0 ) & ( st->voicedHangover > 4 ) & (
+ ( mode == MR475 ) || ( mode == MR515 ) || ( mode == MR59 ) ) )
+ {
+ T0 = st->T0_lagBuff;
+ }
+ }
+ Pred_lt_3or6_40( st->exc, T0, T0_frac, 1 );
+ }
+ else {
+ Dec_lag6( index, PIT_MIN_MR122, PIT_MAX, pit_flag, &T0, &T0_frac );
+
+ if ( ( bfi != 0 ) || ( ( pit_flag != 0 ) & ( index > 60 ) ) ) {
+ st->T0_lagBuff = T0;
+ T0 = st->old_T0;
+ T0_frac = 0;
+ }
+ Pred_lt_3or6_40( st->exc, T0, T0_frac, 0 );
+ }
+
+ /*
+ * (MR122 only: Decode pitch gain.)
+ * Decode innovative codebook.
+ * set pitch sharpening factor
+ */
+ /* MR475, MR515 */
+ if ( ( mode == MR475 ) || ( mode == MR515 ) ) {
+ /* index of position */
+ index = *parm++;
+
+ /* signs */
+ i = *parm++;
+ decode_2i40_9bits( subfrNr, i, index, code );
+ pit_sharp = st->sharp << 1;
+ }
+
+ /* MR59 */
+ else if ( mode == MR59 ) {
+ /* index of position */
+ index = *parm++;
+
+ /* signs */
+ i = *parm++;
+ decode_2i40_11bits( i, index, code );
+ pit_sharp = st->sharp << 1;
+ }
+
+ /* MR67 */
+ else if ( mode == MR67 ) {
+ /* index of position */
+ index = *parm++;
+
+ /* signs */
+ i = *parm++;
+ decode_3i40_14bits( i, index, code );
+ pit_sharp = st->sharp << 1;
+ }
+
+ /* MR74, MR795 */
+ else if ( mode <= MR795 ) {
+ /* index of position */
+ index = *parm++;
+
+ /* signs */
+ i = *parm++;
+ decode_4i40_17bits( i, index, code );
+ pit_sharp = st->sharp << 1;
+ }
+
+ /* MR102 */
+ else if ( mode == MR102 ) {
+ decode_8i40_31bits( parm, code );
+ parm += 7;
+ pit_sharp = st->sharp << 1;
+ }
+
+ /* MR122 */
+ else {
+ index = *parm++;
+
+ if ( bfi != 0 ) {
+ ec_gain_pitch( st->ec_gain_p_st, st->state, &gain_pit );
+ }
+ else {
+ gain_pit = d_gain_pitch( mode, index );
+ }
+ ec_gain_pitch_update( st->ec_gain_p_st, bfi, st->prev_bf, &gain_pit );
+ decode_10i40_35bits( parm, code );
+ parm += 10;
+
+ /*
+ * pit_sharp = gain_pit;
+ * if (pit_sharp > 1.0) pit_sharp = 1.0;
+ */
+ pit_sharp = gain_pit;
+
+ if ( pit_sharp > 16383 )
+ pit_sharp = 32767;
+ else
+ pit_sharp *= 2;
+ }
+
+ /*
+ * Add the pitch contribution to code[].
+ */
+ for ( i = T0; i < L_SUBFR; i++ ) {
+ temp = ( code[i - T0] * pit_sharp ) >> 15;
+ code[i] = code[i] + temp;
+ }
+
+ /*
+ * Decode codebook gain (MR122) or both pitch
+ * gain and codebook gain (all others)
+ * Update pitch sharpening "sharp" with quantized gain_pit
+ */
+ if ( mode == MR475 ) {
+ /* read and decode pitch and code gain */
+ if ( evenSubfr != 0 ) {
+ /* index of gain(s) */
+ index_mr475 = *parm++;
+ }
+
+ if ( bfi == 0 ) {
+ Dec_gain( st->pred_state, mode, index_mr475, code, evenSubfr, &
+ gain_pit, &gain_code );
+ }
+ else {
+ ec_gain_pitch( st->ec_gain_p_st, st->state, &gain_pit );
+ ec_gain_code( st->ec_gain_c_st, st->pred_state, st->state, &
+ gain_code );
+ }
+ ec_gain_pitch_update( st->ec_gain_p_st, bfi, st->prev_bf, &gain_pit );
+ ec_gain_code_update( st->ec_gain_c_st, bfi, st->prev_bf, &gain_code );
+ pit_sharp = gain_pit;
+
+ if ( pit_sharp > SHARPMAX ) {
+ pit_sharp = SHARPMAX;
+ }
+ }
+ else if ( ( mode <= MR74 ) || ( mode == MR102 ) ) {
+ /* read and decode pitch and code gain */
+ /* index of gain(s) */
+ index = *parm++;
+
+ if ( bfi == 0 ) {
+ Dec_gain( st->pred_state, mode, index, code, evenSubfr, &gain_pit, &
+ gain_code );
+ }
+ else {
+ ec_gain_pitch( st->ec_gain_p_st, st->state, &gain_pit );
+ ec_gain_code( st->ec_gain_c_st, st->pred_state, st->state, &
+ gain_code );
+ }
+ ec_gain_pitch_update( st->ec_gain_p_st, bfi, st->prev_bf, &gain_pit );
+ ec_gain_code_update( st->ec_gain_c_st, bfi, st->prev_bf, &gain_code );
+ pit_sharp = gain_pit;
+
+ if ( pit_sharp > SHARPMAX ) {
+ pit_sharp = SHARPMAX;
+ }
+
+ if ( mode == MR102 ) {
+ if ( st->old_T0 > ( L_SUBFR + 5 ) ) {
+ pit_sharp = pit_sharp >> 2;
+ }
+ }
+ }
+ else {
+ /* read and decode pitch gain */
+ /* index of gain(s) */
+ index = *parm++;
+
+ if ( mode == MR795 ) {
+ /* decode pitch gain */
+ if ( bfi != 0 ) {
+ ec_gain_pitch( st->ec_gain_p_st, st->state, &gain_pit );
+ }
+ else {
+ gain_pit = d_gain_pitch( mode, index );
+ }
+ ec_gain_pitch_update( st->ec_gain_p_st, bfi, st->prev_bf, &gain_pit
+ );
+
+ /* read and decode code gain */
+ index = *parm++;
+
+ if ( bfi == 0 ) {
+ d_gain_code( st->pred_state, mode, index, code, &gain_code );
+ }
+ else {
+ ec_gain_code( st->ec_gain_c_st, st->pred_state, st->state, &
+ gain_code );
+ }
+ ec_gain_code_update( st->ec_gain_c_st, bfi, st->prev_bf, &gain_code
+ );
+ pit_sharp = gain_pit;
+
+ if ( pit_sharp > SHARPMAX ) {
+ pit_sharp = SHARPMAX;
+ }
+ }
+ else { /* MR122 */
+
+ if ( bfi == 0 ) {
+ d_gain_code( st->pred_state, mode, index, code, &gain_code );
+ }
+ else {
+ ec_gain_code( st->ec_gain_c_st, st->pred_state, st->state, &
+ gain_code );
+ }
+ ec_gain_code_update( st->ec_gain_c_st, bfi, st->prev_bf, &gain_code
+ );
+ pit_sharp = gain_pit;
+ }
+ }
+
+ /*
+ * store pitch sharpening for next subframe
+ * (for modes which use the previous pitch gain for
+ * pitch sharpening in the search phase)
+ * do not update sharpening in even subframes for MR475
+ */
+ if ( ( mode != MR475 ) || evenSubfr == 0 ) {
+ st->sharp = gain_pit;
+
+ if ( st->sharp > SHARPMAX ) {
+ st->sharp = SHARPMAX;
+ }
+ }
+
+ if ( pit_sharp > 16383 )
+ pit_sharp = 32767;
+ else
+ pit_sharp *= 2;
+
+ if ( pit_sharp > 16384 ) {
+ for ( i = 0; i < L_SUBFR; i++ ) {
+ temp = ( st->exc[i] * pit_sharp ) >> 15;
+ temp2 = ( temp * gain_pit ) << 1;
+
+ if ( mode == MR122 ) {
+ temp2 = ( temp2 >> 1 );
+ }
+ excp[i] = ( temp2 + 0x00008000L ) >> 16;
+ }
+ }
+
+ /*
+ * Store list of LTP gains needed in the source
+ * characteristic detector (SCD)
+ */
+ if ( bfi == 0 ) {
+ for (i = 0; i < 8; i++){
+ st->ltpGainHistory[i] = st->ltpGainHistory[i+1];
+ }
+ st->ltpGainHistory[8] = gain_pit;
+ }
+
+
+ /*
+ * Limit gain_pit if in background noise and BFI
+ * for MR475, MR515, MR59
+ */
+ if ( ( st->prev_bf != 0 || bfi != 0 ) & ( st->inBackgroundNoise != 0 ) & (
+ ( mode == MR475 ) || ( mode == MR515 ) || ( mode == MR59 ) ) ) {
+ /* if (gain_pit > 0.75) in Q14*/
+ if ( gain_pit > 12288 )
+ /* gain_pit = (gain_pit-0.75)/2.0 + 0.75; */
+ gain_pit = ( ( gain_pit - 12288 ) >> 1 ) + 12288;
+
+ /* if (gain_pit > 0.90) in Q14*/
+ if ( gain_pit > 14745 ) {
+ gain_pit = 14745;
+ }
+ }
+
+ /*
+ * Calculate CB mixed gain
+ */
+ Int_lsf( prev_lsf, st->lsfState->past_lsf_q, i_subfr, lsf_i );
+ gain_code_mix = Cb_gain_average( st->Cb_gain_averState, mode, gain_code,
+ lsf_i, st->lsp_avg_st->lsp_meanSave, bfi, st->prev_bf, pdfi, st->
+ prev_pdf, st->inBackgroundNoise, st->voicedHangover );
+
+ /* make sure that MR74, MR795, MR122 have original codeGain*/
+ /* MR74, MR795, MR122 */
+ if ( ( mode > MR67 ) & ( mode != MR102 ) ) {
+ gain_code_mix = gain_code;
+ }
+
+ /*
+ * Find the total excitation.
+ * Find synthesis speech corresponding to st->exc[].
+ */
+ /* MR475, MR515, MR59, MR67, MR74, MR795, MR102*/
+ if ( mode <= MR102 ) {
+ pitch_fac = gain_pit;
+ tmp_shift = 1;
+ }
+
+ /* MR122 */
+ else {
+ pitch_fac = gain_pit >> 1;
+ tmp_shift = 2;
+ }
+
+ /*
+ * copy unscaled LTP excitation to exc_enhanced (used in phase
+ * dispersion below) and compute total excitation for LTP feedback
+ */
+ memcpy( exc_enhanced, st->exc, L_SUBFR <<2 );
+
+ for ( i = 0; i < L_SUBFR; i++ ) {
+ /* st->exc[i] = gain_pit*st->exc[i] + gain_code*code[i]; */
+ temp = ( st->exc[i] * pitch_fac ) + ( code[i] * gain_code );
+ temp2 = ( temp << tmp_shift );
+ if (((temp2 >> 1) ^ temp2) & 0x40000000) {
+ if ((temp ^ temp2) & 0x80000000) {
+ temp2 = (temp & 0x80000000) ? (-1073741824L) : 1073725439;
+ }
+ else {
+ temp2 = (temp2 & 0x80000000) ? (-1073741824L) : 1073725439;
+ }
+ }
+ st->exc[i] = ( temp2 + 0x00004000L ) >> 15;
+ }
+ /*
+ * Adaptive phase dispersion
+ */
+
+ /* free phase dispersion adaption */
+ st->ph_disp_st->lockFull = 0;
+
+ if ( ( ( mode == MR475 ) || ( mode == MR515 ) || ( mode == MR59 ) ) & ( st
+ ->voicedHangover > 3 ) & ( st->inBackgroundNoise != 0 ) & ( bfi != 0
+ ) ) {
+ /*
+ * Always Use full Phase Disp.
+ * if error in bg noise
+ */
+ st->ph_disp_st->lockFull = 1;
+ }
+
+ /*
+ * apply phase dispersion to innovation (if enabled) and
+ * compute total excitation for synthesis part
+ */
+ ph_disp( st->ph_disp_st, mode, exc_enhanced, gain_code_mix, gain_pit, code
+ , pitch_fac, tmp_shift );
+
+ /*
+ * The Excitation control module are active during BFI.
+ * Conceal drops in signal energy if in bg noise.
+ */
+ temp2 = 0;
+
+ for ( i = 0; i < L_SUBFR; i++ ) {
+ temp2 += ( exc_enhanced[i] * exc_enhanced[i] );
+ }
+
+ if ( temp2 > 0x3FFFFFFF ) {
+ excEnergy = 11584;
+ }
+ else {
+ temp2 = sqrt_l_exp( temp2, &temp );
+ temp2 = ( temp2 >> ( ( temp >> 1 ) + 15 ) );
+ excEnergy = temp2 >> 2;
+ }
+
+ if ( ( ( mode == MR475 ) || ( mode == MR515 ) || ( mode == MR59 ) ) & ( st
+ ->voicedHangover > 5 ) & ( st->inBackgroundNoise != 0 ) & ( st->
+ state < 4 ) & ( ( ( pdfi != 0 ) & ( st->prev_pdf != 0 ) ) || bfi !=
+ 0 || st->prev_bf != 0 ) ) {
+ carefulFlag = 0;
+
+ if ( ( pdfi != 0 ) & ( bfi == 0 ) ) {
+ carefulFlag = 1;
+ }
+ Ex_ctrl( exc_enhanced, excEnergy, st->excEnergyHist, st->voicedHangover
+ , st->prev_bf, carefulFlag );
+ }
+
+ if ( ( st->inBackgroundNoise != 0 ) & ( bfi != 0 || st->prev_bf != 0 ) & (
+ st->state < 4 ) ) {; /* do nothing! */
+ }
+ else {
+ /* Update energy history for all modes */
+ for (i = 0; i < 8; i++){
+ st->excEnergyHist[i] = st->excEnergyHist[i+1];
+ }
+ st->excEnergyHist[8] = excEnergy;
+ }
+
+ /*
+ * Excitation control module end.
+ */
+ if ( pit_sharp > 16384 ) {
+ for ( i = 0; i < L_SUBFR; i++ ) {
+ excp[i] = excp[i] + exc_enhanced[i];
+ if (labs(excp[i]) > 32767)
+ excp[i] = (excp[i] & 0x80000000) ? -32768 : 32767;
+ }
+ agc2( exc_enhanced, excp );
+ overflow = Syn_filt( Az, excp, &synth[i_subfr], L_SUBFR, st->mem_syn, 0
+ );
+ }
+ else {
+ overflow = Syn_filt( Az, exc_enhanced, &synth[i_subfr], L_SUBFR, st->
+ mem_syn, 0 );
+ }
+
+ if ( overflow ) {
+ for ( i = 0; i < PIT_MAX + L_INTERPOL + L_SUBFR; i++ ) {
+ st->old_exc[i] = st->old_exc[i] >> 2;
+ }
+
+ for ( i = 0; i < L_SUBFR; i++ ) {
+ exc_enhanced[i] = exc_enhanced[i] >> 2;
+ }
+ Syn_filt_overflow( Az, exc_enhanced, &synth[i_subfr], L_SUBFR, st->mem_syn, 1 );
+ }
+ else {
+ memcpy( st->mem_syn, &synth[i_subfr + 30], 40 );
+ }
+
+ /*
+ * Update signal for next frame.
+ * -> shift to the left by L_SUBFR st->exc[]
+ */
+ memcpy( &st->old_exc[0], &st->old_exc[L_SUBFR], ( PIT_MAX + L_INTERPOL )<<
+ 2 );
+
+ /* interpolated LPC parameters for next subframe */
+ Az += MP1;
+
+ /* store T0 for next subframe */
+ st->old_T0 = T0;
+ }
+
+ /*
+ * Call the Source Characteristic Detector which updates
+ * st->inBackgroundNoise and st->voicedHangover.
+ */
+ st->inBackgroundNoise = Bgn_scd( st->background_state, &( st->ltpGainHistory[
+ 0] ), &( synth[0] ), &( st->voicedHangover ) );
+ dtx_dec_activity_update( st->dtxDecoderState, st->lsfState->past_lsf_q, synth
+ );
+
+ /* store bfi for next subframe */
+ st->prev_bf = bfi;
+ st->prev_pdf = pdfi;
+
+ /*
+ * Calculate the LSF averages on the eight
+ * previous frames
+ */
+ lsp_avg( st->lsp_avg_st, st->lsfState->past_lsf_q );
+theEnd:
+ st->dtxDecoderState->dtxGlobalState = newDTXState;
+ return;
+}
+
+
+/*
+ * Residu40
+ *
+ *
+ * Parameters:
+ * a I: prediction coefficients
+ * x I: speech signal
+ * y O: residual signal
+ *
+ * Function:
+ * The LP residual is computed by filtering the input
+ * speech through the LP inverse filter a(z)
+ *
+ * Returns:
+ * void
+ */
+static void Residu40( Word32 a[], Word32 x[], Word32 y[] )
+{
+ Word32 s, i, j;
+
+
+ for ( i = 0; i < 40; i++ ) {
+ s = a[0] * x[i] + a[1] * x[i - 1] + a[2] * x[i - 2] + a[3] * x[i - 3];
+ s += a[4] * x[i - 4] + a[5] * x[i - 5] + a[6] * x[i - 6] + a[7] * x[i - 7]
+ ;
+ s += a[8] * x[i - 8] + a[9] * x[i - 9] + a[10] * x[i - 10];
+ y[i] = ( s + 0x800 ) >> 12;
+ if (abs(y[i]) > 32767){
+ /* go to safe mode */
+ for (i = 0; i < 40; i++) {
+ s = a[0] * x[i];
+ for (j = 1; j <= 10; j++) {
+ s += a[j] * x[i - j];
+ if (s > 1073741823){
+ s = 1073741823;
+ }
+ else if ( s < -1073741824) {
+ s = -1073741824;
+ }
+ }
+ y[i] = ( s + 0x800 ) >> 12;
+ if (abs(y[i]) > 32767)
+ y[i] = (y[i] & 0x80000000) ? -32768 : 32767;
+ }
+ return;
+ }
+
+ }
+ return;
+}
+
+
+/*
+ * agc
+ *
+ *
+ * Parameters:
+ * st->past_gain B: gain memory
+ * sig_in I: Post_Filter input signal
+ * sig_out B: Post_Filter output signal
+ * agc_fac I: AGC factor
+ *
+ * Function:
+ * Scales the Post_Filter output on a subframe basis
+ *
+ * Returns:
+ * void
+ */
+static void agc( agcState *st, Word32 *sig_in, Word32 *sig_out, Word16 agc_fac )
+{
+ Word32 s, gain_in, gain_out, g0, gain;
+ int exp, i;
+
+
+ /* calculate gain_out with exponent */
+ s = energy_new( sig_out );
+
+ if ( s == 0 ) {
+ st->past_gain = 0;
+ return;
+ }
+ exp=0;
+ i = s;
+ while (!(i & 0x40000000))
+ {
+ exp++;
+ i = i << 1;
+ }
+ exp -=1;
+ if (exp & 0x80000000) {
+ s >>= 1;
+ }
+ else {
+ s <<= exp;
+ }
+ gain_out = ( s + 0x00008000L ) >> 16;
+
+ /* calculate gain_in with exponent */
+ s = energy_new( sig_in );
+
+ if ( s == 0 ) {
+ g0 = 0;
+ }
+ else {
+ i=0;
+ while (!(s & 0x40000000))
+ {
+ i++;
+ s = s << 1;
+ }
+ s = s + 0x00008000L;
+
+ if ( s >= 0 )
+ gain_in = s >> 16;
+ else
+ gain_in = 32767;
+ exp = ( exp - i );
+
+ /*
+ * g0 = (1-agc_fac) * sqrt(gain_in/gain_out);
+ */
+ /* s = gain_out / gain_in */
+ s = ( gain_out << 15 ) / gain_in;
+ exp = 7 - exp;
+
+ if ( exp > 0 ){
+ if (exp > 31)
+ {
+ if(s){
+ s = 2147483647;
+ }
+ }
+ else {
+ s = s << exp ;
+ }
+ }
+ else
+ s = ( s >> ( -exp ) );
+ if (s < 0)
+ s = 2147483647;
+ s = Inv_sqrt( s );
+ i = ( ( s << 9 ) + 0x00008000L ) >> 16;
+ if (i & 0xFFFF8000)
+ i = 32767;
+
+ /* g0 = i * (1-agc_fac) */
+ g0 = ( i * ( 32767 - agc_fac ) ) >> 15;
+ }
+
+ /*
+ * compute gain[n] = agc_fac * gain[n-1] + (1-agc_fac) * sqrt(gain_in/gain_out)
+ * sig_out[n] = gain[n] * sig_out[n]
+ */
+ gain = st->past_gain;
+
+ for ( i = 0; i < L_SUBFR; i++ ) {
+ gain = ( gain * agc_fac ) >> 15;
+ gain = gain + g0;
+ sig_out[i] = ( sig_out[i] * gain ) >> 12;
+ if (labs(sig_out[i]) > 32767)
+ sig_out[i] = (sig_out[i] & 0x8000000) ? -32768 : 32767;
+ }
+ st->past_gain = gain;
+ return;
+}
+
+
+/*
+ * Post_Filter
+ *
+ *
+ * Parameters:
+ * st B: post filter states
+ * mode I: AMR mode
+ * syn B: synthesis speech
+ * Az_4 I: interpolated LPC parameters in all subfr.
+ *
+ * Function:
+ * Post_Filtering of synthesis speech.
+ *
+ * inverse filtering of syn[] through A(z/0.7) to get res2[]
+ * tilt compensation filtering; 1 - MU*k*z^-1
+ * synthesis filtering through 1/A(z/0.75)
+ * adaptive gain control
+ *
+ * Returns:
+ * void
+ */
+static void Post_Filter( Post_FilterState *st, enum Mode mode, Word32 *syn,
+ Word32 *Az_4 )
+{
+ Word32 h[22], Ap3[MP1], Ap4[MP1]; /* bandwidth expanded LP parameters */
+ Word32 tmp, i_subfr, i, temp1, temp2, overflow = 0;
+ Word32 *Az, *p1, *p2, *syn_work = &st->synth_buf[M];
+ const Word32 *pgamma3 = &gamma3[0];
+ const Word32 *pgamma4 = &gamma4_gamma3_MR122[0];
+
+
+ /*
+ * Post filtering
+ */
+ memcpy( syn_work, syn, L_FRAME <<2 );
+ Az = Az_4;
+
+ if ( ( mode == MR122 ) || ( mode == MR102 ) ) {
+ pgamma3 = &gamma4_gamma3_MR122[0];
+ pgamma4 = &gamma4_MR122[0];
+ }
+
+ for ( i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR ) {
+ /* Find weighted filter coefficients Ap3[] and Ap[4] */
+ Ap3[0] = Az[0];
+ Ap4[0] = Az[0];
+
+ for ( i = 1; i <= 10; i++ ) {
+ Ap3[i] = ( Az[i] * pgamma3[i - 1] +0x4000 ) >> 15;
+ Ap4[i] = ( Az[i] * pgamma4[i - 1] +0x4000 ) >> 15;
+ }
+
+ /* filtering of synthesis speech by A(z/0.7) to find res2[] */
+ Residu40( Ap3, &syn_work[i_subfr], st->res2 );
+
+ /* tilt compensation filter */
+ /* impulse response of A(z/0.7)/A(z/0.75) */
+ memcpy( h, Ap3, MP1 <<2 );
+ memset( &h[M +1], 0, ( 22 - M - 1 )<<2 );
+ Syn_filt( Ap4, h, h, 22, &h[M +1], 0 );
+
+ /* 1st correlation of h[] */
+ tmp = 16777216 + h[1] * h[1];
+
+ for ( i = 2; i < 22; i++ ) {
+ tmp += h[i] * h[i];
+ if (tmp > 0x3FFF8000)
+ break;
+ }
+ temp1 = tmp >> 15;
+ if (temp1 & 0xFFFF8000)
+ temp1 = 32767;
+
+ tmp = h[0] * h[1];
+
+ for ( i = 1; i < 21; i++ ) {
+ tmp += h[i] * h[i + 1];
+ if (abs(tmp) > 1073741823)
+ tmp = 1073741823;
+ }
+ temp2 = tmp >> 15;
+
+ if ( temp2 <= 0 ) {
+ temp2 = 0;
+ }
+ else {
+ tmp = temp2 * 26214;
+ temp2 = ( tmp & 0xffff8000 ) / temp1;
+ }
+
+ /* preemphasis */
+ p1 = st->res2 + 39;
+ p2 = p1 - 1;
+ tmp = *p1;
+
+ do {
+ *p1 = *p1 - ( ( temp2 * *p2-- ) >> 15 );
+ if (abs(*p1) > 32767) {
+ *p1 = (*p1 & 0x80000000) ? -32768 : 32767;
+ }
+ p1--;
+ *p1 = *p1 - ( ( temp2 * *p2-- ) >> 15 );
+ if (abs(*p1) > 32767) {
+ *p1 = (*p1 & 0x80000000) ? -32768 : 32767;
+ }
+ p1--;
+ *p1 = *p1 - ( ( temp2 * *p2-- ) >> 15 );
+ if (abs(*p1) > 32767) {
+ *p1 = (*p1 & 0x80000000) ? -32768 : 32767;
+ }
+ p1--;
+ } while( p1 > st->res2 );
+ *p1 = *p1 - ( ( temp2 * st->preemph_state_mem_pre ) >> 15 );
+ if (abs(*p1) > 32767) {
+ *p1 = (*p1 & 0x80000000) ? -32768 : 32767;
+ }
+ st->preemph_state_mem_pre = tmp;
+
+ /* filtering through 1/A(z/0.75) */
+ overflow = Syn_filt( Ap4, st->res2, &syn[i_subfr], L_SUBFR, st->mem_syn_pst, 0 );
+ if (overflow){
+ Syn_filt_overflow( Ap4, st->res2, &syn[i_subfr], L_SUBFR, st->mem_syn_pst, 1 );
+ overflow = 0;
+ }
+ else {
+ memcpy(st->mem_syn_pst, &syn[i_subfr + 30], 40);
+ }
+
+ /* scale output to input */
+ agc( st->agc_state, &syn_work[i_subfr], &syn[i_subfr], AGC_FAC );
+ Az += MP1;
+ }
+
+ /* update syn_work[] buffer */
+ memcpy( &syn_work[- M], &syn_work[L_FRAME - M], M <<2 );
+ return;
+}
+
+
+/*
+ * Post_Process
+ *
+ *
+ * Parameters:
+ * st B: post filter states
+ * signal B: signal
+ *
+ * Function:
+ * Postprocessing of input speech.
+ *
+ * 2nd order high pass filtering with cut off frequency at 60 Hz.
+ * Multiplication of output by two.
+ *
+ *
+ * Returns:
+ * void
+ */
+ static void Post_Process( Post_ProcessState *st, Word32 signal[] )
+ {
+ Word32 x2, tmp, i = 0;
+ Word32 mask = 0x40000000;
+
+ do {
+ x2 = st->x1;
+ st->x1 = st->x0;
+ st->x0 = signal[i];
+
+ /*
+ * y[i] = b[0]*x[i]*2 + b[1]*x[i-1]*2 + b140[2]*x[i-2]/2
+ * + a[1]*y[i-1] + a[2] * y[i-2];
+ */
+ tmp = ( st->y1_hi * 15836) + ( ( ( st->y1_lo * 15836 ) & ( Word32 )0xffff8000 ) >> 15);
+ tmp += (st->y2_hi * -7667) + ( ( ( st->y2_lo * ( -7667 ) ) & ( Word32 )0xffff8000 ) >> 15);
+ tmp += st->x0 * 7699;
+ tmp += st->x1 * -15398;
+ if ( ( (tmp >> 1) ^ tmp ) & mask)
+ tmp = (tmp & 0x80000000) ? -1073741824 : 1073741823;
+
+ tmp += x2 * 7699;
+ if ( ( (tmp >> 1) ^ tmp ) & mask)
+ tmp = (tmp & 0x80000000) ? -1073741824 : 1073741823;
+
+ tmp = tmp << 1;
+ if ( ( (tmp >> 1) ^ tmp ) & mask)
+ tmp = (tmp & 0x80000000) ? -1073741824 : 1073741823;
+
+ tmp = tmp << 1;
+ if ( ( (tmp >> 1) ^ tmp ) & mask)
+ tmp = (tmp & 0x80000000) ? -1073741824 : 1073741823;
+
+ if ( labs( tmp ) < 536862720 ) {
+ signal[i++] = ( tmp + 0x00002000L ) >> 14;
+ }
+ else if ( tmp > 0 ) {
+ signal[i++] = 32767;
+ }
+ else {
+ signal[i++] = -32768;
+ }
+ st->y2_hi = st->y1_hi;
+ st->y2_lo = st->y1_lo;
+ st->y1_hi = tmp >> 15;
+ st->y1_lo = ( ( tmp << 1 ) - ( st->y1_hi << 16 ) ) >> 1;
+ } while( i < 160 );
+ return;
+}
+
+
+/*
+ * Speech_Decode_Frame
+ *
+ *
+ * Parameters:
+ * st B: decoder memory
+ * mode I: AMR mode
+ * parm I: speech parameters
+ * frame_type I: Frame type
+ * synth O: synthesis speech
+
+ * Function:
+ * Decode one frame
+ *
+ * Returns:
+ * void
+ */
+void Speech_Decode_Frame( void *st, enum Mode mode, Word16 *parm, enum
+ RXFrameType frame_type, Word16 *synth )
+{
+ Word32 Az_dec[AZ_SIZE]; /* Decoded Az for post-filter in 4 subframes*/
+ Word32 synth_speech[L_FRAME];
+ Word32 i;
+
+ /* Synthesis */
+ Decoder_amr( ( ( Speech_Decode_FrameState * ) st )->decoder_amrState, mode,
+ parm, frame_type, synth_speech, Az_dec );
+ Post_Filter( ( ( Speech_Decode_FrameState * ) st )->post_state, mode,
+ synth_speech, Az_dec );
+
+ /* post HP filter, and 15->16 bits */
+ Post_Process( ( ( Speech_Decode_FrameState * ) st )->postHP_state,
+ synth_speech );
+
+for ( i = 0; i < L_FRAME; i++ ) {
+#ifndef NO13BIT
+ /* Truncate to 13 bits */
+ synth[i] = ( Word16 )( synth_speech[i] & 0xfff8 );
+#else
+ synth[i] = ( Word16 )( synth_speech[i]);
+#endif
+ }
+
+
+ return;
+}
+
+
+/*
+ * Decoder_amr_exit
+ *
+ *
+ * Parameters:
+ * state I: state structure
+ *
+ * Function:
+ * The memory used for state memory is freed
+ *
+ * Returns:
+ * Void
+ */
+static void Decoder_amr_exit( Decoder_amrState **state )
+{
+ if ( state == NULL || *state == NULL )
+ return;
+ free( ( *state )->lsfState );
+ free( ( *state )->ec_gain_p_st );
+ free( ( *state )->ec_gain_c_st );
+ free( ( *state )->pred_state );
+ free( ( *state )->background_state );
+ free( ( *state )->ph_disp_st );
+ free( ( *state )->Cb_gain_averState );
+ free( ( *state )->lsp_avg_st );
+ free( ( *state )->dtxDecoderState );
+
+ /* deallocate memory */
+ free( *state );
+ *state = NULL;
+ return;
+}
+
+
+/*
+ * Post_Filter_exit
+ *
+ *
+ * Parameters:
+ * state I: state structure
+ *
+ * Function:
+ * The memory used for state memory is freed
+ *
+ * Returns:
+ * Void
+ */
+static void Post_Filter_exit( Post_FilterState **state )
+{
+ if ( state == NULL || *state == NULL )
+ return;
+ free( ( *state )->agc_state );
+
+ /* deallocate memory */
+ free( *state );
+ *state = NULL;
+ return;
+}
+
+
+/*
+ * Post_Process_reset
+ *
+ *
+ * Parameters:
+ * state B: state structure
+ *
+ * Function:
+ * Resets state memory
+ *
+ * Returns:
+ * -1 failure
+ */
+static int Post_Process_reset( Post_ProcessState *state )
+{
+ if ( ( Post_ProcessState * )state == NULL ) {
+ fprintf( stderr, "Post_Process_reset: invalid parameter\n" );
+ return-1;
+ }
+ state->y2_hi = 0;
+ state->y2_lo = 0;
+ state->y1_hi = 0;
+ state->y1_lo = 0;
+ state->x0 = 0;
+ state->x1 = 0;
+ return 0;
+}
+
+
+/*
+ * Post_Process_exit
+ *
+ *
+ * Parameters:
+ * state I: state structure
+ *
+ * Function:
+ * The memory used for state memory is freed
+ *
+ * Returns:
+ * Void
+ */
+static void Post_Process_exit( Post_ProcessState **state )
+{
+ if ( state == NULL || *state == NULL )
+ return;
+
+ /* deallocate memory */
+ free( *state );
+ *state = NULL;
+ return;
+}
+
+
+/*
+ * Decoder_amr_init
+ *
+ *
+ * Parameters:
+ * state O: state structure
+ *
+ * Function:
+ * Allocates state memory and initializes state memory
+ *
+ * Returns:
+ * success = 0
+ */
+static int Decoder_amr_init( Decoder_amrState **state )
+{
+ Decoder_amrState * s;
+
+ if ( ( Decoder_amrState * )state == NULL ) {
+ fprintf( stderr, "Decoder_amr_init: invalid parameter\n" );
+ return-1;
+ }
+ *state = NULL;
+
+ /* allocate memory */
+ if ( ( s = ( Decoder_amrState * ) malloc( sizeof( Decoder_amrState ) ) ) ==
+ NULL ) {
+ fprintf( stderr, "Decoder_amr_init: can not malloc state structure\n" );
+ return-1;
+ }
+
+ /* DPlsf_init */
+ /* allocate memory */
+ if ( ( s->lsfState = ( D_plsfState * ) malloc( sizeof( D_plsfState ) ) ) ==
+ NULL ) {
+ fprintf( stderr, "DPlsf_init: can not malloc state structure\n" );
+ return-1;
+ }
+
+ /* ecGainPitchInit */
+ /* allocate memory */
+ if ( ( s->ec_gain_p_st = ( ec_gain_pitchState * ) malloc( sizeof(
+ ec_gain_pitchState ) ) ) == NULL ) {
+ fprintf( stderr, "ecGainPitchInit: can not malloc state structure\n" );
+ return-1;
+ }
+
+ /* ecGainCodeInit */
+ /* allocate memory */
+ if ( ( s->ec_gain_c_st = ( ec_gain_codeState * ) malloc( sizeof(
+ ec_gain_codeState ) ) ) == NULL ) {
+ fprintf( stderr, "ecGainCodeInit: can not malloc state structure\n" );
+ return-1;
+ }
+
+ /* gcPredInit */
+ /* allocate memory */
+ if ( ( s->pred_state = ( gc_predState * ) malloc( sizeof( gc_predState ) ) )
+ == NULL ) {
+ fprintf( stderr, "gcPredInit: can not malloc state structure\n" );
+ return-1;
+ }
+
+ /* Cb_gain_averageInit */
+ /* allocate memory */
+ if ( ( s->Cb_gain_averState = ( Cb_gain_averageState * ) malloc( sizeof(
+ Cb_gain_averageState ) ) ) == NULL ) {
+ fprintf( stderr, "Cb_gain_averageInit: can not malloc state structure\n" )
+ ;
+ return-1;
+ }
+ memset( s->Cb_gain_averState->cbGainHistory, 0, L_CBGAINHIST <<2 );
+
+ /* Initialize hangover handling */
+ s->Cb_gain_averState->hangVar = 0;
+ s->Cb_gain_averState->hangCount = 0;
+
+ /* lsp_avgInit */
+ /* allocate memory */
+ if ( ( s->lsp_avg_st = ( lsp_avgState * ) malloc( sizeof( lsp_avgState ) ) )
+ == NULL ) {
+ fprintf( stderr, "lsp_avgInit: can not malloc state structure\n" );
+ return-1;
+ }
+
+ /* Bgn_scdInit */
+ /* allocate memory */
+ if ( ( s->background_state = ( Bgn_scdState * ) malloc( sizeof( Bgn_scdState
+ ) ) ) == NULL ) {
+ fprintf( stderr, "Bgn_scdInit: can not malloc state structure\n" );
+ return-1;
+ }
+
+ /* phDispInit */
+ /* allocate memory */
+ if ( ( s->ph_disp_st = ( ph_dispState * ) malloc( sizeof( ph_dispState ) ) )
+ == NULL ) {
+ fprintf( stderr, "phDispInit: can not malloc state structure\n" );
+ return-1;
+ }
+
+ /* dtxDecInit */
+ /* allocate memory */
+ if ( ( s->dtxDecoderState = ( dtx_decState * ) malloc( sizeof( dtx_decState )
+ ) ) == NULL ) {
+ fprintf( stderr, "dtxDecInit: can not malloc state structure\n" );
+ return-1;
+ }
+ Decoder_amr_reset( s, 0 );
+ *state = s;
+ return 0;
+}
+
+
+/*
+ * Post_Filter_reset
+ *
+ *
+ * Parameters:
+ * state B: state structure
+ *
+ * Function:
+ * Resets state memory
+ *
+ * Returns:
+ * -1 failure
+ */
+static int Post_Filter_reset( Post_FilterState *state )
+{
+ if ( ( Post_FilterState * )state == NULL ) {
+ fprintf( stderr, "Post_Filter_reset: invalid parameter\n" );
+ return-1;
+ }
+ state->preemph_state_mem_pre = 0;
+ state->agc_state->past_gain = 4096;
+ memset( state->mem_syn_pst, 0, M <<2 );
+ memset( state->res2, 0, L_SUBFR <<2 );
+ memset( state->synth_buf, 0, ( L_FRAME + M )<<2 );
+ return 0;
+}
+
+
+/*
+ * Post_Filter_init
+ *
+ *
+ * Parameters:
+ * state O: state structure
+ *
+ * Function:
+ * Allocates state memory and initializes state memory
+ *
+ * Returns:
+ * success = 0
+ */
+static int Post_Filter_init( Post_FilterState **state )
+{
+ Post_FilterState * s;
+
+ if ( ( Post_FilterState * )state == NULL ) {
+ fprintf( stderr, "F057:invalid parameter\n" );
+ return-1;
+ }
+ *state = NULL;
+
+ /* allocate memory */
+ if ( ( s = ( Post_FilterState * ) malloc( sizeof( Post_FilterState ) ) ) ==
+ NULL ) {
+ fprintf( stderr, "F057:can not malloc filter structure\n" );
+ return-1;
+ }
+ s->agc_state = NULL;
+
+ /* allocate memory */
+ if ( ( s->agc_state = ( agcState * ) malloc( sizeof( agcState ) ) ) == NULL )
+ {
+ fprintf( stderr, "agcInit: can not malloc state structure\n" );
+ return-1;
+ }
+ Post_Filter_reset( s );
+ *state = s;
+ return 0;
+}
+
+
+/*
+ * Post_Process_init
+ *
+ *
+ * Parameters:
+ * state O: state structure
+ *
+ * Function:
+ * Allocates state memory and initializes state memory
+ *
+ * Returns:
+ * success = 0
+ */
+static int Post_Process_init( Post_ProcessState **state )
+{
+ Post_ProcessState * s;
+
+ if ( ( Post_ProcessState * )state == NULL ) {
+ fprintf( stderr, "Post_Process_init: invalid parameter\n" );
+ return-1;
+ }
+ *state = NULL;
+
+ /* allocate memory */
+ if ( ( s = ( Post_ProcessState * ) malloc( sizeof( Post_ProcessState ) ) ) ==
+ NULL ) {
+ fprintf( stderr, "Post_Process_init: can not malloc state structure\n" );
+ return-1;
+ }
+ Post_Process_reset( s );
+ *state = s;
+ return 0;
+}
+
+
+/*
+ * Speech_Decode_Frame_exit
+ *
+ *
+ * Parameters:
+ * state I: state structure
+ *
+ * Function:
+ * The memory used for state memory is freed
+ *
+ * Returns:
+ * Void
+ */
+void Speech_Decode_Frame_exit( void **st )
+{
+ if ( (( Speech_Decode_FrameState * )( st )) == NULL )
+ return;
+ Decoder_amr_exit( &( ( ( Speech_Decode_FrameState * ) st )->decoder_amrState
+ ) );
+ Post_Filter_exit( &( ( ( Speech_Decode_FrameState * ) st )->post_state ) );
+ Post_Process_exit( &( ( ( Speech_Decode_FrameState * ) st )->postHP_state ) )
+ ;
+
+ /* deallocate memory */
+ free( (( Speech_Decode_FrameState * )st) );
+ return;
+}
+
+
+/*
+ * Speech_Decode_Frame_reset
+ *
+ *
+ * Parameters:
+ * state B: state structure
+ *
+ * Function:
+ * Resets state memory
+ *
+ * Returns:
+ * -1 = failure
+ */
+int Speech_Decode_Frame_reset( void **st )
+{
+ Speech_Decode_FrameState * state;
+
+ if ( st == NULL || *st == NULL )
+ return (-1);
+ state = ( Speech_Decode_FrameState * )st;
+ Decoder_amr_reset( state->decoder_amrState, ( enum Mode ) 0 );
+ Post_Filter_reset( state->post_state );
+ Post_Process_reset( state->postHP_state );
+ return 0;
+}
+
+
+/*
+ * Speech_Decode_Frame_init
+ *
+ *
+ * Parameters:
+ * state O: state structure
+ *
+ * Function:
+ * Allocates state memory and initializes state memory
+ *
+ * Returns:
+ * success = 0
+ */
+void * Speech_Decode_Frame_init( )
+{
+ Speech_Decode_FrameState * s;
+
+ /* allocate memory */
+ if ( ( s = ( Speech_Decode_FrameState * ) malloc( sizeof(
+ Speech_Decode_FrameState ) ) ) == NULL ) {
+ fprintf( stderr, "Speech_Decode_Frame_init: can not malloc state "
+ "structure\n" );
+ return NULL;
+ }
+ s->decoder_amrState = NULL;
+ s->post_state = NULL;
+ s->postHP_state = NULL;
+
+ if ( Decoder_amr_init( &s->decoder_amrState ) || Post_Filter_init( &s->
+ post_state ) || Post_Process_init( &s->postHP_state ) ) {
+ Speech_Decode_Frame_exit( ( void ** )( &s ) );
+ return NULL;
+ }
+ return s;
+}
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/sp_dec.h b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/sp_dec.h
new file mode 100644
index 000000000..bd7ec3471
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/sp_dec.h
@@ -0,0 +1,81 @@
+/*
+ * ===================================================================
+ * TS 26.104
+ * REL-5 V5.4.0 2004-03
+ * REL-6 V6.1.0 2004-03
+ * 3GPP AMR Floating-point Speech Codec
+ * ===================================================================
+ *
+ */
+
+/*
+ * sp_enc.h
+ *
+ *
+ * Project:
+ * AMR Floating-Point Codec
+ *
+ * Contains:
+ * Defines interface to AMR encoder
+ *
+ */
+#ifndef _SP_DEC_H_
+#define _SP_DEC_H_
+/*
+ * definition of enumerated types
+ */
+
+/*
+ * definition of modes for decoder
+ */
+enum Mode { MR475 = 0,
+ MR515,
+ MR59,
+ MR67,
+ MR74,
+ MR795,
+ MR102,
+ MR122,
+ MRDTX,
+ N_MODES /* number of (SPC) modes */
+};
+
+/* Declaration recieved frame types */
+enum RXFrameType { RX_SPEECH_GOOD = 0,
+ RX_SPEECH_DEGRADED,
+ RX_ONSET,
+ RX_SPEECH_BAD,
+ RX_SID_FIRST,
+ RX_SID_UPDATE,
+ RX_SID_BAD,
+ RX_NO_DATA,
+ RX_N_FRAMETYPES /* number of frame types */
+};
+
+/*
+ * Function prototypes
+ */
+
+/*
+ * initialize one instance of the speech decoder
+ */
+void* Speech_Decode_Frame_init ();
+
+/*
+ * free status struct
+ */
+void Speech_Decode_Frame_exit (void **st);
+
+/*
+ * Decodes one frame from encoded parameters
+ */
+void Speech_Decode_Frame (void *st, enum Mode mode, short *serial,
+ enum RXFrameType frame_type, short *synth);
+
+/*
+ * reset speech decoder
+ */
+int Speech_Decode_Frame_reset (void **st);
+
+#endif
+
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/sp_enc.c b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/sp_enc.c
new file mode 100644
index 000000000..aad573b75
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/sp_enc.c
@@ -0,0 +1,11374 @@
+/*
+ * ===================================================================
+ * TS 26.104
+ * REL-5 V5.4.0 2004-03
+ * REL-6 V6.1.0 2004-03
+ * 3GPP AMR Floating-point Speech Codec
+ * ===================================================================
+ *
+ */
+
+/*
+ * sp_enc.c
+ *
+ *
+ * Project:
+ * AMR Floating-Point Codec
+ *
+ * Contains:
+ * This module contains all the functions needed encoding 160
+ * 16-bit speech samples to AMR encoder parameters.
+ *
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <memory.h>
+#include <math.h>
+#include <float.h>
+#include "sp_enc.h"
+#include "rom_enc.h"
+
+/*
+ * Definition of structures used in encoding process
+ */
+typedef struct
+{
+ Float32 y2;
+ Float32 y1;
+ Float32 x0;
+ Float32 x1;
+
+}Pre_ProcessState;
+
+#ifdef VAD2
+
+/* Defines for VAD2 */
+#define FRM_LEN1 80
+#define DELAY0 24
+#define FFT_LEN1 128
+
+#define UPDATE_CNT_THLD1 50
+
+#define INIT_FRAMES 4
+
+#define CNE_SM_FAC1 0.1
+#define CEE_SM_FAC1 0.55
+
+#define HYSTER_CNT_THLD1 6 /* forced update constants... */
+#define HIGH_ALPHA1 0.9
+#define LOW_ALPHA1 0.7
+#define ALPHA_RANGE1 (HIGH_ALPHA1-LOW_ALPHA1)
+
+#define NORM_ENRG (4.0) /* account for div by 2 by the HPF */
+#define MIN_CHAN_ENRG (0.0625 / NORM_ENRG)
+#define INE (16.0 / NORM_ENRG)
+#define NOISE_FLOOR (1.0 / NORM_ENRG)
+
+#define PRE_EMP_FAC1 (-0.8)
+
+#define NUM_CHAN 16
+#define LO_CHAN 0
+#define HI_CHAN 15
+#define UPDATE_THLD 35
+
+#define SINE_START_CHAN 2
+#define P2A_THRESH 10.0
+#define DEV_THLD1 28.0
+
+/* Defines for the FFT function */
+#define SIZE 128
+#define SIZE_BY_TWO 64
+#define NUM_STAGE 6
+
+#define PI 3.141592653589793
+
+#define TRUE 1
+#define FALSE 0
+
+/* Macros */
+#define min(a,b) ((a)<(b)?(a):(b))
+#define max(a,b) ((a)>(b)?(a):(b))
+#define square(a) ((a)*(a))
+
+/* structures */
+typedef struct
+{
+ Float32 pre_emp_mem;
+ Word16 update_cnt;
+ Word16 hyster_cnt;
+ Word16 last_update_cnt;
+ Float32 ch_enrg_long_db[NUM_CHAN];
+ Word32 Lframe_cnt;
+ Float32 ch_enrg[NUM_CHAN];
+ Float32 ch_noise[NUM_CHAN];
+ Float32 tsnr;
+ Word16 hangover;
+ Word16 burstcount;
+ Word16 fupdate_flag;
+ Float32 negSNRvar;
+ Float32 negSNRbias;
+ Float32 R0;
+ Float32 Rmax;
+ Word16 LTP_flag;
+}vadState;
+#else
+typedef struct
+{
+ Float32 bckr_est[COMPLEN]; /* background noise estimate */
+ Float32 ave_level[COMPLEN];
+
+
+ /* averaged input components for stationary estimation */
+ Float32 old_level[COMPLEN]; /* input levels of the previous frame */
+ Float32 sub_level[COMPLEN];
+
+
+ /* input levels calculated at the end of a frame (lookahead) */
+ Float32 a_data5[3][2]; /* memory for the filter bank */
+ Float32 a_data3[5]; /* memory for the filter bank */
+ Float32 best_corr_hp; /* FIP filtered value */
+
+
+ /* counts length of a speech burst incl HO addition */
+ Float32 corr_hp_fast; /* filtered value */
+ Word32 vadreg; /* flags for intermediate VAD decisions */
+ Word32 pitch; /* flags for pitch detection */
+ Word32 oldlag_count, oldlag; /* variables for pitch detection */
+ Word32 complex_high; /* flags for complex detection */
+ Word32 complex_low; /* flags for complex detection */
+ Word32 complex_warning; /* complex background warning */
+ Word32 tone; /* flags for tone detection */
+ Word16 burst_count; /* counts length of a speech burst */
+ Word16 hang_count; /* hangover counter */
+ Word16 stat_count; /* stationary counter */
+ Word16 complex_hang_count; /* complex hangover counter, used by VAD */
+ Word16 complex_hang_timer; /* hangover initiator, used by CAD */
+ Word16 speech_vad_decision; /* final decision */
+ Word16 sp_burst_count;
+
+
+}vadState;
+#endif
+#define DTX_HIST_SIZE 8
+#define DTX_ELAPSED_FRAMES_THRESH (24 + 7 -1)
+#define DTX_HANG_CONST 7 /* yields eight frames of SP HANGOVER */
+typedef struct
+{
+ Float32 lsp_hist[M * DTX_HIST_SIZE];
+ Float32 log_en_hist[DTX_HIST_SIZE];
+ Word32 init_lsf_vq_index;
+ Word16 hist_ptr;
+ Word16 log_en_index;
+ Word16 lsp_index[3];
+
+
+ /* DTX handler stuff */
+ Word16 dtxHangoverCount;
+ Word16 decAnaElapsedCount;
+
+
+}dtx_encState;
+typedef struct
+{
+ /* gain history */
+ Float32 gp[N_FRAME];
+
+
+ /* counters */
+ Word16 count;
+
+
+}tonStabState;
+typedef struct
+{
+ Word32 past_qua_en[4];
+
+
+ /* normal MA predictor memory, (contains 20*log10(qua_err)) */
+}gc_predState;
+
+typedef struct
+{
+ Float32 prev_alpha; /* previous adaptor output, */
+ Float32 prev_gc; /* previous code gain, */
+ Float32 ltpg_mem[LTPG_MEM_SIZE]; /* LTP coding gain history, */
+ Word16 onset; /* onset state, */
+
+
+ /* (ltpg_mem[0] not used for history) */
+}gain_adaptState;
+typedef struct
+{
+
+ Float32 sf0_target_en;
+ Float32 sf0_coeff[5];
+ Word32 sf0_gcode0_exp;
+ Word32 sf0_gcode0_fra;
+ Word16 *gain_idx_ptr;
+
+
+ gc_predState * gc_predSt;
+ gc_predState * gc_predUncSt;
+ gain_adaptState * adaptSt;
+}gainQuantState;
+typedef struct
+{
+ Word32 T0_prev_subframe; /* integer pitch lag of previous sub-frame */
+
+
+}Pitch_frState;
+typedef struct
+{
+ Pitch_frState * pitchSt;
+}clLtpState;
+typedef struct
+{
+ Float32 ada_w;
+ Word32 old_T0_med;
+ Word16 wght_flg;
+
+
+}pitchOLWghtState;
+typedef struct
+{
+ Float32 past_rq[M]; /* Past quantized prediction error */
+
+
+}Q_plsfState;
+typedef struct
+{
+ /* Past LSPs */
+ Float32 lsp_old[M];
+ Float32 lsp_old_q[M];
+
+
+ /* Quantization state */
+ Q_plsfState * qSt;
+}lspState;
+typedef struct
+{
+ Float32 old_A[M + 1]; /* Last A(z) for case of unstable filter */
+
+
+}LevinsonState;
+typedef struct
+{
+ LevinsonState * LevinsonSt;
+}lpcState;
+typedef struct
+{
+ /* Speech vector */
+ Float32 old_speech[L_TOTAL];
+ Float32 *speech, *p_window, *p_window_12k2;
+ Float32 *new_speech; /* Global variable */
+
+
+ /* Weight speech vector */
+ Float32 old_wsp[L_FRAME + PIT_MAX];
+ Float32 *wsp;
+
+
+ /* OL LTP states */
+ Word32 old_lags[5];
+ Float32 ol_gain_flg[2];
+
+
+ /* Excitation vector */
+ Float32 old_exc[L_FRAME + PIT_MAX + L_INTERPOL];
+ Float32 *exc;
+
+
+ /* Zero vector */
+ Float32 ai_zero[L_SUBFR + MP1];
+ Float32 *zero;
+
+
+ /* Impulse response vector */
+ Float32 *h1;
+ Float32 hvec[L_SUBFR * 2];
+
+
+ /* Substates */
+ lpcState * lpcSt;
+ lspState * lspSt;
+ clLtpState * clLtpSt;
+ gainQuantState * gainQuantSt;
+ pitchOLWghtState * pitchOLWghtSt;
+ tonStabState * tonStabSt;
+ vadState * vadSt;
+
+ Word32 dtx;
+
+
+ dtx_encState * dtxEncSt;
+
+ /* Filter's memory */
+ Float32 mem_syn[M], mem_w0[M], mem_w[M];
+ Float32 mem_err[M + L_SUBFR], *error;
+ Float32 sharp;
+
+
+}cod_amrState;
+typedef struct
+{
+ cod_amrState * cod_amr_state;
+ Pre_ProcessState * pre_state;
+
+ Word32 dtx;
+
+
+}Speech_Encode_FrameState;
+
+
+/*
+ * Dotproduct40
+ *
+ *
+ * Parameters:
+ * x I: First input
+ * y I: Second input
+ * Function:
+ * Computes dot product size 40
+ *
+ * Returns:
+ * acc dot product
+ */
+static Float64 Dotproduct40( Float32 *x, Float32 *y )
+{
+ Float64 acc;
+
+
+ acc = x[0] * y[0] + x[1] * y[1] + x[2] * y[2] + x[3] * y[3];
+ acc += x[4] * y[4] + x[5] * y[5] + x[6] * y[6] + x[7] * y[7];
+ acc += x[8] * y[8] + x[9] * y[9] + x[10] * y[10] + x[11] * y[11];
+ acc += x[12] * y[12] + x[13] * y[13] + x[14] * y[14] + x[15] * y[15];
+ acc += x[16] * y[16] + x[17] * y[17] + x[18] * y[18] + x[19] * y[19];
+ acc += x[20] * y[20] + x[21] * y[21] + x[22] * y[22] + x[23] * y[23];
+ acc += x[24] * y[24] + x[25] * y[25] + x[26] * y[26] + x[27] * y[27];
+ acc += x[28] * y[28] + x[29] * y[29] + x[30] * y[30] + x[31] * y[31];
+ acc += x[32] * y[32] + x[33] * y[33] + x[34] * y[34] + x[35] * y[35];
+ acc += x[36] * y[36] + x[37] * y[37] + x[38] * y[38] + x[39] * y[39];
+ return( acc );
+}
+
+
+/*
+ * Autocorr
+ *
+ *
+ * Parameters:
+ * x I: Input signal
+ * r O: Autocorrelations
+ * wind I: Window for LPC analysis
+ * Function:
+ * Calculate autocorrelation with window, LPC order = M
+ *
+ * Returns:
+ * void
+ */
+static void Autocorr( Float32 x[], Float32 r[], const Float32 wind[] )
+{
+ Word32 i, j; /* Counters */
+ Float32 y[L_WINDOW + M + 1]; /* Windowed signal */
+ Float64 sum; /* temp */
+
+
+ /*
+ * Windowing of signal
+ */
+ for ( i = 0; i < L_WINDOW; i++ ) {
+ y[i] = x[i] * wind[i];
+ }
+
+ /*
+ * Zero remaining memory
+ */
+ memset( &y[L_WINDOW], 0, 44 );
+
+ /*
+ * Autocorrelation
+ */
+ for ( i = 0; i <= M; i++ ) {
+ sum = 0;
+
+ for ( j = 0; j < L_WINDOW; j += 40 ) {
+ sum += Dotproduct40( &y[j], &y[j + i] );
+ }
+ r[i] = (Float32)sum;
+ }
+}
+
+
+/*
+ * Levinson
+ *
+ *
+ * Parameters:
+ * old_A I: Vector of old LP coefficients [M+1]
+ * r I: Vector of autocorrelations [M+1]
+ * a O: LP coefficients [M+1]
+ * rc O: Reflection coefficients [4]
+ * Function:
+ * Levinson-Durbin algorithm
+ *
+ * Returns:
+ * void
+ *
+ */
+static void Levinson( Float32 *old_A, Float32 *r, Float32 *A, Float32 *rc )
+{
+ Float32 sum, at, err;
+ Word32 l, j, i;
+ Float32 rct[M]; /* temporary reflection coefficients 0,...,m-1 */
+
+
+ rct[0] = ( -r[1] ) / r[0];
+ A[0] = 1.0F;
+ A[1] = rct[0];
+ err = r[0] + r[1] * rct[0];
+
+ if ( err <= 0.0 )
+ err = 0.01F;
+
+ for ( i = 2; i <= M; i++ ) {
+ sum = 0.0F;
+
+ for ( j = 0; j < i; j++ )
+ sum += r[i - j] * A[j];
+ rct[i - 1] = ( -sum ) / ( err );
+
+ for ( j = 1; j <= ( i / 2 ); j++ ) {
+ l = i - j;
+ at = A[j] + rct[i - 1] *A[l];
+ A[l] += rct[i - 1] *A[j];
+ A[j] = at;
+ }
+ A[i] = rct[i - 1];
+ err += rct[i - 1] *sum;
+
+ if ( err <= 0.0 )
+ err = 0.01F;
+ }
+ memcpy( rc, rct, 4 * sizeof( Float32 ) );
+ memcpy( old_A, A, MP1 * sizeof( Float32 ) );
+}
+
+
+/*
+ * lpc
+ *
+ *
+ * Parameters:
+ * old_A O: Vector of old LP coefficients [M+1]
+ * x I: Input signal
+ * x_12k2 I: Input signal 12.2k
+ * a O: predictor coefficients
+ * mode I: AMR mode
+ * Function:
+ * LP analysis
+ *
+ * In 12.2 kbit/s mode linear prediction (LP) analysis is performed
+ * twice per speech frame using the auto-correlation approach with
+ * 30 ms asymmetric windows. No lookahead is used in
+ * the auto-correlation computation.
+ *
+ * In other modes analysis is performed once per speech frame
+ * using the auto-correlation approach with 30 ms asymmetric windows.
+ * A lookahead of 40 samples (5 ms) is used in the auto-correlation computation.
+ *
+ * The auto-correlations of windowed speech are converted to the LP
+ * coefficients using the Levinson-Durbin algorithm.
+ * Then the LP coefficients are transformed to the Line Spectral Pair
+ * (LSP) domain for quantization and interpolation purposes.
+ * The interpolated quantified and unquantized filter coefficients
+ * are converted back to the LP filter coefficients
+ * (to construct the synthesis and weighting filters at each subframe).
+ *
+ * Returns:
+ * void
+ *
+ */
+static void lpc( Float32 *old_A, Float32 x[], Float32 x_12k2[], Float32 a[], enum Mode
+ mode )
+{
+ Word32 i;
+ Float32 r[MP1];
+ Float32 rc[4];
+
+
+ if ( mode == MR122 ) {
+ Autocorr( x_12k2, r, window_160_80 );
+
+ /*
+ * Lag windowing
+ */
+ for ( i = 1; i <= M; i++ ) {
+ r[i] = r[i] * lag_wind[i - 1];
+ }
+ r[0] *= 1.0001F;
+
+ if ( r[0] < 1.0F )
+ r[0] = 1.0F;
+
+ /*
+ * Levinson Durbin
+ */
+ Levinson( old_A, r, &a[MP1], rc );
+
+ /*
+ * Autocorrelations
+ */
+ Autocorr( x_12k2, r, window_232_8 );
+
+ /*
+ * Lag windowing
+ */
+ for ( i = 1; i <= M; i++ ) {
+ r[i] = r[i] * lag_wind[i - 1];
+ }
+ r[0] *= 1.0001F;
+
+ if ( r[0] < 1.0F )
+ r[0] = 1.0F;
+
+ /*
+ * Levinson Durbin
+ */
+ Levinson( old_A, r, &a[MP1 * 3], rc );
+ }
+ else {
+ /*
+ * Autocorrelations
+ */
+ Autocorr( x, r, window_200_40 );
+
+ /*
+ * a 60 Hz bandwidth expansion is used by lag windowing
+ * the auto-correlations. Further, auto-correlation[0] is
+ * multiplied by the white noise correction factor 1.0001
+ * which is equivalent to adding a noise floor at -40 dB.
+ */
+ for ( i = 1; i <= M; i++ ) {
+ r[i] = r[i] * lag_wind[i - 1];
+ }
+ r[0] *= 1.0001F;
+
+ if ( r[0] < 1.0F )
+ r[0] = 1.0F;
+
+ /*
+ * Levinson Durbin
+ */
+ Levinson( old_A, r, &a[MP1 * 3], rc );
+ }
+}
+
+
+/*
+ * Chebps
+ *
+ *
+ * Parameters:
+ * x I: Cosine value for the freqency given
+ * f I: angular freqency
+ * Function:
+ * Evaluates the Chebyshev polynomial series
+ *
+ * Returns:
+ * result of polynomial evaluation
+ */
+static Float32 Chebps( Float32 x, Float32 f[] )
+{
+ Float32 b0, b1, b2, x2;
+ Word32 i;
+
+
+ x2 = 2.0F * x;
+ b2 = 1.0F;
+ b1 = x2 + f[1];
+
+ for ( i = 2; i < 5; i++ ) {
+ b0 = x2 * b1 - b2 + f[i];
+ b2 = b1;
+ b1 = b0;
+ }
+ return( x * b1 - b2 + f[i] );
+}
+
+
+/*
+ * Az_lsp
+ *
+ *
+ * Parameters:
+ * a I: Predictor coefficients [MP1]
+ * lsp O: Line spectral pairs [M]
+ * old_lsp I: Old lsp, in case not found 10 roots [M]
+ *
+ * Function:
+ * LP to LSP conversion
+ *
+ * The LP filter coefficients A[], are converted to the line spectral pair
+ * (LSP) representation for quantization and interpolation purposes.
+ *
+ * Returns:
+ * void
+ */
+static void Az_lsp( Float32 a[], Float32 lsp[], Float32 old_lsp[] )
+{
+ Word32 i, j, nf, ip;
+ Float32 xlow, ylow, xhigh, yhigh, xmid, ymid, xint;
+ Float32 y;
+ Float32 *coef;
+ Float32 f1[6], f2[6];
+
+
+ /*
+ * find the sum and diff. pol. F1(z) and F2(z)
+ */
+ f1[0] = 1.0F;
+ f2[0] = 1.0F;
+
+ for ( i = 0; i < ( NC ); i++ ) {
+ f1[i + 1] = a[i + 1] +a[M - i] - f1[i];
+ f2[i + 1] = a[i + 1] -a[M - i] + f2[i];
+ }
+ f1[NC] *= 0.5F;
+ f2[NC] *= 0.5F;
+
+ /*
+ * find the LSPs using the Chebychev pol. evaluation
+ */
+ nf = 0; /* number of found frequencies */
+ ip = 0; /* indicator for f1 or f2 */
+ coef = f1;
+ xlow = grid[0];
+ ylow = Chebps( xlow, coef );
+ j = 0;
+
+ while ( ( nf < M ) && ( j < 60 ) ) {
+ j++;
+ xhigh = xlow;
+ yhigh = ylow;
+ xlow = grid[j];
+ ylow = Chebps( xlow, coef );
+
+ if ( ylow * yhigh <= 0 ) {
+ /* divide 4 times the interval */
+ for ( i = 0; i < 4; i++ ) {
+ xmid = ( xlow + xhigh ) * 0.5F;
+ ymid = Chebps( xmid, coef );
+
+ if ( ylow * ymid <= 0.0F ) {
+ yhigh = ymid;
+ xhigh = xmid;
+ }
+ else {
+ ylow = ymid;
+ xlow = xmid;
+ }
+ }
+
+ /*
+ * Linear interpolation
+ * xint = xlow - ylow*(xhigh-xlow)/(yhigh-ylow)
+ */
+ y = yhigh - ylow;
+
+ if ( y == 0 ) {
+ xint = xlow;
+ }
+ else {
+ y = ( xhigh - xlow ) / ( yhigh - ylow );
+ xint = xlow - ylow * y;
+ }
+ lsp[nf] = xint;
+ xlow = xint;
+ nf++;
+
+ if ( ip == 0 ) {
+ ip = 1;
+ coef = f2;
+ }
+ else {
+ ip = 0;
+ coef = f1;
+ }
+ ylow = Chebps( xlow, coef );
+ }
+ }
+
+ /* Check if M roots found */
+ if ( nf < M ) {
+ memcpy( lsp, old_lsp, M <<2 );
+ }
+ return;
+}
+
+
+/*
+ * Get_lsp_pol
+ *
+ *
+ * Parameters:
+ * lsp I: line spectral frequencies
+ * f O: polynomial F1(z) or F2(z)
+ *
+ * Function:
+ * Find the polynomial F1(z) or F2(z) from the LSPs.
+ *
+ * F1(z) = product ( 1 - 2 lsp[i] z^-1 + z^-2 )
+ * i=0,2,4,6,8
+ * F2(z) = product ( 1 - 2 lsp[i] z^-1 + z^-2 )
+ * i=1,3,5,7,9
+ *
+ * where lsp[] is the LSP vector in the cosine domain.
+ *
+ * The expansion is performed using the following recursion:
+ *
+ * f[0] = 1
+ * b = -2.0 * lsp[0]
+ * f[1] = b
+ * for i=2 to 5 do
+ * b = -2.0 * lsp[2*i-2];
+ * f[i] = b*f[i-1] + 2.0*f[i-2];
+ * for j=i-1 down to 2 do
+ * f[j] = f[j] + b*f[j-1] + f[j-2];
+ * f[1] = f[1] + b;
+ *
+ * Returns:
+ * void
+ */
+static void Get_lsp_pol( Float32 *lsp, Float32 *f )
+{
+ Word32 i, j;
+ Float32 T0;
+
+
+ f[0] = 1.0F;
+ f[1] = -2.0F * lsp[0];
+
+ for ( i = 2; i <= 5; i++ ) {
+ T0 = -2.0F * lsp[2 * i - 2];
+ f[i] = ( Float32 )( T0 * f[i - 1] +2.0F * f[i - 2] );
+
+ for ( j = i - 1; j >= 2; j-- ) {
+ f[j] = f[j] + T0 * f[j - 1] +f[j - 2];
+ }
+ f[1] = f[1] + T0;
+ }
+ return;
+}
+
+
+/*
+ * Lsp_Az
+ *
+ *
+ * Parameters:
+ * lsp I: Line spectral frequencies
+ * a O: Predictor coefficients
+ *
+ * Function:
+ * Converts from the line spectral pairs (LSP) to LP coefficients,
+ * for a 10th order filter.
+ *
+ * Returns:
+ * void
+ */
+static void Lsp_Az( Float32 lsp[], Float32 a[] )
+{
+ Float32 f1[6], f2[6];
+ Word32 i, j;
+
+
+ Get_lsp_pol( &lsp[0], f1 );
+ Get_lsp_pol( &lsp[1], f2 );
+
+ for ( i = 5; i > 0; i-- ) {
+ f1[i] += f1[i - 1];
+ f2[i] -= f2[i - 1];
+ }
+ a[0] = 1;
+
+ for ( i = 1, j = 10; i <= 5; i++, j-- ) {
+ a[i] = ( Float32 )( ( f1[i] + f2[i] ) * 0.5F );
+ a[j] = ( Float32 )( ( f1[i] - f2[i] ) * 0.5F );
+ }
+ return;
+}
+
+
+/*
+ * Int_lpc_1and3_2
+ *
+ *
+ * Parameters:
+ * lsp_old I: LSP vector at the 4th subfr. of past frame [M]
+ * lsp_mid I: LSP vector at the 2nd subframe of present frame [M]
+ * lsp_new I: LSP vector at the 4th subframe of present frame [M]
+ * az O: interpolated LP parameters in subframes 1 and 3
+ * [AZ_SIZE]
+ *
+ * Function:
+ * Interpolation of the LPC parameters. Same as the Int_lpc
+ * function but we do not recompute Az() for subframe 2 and
+ * 4 because it is already available.
+ *
+ * Returns:
+ * void
+ */
+static void Int_lpc_1and3_2( Float32 lsp_old[], Float32 lsp_mid[], Float32
+ lsp_new[], Float32 az[] )
+{
+ Float32 lsp[M];
+ Word32 i;
+
+
+ for ( i = 0; i < M; i += 2 ) {
+ lsp[i] = ( lsp_mid[i] + lsp_old[i] ) * 0.5F;
+ lsp[i + 1] = ( lsp_mid[i + 1] +lsp_old[i+1] )*0.5F;
+ }
+
+ /* Subframe 1 */
+ Lsp_Az( lsp, az );
+ az += MP1 * 2;
+
+ for ( i = 0; i < M; i += 2 ) {
+ lsp[i] = ( lsp_mid[i] + lsp_new[i] ) * 0.5F;
+ lsp[i + 1] = ( lsp_mid[i + 1] +lsp_new[i+1] )*0.5F;
+ }
+
+ /* Subframe 3 */
+ Lsp_Az( lsp, az );
+ return;
+}
+
+
+/*
+ * Lsp_lsf
+ *
+ *
+ * Parameters:
+ * lsp I: LSP vector
+ * lsf O: LSF vector
+ *
+ * Function:
+ * Transformation lsp to lsf, LPC order M
+ *
+ * Returns:
+ * void
+ */
+static void Lsp_lsf( Float32 lsp[], Float32 lsf[] )
+{
+ Word32 i;
+
+
+ for ( i = 0; i < M; i++ ) {
+ lsf[i] = ( Float32 )( acos( lsp[i] )*SCALE_LSP_FREQ );
+ }
+ return;
+}
+
+
+/*
+ * Lsf_wt
+ *
+ *
+ * Parameters:
+ * lsf I: LSF vector
+ * wf O: square of weighting factors
+ *
+ * Function:
+ * Compute LSF weighting factors
+ *
+ * Returns:
+ * void
+ */
+static void Lsf_wt( Float32 *lsf, Float32 *wf )
+{
+ Float32 temp;
+ Word32 i;
+
+
+ wf[0] = lsf[1];
+
+ for ( i = 1; i < 9; i++ ) {
+ wf[i] = lsf[i + 1] -lsf[i - 1];
+ }
+ wf[9] = 4000.0F - lsf[8];
+
+ for ( i = 0; i < 10; i++ ) {
+ if ( wf[i] < 450.0F ) {
+ temp = 3.347F - SLOPE1_WGHT_LSF * wf[i];
+ }
+ else {
+ temp = 1.8F - SLOPE2_WGHT_LSF * ( wf[i] - 450.0F );
+ }
+ wf[i] = temp * temp;
+ }
+ return;
+}
+
+
+/*
+ * Vq_subvec
+ *
+ *
+ * Parameters:
+ * lsf_r1 I: 1st LSF residual vector
+ * lsf_r2 I: 2nd LSF residual vector
+ * dico I: quantization codebook
+ * wf1 I: 1st LSF weighting factors
+ * wf2 I: 2nd LSF weighting factors
+ * dico_size I: size of quantization codebook
+ * Function:
+ * Quantization of a 4 dimensional subvector
+ *
+ * Returns:
+ * index quantization index
+ */
+static Word16 Vq_subvec( Float32 *lsf_r1, Float32 *lsf_r2, const Float32 *dico,
+ Float32 *wf1, Float32 *wf2, Word16 dico_size )
+{
+ Float64 temp, dist, dist_min;
+ const Float32 *p_dico;
+ Word32 i, index = 0;
+
+
+ dist_min = DBL_MAX;
+ p_dico = dico;
+
+ for ( i = 0; i < dico_size; i++ ) {
+ temp = lsf_r1[0] - *p_dico++;
+ dist = temp * temp * wf1[0];
+ temp = lsf_r1[1] - *p_dico++;
+ dist += temp * temp * wf1[1];
+ temp = lsf_r2[0] - *p_dico++;
+ dist += temp * temp * wf2[0];
+ temp = lsf_r2[1] - *p_dico++;
+ dist += temp * temp * wf2[1];
+
+ if ( dist < dist_min ) {
+ dist_min = dist;
+ index = i;
+ }
+ }
+
+ /* Reading the selected vector */
+ p_dico = &dico[index << 2];
+ lsf_r1[0] = *p_dico++;
+ lsf_r1[1] = *p_dico++;
+ lsf_r2[0] = *p_dico++;
+ lsf_r2[1] = *p_dico++;
+ return( Word16 )index;
+}
+
+
+/*
+ * Vq_subvec_s
+ *
+ *
+ * Parameters:
+ * lsf_r1 I: 1st LSF residual vector
+ * lsf_r2 I: 2nd LSF residual vector
+ * dico I: quantization codebook
+ * wf1 I: 1st LSF weighting factors
+ * wf2 I: 2nd LSF weighting factors
+ * dico_size I: size of quantization codebook
+ * Function:
+ * Quantization of a 4 dimensional subvector with a signed codebook
+ *
+ * Returns:
+ * index quantization index
+ */
+static Word16 Vq_subvec_s( Float32 *lsf_r1, Float32 *lsf_r2, const Float32 *dico
+ , Float32 *wf1, Float32 *wf2, Word16 dico_size )
+{
+ Float64 dist_min, dist1, dist2, temp1, temp2;
+ const Float32 *p_dico;
+ Word32 i, index = 0;
+ Word16 sign = 0;
+
+
+ dist_min = DBL_MAX;
+ p_dico = dico;
+
+ for ( i = 0; i < dico_size; i++ ) {
+ temp1 = lsf_r1[0] - *p_dico;
+ temp2 = lsf_r1[0] + *p_dico++;
+ dist1 = temp1 * temp1 * wf1[0];
+ dist2 = temp2 * temp2 * wf1[0];
+ temp1 = lsf_r1[1] - *p_dico;
+ temp2 = lsf_r1[1] + *p_dico++;
+ dist1 += temp1 * temp1 * wf1[1];
+ dist2 += temp2 * temp2 * wf1[1];
+ temp1 = lsf_r2[0] - *p_dico;
+ temp2 = lsf_r2[0] + *p_dico++;
+ dist1 += temp1 * temp1 * wf2[0];
+ dist2 += temp2 * temp2 * wf2[0];
+ temp1 = lsf_r2[1] - *p_dico;
+ temp2 = lsf_r2[1] + *p_dico++;
+ dist1 += temp1 * temp1 * wf2[1];
+ dist2 += temp2 * temp2 * wf2[1];
+
+ if ( dist1 < dist_min ) {
+ dist_min = dist1;
+ index = i;
+ sign = 0;
+ }
+
+ if ( dist2 < dist_min ) {
+ dist_min = dist2;
+ index = i;
+ sign = 1;
+ }
+ }
+
+ /* Reading the selected vector */
+ p_dico = &dico[index << 2];
+
+ if ( sign == 0 ) {
+ lsf_r1[0] = *p_dico++;
+ lsf_r1[1] = *p_dico++;
+ lsf_r2[0] = *p_dico++;
+ lsf_r2[1] = *p_dico++;
+ }
+ else {
+ lsf_r1[0] = -( *p_dico++ );
+ lsf_r1[1] = -( *p_dico++ );
+ lsf_r2[0] = -( *p_dico++ );
+ lsf_r2[1] = -( *p_dico++ );
+ }
+ index = index << 1;
+ index = index + sign;
+ return( Word16 )index;
+}
+
+
+/*
+ * Reorder_lsf
+ *
+ *
+ * Parameters:
+ * lsf B: vector of LSFs
+ * min_dist I: minimum required distance
+ *
+ * Function:
+ * Make sure that the LSFs are properly ordered and to keep a certain minimum
+ * distance between adjacent LSFs. LPC order = M.
+ *
+ * Returns:
+ * void
+ */
+static void Reorder_lsf( Float32 *lsf, Float32 min_dist )
+{
+ Float32 lsf_min;
+ Word32 i;
+
+
+ lsf_min = min_dist;
+
+ for ( i = 0; i < M; i++ ) {
+ if ( lsf[i] < lsf_min ) {
+ lsf[i] = lsf_min;
+ }
+ lsf_min = lsf[i] + min_dist;
+ }
+}
+
+
+/*
+ * Lsf_lsp
+ *
+ *
+ * Parameters:
+ * lsf I: vector of LSFs
+ * lsp O: vector of LSPs
+ *
+ * Function:
+ * Transformation lsf to lsp, order M
+ *
+ * Returns:
+ * void
+ */
+static void Lsf_lsp( Float32 lsf[], Float32 lsp[] )
+{
+ Word32 i;
+
+
+ for ( i = 0; i < M; i++ ) {
+ lsp[i] = ( Float32 )cos( SCALE_FREQ_LSP * lsf[i] );
+ }
+ return;
+}
+
+
+/*
+ * Vq_subvec3
+ *
+ *
+ * Parameters:
+ * lsf_r1 I: 1st LSF residual vector
+ * dico I: quantization codebook
+ * wf1 I: 1st LSF weighting factors
+ * dico_size I: size of quantization codebook
+ * use_half I: use every second entry in codebook
+ *
+ * Function:
+ * Quantization of a 3 dimensional subvector
+ *
+ * Returns:
+ * index quantization index
+ */
+static Word16 Vq_subvec3( Float32 *lsf_r1, const Float32 *dico, Float32 *wf1,
+ Word16 dico_size, Word32 use_half )
+{
+ Float64 dist, dist_min;
+ Float32 temp;
+ const Float32 *p_dico;
+ Word32 i, index = 0;
+
+
+ dist_min = FLT_MAX;
+ p_dico = dico;
+
+ if ( use_half == 0 ) {
+ for ( i = 0; i < dico_size; i++ ) {
+ temp = lsf_r1[0] - *p_dico++;
+ temp *= wf1[0];
+ dist = temp * temp;
+ temp = lsf_r1[1] - *p_dico++;
+ temp *= wf1[1];
+ dist += temp * temp;
+ temp = lsf_r1[2] - *p_dico++;
+ temp *= wf1[2];
+ dist += temp * temp;
+
+ if ( dist < dist_min ) {
+ dist_min = dist;
+ index = i;
+ }
+ }
+ p_dico = &dico[( 3 * index )];
+ }
+ else {
+ for ( i = 0; i < dico_size; i++ ) {
+ temp = lsf_r1[0] - *p_dico++;
+ temp *= wf1[0];
+ dist = temp * temp;
+ temp = lsf_r1[1] - *p_dico++;
+ temp *= wf1[1];
+ dist += temp * temp;
+ temp = lsf_r1[2] - *p_dico++;
+ temp *= wf1[2];
+ dist += temp * temp;
+
+ if ( dist < dist_min ) {
+ dist_min = dist;
+ index = i;
+ }
+ p_dico = p_dico + 3;
+ }
+ p_dico = &dico[6 * index];
+ }
+
+ /* Reading the selected vector */
+ lsf_r1[0] = *p_dico++;
+ lsf_r1[1] = *p_dico++;
+ lsf_r1[2] = *p_dico++;
+ return( Word16 )index;
+}
+
+
+/*
+ * Vq_subvec4
+ *
+ *
+ * Parameters:
+ * lsf_r1 I: 1st LSF residual vector
+ * dico I: quantization codebook
+ * wf1 I: 1st LSF weighting factors
+ * dico_size I: size of quantization codebook
+ *
+ * Function:
+ * Quantization of a 4 dimensional subvector
+ *
+ * Returns:
+ * index quantization index
+ */
+static Word16 Vq_subvec4( Float32 *lsf_r1, const Float32 *dico, Float32 *wf1,
+ Word16 dico_size )
+{
+ Float64 dist, dist_min;
+ Float32 temp;
+ const Float32 *p_dico;
+ Word32 i, index = 0;
+
+
+ dist_min = FLT_MAX;
+ p_dico = dico;
+
+ for ( i = 0; i < dico_size; i++ ) {
+ temp = lsf_r1[0] - *p_dico++;
+ temp *= wf1[0];
+ dist = temp * temp;
+ temp = lsf_r1[1] - *p_dico++;
+ temp *= wf1[1];
+ dist += temp * temp;
+ temp = lsf_r1[2] - *p_dico++;
+ temp *= wf1[2];
+ dist += temp * temp;
+ temp = lsf_r1[3] - *p_dico++;
+ temp *= wf1[3];
+ dist += temp * temp;
+
+ if ( dist < dist_min ) {
+ dist_min = dist;
+ index = i;
+ }
+ }
+
+ /* Reading the selected vector */
+ p_dico = &dico[index << 2];
+ lsf_r1[0] = *p_dico++;
+ lsf_r1[1] = *p_dico++;
+ lsf_r1[2] = *p_dico++;
+ lsf_r1[3] = *p_dico++;
+ return( Word16 )index;
+}
+
+
+/*
+ * Q_plsf_3
+ *
+ *
+ * Parameters:
+ * mode I: AMR mode
+ * past_rq B: past quantized residual
+ * lsp1 I: 1st LSP vector
+ * lsp1_q O: quantized 1st LSP vector
+ * indice I: quantization indices of 5 matrices and
+ * one sign for 3rd
+ * pred_init_i O: init index for MA prediction in DTX mode
+ *
+ * Function:
+ * Quantization of LSF parameters with 1st order MA prediction and
+ * split by 3 vector quantization (split-VQ)
+ *
+ * Returns:
+ * void
+ */
+static void Q_plsf_3( enum Mode mode, Float32 *past_rq, Float32 *lsp1, Float32 *
+ lsp1_q, Word16 *indice, Word32 *pred_init_i )
+{
+ Float32 lsf1[M], wf1[M], lsf_p[M], lsf_r1[M];
+ Float32 lsf1_q[M];
+ Float32 pred_init_err;
+ Float32 min_pred_init_err;
+ Float32 temp_r1[M];
+ Float32 temp_p[M];
+ Word32 j, i;
+
+
+ /* convert LSFs to normalize frequency domain */
+ Lsp_lsf( lsp1, lsf1 );
+
+ /* compute LSF weighting factors */
+ Lsf_wt( lsf1, wf1 );
+
+ /* Compute predicted LSF and prediction error */
+ if ( mode != MRDTX ) {
+ for ( i = 0; i < M; i++ ) {
+ lsf_p[i] = mean_lsf_3[i] + past_rq[i] * pred_fac[i];
+ lsf_r1[i] = lsf1[i] - lsf_p[i];
+ }
+ }
+ else {
+ /*
+ * DTX mode, search the init vector that yields
+ * lowest prediction resuidual energy
+ */
+ *pred_init_i = 0;
+ min_pred_init_err = FLT_MAX;
+
+ for ( j = 0; j < PAST_RQ_INIT_SIZE; j++ ) {
+ pred_init_err = 0;
+
+ for ( i = 0; i < M; i++ ) {
+ temp_p[i] = mean_lsf_3[i] + past_rq_init[j * M + i];
+ temp_r1[i] = lsf1[i] - temp_p[i];
+ pred_init_err += temp_r1[i] * temp_r1[i];
+ } /* next i */
+
+ if ( pred_init_err < min_pred_init_err ) {
+ min_pred_init_err = pred_init_err;
+ memcpy( lsf_r1, temp_r1, M <<2 );
+ memcpy( lsf_p, temp_p, M <<2 );
+ memcpy( past_rq, &past_rq_init[j * M], M <<2 );
+ *pred_init_i = j;
+ }
+ }
+ }
+
+ /* Split-VQ of prediction error */
+ /* MR475, MR515 */
+ if ( ( mode == MR475 ) || ( mode == MR515 ) ) {
+ indice[0] = Vq_subvec3( &lsf_r1[0], dico1_lsf_3, &wf1[0], DICO1_SIZE_3, 0
+ );
+ indice[1] = Vq_subvec3( &lsf_r1[3], dico2_lsf_3, &wf1[3], DICO2_SIZE_3 /2,
+ 1 );
+ indice[2] = Vq_subvec4( &lsf_r1[6], mr515_3_lsf, &wf1[6], MR515_3_SIZE );
+ }
+
+ /* MR795 */
+ else if ( mode == MR795 ) {
+ indice[0] = Vq_subvec3( &lsf_r1[0], mr795_1_lsf, &wf1[0], MR795_1_SIZE, 0
+ );
+ indice[1] = Vq_subvec3( &lsf_r1[3], dico2_lsf_3, &wf1[3], DICO2_SIZE_3, 0
+ );
+ indice[2] = Vq_subvec4( &lsf_r1[6], dico3_lsf_3, &wf1[6], DICO3_SIZE_3 );
+ }
+
+ /* MR59, MR67, MR74, MR102 , MRDTX */
+ else {
+ indice[0] = Vq_subvec3( &lsf_r1[0], dico1_lsf_3, &wf1[0], DICO1_SIZE_3, 0
+ );
+ indice[1] = Vq_subvec3( &lsf_r1[3], dico2_lsf_3, &wf1[3], DICO2_SIZE_3, 0
+ );
+ indice[2] = Vq_subvec4( &lsf_r1[6], dico3_lsf_3, &wf1[6], DICO3_SIZE_3 );
+ }
+
+ /* Compute quantized LSFs and update the past quantized residual */
+ for ( i = 0; i < M; i++ ) {
+ lsf1_q[i] = lsf_r1[i] + lsf_p[i];
+ past_rq[i] = lsf_r1[i];
+ }
+
+ /* verification that LSFs has mimimum distance of LSF_GAP 50 Hz */
+ Reorder_lsf( lsf1_q, 50.0F );
+
+ /* convert LSFs to the cosine domain */
+ Lsf_lsp( lsf1_q, lsp1_q );
+}
+
+
+/*
+ * Q_plsf_5
+ *
+ *
+ * Parameters:
+ * past_rq B: past quantized residual
+ * lsp1 I: 1st LSP vector
+ * lsp2 I: 2nd LSP vector
+ * lsp1_q O: quantized 1st LSP vector
+ * lsp2_q O: quantized 2nd LSP vector
+ * indice I: quantization indices of 5 matrices and
+ * one sign for 3rd
+ *
+ * Function:
+ * Quantization of 2 sets of LSF parameters using 1st order MA
+ * prediction and split by 5 matrix quantization (split-MQ).
+ *
+ * Returns:
+ * void
+ */
+static void Q_plsf_5( Float32 *past_rq, Float32 *lsp1, Float32 *lsp2, Float32 *
+ lsp1_q, Float32 *lsp2_q, Word16 *indice )
+{
+ Float32 lsf1[M], lsf2[M], wf1[M], wf2[M], lsf_p[M], lsf_r1[M], lsf_r2[M];
+ Float32 lsf1_q[M], lsf2_q[M];
+ Word32 i;
+
+
+ /* convert LSFs to normalize frequency domain */
+ Lsp_lsf( lsp1, lsf1 );
+ Lsp_lsf( lsp2, lsf2 );
+
+ /* Compute LSF weighting factors */
+ Lsf_wt( lsf1, wf1 );
+ Lsf_wt( lsf2, wf2 );
+
+ /* Compute predicted LSF and prediction error */
+ for ( i = 0; i < M; i++ ) {
+ /* MR122 LSP prediction factor = 0.65 */
+ lsf_p[i] = mean_lsf_5[i] + past_rq[i] * 0.65F;
+ lsf_r1[i] = lsf1[i] - lsf_p[i];
+ lsf_r2[i] = lsf2[i] - lsf_p[i];
+ }
+
+ /* Split-MQ of prediction error */
+ indice[0] = Vq_subvec( &lsf_r1[0], &lsf_r2[0], dico1_lsf_5, &wf1[0], &wf2[0],
+ DICO1_SIZE_5 );
+ indice[1] = Vq_subvec( &lsf_r1[2], &lsf_r2[2], dico2_lsf_5, &wf1[2], &wf2[2],
+ DICO2_SIZE_5 );
+ indice[2] = Vq_subvec_s( &lsf_r1[4], &lsf_r2[4], dico3_lsf_5, &wf1[4], &wf2[4
+ ], DICO3_SIZE_5 );
+ indice[3] = Vq_subvec( &lsf_r1[6], &lsf_r2[6], dico4_lsf_5, &wf1[6], &wf2[6],
+ DICO4_SIZE_5 );
+ indice[4] = Vq_subvec( &lsf_r1[8], &lsf_r2[8], dico5_lsf_5, &wf1[8], &wf2[8],
+ DICO5_SIZE_5 );
+
+ /* Compute quantized LSFs and update the past quantized residual */
+ for ( i = 0; i < M; i++ ) {
+ lsf1_q[i] = lsf_r1[i] + lsf_p[i];
+ lsf2_q[i] = lsf_r2[i] + lsf_p[i];
+ past_rq[i] = lsf_r2[i];
+ }
+
+ /* verification that LSFs has minimum distance of LSF_GAP 50hz */
+ Reorder_lsf( lsf1_q, 50.0F );
+ Reorder_lsf( lsf2_q, 50.0F );
+
+ /* convert LSFs to the cosine domain */
+ Lsf_lsp( lsf1_q, lsp1_q );
+ Lsf_lsp( lsf2_q, lsp2_q );
+}
+
+
+/*
+ * Int_lpc_1and3
+ *
+ *
+ * Parameters:
+ * lsp_old I: LSP vector at the 4th subfr. of past frame [M]
+ * lsp_mid I: LSP vector at the 2nd subframe of present frame [M]
+ * lsp_new I: LSP vector at the 4th subframe of present frame [M]
+ * az O: interpolated LP parameters in subframes 1 and 3
+ * [AZ_SIZE]
+ *
+ * Function:
+ * Interpolates the LSPs and converts to LPC parameters
+ * to get a different LP filter in each subframe.
+ *
+ * The 20 ms speech frame is divided into 4 subframes.
+ * The LSPs are quantized and transmitted at the 2nd and
+ * 4th subframes (twice per frame) and interpolated at the
+ * 1st and 3rd subframe.
+ *
+ * Returns:
+ * void
+ */
+static void Int_lpc_1and3( Float32 lsp_old[], Float32 lsp_mid[], Float32 lsp_new
+ [], Float32 az[] )
+{
+ Word32 i;
+ Float32 lsp[M];
+
+
+ for ( i = 0; i < M; i++ ) {
+ lsp[i] = ( lsp_mid[i] + lsp_old[i] ) * 0.5F;
+ }
+
+ /* Subframe 1 */
+ Lsp_Az( lsp, az );
+ az += MP1;
+
+ /* Subframe 2 */
+ Lsp_Az( lsp_mid, az );
+ az += MP1;
+
+ for ( i = 0; i < M; i++ ) {
+ lsp[i] = ( lsp_mid[i] + lsp_new[i] ) * 0.5F;
+ }
+
+ /* Subframe 3 */
+ Lsp_Az( lsp, az );
+ az += MP1;
+
+ /* Subframe 4 */
+ Lsp_Az( lsp_new, az );
+ return;
+}
+
+
+/*
+ * Int_lpc_1to3_2
+ *
+ *
+ * Parameters:
+ * lsp_old I: LSP vector at the 4th subfr. of past frame [M]
+ * lsp_new I: LSP vector at the 4th subframe of present frame [M]
+ * az O: interpolated LP parameters in subframes 1, 2 and 3
+ * [AZ_SIZE]
+ *
+ * Function:
+ * Interpolation of the LPC parameters.
+ *
+ * Returns:
+ * void
+ */
+static void Int_lpc_1to3_2( Float32 lsp_old[], Float32 lsp_new[], Float32 az[] )
+{
+ Float32 lsp[M];
+ Word32 i;
+
+
+ for ( i = 0; i < M; i += 2 ) {
+ lsp[i] = lsp_new[i] * 0.25F + lsp_old[i] * 0.75F;
+ lsp[i + 1] = lsp_new[i + 1] *0.25F + lsp_old[i + 1] *0.75F;
+ }
+
+ /* Subframe 1 */
+ Lsp_Az( lsp, az );
+ az += MP1;
+
+ for ( i = 0; i < M; i += 2 ) {
+ lsp[i] = ( lsp_old[i] + lsp_new[i] ) * 0.5F;
+ lsp[i + 1] = ( lsp_old[i + 1] +lsp_new[i+1] )*0.5F;
+ }
+
+ /* Subframe 2 */
+ Lsp_Az( lsp, az );
+ az += MP1;
+
+ for ( i = 0; i < M; i += 2 ) {
+ lsp[i] = lsp_old[i] * 0.25F + lsp_new[i] * 0.75F;
+ lsp[i + 1] = lsp_old[i + 1] *0.25F + lsp_new[i + 1] *0.75F;
+ }
+
+ /* Subframe 3 */
+ Lsp_Az( lsp, az );
+ return;
+}
+
+
+/*
+ * Int_lpc_1to3
+ *
+ *
+ * Parameters:
+ * lsp_old I: LSP vector at the 4th subfr. of past frame [M]
+ * lsp_new I: LSP vector at the 4th subframe of present frame [M]
+ * az O: interpolated LP parameters in all subframes
+ * [AZ_SIZE]
+ *
+ * Function:
+ * Interpolates the LSPs and converts to LPC parameters to get a different
+ * LP filter in each subframe.
+ *
+ * The 20 ms speech frame is divided into 4 subframes.
+ * The LSPs are quantized and transmitted at the 4th
+ * subframes (once per frame) and interpolated at the
+ * 1st, 2nd and 3rd subframe.
+ *
+ * Returns:
+ * void
+ */
+static void Int_lpc_1to3( Float32 lsp_old[], Float32 lsp_new[], Float32 az[] )
+{
+ Float32 lsp[M];
+ Word32 i;
+
+
+ for ( i = 0; i < M; i++ ) {
+ lsp[i] = lsp_new[i] * 0.25F + lsp_old[i] * 0.75F;
+ }
+
+ /* Subframe 1 */
+ Lsp_Az( lsp, az );
+ az += MP1;
+
+ for ( i = 0; i < M; i++ ) {
+ lsp[i] = ( lsp_old[i] + lsp_new[i] ) * 0.5F;
+ }
+
+ /* Subframe 2 */
+ Lsp_Az( lsp, az );
+ az += MP1;
+
+ for ( i = 0; i < M; i++ ) {
+ lsp[i] = lsp_old[i] * 0.25F + lsp_new[i] * 0.75F;
+ }
+
+ /* Subframe 3 */
+ Lsp_Az( lsp, az );
+ az += MP1;
+
+ /* Subframe 4 */
+ Lsp_Az( lsp_new, az );
+ return;
+}
+
+
+/*
+ * lsp
+ *
+ *
+ * Parameters:
+ * req_mode I: requested mode
+ * used_mode I: used mode
+ * lsp_old B: old LSP vector
+ * lsp_old_q B: old quantized LSP vector
+ * past_rq B: past quantized residual
+ * az B: interpolated LP parameters
+ * azQ O: quantization interpol. LP parameters
+ * lsp_new O: new lsp vector
+ * anap O: analysis parameters
+ *
+ * Function:
+ * From A(z) to lsp. LSP quantization and interpolation
+ *
+ * Returns:
+ * void
+ */
+static void lsp( enum Mode req_mode, enum Mode used_mode, Float32 *lsp_old,
+ Float32 *lsp_old_q, Float32 *past_rq, Float32 az[], Float32 azQ[], Float32
+ lsp_new[], Word16 **anap )
+{
+ Float32 lsp_new_q[M]; /* LSPs at 4th subframe */
+ Float32 lsp_mid[M], lsp_mid_q[M]; /* LSPs at 2nd subframe */
+ Word32 pred_init_i; /* init index for MA prediction in DTX mode */
+
+
+ if ( req_mode == MR122 ) {
+ Az_lsp( &az[MP1], lsp_mid, lsp_old );
+ Az_lsp( &az[MP1 * 3], lsp_new, lsp_mid );
+
+ /*
+ * Find interpolated LPC parameters in all subframes
+ * (both quantized and unquantized).
+ * The interpolated parameters are in array A_t[] of size (M+1)*4
+ * and the quantized interpolated parameters are in array Aq_t[]
+ */
+ Int_lpc_1and3_2( lsp_old, lsp_mid, lsp_new, az );
+
+ if ( used_mode != MRDTX ) {
+ /* LSP quantization (lsp_mid[] and lsp_new[] jointly quantized) */
+ Q_plsf_5( past_rq, lsp_mid, lsp_new, lsp_mid_q, lsp_new_q, *anap );
+ Int_lpc_1and3( lsp_old_q, lsp_mid_q, lsp_new_q, azQ );
+
+ /* Advance analysis parameters pointer */
+ ( *anap ) += 5;
+ }
+ }
+ else {
+ /* From A(z) to lsp */
+ Az_lsp( &az[MP1 * 3], lsp_new, lsp_old );
+
+ /*
+ * Find interpolated LPC parameters in all subframes
+ * (both quantized and unquantized).
+ * The interpolated parameters are in array A_t[] of size (M+1)*4
+ * and the quantized interpolated parameters are in array Aq_t[]
+ */
+ Int_lpc_1to3_2( lsp_old, lsp_new, az );
+
+ /* LSP quantization */
+ if ( used_mode != MRDTX ) {
+ Q_plsf_3( req_mode, past_rq, lsp_new, lsp_new_q, *anap, &pred_init_i );
+ Int_lpc_1to3( lsp_old_q, lsp_new_q, azQ );
+
+ /* Advance analysis parameters pointer */
+ ( *anap ) += 3;
+ }
+ }
+
+ /* update the LSPs for the next frame */
+ memcpy( lsp_old, lsp_new, M <<2 );
+ memcpy( lsp_old_q, lsp_new_q, M <<2 );
+}
+
+
+/*
+ * check_lsp
+ *
+ *
+ * Parameters:
+ * count B: counter for resonance
+ * lsp B: LSP vector
+ *
+ * Function:
+ * Check the LSP's to detect resonances
+ *
+ * Resonances in the LPC filter are monitored to detect possible problem
+ * areas where divergence between the adaptive codebook memories in
+ * the encoder and the decoder could cause unstable filters in areas
+ * with highly correlated continuos signals. Typically, this divergence
+ * is due to channel errors.
+ * The monitoring of resonance signals is performed using unquantized LSPs
+ * q(i), i = 1,...,10. The algorithm utilises the fact that LSPs are
+ * closely located at a peak in the spectrum. First, two distances,
+ * dist 1 and dist 2 ,are calculated in two different regions,
+ * defined as
+ *
+ * dist1 = min[q(i) - q(i + 1)], i = 4,...,8
+ * dist2 = min[q(i) - q(i + 1)], i = 2,3
+ *
+ * Either of these two minimum distance conditions must be fulfilled
+ * to classify the frame as a resonance frame and increase the resonance
+ * counter.
+ *
+ * if(dist1 < TH1) || if (dist2 < TH2)
+ * counter++
+ * else
+ * counter = 0
+ *
+ * TH1 = 0.046
+ * TH2 = 0.018, q(2) > 0.98
+ * TH2 = 0.024, 0.93 < q(2) <= 0.98
+ * TH2 = 0.018, otherwise
+ *
+ * 12 consecutive resonance frames are needed to indicate possible
+ * problem conditions, otherwise the LSP_flag is cleared.
+ *
+ * Returns:
+ * resonance flag
+ */
+static Word16 check_lsp( Word16 *count, Float32 *lsp )
+{
+ Float32 dist, dist_min1, dist_min2, dist_th;
+ Word32 i;
+
+
+ /*
+ * Check for a resonance:
+ * Find minimum distance between lsp[i] and lsp[i+1]
+ */
+ dist_min1 = FLT_MAX;
+
+ for ( i = 3; i < 8; i++ ) {
+ dist = lsp[i] - lsp[i + 1];
+
+ if ( dist < dist_min1 ) {
+ dist_min1 = dist;
+ }
+ }
+ dist_min2 = FLT_MAX;
+
+ for ( i = 1; i < 3; i++ ) {
+ dist = lsp[i] - lsp[i + 1];
+
+ if ( dist < dist_min2 ) {
+ dist_min2 = dist;
+ }
+ }
+
+ if ( lsp[1] > 0.98F ) {
+ dist_th = 0.018F;
+ }
+ else if ( lsp[1] > 0.93F ) {
+ dist_th = 0.024F;
+ }
+ else {
+ dist_th = 0.034F;
+ }
+
+ if ( ( dist_min1 < 0.046F ) || ( dist_min2 < dist_th ) ) {
+ *count += 1;
+ }
+ else {
+ *count = 0;
+ }
+
+ /* Need 12 consecutive frames to set the flag */
+ if ( *count >= 12 ) {
+ *count = 12;
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+
+
+/*
+ * Weight_Ai
+ *
+ *
+ * Parameters:
+ * a I: LPC coefficients [M+1]
+ * fac I: Spectral expansion factors. [M+1]
+ * a_exp O: Spectral expanded LPC coefficients [M+1]
+ *
+ * Function:
+ * Spectral expansion of LP coefficients
+ *
+ * Returns:
+ * void
+ */
+static void Weight_Ai( Float32 a[], const Float32 fac[], Float32 a_exp[] )
+{
+ Word32 i;
+
+
+ a_exp[0] = a[0];
+
+ for ( i = 1; i <= M; i++ ) {
+ a_exp[i] = a[i] * fac[i - 1];
+ }
+ return;
+}
+
+
+/*
+ * Residu
+ *
+ *
+ * Parameters:
+ * a I: prediction coefficients
+ * x I: speech signal
+ * y O: residual signal
+ *
+ * Function:
+ * Computes the LTP residual signal.
+ *
+ * Returns:
+ * void
+ */
+static void Residu( Float32 a[], Float32 x[], Float32 y[] )
+{
+ Float32 s;
+ Word32 i;
+
+
+ for ( i = 0; i < L_SUBFR; i += 4 ) {
+ s = x[i] * a[0];
+ s += x[i - 1] *a[1];
+ s += x[i - 2] * a[2];
+ s += x[i - 3] * a[3];
+ s += x[i - 4] * a[4];
+ s += x[i - 5] * a[5];
+ s += x[i - 6] * a[6];
+ s += x[i - 7] * a[7];
+ s += x[i - 8] * a[8];
+ s += x[i - 9] * a[9];
+ s += x[i - 10] * a[10];
+ y[i] = s;
+ s = x[i + 1] *a[0];
+ s += x[i] * a[1];
+ s += x[i - 1] *a[2];
+ s += x[i - 2] * a[3];
+ s += x[i - 3] * a[4];
+ s += x[i - 4] * a[5];
+ s += x[i - 5] * a[6];
+ s += x[i - 6] * a[7];
+ s += x[i - 7] * a[8];
+ s += x[i - 8] * a[9];
+ s += x[i - 9] * a[10];
+ y[i + 1] = s;
+ s = x[i + 2] * a[0];
+ s += x[i + 1] *a[1];
+ s += x[i] * a[2];
+ s += x[i - 1] *a[3];
+ s += x[i - 2] * a[4];
+ s += x[i - 3] * a[5];
+ s += x[i - 4] * a[6];
+ s += x[i - 5] * a[7];
+ s += x[i - 6] * a[8];
+ s += x[i - 7] * a[9];
+ s += x[i - 8] * a[10];
+ y[i + 2] = s;
+ s = x[i + 3] * a[0];
+ s += x[i + 2] * a[1];
+ s += x[i + 1] *a[2];
+ s += x[i] * a[3];
+ s += x[i - 1] *a[4];
+ s += x[i - 2] * a[5];
+ s += x[i - 3] * a[6];
+ s += x[i - 4] * a[7];
+ s += x[i - 5] * a[8];
+ s += x[i - 6] * a[9];
+ s += x[i - 7] * a[10];
+ y[i + 3] = s;
+ }
+ return;
+}
+
+
+/*
+ * Syn_filt
+ *
+ *
+ * Parameters:
+ * a I: prediction coefficients [M+1]
+ * x I: input signal
+ * y O: output signal
+ * mem B: memory associated with this filtering
+ * update I: 0=no update, 1=update of memory.
+ *
+ * Function:
+ * Perform synthesis filtering through 1/A(z).
+ *
+ * Returns:
+ * void
+ */
+static void Syn_filt( Float32 a[], Float32 x[], Float32 y[], Float32 mem[],
+ Word16 update )
+{
+ Float64 tmp[50];
+ Float64 sum;
+ Float64 *yy;
+ Word32 i;
+
+
+ /* Copy mem[] to yy[] */
+ yy = tmp;
+
+ for ( i = 0; i < M; i++ ) {
+ *yy++ = mem[i];
+ }
+
+ /* Do the filtering. */
+ for ( i = 0; i < L_SUBFR; i = i + 4 ) {
+ sum = x[i] * a[0];
+ sum -= a[1] * yy[ - 1];
+ sum -= a[2] * yy[ - 2];
+ sum -= a[3] * yy[ - 3];
+ sum -= a[4] * yy[ - 4];
+ sum -= a[5] * yy[ - 5];
+ sum -= a[6] * yy[ - 6];
+ sum -= a[7] * yy[ - 7];
+ sum -= a[8] * yy[ - 8];
+ sum -= a[9] * yy[ - 9];
+ sum -= a[10] * yy[ - 10];
+ *yy++ = sum;
+ y[i] = ( Float32 )yy[ - 1];
+ sum = x[i + 1] *a[0];
+ sum -= a[1] * yy[ - 1];
+ sum -= a[2] * yy[ - 2];
+ sum -= a[3] * yy[ - 3];
+ sum -= a[4] * yy[ - 4];
+ sum -= a[5] * yy[ - 5];
+ sum -= a[6] * yy[ - 6];
+ sum -= a[7] * yy[ - 7];
+ sum -= a[8] * yy[ - 8];
+ sum -= a[9] * yy[ - 9];
+ sum -= a[10] * yy[ - 10];
+ *yy++ = sum;
+ y[i + 1] = ( Float32 )yy[ - 1];
+ sum = x[i + 2] * a[0];
+ sum -= a[1] * yy[ - 1];
+ sum -= a[2] * yy[ - 2];
+ sum -= a[3] * yy[ - 3];
+ sum -= a[4] * yy[ - 4];
+ sum -= a[5] * yy[ - 5];
+ sum -= a[6] * yy[ - 6];
+ sum -= a[7] * yy[ - 7];
+ sum -= a[8] * yy[ - 8];
+ sum -= a[9] * yy[ - 9];
+ sum -= a[10] * yy[ - 10];
+ *yy++ = sum;
+ y[i + 2] = ( Float32 )yy[ - 1];
+ sum = x[i + 3] * a[0];
+ sum -= a[1] * yy[ - 1];
+ sum -= a[2] * yy[ - 2];
+ sum -= a[3] * yy[ - 3];
+ sum -= a[4] * yy[ - 4];
+ sum -= a[5] * yy[ - 5];
+ sum -= a[6] * yy[ - 6];
+ sum -= a[7] * yy[ - 7];
+ sum -= a[8] * yy[ - 8];
+ sum -= a[9] * yy[ - 9];
+ sum -= a[10] * yy[ - 10];
+ *yy++ = sum;
+ y[i + 3] = ( Float32 )yy[ - 1];
+ }
+
+ /* Update of memory if update==1 */
+ if ( update != 0 ) {
+ for ( i = 0; i < M; i++ ) {
+ mem[i] = y[30 + i];
+ }
+ }
+ return;
+}
+
+
+/*
+ * pre_big
+ *
+ *
+ * Parameters:
+ * mode I: AMR mode
+ * gamma1 I: spectral exp. factor 1
+ * gamma1_12k2 I: spectral exp. factor 1 for modes above MR795
+ * gamma2 I: spectral exp. factor 2
+ * A_t I: A(z) unquantized, for 4 subframes
+ * frame_offset I: frameoffset, 1st or second big_sbf
+ * speech I: speech
+ * mem_w B: synthesis filter memory state
+ * wsp O: weighted speech
+ *
+ * Function:
+ * Big subframe (2 subframes) preprocessing
+ *
+ * Open-loop pitch analysis is performed in order to simplify the pitch
+ * analysis and confine the closed-loop pitch search to a small number of
+ * lags around the open-loop estimated lags.
+ * Open-loop pitch estimation is based on the weighted speech signal Sw(n)
+ * which is obtained by filtering the input speech signal through
+ * the weighting filter
+ *
+ * W(z) = A(z/g1) / A(z/g2)
+ *
+ * That is, in a subframe of size L, the weighted speech is given by:
+ *
+ * 10 10
+ * Sw(n) = S(n) + SUM[a(i) * g1(i) * S(n-i)] - SUM[a(i) * g2(i) * Sw(n-i)],
+ * i=1 i=1
+ * n = 0, ..., L-1
+ *
+ * Returns:
+ * void
+ */
+static Word32 pre_big( enum Mode mode, const Float32 gamma1[], const Float32
+ gamma1_12k2[], const Float32 gamma2[], Float32 A_t[], Word16 frame_offset,
+ Float32 speech[], Float32 mem_w[], Float32 wsp[] )
+{
+ Float32 Ap1[MP1], Ap2[MP1];
+ Word32 offset, i;
+
+
+ /* A(z) with spectral expansion */
+ const Float32 *g1;
+
+
+ g1 = gamma1_12k2;
+
+ if ( mode <= MR795 ) {
+ g1 = gamma1;
+ }
+ offset = 0;
+
+ if ( frame_offset > 0 ) {
+ offset = MP1 << 1;
+ }
+
+ /* process two subframes (which form the "big" subframe) */
+ for ( i = 0; i < 2; i++ ) {
+ /* a(i) * g1(i) */
+ Weight_Ai( &A_t[offset], g1, Ap1 );
+
+ /* a(i) * g2(i) */
+ Weight_Ai( &A_t[offset], gamma2, Ap2 );
+
+ /*
+ * 10
+ * S(n) + SUM[a(i) * g1(i) * S(n-i)]
+ * i=1
+ */
+ Residu( Ap1, &speech[frame_offset], &wsp[frame_offset] );
+
+ /*
+ * 10 10
+ * S(n) + SUM[a(i) * g1(i) * S(n-i)] SUM[a(i) * g2(i) * Sn(n-i)]
+ * i=1 i=1
+ */
+ Syn_filt( Ap2, &wsp[frame_offset], &wsp[frame_offset], mem_w, 1 );
+ offset += MP1;
+ frame_offset += L_SUBFR;
+ }
+ return 0;
+}
+
+
+/*
+ * comp_corr
+ *
+ *
+ * Parameters:
+ * sig I: signal
+ * L_frame I: length of frame to compute pitch
+ * lag_max I: maximum lag
+ * lag_min I: minimum lag
+ * corr O: correlation of selected lag
+ *
+ * Function:
+ * Calculate all correlations in a given delay range.
+ *
+ * Returns:
+ * void
+ */
+static void comp_corr( Float32 sig[], Word32 L_frame, Word32 lag_max, Word32
+ lag_min, Float32 corr[] )
+{
+ Word32 i, j;
+ Float32 *p, *p1;
+ Float32 T0;
+
+
+ for ( i = lag_max; i >= lag_min; i-- ) {
+ p = sig;
+ p1 = &sig[ - i];
+ T0 = 0.0F;
+
+ for ( j = 0; j < L_frame; j = j + 40, p += 40, p1 += 40 ) {
+ T0 += p[0] * p1[0] + p[1] * p1[1] + p[2] * p1[2] + p[3] * p1[3];
+ T0 += p[4] * p1[4] + p[5] * p1[5] + p[6] * p1[6] + p[7] * p1[7];
+ T0 += p[8] * p1[8] + p[9] * p1[9] + p[10] * p1[10] + p[11] * p1[11];
+ T0 += p[12] * p1[12] + p[13] * p1[13] + p[14] * p1[14] + p[15] * p1[15]
+ ;
+ T0 += p[16] * p1[16] + p[17] * p1[17] + p[18] * p1[18] + p[19] * p1[19]
+ ;
+ T0 += p[20] * p1[20] + p[21] * p1[21] + p[22] * p1[22] + p[23] * p1[23]
+ ;
+ T0 += p[24] * p1[24] + p[25] * p1[25] + p[26] * p1[26] + p[27] * p1[27]
+ ;
+ T0 += p[28] * p1[28] + p[29] * p1[29] + p[30] * p1[30] + p[31] * p1[31]
+ ;
+ T0 += p[32] * p1[32] + p[33] * p1[33] + p[34] * p1[34] + p[35] * p1[35]
+ ;
+ T0 += p[36] * p1[36] + p[37] * p1[37] + p[38] * p1[38] + p[39] * p1[39]
+ ;
+ }
+ corr[ - i] = T0;
+ }
+ return;
+}
+
+
+/*
+ * vad_tone_detection
+ *
+ *
+ * Parameters:
+ * st->tone B: flags indicating presence of a tone
+ * T0 I: autocorrelation maxima
+ * t1 I: energy
+ *
+ * Function:
+ * Set tone flag if pitch gain is high.
+ * This is used to detect signaling tones and other signals
+ * with high pitch gain.
+ *
+ * Returns:
+ * void
+ */
+#ifndef VAD2
+static void vad_tone_detection( vadState *st, Float32 T0, Float32 t1 )
+{
+ if ( ( t1 > 0 ) && ( T0 > t1 * TONE_THR ) ) {
+ st->tone = st->tone | 0x00004000;
+ }
+}
+#endif
+
+/*
+ * Lag_max
+ *
+ *
+ * Parameters:
+ * vadSt B: vad structure
+ * corr I: correlation vector
+ * sig I: signal
+ * L_frame I: length of frame to compute pitch
+ * lag_max I: maximum lag
+ * lag_min I: minimum lag
+ * cor_max O: maximum correlation
+ * dtx I: dtx on/off
+ *
+ * Function:
+ * Compute the open loop pitch lag.
+ *
+ * Returns:
+ * p_max lag found
+ */
+#ifdef VAD2
+static Word16 Lag_max( Float32 corr[], Float32 sig[], Word16 L_frame,
+ Word32 lag_max, Word32 lag_min, Float32 *cor_max,
+ Word32 dtx, Float32 *rmax, Float32 *r0 )
+#else
+static Word16 Lag_max( vadState *vadSt, Float32 corr[], Float32 sig[], Word16
+ L_frame, Word32 lag_max, Word32 lag_min, Float32 *cor_max, Word32 dtx )
+#endif
+{
+ Float32 max, T0;
+ Float32 *p;
+ Word32 i, j, p_max;
+
+
+ max = -FLT_MAX;
+ p_max = lag_max;
+
+ for ( i = lag_max, j = ( PIT_MAX - lag_max - 1 ); i >= lag_min; i--, j-- ) {
+ if ( corr[ - i] >= max ) {
+ max = corr[ - i];
+ p_max = i;
+ }
+ }
+
+ /* compute energy for normalization */
+ T0 = 0.0F;
+ p = &sig[ - p_max];
+
+ for ( i = 0; i < L_frame; i++, p++ ) {
+ T0 += *p * *p;
+ }
+
+ if ( dtx ) {
+#ifdef VAD2
+ *rmax = max;
+ *r0 = T0;
+#else
+ /* check tone */
+ vad_tone_detection( vadSt, max, T0 );
+#endif
+ }
+
+ if ( T0 > 0.0F )
+ T0 = 1.0F / ( Float32 )sqrt( T0 );
+ else
+ T0 = 0.0F;
+
+ /* max = max/sqrt(energy) */
+ max *= T0;
+ *cor_max = max;
+ return( ( Word16 )p_max );
+}
+
+
+/*
+ * hp_max
+ *
+ *
+ * Parameters:
+ * corr I: correlation vector
+ * sig I: signal
+ * L_frame I: length of frame to compute pitch
+ * lag_max I: maximum lag
+ * lag_min I: minimum lag
+ * cor_hp_max O: max high-pass filtered correlation
+ *
+ * Function:
+ * Find the maximum correlation of scal_sig[] in a given delay range.
+ *
+ * The correlation is given by
+ * cor[t] = <scal_sig[n],scal_sig[n-t]>, t=lag_min,...,lag_max
+ * The functions outputs the maximum correlation after normalization
+ * and the corresponding lag.
+ *
+ * Returns:
+ * void
+ */
+#ifndef VAD2
+static void hp_max( Float32 corr[], Float32 sig[], Word32 L_frame, Word32
+ lag_max, Word32 lag_min, Float32 *cor_hp_max )
+{
+ Float32 T0, t1, max;
+ Float32 *p, *p1;
+ Word32 i;
+
+
+ max = -FLT_MAX;
+ T0 = 0;
+
+ for ( i = lag_max - 1; i > lag_min; i-- ) {
+ /* high-pass filtering */
+ T0 = ( ( corr[ - i] * 2 ) - corr[ - i-1] )-corr[ - i + 1];
+ T0 = ( Float32 )fabs( T0 );
+
+ if ( T0 >= max ) {
+ max = T0;
+ }
+ }
+
+ /* compute energy */
+ p = sig;
+ p1 = &sig[0];
+ T0 = 0;
+
+ for ( i = 0; i < L_frame; i++, p++, p1++ ) {
+ T0 += *p * *p1;
+ }
+ p = sig;
+ p1 = &sig[ - 1];
+ t1 = 0;
+
+ for ( i = 0; i < L_frame; i++, p++, p1++ ) {
+ t1 += *p * *p1;
+ }
+
+ /* high-pass filtering */
+ T0 = T0 - t1;
+ T0 = ( Float32 )fabs( T0 );
+
+ /* max/T0 */
+ if ( T0 != 0 ) {
+ *cor_hp_max = max / T0;
+ }
+ else {
+ *cor_hp_max = 0;
+ }
+}
+#endif
+
+/*
+ * vad_tone_detection_update
+ *
+ *
+ * Parameters:
+ * st->tone B: flags indicating presence of a tone
+ * one_lag_per_frame I: 1 open-loop lag is calculated per each frame
+ *
+ * Function:
+ * Update the tone flag register.
+ *
+ * Returns:
+ * void
+ */
+#ifndef VAD2
+static void vad_tone_detection_update( vadState *st, Word16 one_lag_per_frame )
+{
+ /* Shift tone flags right by one bit */
+ st->tone = st->tone >> 1;
+
+ /*
+ * If open-loop lag is calculated only once in each frame,
+ * do extra update and assume that the other tone flag
+ * of the frame is one.
+ */
+ if ( one_lag_per_frame != 0 ) {
+ st->tone = st->tone >> 1;
+ st->tone = st->tone | 0x00002000;
+ }
+}
+#endif
+
+/*
+ * Pitch_ol
+ *
+ *
+ * Parameters:
+ * mode I: AMR mode
+ * vadSt B: VAD state struct
+ * signal I: signal used to compute the open loop pitch
+ * [[-pit_max]:[-1]]
+ * pit_min I: minimum pitch lag
+ * pit_max I: maximum pitch lag
+ * L_frame I: length of frame to compute pitch
+ * dtx I: DTX flag
+ * idx I: frame index
+ *
+ * Function:
+ * Compute the open loop pitch lag.
+ *
+ * Open-loop pitch analysis is performed twice per frame (each 10 ms)
+ * to find two estimates of the pitch lag in each frame.
+ * Open-loop pitch analysis is performed as follows.
+ * In the first step, 3 maxima of the correlation:
+ *
+ * 79
+ * O(k) = SUM Sw(n)*Sw(n-k)
+ * n=0
+ *
+ * are found in the three ranges:
+ * pit_min ... 2*pit_min-1
+ * 2*pit_min ... 4*pit_min-1
+ * 4*pit_min ... pit_max
+ *
+ * The retained maxima O(t(i)), i = 1, 2, 3, are normalized by dividing by
+ *
+ * SQRT[SUM[POW(Sw(n-t(i)), 2]], i = 1, 2, 3,
+ * n
+ *
+ * respectively.
+ * The normalized maxima and corresponding delays are denoted by
+ * (M(i), t(i)), i = 1, 2, 3. The winner, Top, among the three normalized
+ * correlations is selected by favouring the delays with the values
+ * in the lower range. This is performed by weighting the normalized
+ * correlations corresponding to the longer delays. The best
+ * open-loop delay Top is determined as follows:
+ *
+ * Top = t(1)
+ * M(Top) = M(1)
+ * if M(2) > 0.85 * M(Top)
+ * M(Top) = M(2)
+ * Top = t(2)
+ * end
+ * if M(3) > 0.85 * M(Top)
+ * M(Top) = M(3)
+ * Top = t(3)
+ * end
+ *
+ * Returns:
+ * void
+ */
+static Word32 Pitch_ol( enum Mode mode, vadState *vadSt, Float32 signal[],
+ Word32 pit_min, Word32 pit_max, Word16 L_frame, Word32 dtx, Word16 idx )
+{
+ Float32 corr[PIT_MAX + 1];
+ Float32 max1, max2, max3, p_max1, p_max2, p_max3;
+ Float32 *corr_ptr;
+ Word32 i, j;
+#ifdef VAD2
+ Float32 r01, r02, r03;
+ Float32 rmax1, rmax2, rmax3;
+#else
+ Float32 corr_hp_max;
+#endif
+
+
+#ifndef VAD2
+ if ( dtx ) {
+ /* update tone detection */
+ if ( ( mode == MR475 ) || ( mode == MR515 ) ) {
+ vad_tone_detection_update( vadSt, 1 );
+ }
+ else {
+ vad_tone_detection_update( vadSt, 0 );
+ }
+ }
+#endif
+
+ corr_ptr = &corr[pit_max];
+
+ /* 79 */
+ /* O(k) = SUM Sw(n)*Sw(n-k) */
+ /* n=0 */
+ comp_corr( signal, L_frame, pit_max, pit_min, corr_ptr );
+
+#ifdef VAD2
+ /* Find a maximum for each section. */
+ /* Maxima 1 */
+ j = pit_min << 2;
+ p_max1 =
+ Lag_max( corr_ptr, signal, L_frame, pit_max, j, &max1, dtx, &rmax1, &r01 );
+
+ /* Maxima 2 */
+ i = j - 1;
+ j = pit_min << 1;
+ p_max2 = Lag_max( corr_ptr, signal, L_frame, i, j, &max2, dtx, &rmax2, &r02 );
+
+ /* Maxima 3 */
+ i = j - 1;
+ p_max3 =
+ Lag_max( corr_ptr, signal, L_frame, i, pit_min, &max3, dtx, &rmax3, &r03 );
+#else
+ /* Find a maximum for each section. */
+ /* Maxima 1 */
+ j = pit_min << 2;
+ p_max1 = Lag_max( vadSt, corr_ptr, signal, L_frame, pit_max, j, &max1, dtx );
+
+ /* Maxima 2 */
+ i = j - 1;
+ j = pit_min << 1;
+ p_max2 = Lag_max( vadSt, corr_ptr, signal, L_frame, i, j, &max2, dtx );
+
+ /* Maxima 3 */
+ i = j - 1;
+ p_max3 = Lag_max( vadSt, corr_ptr, signal, L_frame, i, pit_min, &max3, dtx );
+
+ if ( dtx ) {
+ if ( idx == 1 ) {
+ /* calculate max high-passed filtered correlation of all lags */
+ hp_max( corr_ptr, signal, L_frame, pit_max, pit_min, &corr_hp_max );
+
+ /* update complex background detector */
+ vadSt->best_corr_hp = corr_hp_max * 0.5F;
+ }
+ }
+#endif
+
+ /* The best open-loop delay */
+ if ( ( max1 * 0.85F ) < max2 ) {
+ max1 = max2;
+ p_max1 = p_max2;
+#ifdef VAD2
+ if (dtx) {
+ rmax1 = rmax2;
+ r01 = r02;
+ }
+#endif
+ }
+
+ if ( ( max1 * 0.85F ) < max3 ) {
+ p_max1 = p_max3;
+#ifdef VAD2
+ if (dtx) {
+ rmax1 = rmax3;
+ r01 = r03;
+ }
+#endif
+ }
+#ifdef VAD2
+ if (dtx) {
+ vadSt->Rmax += rmax1; /* Save max correlation */
+ vadSt->R0 += r01; /* Save max energy */
+ }
+#endif
+ return( Word32 )p_max1;
+}
+
+
+/*
+ * Lag_max_wght
+ *
+ *
+ * Parameters:
+ * vadSt B: vad structure
+ * corr I: correlation vector
+ * signal I: signal
+ * L_frame I: length of frame to compute pitch
+ * old_lag I: old open-loop lag
+ * cor_max O: maximum correlation
+ * wght_flg I: weighting function flag
+ * gain_flg O: open-loop flag
+ * dtx I: dtx on/off
+ *
+ * Function:
+ * Find the lag that has maximum correlation of signal in a given delay range.
+ * maximum lag = 143
+ * minimum lag = 20
+ *
+ * Returns:
+ * p_max lag found
+ */
+static Word32 Lag_max_wght( vadState *vadSt, Float32 corr[], Float32 signal[],
+ Word32 old_lag, Word32 *cor_max, Word32 wght_flg, Float32 *gain_flg,
+ Word32 dtx )
+{
+ Float32 t0, t1, max;
+ Float32 *psignal, *p1signal;
+ const Float32 *ww, *we;
+ Word32 i, j, p_max;
+
+
+ ww = &corrweight[250];
+ we = &corrweight[266 - old_lag];
+ max = -FLT_MAX;
+ p_max = PIT_MAX;
+
+ /* see if the neigbouring emphasis is used */
+ if ( wght_flg > 0 ) {
+ /* find maximum correlation with weighting */
+ for ( i = PIT_MAX; i >= PIT_MIN; i-- ) {
+ /* Weighting of the correlation function. */
+ t0 = corr[ - i] * *ww--;
+ /* Weight the neighbourhood of the old lag. */
+ t0 *= *we--;
+
+ if ( t0 >= max ) {
+ max = t0;
+ p_max = i;
+ }
+ }
+
+ }
+ else {
+ /* find maximum correlation with weighting */
+ for ( i = PIT_MAX; i >= PIT_MIN; i-- ) {
+ /* Weighting of the correlation function. */
+ t0 = corr[ - i] * *ww--;
+
+ if ( t0 >= max ) {
+ max = t0;
+ p_max = i;
+ }
+ }
+
+ }
+ psignal = &signal[0];
+ p1signal = &signal[ - p_max];
+ t0 = 0;
+ t1 = 0;
+
+ /* Compute energy */
+ for ( j = 0; j < L_FRAME_BY2; j++, psignal++, p1signal++ ) {
+ t0 += *psignal * *p1signal;
+ t1 += *p1signal * *p1signal;
+ }
+
+ if ( dtx ) {
+#ifdef VAD2
+ vadSt->Rmax += t0; /* Save max correlation */
+ vadSt->R0 += t1; /* Save max energy */
+#else
+ /* update and detect tone */
+ vad_tone_detection_update( vadSt, 0 );
+ vad_tone_detection( vadSt, t0, t1 );
+#endif
+ }
+
+ /*
+ * gain flag is set according to the open_loop gain
+ * is t2/t1 > 0.4 ?
+ */
+ *gain_flg = t0 - ( t1 * 0.4F );
+ *cor_max = 0;
+ return( p_max );
+}
+
+
+/*
+ * gmed_n
+ *
+ *
+ * Parameters:
+ * ind I: values
+ * n I: The number of gains
+ *
+ * Function:
+ * Calculates N-point median.
+ *
+ * Returns:
+ * index of the median value
+ */
+static Word32 gmed_n( Word32 ind[], Word32 n )
+{
+ Word32 i, j, ix = 0;
+ Word32 max;
+ Word32 medianIndex;
+ Word32 tmp[9];
+ Word32 tmp2[9];
+
+
+ for ( i = 0; i < n; i++ ) {
+ tmp2[i] = ind[i];
+ }
+
+ for ( i = 0; i < n; i++ ) {
+ max = -32767;
+
+ for ( j = 0; j < n; j++ ) {
+ if ( tmp2[j] >= max ) {
+ max = tmp2[j];
+ ix = j;
+ }
+ }
+ tmp2[ix] = -32768;
+ tmp[i] = ix;
+ }
+ medianIndex = tmp[( n >>1 )];
+ return( ind[medianIndex] );
+}
+
+
+/*
+ * Pitch_ol_wgh
+ *
+ *
+ * Parameters:
+ * old_T0_med O: old Cl lags median
+ * wght_flg I: weighting function flag
+ * ada_w B:
+ * vadSt B: VAD state struct
+ * signal I: signal used to compute the open loop pitch
+ * [[-pit_max]:[-1]]
+ * old_lags I: history with old stored Cl lags
+ * ol_gain_flg I: OL gain flag
+ * idx I: frame index
+ * dtx I: DTX flag
+ *
+ * Function:
+ * Open-loop pitch search with weight
+ *
+ * Open-loop pitch analysis is performed twice per frame (every 10 ms)
+ * for the 10.2 kbit/s mode to find two estimates of the pitch lag
+ * in each frame. The open-loop pitch analysis is done in order to simplify
+ * the pitch analysis and confine the closed loop pitch search to
+ * a small number of lags around the open-loop estimated lags.
+ * Open-loop pitch estimation is based on the weighted speech signal
+ * which is obtained by filtering the input speech signal through
+ * the weighting filter.
+ * The correlation of weighted speech is determined.
+ * The estimated pitch-lag is the delay that maximises
+ * the weighted autocorrelation function. To enhance pitch-lag analysis
+ * the autocorrelation function estimate is modified by a weighting window.
+ * The weighting emphasises relevant pitch-lags, thus increasing
+ * the likelihood of selecting the correct delay.
+ * minimum pitch lag = 20
+ * maximum pitch lag = 143
+ *
+ * Returns:
+ * p_max1 open loop pitch lag
+ */
+static Word32 Pitch_ol_wgh( Word32 *old_T0_med, Word16 *wght_flg, Float32 *ada_w,
+ vadState *vadSt, Float32 signal[], Word32 old_lags[], Float32 ol_gain_flg[],
+ Word16 idx, Word32 dtx )
+{
+ Float32 corr[PIT_MAX + 1];
+#ifndef VAD2
+ Float32 corr_hp_max;
+#endif
+ Float32 *corrPtr;
+ Word32 i, max1, p_max1;
+
+
+ /* calculate all coreelations of signal, from pit_min to pit_max */
+ corrPtr = &corr[PIT_MAX];
+ comp_corr( signal, L_FRAME_BY2, PIT_MAX, PIT_MIN, corrPtr );
+ p_max1 = Lag_max_wght( vadSt, corrPtr, signal, *old_T0_med,
+ &max1, *wght_flg, &ol_gain_flg[idx], dtx );
+
+ if ( ol_gain_flg[idx] > 0 ) {
+ /* Calculate 5-point median of previous lags */
+ /* Shift buffer */
+ for ( i = 4; i > 0; i-- ) {
+ old_lags[i] = old_lags[i - 1];
+ }
+ old_lags[0] = p_max1;
+ *old_T0_med = gmed_n( old_lags, 5 );
+ *ada_w = 1;
+ }
+ else {
+ *old_T0_med = p_max1;
+ *ada_w = *ada_w * 0.9F;
+ }
+
+ if ( *ada_w < 0.3 ) {
+ *wght_flg = 0;
+ }
+ else {
+ *wght_flg = 1;
+ }
+
+#ifndef VAD2
+ if ( dtx ) {
+ if ( idx == 1 ) {
+ /* calculate max high-passed filtered correlation of all lags */
+ hp_max( corrPtr, signal, L_FRAME_BY2, PIT_MAX, PIT_MIN, &corr_hp_max );
+
+ /* update complex background detector */
+ vadSt->best_corr_hp = corr_hp_max * 0.5F;
+ }
+ }
+#endif
+ return( p_max1 );
+}
+
+
+/*
+ * ol_ltp
+ *
+ *
+ * Parameters:
+ * mode I: AMR mode
+ * vadSt B: VAD state struct
+ * wsp I: signal used to compute the OL pitch
+ * T_op O: open loop pitch lag
+ * ol_gain_flg I: OL gain flag
+ * old_T0_med O: old Cl lags median
+ * wght_flg I: weighting function flag
+ * ada_w B:
+ * old_lags I: history with old stored Cl lags
+ * ol_gain_flg I: OL gain flag
+ * dtx I: DTX flag
+ * idx I: frame index
+ *
+ * Function:
+ * Compute the open loop pitch lag.
+ *
+ * Open-loop pitch analysis is performed in order to simplify
+ * the pitch analysis and confine the closed-loop pitch search to
+ * a small number of lags around the open-loop estimated lags.
+ * Open-loop pitch estimation is based on the weighted speech signal Sw(n)
+ * which is obtained by filtering the input speech signal through
+ * the weighting filter W(z) = A(z/g1) / A(z/g2). That is,
+ * in a subframe of size L, the weighted speech is given by:
+ *
+ * 10
+ * Sw(n) = S(n) + SUM[ a(i) * g1(i) * S(n-i) ]
+ * i=1
+ * 10
+ * - SUM[ a(i) * g2(i) * Sw(n-i) ], n = 0, ..., L-1
+ * i=1
+ *
+ * Returns:
+ * void
+ */
+static void ol_ltp( enum Mode mode, vadState *vadSt, Float32 wsp[], Word32 *T_op
+ , Float32 ol_gain_flg[], Word32 *old_T0_med, Word16 *wght_flg, Float32 *ada_w
+ , Word32 *old_lags, Word32 dtx, Word16 idx )
+{
+ if ( mode != MR102 ) {
+ ol_gain_flg[0] = 0;
+ ol_gain_flg[1] = 0;
+ }
+
+ if ( ( mode == MR475 ) || ( mode == MR515 ) ) {
+ *T_op = Pitch_ol( mode, vadSt, wsp, PIT_MIN, PIT_MAX, L_FRAME, dtx, idx );
+ }
+ else {
+ if ( mode <= MR795 ) {
+ *T_op = Pitch_ol( mode, vadSt, wsp, PIT_MIN, PIT_MAX, L_FRAME_BY2, dtx,
+ idx );
+ }
+ else if ( mode == MR102 ) {
+ *T_op = Pitch_ol_wgh( old_T0_med, wght_flg, ada_w, vadSt, wsp, old_lags,
+ ol_gain_flg, idx, dtx );
+ }
+ else {
+ *T_op = Pitch_ol( mode, vadSt, wsp, PIT_MIN_MR122, PIT_MAX, L_FRAME_BY2
+ , dtx, idx );
+ }
+ }
+}
+
+
+/*
+ * subframePreProc
+ *
+ *
+ * Parameters:
+ * mode I: AMR mode
+ * gamma1 I: spectral exp. factor 1
+ * gamma1_12k2 I: spectral exp. factor 1 for EFR
+ * gamma2 I: spectral exp. factor 2
+ * A I: A(z) unquantized for the 4 subframes
+ * Aq I: A(z) quantized for the 4 subframes
+ * speech I: speech segment
+ * mem_err I: pointer to error signal
+ * mem_w0 I: memory of weighting filter
+ * zero I: pointer to zero vector
+ * ai_zero O: history of weighted synth. filter
+ * exc O: long term prediction residual
+ * h1 O: impulse response
+ * xn O: target vector for pitch search
+ * res2 O: long term prediction residual
+ * error O: error of LPC synthesis filter
+ *
+ * Function:
+ * Subframe preprocessing
+ *
+ * Impulse response computation:
+ * The impulse response, h(n), of the weighted synthesis filter
+ *
+ * H(z) * W(z) = A(z/g1) / ( A'(z) * A(z/g2) )
+ *
+ * is computed each subframe. This impulse response is needed for
+ * the search of adaptive and fixed codebooks. The impulse response h(n)
+ * is computed by filtering the vector of coefficients of
+ * the filter A(z/g1) extended by zeros through the two filters
+ * 1/A'(z) and 1/A(z/g2).
+ *
+ * Target signal computation:
+ * The target signal for adaptive codebook search is usually computed
+ * by subtracting the zero input response of
+ * the weighted synthesis filter H(z) * W(z) from the weighted
+ * speech signal Sw(n). This is performed on a subframe basis.
+ * An equivalent procedure for computing the target signal is
+ * the filtering of the LP residual signal res(n) through
+ * the combination of synthesis filter 1/A'(z) and
+ * the weighting filter A(z/g1)/A(z/g2). After determining
+ * the excitation for the subframe, the initial states of
+ * these filters are updated by filtering the difference between
+ * the LP residual and excitation.
+ *
+ * The residual signal res(n) which is needed for finding
+ * the target vector is also used in the adaptive codebook search
+ * to extend the past excitation buffer. This simplifies
+ * the adaptive codebook search procedure for delays less than
+ * the subframe size of 40. The LP residual is given by:
+ *
+ * 10
+ * res(n) = S(n) + SUM[A'(i)* S(n-i)
+ * i=1
+ *
+ * Returns:
+ * void
+ */
+static void subframePreProc( enum Mode mode, const Float32 gamma1[], const
+ Float32 gamma1_12k2[], const Float32 gamma2[], Float32 *A, Float32 *Aq,
+ Float32 *speech, Float32 *mem_err, Float32 *mem_w0, Float32 *zero, Float32
+ ai_zero[], Float32 *exc, Float32 h1[], Float32 xn[], Float32 res2[],
+ Float32 error[] )
+{
+ Float32 Ap1[MP1]; /* weighted LPC coefficients */
+ Float32 Ap2[MP1]; /* weighted LPC coefficients */
+ const Float32 *g1;
+
+
+ /* mode specific pointer to gamma1 values */
+ g1 = gamma1;
+
+ if ( ( mode == MR122 ) || ( mode == MR102 ) ) {
+ g1 = gamma1_12k2;
+ }
+
+ /* Find the weighted LPC coefficients for the weighting filter. */
+ Weight_Ai( A, g1, Ap1 );
+ Weight_Ai( A, gamma2, Ap2 );
+
+ /*
+ * Compute impulse response, h1[],
+ * of weighted synthesis filter A(z/g1)/A(z/g2)
+ */
+ memcpy( ai_zero, Ap1, MP1 <<2 );
+ Syn_filt( Aq, ai_zero, h1, zero, 0 );
+ Syn_filt( Ap2, h1, h1, zero, 0 );
+
+ /*
+ * Find the target vector for pitch search:
+ */
+ /* LP residual */
+ Residu( Aq, speech, res2 );
+ memcpy( exc, res2, L_SUBFR <<2 );
+
+ /* Synthesis filter */
+ Syn_filt( Aq, exc, error, mem_err, 0 );
+ Residu( Ap1, error, xn );
+
+ /* target signal xn[] */
+ Syn_filt( Ap2, xn, xn, mem_w0, 0 );
+}
+
+
+/*
+ * getRange
+ *
+ *
+ * Parameters:
+ * T0 I: integer pitch
+ * delta_low I: search start offset
+ * delta_range I: search range
+ * pitmin I: minimum pitch
+ * pitmax I: maximum pitch
+ * T0_min I: search range minimum
+ * T0_max I: search range maximum
+ *
+ * Function:
+ * Sets range around open-loop pitch or integer pitch of last subframe
+ *
+ * Takes integer pitch T0 and calculates a range around it with
+ * T0_min = T0-delta_low and T0_max = (T0-delta_low) + delta_range
+ * T0_min and T0_max are bounded by pitmin and pitmax
+ *
+ * Returns:
+ * void
+ */
+static void getRange( Word32 T0, Word16 delta_low, Word16 delta_range,
+ Word16 pitmin, Word16 pitmax, Word32 *T0_min, Word32 *T0_max )
+{
+ *T0_min = T0 - delta_low;
+
+ if ( *T0_min < pitmin ) {
+ *T0_min = pitmin;
+ }
+ *T0_max = *T0_min + delta_range;
+
+ if ( *T0_max > pitmax ) {
+ *T0_max = pitmax;
+ *T0_min = *T0_max - delta_range;
+ }
+}
+
+
+/*
+ * Norm_Corr
+ *
+ *
+ * Parameters:
+ * exc I: excitation buffer [L_SUBFR]
+ * xn I: target vector [L_SUBFR]
+ * h I: impulse response of synthesis and weighting filters
+ * [L_SUBFR]
+ * t_min I: interval to compute normalized correlation
+ * t_max I: interval to compute normalized correlation
+ * corr_norm O: Normalized correlation [wT_min-wT_max]
+ *
+ * Function:
+ * Normalized correlation
+ *
+ * The closed-loop pitch search is performed by minimizing
+ * the mean-square weighted error between the original and
+ * synthesized speech. This is achieved by maximizing the term:
+ *
+ * 39 39
+ * R(k) = SUM[ X(n) * Yk(n)) ] / SQRT[ SUM[ Yk(n) * Yk(n)] ]
+ * n=0 n=0
+ *
+ * where X(n) is the target signal and Yk(n) is the past filtered
+ * excitation at delay k (past excitation convolved with h(n) ).
+ * The search range is limited around the open-loop pitch.
+ *
+ * The convolution Yk(n) is computed for the first delay t_min in
+ * the searched range, and for the other delays in the search range
+ * k = t_min + 1, ..., t_max, it is updated using the recursive relation:
+ *
+ * Yk(n) = Yk-1(n-1) + u(-k) * h(n),
+ *
+ * where u(n), n = -( 143 + 11 ), ..., 39, is the excitation buffer.
+ * Note that in search stage, the samples u(n), n = 0, ..., 39,
+ * are not known, and they are needed for pitch delays less than 40.
+ * To simplify the search, the LP residual is copied to u(n) in order
+ * to make the relation in above equation valid for all delays.
+ *
+ * Returns:
+ * void
+ */
+static void Norm_Corr( Float32 exc[], Float32 xn[], Float32 h[], Word32 t_min,
+ Word32 t_max, Float32 corr_norm[] )
+{
+ Float32 exc_temp[L_SUBFR];
+ Float32 *p_exc;
+ Float32 corr, norm;
+ Float32 sum;
+ Word32 i, j, k;
+
+
+ k = -t_min;
+ p_exc = &exc[ - t_min];
+
+ /* compute the filtered excitation for the first delay t_min */
+ /* convolution Yk(n) */
+ for ( j = 0; j < L_SUBFR; j++ ) {
+ sum = 0;
+
+ for ( i = 0; i <= j; i++ ) {
+ sum += p_exc[i] * h[j - i];
+ }
+ exc_temp[j] = sum;
+ }
+
+ /* loop for every possible period */
+ for ( i = t_min; i <= t_max; i++ ) {
+ /* 39 */
+ /* SQRT[ SUM[ Yk(n) * Yk(n)] ] */
+ /* n=0 */
+ norm = (Float32)Dotproduct40( exc_temp, exc_temp );
+
+ if ( norm == 0 )
+ norm = 1.0;
+ else
+ norm = ( Float32 )( 1.0 / ( sqrt( norm ) ) );
+
+ /* 39 */
+ /* SQRT[ SUM[ X(n) * Yk(n)] ] */
+ /* n=0 */
+ corr = (Float32)Dotproduct40( xn, exc_temp );
+
+ /* R(k) */
+ corr_norm[i] = corr * norm;
+
+ /* modify the filtered excitation exc_tmp[] for the next iteration */
+ if ( i != t_max ) {
+ k--;
+
+ for ( j = L_SUBFR - 1; j > 0; j-- ) {
+ /* Yk(n) = Yk-1(n-1) + u(-k) * h(n) */
+ exc_temp[j] = exc_temp[j - 1] + exc[k] * h[j];
+ }
+ exc_temp[0] = exc[k];
+ }
+ }
+}
+
+
+/*
+ * Interpol_3or6
+ *
+ *
+ * Parameters:
+ * x I: input vector
+ * frac I: fraction (-2..2 for 3*, -3..3 for 6*)
+ * flag3 I: if set, upsampling rate = 3 (6 otherwise)
+ *
+ * Function:
+ * Interpolating the normalized correlation with 1/3 or 1/6 resolution.
+ *
+ * The interpolation is performed using an FIR filter b24
+ * based on a Hamming windowed sin(x)/x function truncated at ±23
+ * and padded with zeros at ±24 (b24(24) = 0). The filter has its
+ * cut-off frequency (-3 dB) at 3 600 Hz in the over-sampled domain.
+ * The interpolated values of R(k) for the fractions -3/6 to 3/6
+ * are obtained using the interpolation formula:
+ *
+ * 3 3
+ * R(k)t = SUM[ R(k-i) * b24(t+i*6) ] + SUM [ R(k+1+i) * b24(6-t+i*6) ],
+ * i=0 i=0
+ * t = 0, ..., 5,
+ *
+ * where t = 0, ..., 5, corresponds to the fractions
+ * 0, 1/6, 2/6, 3/6, -2/6, and -1/6, respectively. Note that it is
+ * necessary to compute the correlation terms using a range t_min - 4,
+ * t_max + 4, to allow for the proper interpolation.
+ *
+ * Returns:
+ * s interpolated value
+ */
+static Float32 Interpol_3or6( Float32 *x, Word32 frac, Word16 flag3 )
+{
+ Float32 s;
+ Float32 *x1, *x2;
+ const Float32 *c1, *c2;
+ Word32 i, k;
+
+
+ if ( flag3 != 0 ) {
+ /* inter_3[k] = b60[2*k] -> k' = 2*k */
+ frac <<= 1;
+ }
+
+ if ( frac < 0 ) {
+ frac += UP_SAMP_MAX;
+ x--;
+ }
+ x1 = &x[0];
+ x2 = &x[1];
+ c1 = &b24[frac];
+ c2 = &b24[UP_SAMP_MAX - frac];
+ s = 0;
+
+ for ( i = 0, k = 0; i < L_INTER_SRCH; i++, k += UP_SAMP_MAX ) {
+ /* R(k-i) * b24(t+i*6) */
+ s += x1[ - i] * c1[k];
+
+ /* R(k+1+i) * b24(6-t+i*6) */
+ s += x2[i] * c2[k];
+ }
+ return s;
+}
+
+
+/*
+ * searchFrac
+ *
+ *
+ * Parameters:
+ * lag B: integer pitch
+ * frac B: start point of search - fractional pitch
+ * last_frac I: endpoint of search
+ * corr I: normalized correlation
+ * flag3 I: if set, upsampling rate = 3 (6 otherwise)
+ *
+ * Function:
+ * Find fractional pitch
+ *
+ * The function interpolates the normalized correlation at the
+ * fractional positions around lag T0. The position at which the
+ * interpolation function reaches its maximum is the fractional pitch.
+ * Starting point of the search is frac, end point is last_frac.
+ * frac is overwritten with the fractional pitch.
+ *
+ * Returns:
+ * void
+ */
+static void searchFrac( Word32 *lag, Word32 *frac, Word16 last_frac, Float32
+ corr[], Word16 flag3 )
+{
+ Float32 max, corr_int;
+ Word32 i;
+
+
+ /*
+ * Test the fractions around T0 and choose the one which maximizes
+ * the interpolated normalized correlation.
+ */
+ max = Interpol_3or6( &corr[ * lag], *frac, flag3 );
+
+ for ( i = *frac + 1; i <= last_frac; i++ ) {
+ corr_int = Interpol_3or6( &corr[ * lag], i, flag3 );
+
+ if ( corr_int > max ) {
+ max = corr_int;
+ *frac = i;
+ }
+ }
+
+ if ( flag3 == 0 ) {
+ /* Limit the fraction value in the interval [-2,-1,0,1,2,3] */
+ if ( *frac == -3 ) {
+ *frac = 3;
+ *lag -= 1;
+ }
+ }
+ else {
+ /* limit the fraction value between -1 and 1 */
+ if ( *frac == -2 ) {
+ *frac = 1;
+ *lag -= 1;
+ }
+
+ if ( *frac == 2 ) {
+ *frac = -1;
+ *lag += 1;
+ }
+ }
+}
+
+
+/*
+ * Enc_lag3
+ *
+ *
+ * Parameters:
+ * T0 I: Pitch delay
+ * T0_frac I: Fractional pitch delay
+ * T0_prev I: Integer pitch delay of last subframe
+ * T0_min I: minimum of search range
+ * T0_max I: maximum of search range
+ * delta_flag I: Flag for 1st (or 3rd) subframe
+ * flag4 I: Flag for encoding with 4 bits
+ *
+ * Function:
+ * Encoding of fractional pitch lag with 1/3 resolution.
+ *
+ * Returns:
+ * index index of encoding
+ */
+static Word32 Enc_lag3( Word32 T0, Word32 T0_frac, Word32 T0_prev, Word32 T0_min
+ , Word32 T0_max, Word16 delta_flag, Word16 flag4 )
+{
+ Word32 index, i, tmp_ind, uplag, tmp_lag;
+
+
+ /* if 1st or 3rd subframe */
+ if ( delta_flag == 0 ) {
+ /* encode pitch delay (with fraction) */
+ if ( T0 <= 85 ) {
+ index = T0 * 3 - 58 + T0_frac;
+ }
+ else {
+ index = T0 + 112;
+ }
+ }
+
+ /* if second or fourth subframe */
+ else {
+ if ( flag4 == 0 ) {
+ /* 'normal' encoding: either with 5 or 6 bit resolution */
+ index = 3 * ( T0 - T0_min ) + 2 + T0_frac;
+ }
+ else {
+ /* encoding with 4 bit resolution */
+ tmp_lag = T0_prev;
+
+ if ( ( tmp_lag - T0_min ) > 5 )
+ tmp_lag = T0_min + 5;
+
+ if ( ( T0_max - tmp_lag ) > 4 )
+ tmp_lag = T0_max - 4;
+ uplag = T0 + T0 + T0 + T0_frac;
+ i = tmp_lag - 2;
+ tmp_ind = i + i + i;
+
+ if ( tmp_ind >= uplag ) {
+ index = ( T0 - tmp_lag ) + 5;
+ }
+ else {
+ i = tmp_lag + 1;
+ i = i + i + i;
+
+ if ( i > uplag ) {
+ index = ( uplag - tmp_ind ) + 3;
+ }
+ else {
+ index = ( T0 - tmp_lag ) + 11;
+ }
+ }
+ } /* end if (encoding with 4 bit resolution) */
+ } /* end if (second of fourth subframe) */
+ return index;
+}
+
+
+/*
+ * Enc_lag6
+ *
+ *
+ * Parameters:
+ * T0 I: Pitch delay
+ * T0_frac I: Fractional pitch delay
+ * T0_min I: minimum of search range
+ * delta_flag I: Flag for 1st (or 3rd) subframe
+ *
+ * Function:
+ * Encoding of fractional pitch lag with 1/6 resolution.
+ *
+ * First and third subframes:
+ * The pitch range is divided as follows:
+ * 17 3/6 to 94 3/6 resolution 1/6
+ * 95 to 143 resolution 1
+ * The period is encoded with 9 bits.
+ * For the range with fractions:
+ * index = (T-17)*6 + frac - 3;
+ * where T=[17..94] and frac=[-2,-1,0,1,2,3]
+ * and for the integer only range
+ * index = (T - 95) + 463;
+ * where T=[95..143]
+ * Second and fourth subframes:
+ * For the 2nd and 4th subframes a resolution of 1/6 is always used,
+ * and the search range is relative to the lag in previous subframe.
+ * If T0 is the lag in the previous subframe then
+ * t_min=T0-5 and t_max=T0+4 and the range is given by
+ * (t_min-1) 3/6 to (t_max) 3/6
+ * The period in the 2nd (and 4th) subframe is encoded with 6 bits:
+ * index = (T-(t_min-1))*6 + frac - 3;
+ * where T=[t_min-1..t_max] and frac=[-2,-1,0,1,2,3]
+ * Note that only 61 values are used. If the decoder receives 61, 62,
+ * or 63 as the relative pitch index, it means that a transmission
+ * error occurred and the pitch from previous subframe should be used.
+ *
+ * Returns:
+ * index index of encoding
+ */
+static Word32 Enc_lag6( Word32 T0, Word32 T0_frac, Word32 T0_min, Word16
+ delta_flag )
+{
+ Word32 index;
+
+
+ /* if 1st or 3rd subframe */
+ if ( delta_flag == 0 ) {
+ /* encode pitch delay (with fraction) */
+ if ( T0 <= 94 ) {
+ /* index = (t-17)*6 + frac - 3 */
+ index = T0 * 6 - 105 + T0_frac;
+ }
+ else {
+ /* index = (t - 95) + 463 */
+ index = T0 + 368;
+ }
+ }
+
+ /* if second or fourth subframe */
+ else {
+ /* index = (t-(t_min-1))*6 + frac - 3 */
+ index = 6 * ( T0 - T0_min ) + 3 + T0_frac;
+ }
+ return index;
+}
+
+
+/*
+ * Pitch_fr
+ *
+ *
+ * Parameters:
+ * T0_prev_subframe B: integer pitch lag of previous sub-frame
+ * mode I: codec mode
+ * T_op I: open-loop pitch estimations for
+ * the 2 big subframes [2]
+ * exc I: excitation buffer
+ * xn I: target vector
+ * h I: impulse response of synthesis
+ * and weighting filters
+ * i_subfr I: subframe number
+ * pit_frac O: pitch period (fractional)
+ * resu3 O: subsample resolution 1/3 (=1) or 1/6 (=0)
+ * ana_index O: index of encoding
+ *
+ * Function:
+ * Closed-loop pitch search
+ *
+ * In the first and third subframes, a fractional pitch delay is used
+ * with resolutions: 1/6 in the range [17 3/6, 94 3/6] and integers only
+ * in the range [95, 143]. For the second and fourth subframes,
+ * a pitch resolution of 1/6 is always used in
+ * the range [T1 - 5 3/6, T1 + 4 /3/6], where T1 is nearest integer to
+ * the fractional pitch lag of the previous (1st or 3rd) subframe,
+ * bounded by 18...143.
+ *
+ * Closed-loop pitch analysis is performed around
+ * the open-loop pitch estimates on a subframe basis.
+ * In the first (and third) subframe the range Top±3,
+ * bounded by 18...143, is searched. For the other subframes,
+ * closed-loop pitch analysis is performed around the integer pitch
+ * selected in the previous subframe, as described above.
+ * The pitch delay is encoded with 9 bits in the first and
+ * third subframes and the relative delay of the other subframes
+ * is encoded with 6 bits.
+ *
+ * The closed-loop pitch search is performed by minimizing
+ * the mean-square weighted error between the original and
+ * synthesized speech. This is achieved by maximizing the term:
+ *
+ * 39 39
+ * R(k) = SUM[ X(n) * Yk(n)) ] / SQRT[ SUM[ Yk(n) * Yk(n)] ]
+ * n=0 n=0
+ *
+ * where X(n) is the target signal and Yk(n) is the past filtered
+ * excitation at delay k (past excitation convolved with h(n) ).
+ *
+ * Once the optimum integer pitch delay is determined, the fractions
+ * from -3/6 to 3/6 with a step of 1/6 around that integer are tested.
+ * The fractional pitch search is performed by interpolating
+ * the normalized correlation R(k) and searching for its maximum.
+ * The interpolation is performed using an FIR filter b24
+ * based on a Hamming windowed sin(x)/x function truncated at ±23
+ * and padded with zeros at ±24 (b24(24) = 0). The filter has its
+ * cut-off frequency (-3 dB) at 3 600 Hz in the over-sampled domain.
+ * The interpolated values of R(k) for the fractions -3/6 to 3/6
+ * are obtained using the interpolation formula:
+ *
+ * 3 3
+ * R(k)t = SUM[ R(k-i) * b24(t+i*6) ] + SUM [ R(k+1+i) * b24(6-t+i*6) ],
+ * i=0 i=0
+ * t = 0, ..., 5,
+ *
+ * where t = 0, ..., 5, corresponds to the fractions
+ * 0, 1/6, 2/6, 3/6, -2/6, and -1/6, respectively. Note that it is
+ * necessary to compute the correlation terms using a range t_min -4,
+ * t_max + 4, to allow for the proper interpolation.
+ *
+ * Returns:
+ * lag closed-loop pitch lag
+ */
+static Word32 Pitch_fr( Word32 *T0_prev_subframe, enum Mode mode, Word32 T_op[],
+ Float32 exc[], Float32 xn[], Float32 h[], Word16 i_subfr, Word32 *pit_frac
+ , Word16 *resu3, Word32 *ana_index )
+{
+ Float32 corr_v[40];
+ Float32 max;
+ Float32 *corr;
+ Word32 i, t_min, t_max, T0_min, T0_max;
+ Word32 lag, frac, tmp_lag;
+ Word16 max_frac_lag, flag3, flag4, last_frac;
+ Word16 delta_int_low, delta_int_range, delta_frc_low, delta_frc_range;
+ Word16 pit_min;
+ Word16 frame_offset;
+ Word16 delta_search;
+
+
+ /* set mode specific variables */
+ max_frac_lag = mode_dep_parm[mode].max_frac_lag;
+ flag3 = mode_dep_parm[mode].flag3;
+ frac = mode_dep_parm[mode].first_frac;
+ last_frac = mode_dep_parm[mode].last_frac;
+ delta_int_low = mode_dep_parm[mode].delta_int_low;
+ delta_int_range = mode_dep_parm[mode].delta_int_range;
+ delta_frc_low = mode_dep_parm[mode].delta_frc_low;
+ delta_frc_range = mode_dep_parm[mode].delta_frc_range;
+ pit_min = mode_dep_parm[mode].pit_min;
+
+ /* decide upon full or differential search */
+ delta_search = 1;
+
+ if ( ( i_subfr == 0 ) || ( i_subfr == L_FRAME_BY2 ) ) {
+ /* Subframe 1 and 3 */
+ if ( ( ( mode != MR475 ) && ( mode != MR515 ) ) || ( i_subfr !=
+ L_FRAME_BY2 ) ) {
+ /*
+ * set T0_min, T0_max for full search
+ * this is *not* done for mode MR475, MR515 in subframe 3
+ */
+ delta_search = 0; /* no differential search */
+
+ /*
+ * calculate index into T_op which contains the open-loop
+ * pitch estimations for the 2 big subframes
+ */
+ frame_offset = 1;
+
+ if ( i_subfr == 0 )
+ frame_offset = 0;
+
+ /*
+ * get T_op from the corresponding half frame and
+ * set T0_min, T0_max
+ */
+ getRange( T_op[frame_offset], delta_int_low, delta_int_range, pit_min,
+ PIT_MAX, &T0_min, &T0_max );
+ }
+ else {
+ /* mode MR475, MR515 and 3. Subframe: delta search as well */
+ getRange( *T0_prev_subframe, delta_frc_low, delta_frc_range, pit_min,
+ PIT_MAX, &T0_min, &T0_max );
+ }
+ }
+ else {
+ /*
+ * for Subframe 2 and 4
+ * get range around T0 of previous subframe for delta search
+ */
+ getRange( *T0_prev_subframe, delta_frc_low, delta_frc_range, pit_min,
+ PIT_MAX, &T0_min, &T0_max );
+ }
+
+ /* Find interval to compute normalized correlation */
+ t_min = T0_min - L_INTER_SRCH;
+ t_max = T0_max + L_INTER_SRCH;
+ corr = &corr_v[ - t_min];
+
+ /* Compute normalized correlation between target and filtered excitation */
+ Norm_Corr( exc, xn, h, t_min, t_max, corr );
+
+ /* Find integer pitch */
+ max = corr[T0_min];
+ lag = T0_min;
+
+ for ( i = T0_min + 1; i <= T0_max; i++ ) {
+ if ( corr[i] >= max ) {
+ max = corr[i];
+ lag = i;
+ }
+ }
+
+ /* Find fractional pitch */
+ if ( ( delta_search == 0 ) && ( lag > max_frac_lag ) ) {
+ /*
+ * full search and integer pitch greater than max_frac_lag
+ * fractional search is not needed, set fractional to zero
+ */
+ frac = 0;
+ }
+ else {
+ /*
+ * if differential search AND mode MR475 OR MR515 OR MR59 OR MR67
+ * then search fractional with 4 bits resolution
+ */
+ if ( ( delta_search != 0 ) && ( ( mode == MR475 ) || ( mode == MR515 ) ||
+ ( mode == MR59 ) || ( mode == MR67 ) ) ) {
+ /*
+ * modify frac or last_frac according to position of last
+ * integer pitch: either search around integer pitch,
+ * or only on left or right side
+ */
+ tmp_lag = *T0_prev_subframe;
+
+ if ( ( tmp_lag - T0_min ) > 5 )
+ tmp_lag = T0_min + 5;
+
+ if ( ( T0_max - tmp_lag ) > 4 )
+ tmp_lag = T0_max - 4;
+
+ if ( ( lag == tmp_lag ) || ( lag == ( tmp_lag - 1 ) ) ) {
+ /* normal search in fractions around T0 */
+ searchFrac( &lag, &frac, last_frac, corr, flag3 );
+ }
+ else if ( lag == ( tmp_lag - 2 ) ) {
+ /* limit search around T0 to the right side */
+ frac = 0;
+ searchFrac( &lag, &frac, last_frac, corr, flag3 );
+ }
+ else if ( lag == ( tmp_lag + 1 ) ) {
+ /* limit search around T0 to the left side */
+ last_frac = 0;
+ searchFrac( &lag, &frac, last_frac, corr, flag3 );
+ }
+ else {
+ /* no fractional search */
+ frac = 0;
+ }
+ }
+ else
+
+ /* test the fractions around T0 */
+ searchFrac( &lag, &frac, last_frac, corr, flag3 );
+ }
+
+ /*
+ * encode pitch
+ */
+ if ( flag3 != 0 ) {
+ /*
+ * flag4 indicates encoding with 4 bit resolution;
+ * this is needed for mode MR475, MR515 and MR59
+ */
+ flag4 = 0;
+
+ if ( ( mode == MR475 ) || ( mode == MR515 ) || ( mode == MR59 ) || ( mode
+ == MR67 ) ) {
+ flag4 = 1;
+ }
+
+ /* encode with 1/3 subsample resolution */
+ *ana_index = Enc_lag3( lag, frac, *T0_prev_subframe, T0_min, T0_max,
+ delta_search, flag4 );
+ }
+ else {
+ /* encode with 1/6 subsample resolution */
+ *ana_index = Enc_lag6( lag, frac, T0_min, delta_search );
+ }
+
+ /*
+ * update state variables
+ */
+ *T0_prev_subframe = lag;
+
+ /*
+ * update output variables
+ */
+ *resu3 = flag3;
+ *pit_frac = frac;
+ return( lag );
+}
+
+
+/*
+ * Pred_lt_3or6
+ *
+ *
+ * Parameters:
+ * exc B: excitation buffer
+ * T0 I: integer pitch lag
+ * frac I: fraction of lag
+ * flag3 I: if set, upsampling rate = 3 (6 otherwise)
+ *
+ * Function:
+ * Compute the result of long term prediction with fractional
+ * interpolation of resolution 1/3 or 1/6. (Interpolated past excitation).
+ *
+ * Once the fractional pitch lag is determined,
+ * the adaptive codebook vector v(n) is computed by interpolating
+ * the past excitation signal u(n) at the given integer delay k
+ * and phase (fraction) :
+ *
+ * 9 9
+ * v(n) = SUM[ u(n-k-i) * b60(t+i*6) ] + SUM[ u(n-k+1+i) * b60(6-t+i*6) ],
+ * i=0 i=0
+ * n = 0, ...,39, t = 0, ...,5.
+ *
+ * The interpolation filter b60 is based on a Hamming windowed sin(x)/x
+ * function truncated at ± 59 and padded with zeros at ± 60 (b60(60)=0)).
+ * The filter has a cut-off frequency (-3 dB) at 3 600 Hz in
+ * the over-sampled domain.
+ *
+ * Returns:
+ * void
+ */
+static void Pred_lt_3or6( Float32 exc[], Word32 T0, Word32 frac, Word16 flag3 )
+{
+ Float32 s;
+ Float32 *x0, *x1, *x2;
+ const Float32 *c1, *c2;
+ Word32 j;
+
+
+ x0 = &exc[ - T0];
+ frac = -frac;
+
+ if ( flag3 != 0 ) {
+ /* inter_3l[k] = b60[2*k] -> k' = 2*k */
+ frac <<= 1;
+ }
+
+ if ( frac < 0 ) {
+ frac += UP_SAMP_MAX;
+ x0--;
+ }
+ c1 = &b60[frac];
+ c2 = &b60[UP_SAMP_MAX - frac];
+
+ for ( j = 0; j < L_SUBFR; j += 4 ) {
+ x1 = x0++;
+ x2 = x0;
+ s = x1[0] * c1[0] + x2[0] * c2[0];
+ s += x1[ - 1] *c1[6] + x2[1] * c2[6];
+ s += x1[ - 2] * c1[12] + x2[2] * c2[12];
+ s += x1[ - 3] * c1[18] + x2[3] * c2[18];
+ s += x1[ - 4] * c1[24] + x2[4] * c2[24];
+ s += x1[ - 5] * c1[30] + x2[5] * c2[30];
+ s += x1[ - 6] * c1[36] + x2[6] * c2[36];
+ s += x1[ - 7] * c1[42] + x2[7] * c2[42];
+ s += x1[ - 8] * c1[48] + x2[8] * c2[48];
+ s += x1[ - 9] * c1[54] + x2[9] * c2[54];
+ exc[j] = ( Float32 )floor(s + 0.5F);
+ x1 = x0++;
+ x2 = x0;
+ s = x1[0] * c1[0] + x2[0] * c2[0];
+ s += x1[ - 1] *c1[6] + x2[1] * c2[6];
+ s += x1[ - 2] * c1[12] + x2[2] * c2[12];
+ s += x1[ - 3] * c1[18] + x2[3] * c2[18];
+ s += x1[ - 4] * c1[24] + x2[4] * c2[24];
+ s += x1[ - 5] * c1[30] + x2[5] * c2[30];
+ s += x1[ - 6] * c1[36] + x2[6] * c2[36];
+ s += x1[ - 7] * c1[42] + x2[7] * c2[42];
+ s += x1[ - 8] * c1[48] + x2[8] * c2[48];
+ s += x1[ - 9] * c1[54] + x2[9] * c2[54];
+ exc[j + 1] = ( Float32 )floor(s + 0.5F);
+ x1 = x0++;
+ x2 = x0;
+ s = x1[0] * c1[0] + x2[0] * c2[0];
+ s += x1[ - 1] *c1[6] + x2[1] * c2[6];
+ s += x1[ - 2] * c1[12] + x2[2] * c2[12];
+ s += x1[ - 3] * c1[18] + x2[3] * c2[18];
+ s += x1[ - 4] * c1[24] + x2[4] * c2[24];
+ s += x1[ - 5] * c1[30] + x2[5] * c2[30];
+ s += x1[ - 6] * c1[36] + x2[6] * c2[36];
+ s += x1[ - 7] * c1[42] + x2[7] * c2[42];
+ s += x1[ - 8] * c1[48] + x2[8] * c2[48];
+ s += x1[ - 9] * c1[54] + x2[9] * c2[54];
+ exc[j + 2] = ( Float32 )floor(s + 0.5F);
+ x1 = x0++;
+ x2 = x0;
+ s = x1[0] * c1[0] + x2[0] * c2[0];
+ s += x1[ - 1] *c1[6] + x2[1] * c2[6];
+ s += x1[ - 2] * c1[12] + x2[2] * c2[12];
+ s += x1[ - 3] * c1[18] + x2[3] * c2[18];
+ s += x1[ - 4] * c1[24] + x2[4] * c2[24];
+ s += x1[ - 5] * c1[30] + x2[5] * c2[30];
+ s += x1[ - 6] * c1[36] + x2[6] * c2[36];
+ s += x1[ - 7] * c1[42] + x2[7] * c2[42];
+ s += x1[ - 8] * c1[48] + x2[8] * c2[48];
+ s += x1[ - 9] * c1[54] + x2[9] * c2[54];
+ exc[j + 3] = ( Float32 )floor(s + 0.5F);
+ }
+ return;
+}
+
+static void Pred_lt_3or6_fixed( Word32 exc[], Word32 T0, Word32 frac, Word32 flag3 )
+{
+ Word32 s, i;
+ Word32 *x0, *x1, *x2;
+ const Word32 *c1, *c2;
+
+ x0 = &exc[ - T0];
+ frac = -frac;
+
+ if ( flag3 != 0 ) {
+ frac <<= 1; /* inter_3l[k] = inter6[2*k] -> k' = 2*k */
+ }
+
+ if ( frac < 0 ) {
+ frac += 6;
+ x0--;
+ }
+ c1 = &inter6[frac];
+ c2 = &inter6[6 - frac];
+
+ for ( i = 0; i < 40; i++ ) {
+ x1 = x0++;
+ x2 = x0;
+ s = x1[0] * c1[0];
+ s += x1[ - 1] * c1[6];
+ s += x1[ - 2] * c1[12];
+ s += x1[ - 3] * c1[18];
+ s += x1[ - 4] * c1[24];
+ s += x1[ - 5] * c1[30];
+ s += x1[ - 6] * c1[36];
+ s += x1[ - 7] * c1[42];
+ s += x1[ - 8] * c1[48];
+ s += x1[ - 9] * c1[54];
+ s += x2[0] * c2[0];
+ s += x2[1] * c2[6];
+ s += x2[2] * c2[12];
+ s += x2[3] * c2[18];
+ s += x2[4] * c2[24];
+ s += x2[5] * c2[30];
+ s += x2[6] * c2[36];
+ s += x2[7] * c2[42];
+ s += x2[8] * c2[48];
+ s += x2[9] * c2[54];
+ exc[i] = ( s + 0x4000 ) >> 15;
+
+ }
+}
+
+
+/*
+ * G_pitch
+ *
+ *
+ * Parameters:
+ * xn I: Pitch target
+ * y1 I: Filtered adaptive codebook
+ * gCoeff O: Correlations need for gain quantization
+ *
+ * Function:
+ * Compute the pitch (adaptive codebook) gain.
+ *
+ * The adaptive codebook gain is given by
+ *
+ * g = <x[], y[]> / <y[], y[]>
+ *
+ * where x[] is the target vector, y[] is the filtered adaptive
+ * codevector, and <> denotes dot product.
+ *
+ * Returns:
+ * gain gain saturated to 1.2
+ */
+static Float32 G_pitch( Float32 xn[], Float32 y1[], Float32 gCoeff[] )
+{
+ Float32 gain, sum;
+
+
+ /* Compute scalar product <y1[],y1[]> */
+ sum = (Float32)Dotproduct40( y1, y1 );
+
+ /* Avoid case of all zeros */
+ sum += 0.01F;
+ gCoeff[0] = sum;
+
+ /* Compute scalar product <xn[],y1[]> */
+ sum = (Float32)Dotproduct40( xn, y1 );
+ gCoeff[1] = sum;
+
+ /* compute gain = xy/yy */
+ gain = ( Float32 )( gCoeff[1] / gCoeff[0] );
+
+ /* if(gain >1.2) gain = 1.2 */
+ if ( gain < 0.0 )
+ gain = 0.0F;
+
+ if ( gain > 1.2 )
+ gain = 1.2F;
+ return( gain );
+}
+
+
+/*
+ * check_gp_clipping
+ *
+ *
+ * Parameters:
+ * gp I: old pitch gains
+ * g_pitch I: pitch gain
+ *
+ * Function:
+ * Verify that the sum of the last (N_FRAME+1) pitch gains is under
+ * a certain threshold.
+ *
+ * Returns:
+ * True or false
+ */
+static Word16 check_gp_clipping( Float32 *gp, Float32 g_pitch )
+{
+ Float32 sum;
+ Word32 i;
+
+
+ sum = g_pitch;
+
+ for ( i = 0; i < N_FRAME; i++ ) {
+ sum += gp[i];
+ }
+
+ if ( sum > 7.6F /*FGP_CLIP*/ ) {
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+
+
+/*
+ * q_gain_pitch
+ *
+ *
+ * Parameters:
+ * mode I: codec mode
+ * gp_limit I: pitch gain limit
+ * gain B: Pitch gain (unquant/quant)
+ * gain_cand O: pitch gain candidates (3), MR795 only
+ * gain_cind O: pitch gain cand. indices (3),MR795 only
+ *
+ * Function:
+ * Closed-loop pitch search
+ *
+ * Returns:
+ * index index of quantization
+ */
+static Word16 q_gain_pitch( enum Mode mode, Float32 gp_limit, Float32 *gain,
+ Float32 gain_cand[], Word32 gain_cind[] )
+{
+ Float32 err_min, err;
+ Word32 i, index;
+
+
+ err_min = ( Float32 )fabs( *gain - qua_gain_pitch[0] );
+ index = 0;
+
+ for ( i = 1; i < NB_QUA_PITCH; i++ ) {
+ if ( qua_gain_pitch[i] <= gp_limit ) {
+ err = ( Float32 )fabs( *gain - qua_gain_pitch[i] );
+
+ if ( err < err_min ) {
+ err_min = err;
+ index = i;
+ }
+ }
+ }
+
+ if ( mode == MR795 ) {
+ /*
+ * in MR795 mode, compute three gain_pit candidates around the index
+ * found in the quantization loop: the index found and the two direct
+ * neighbours, except for the extreme cases (i=0 or i=NB_QUA_PITCH-1),
+ * where the direct neighbour and the neighbour to that is used.
+ */
+ Word32 ii;
+
+
+ if ( index == 0 ) {
+ ii = index;
+ }
+ else {
+ ii = index - 1;
+
+ if ( index == ( NB_QUA_PITCH - 1 ) || ( qua_gain_pitch[index + 1] >
+ gp_limit ) ) {
+ ii = index - 2;
+ }
+ }
+
+ /* store candidate indices and values */
+ for ( i = 0; i < 3; i++ ) {
+ gain_cind[i] = ii;
+ gain_cand[i] = qua_gain_pitch[ii];
+ ii++;
+ }
+ *gain = qua_gain_pitch[index];
+ }
+ else {
+ /* return the index and gain pitch found */
+ *gain = qua_gain_pitch_MR122[index];
+ }
+ return( Word16 )index;
+}
+
+
+/*
+ * cl_ltp
+ *
+ *
+ * Parameters:
+ * T0_prev_subframe B: Integer pitch lag of previous sub-frame
+ * gp I: Gain history
+ * mode I: Coder mode
+ * frame_offset I: Offset to subframe
+ * T_op I: Open loop pitch lags
+ * h1 I: Impulse response vector
+ * exc B: Excitation vector
+ * res2 B: Long term prediction residual
+ * xn I: Target vector for pitch search
+ * lsp_flag I: LSP resonance flag
+ * xn2 O: Target vector for codebook search
+ * y1 O: Filtered adaptive excitation
+ * T0 O: Pitch delay (integer part)
+ * T0_frac O: Pitch delay (fractional part)
+ * gain_pit O: Pitch gain
+ * gCoeff[] O: Correlations between xn, y1, & y2
+ * anap O: Analysis parameters
+ * gp_limit O: pitch gain limit
+ *
+ * Function:
+ * Closed-loop ltp search
+ *
+ * Adaptive codebook search is performed on a subframe basis.
+ * It consists of performing closed-loop pitch search, and then computing
+ * the adaptive codevector by interpolating the past excitation at
+ * the selected fractional pitch lag.
+ * The adaptive codebook parameters (or pitch parameters) are
+ * the delay and gain of the pitch filter. In the adaptive codebook approach
+ * for implementing the pitch filter, the excitation is repeated for delays
+ * less than the subframe length. In the search stage, the excitation is
+ * extended by the LP residual to simplify the closed-loop search.
+ *
+ * Returns:
+ * void
+ */
+static void cl_ltp( Word32 *T0_prev_subframe, Float32 *gp, enum Mode mode,
+ Word16 frame_offset, Word32 T_op[], Float32 *h1, Float32 *exc, Float32
+ res2[], Float32 xn[], Word16 lsp_flag, Float32 xn2[], Float32 y1[], Word32
+ *T0, Word32 *T0_frac, Float32 *gain_pit, Float32 gCoeff[], Word16 **anap,
+ Float32 *gp_limit )
+{
+ Float32 s;
+ Word32 i, n;
+ Word16 gpc_flag, resu3; /* flag for upsample resolution */
+
+ Word32 exc_tmp[314];
+ Word32 *exc_tmp_p;
+
+ exc_tmp_p = exc_tmp + PIT_MAX + L_INTERPOL;
+
+
+ /* Closed-loop fractional pitch search */
+ *T0 = Pitch_fr( T0_prev_subframe, mode, T_op, exc, xn, h1, frame_offset,
+ T0_frac, &resu3, &i );
+ *( *anap )++ = ( Word16 )i;
+
+ /*
+ * Compute the adaptive codebook vector
+ * using fixed point. This is required
+ * to maintain encoder/decoder excitation
+ * syncronisation
+ */
+ for (i = -(PIT_MAX + L_INTERPOL); i < 40; i++)
+ exc_tmp_p[i] = (Word32)exc[i];
+
+ Pred_lt_3or6_fixed( exc_tmp_p, *T0, *T0_frac, resu3 );
+
+ for (i = -(PIT_MAX + L_INTERPOL); i < 40; i++)
+ exc[i] = (Float32)exc_tmp_p[i];
+
+ /*
+ * Convolve to get filtered adaptive codebook vector
+ * y[n] = sum_{i=0}^{n} x[i] h[n-i], n=0,...,L-1
+ */
+ for ( n = 0; n < L_SUBFR; n++ ) {
+ s = 0;
+
+ for ( i = 0; i <= n; i++ ) {
+ s += exc[i] * h1[n - i];
+ }
+ y1[n] = s;
+ }
+
+ /* The adaptive codebook gain */
+ *gain_pit = G_pitch( xn, y1, gCoeff );
+
+ /* check if the pitch gain should be limit due to resonance in LPC filter */
+ gpc_flag = 0;
+ *gp_limit = 2.0F;
+
+ if ( ( lsp_flag != 0 ) && ( *gain_pit > 0.95F ) ) {
+ gpc_flag = check_gp_clipping( gp, *gain_pit );
+ }
+
+ /*
+ * special for the MR475, MR515 mode; limit the gain to 0.85 to
+ * cope with bit errors in the decoder in a better way.
+ */
+ if ( ( mode == MR475 ) || ( mode == MR515 ) ) {
+ if ( *gain_pit > 0.85 ) {
+ *gain_pit = 0.85F;
+ }
+
+ if ( gpc_flag != 0 )
+ *gp_limit = GP_CLIP;
+ }
+ else {
+ if ( gpc_flag != 0 ) {
+ *gp_limit = GP_CLIP;
+ *gain_pit = GP_CLIP;
+ }
+
+ /*
+ * 12k2 gain_pit is quantized here and not in gainQuant.
+ */
+ if ( mode == MR122 ) {
+
+ *( *anap )++ = q_gain_pitch( MR122, *gp_limit, gain_pit, NULL, NULL );
+ }
+ }
+
+ /*
+ * Update target vector for codebook search
+ * Find LTP residual
+ */
+ for ( i = 0; i < L_SUBFR; i++ ) {
+ xn2[i] = xn[i] - y1[i] * *gain_pit;
+ res2[i] = res2[i] - exc[i] * *gain_pit;
+ }
+}
+
+
+/*
+ * DotProduct
+ *
+ *
+ * Parameters:
+ * x I: first input
+ * y I: second input
+ * len I: length of product
+ *
+ * Function:
+ * Computes dot product
+ *
+ * Returns:
+ * acc dot product
+ */
+static Float32 DotProduct( Float32 *x, Float32 *y, Word32 len )
+{
+ Word32 i;
+ Float32 acc;
+
+
+ acc = 0.0F;
+
+ for ( i = 0; i < len; i++ )
+ acc += x[i] * y[i];
+ return( acc );
+}
+
+
+/*
+ * cor_h_x
+ *
+ *
+ * Parameters:
+ * h I: impulse response of weighted synthesis filter
+ * x I: target
+ * dn O: correlation between target and impulse response
+ *
+ * Function:
+ * Computes correlation between target signal and impulse response.
+ *
+ * Returns:
+ * void
+ */
+static void cor_h_x( Float32 h[], Float32 x[], Float32 dn[] )
+{
+ Word32 i;
+
+
+ dn[0] = (Float32)Dotproduct40( h, x );
+
+ for ( i = 1; i < L_CODE; i++ )
+ dn[i] = (Float32)DotProduct( h, &x[i], L_CODE - i );
+}
+
+
+/*
+ * set_sign
+ *
+ *
+ * Parameters:
+ * dn B: correlation between target and h[]
+ * sign O: sign of dn[]
+ * dn2 O: maximum of correlation in each track
+ * n I: # of maximum correlations in dn2[]
+ *
+ * Function:
+ * Builds sign[] vector.
+ *
+ * Returns:
+ * void
+ */
+static void set_sign( Float32 dn[], Float32 sign[], Float32 dn2[], Word16 n )
+{
+ Float32 val, min;
+ Word32 i, j, k, pos = 0;
+
+
+ /* set sign according to dn[] */
+ for ( i = 0; i < L_CODE; i++ ) {
+ val = dn[i];
+
+ if ( val >= 0 ) {
+ sign[i] = 1.0F;
+ }
+ else {
+ sign[i] = -1.0F;
+ val = -val;
+ }
+
+ /* modify dn[] according to the fixed sign */
+ dn[i] = val;
+ dn2[i] = val;
+ }
+
+ /* keep 8-n maximum positions/8 of each track and store it in dn2[] */
+ for ( i = 0; i < NB_TRACK; i++ ) {
+ for ( k = 0; k < ( 8 - n ); k++ ) {
+ min = FLT_MAX;
+
+ for ( j = i; j < L_CODE; j += STEP ) {
+ if ( dn2[j] >= 0 ) {
+ val = dn2[j] - min;
+
+ if ( val < 0 ) {
+ min = dn2[j];
+ pos = j;
+ }
+ }
+ }
+ dn2[pos] = -1.0F;
+ }
+ }
+ return;
+}
+
+
+/*
+ * cor_h
+ *
+ *
+ * Parameters:
+ * h I: h[]
+ * sign I: sign information
+ * rr O: correlations
+ *
+ * Function:
+ * Computes correlations of h[] needed for the codebook search,
+ * and includes the sign information into the correlations.
+ *
+ * Returns:
+ * void
+ */
+static void cor_h( Float32 h[], Float32 sign[], Float32 rr[][L_CODE] )
+{
+ Float32 sum;
+ Float32 *prr, *ph, *ph_max;
+ Float32 *rrj, *rri, *signi, *signj;
+ Word32 ii, total_loops, four_loops;
+
+
+ sum = 0.0F;
+
+ /* Compute diagonal matrix of autocorrelation of h */
+ rr[0][0] = (Float32)Dotproduct40( h, h );
+ prr = &rr[39][39];
+ ph = &h[0];
+ ph_max = ph + 39;
+
+ /*
+ * speed optimization of code:
+ * for (k=0; k<m; k++)
+ * {
+ * sum += h[k]*h[k];
+ * rr[i][i] = sum;
+ * i--;
+ * }
+ */
+ do {
+ sum += *ph * *ph;
+ ph++;
+ *prr = sum;
+ prr -= 41;
+ sum += *ph * *ph;
+ ph++;
+ *prr = sum;
+ prr -= 41;
+ sum += *ph * *ph;
+ ph++;
+ *prr = sum;
+ prr -= 41;
+ sum += *ph * *ph;
+ ph++;
+ *prr = sum;
+ prr -= 41;
+ sum += *ph * *ph;
+ ph++;
+ *prr = sum;
+ prr -= 41;
+ sum += *ph * *ph;
+ ph++;
+ *prr = sum;
+ prr -= 41;
+ sum += *ph * *ph;
+ ph++;
+ *prr = sum;
+ prr -= 41;
+ sum += *ph * *ph;
+ ph++;
+ *prr = sum;
+ prr -= 41;
+ sum += *ph * *ph;
+ ph++;
+ *prr = sum;
+ prr -= 41;
+ sum += *ph * *ph;
+ ph++;
+ *prr = sum;
+ prr -= 41;
+ sum += *ph * *ph;
+ ph++;
+ *prr = sum;
+ prr -= 41;
+ sum += *ph * *ph;
+ ph++;
+ *prr = sum;
+ prr -= 41;
+ sum += *ph * *ph;
+ ph++;
+ *prr = sum;
+ prr -= 41;
+ } while ( ph < ph_max );
+
+ /*
+ * Compute upper & bottom symmetric matrix of autocorrelation of h.
+ */
+ /* speed optimization of code:
+ * for (ii=1; ii<L_CODE; ii++)
+ * {
+ * j = m;
+ * i = j - ii;
+ * sum = (Float32)0.0;
+ * for ( k = 0; k < (L_CODE-ii); k++ )
+ * {
+ * sum += h[k]*h[k+ii];
+ * rr[i][j] = rr[j][i] = (sum*sign[i]*sign[j]);
+ * i--; j--;
+ * }
+ * }
+ */
+ ii = 1;
+
+ for ( total_loops = 9; total_loops >= 0; total_loops-- ) {
+ rrj = rri = &rr[39][39];
+ rrj -= ii;
+ rri = ( rri - 40 * ii );
+ signi = signj = &sign[39];
+ signi -= ii;
+ sum = 0.0F;
+ ph = &h[0];
+
+ for ( four_loops = 0; four_loops < total_loops; four_loops++ ) {
+ sum += *ph * *( ph + ii );
+ ph++;
+ *rri = *rrj = sum * *signi * *signj;
+ rri -= 41;
+ rrj -= 41;
+ signi--;
+ signj--;
+ sum += *ph * *( ph + ii );
+ ph++;
+ *rri = *rrj = sum * *signi * *signj;
+ rri -= 41;
+ rrj -= 41;
+ signi--;
+ signj--;
+ sum += *ph * *( ph + ii );
+ ph++;
+ *rri = *rrj = sum * *signi * *signj;
+ rri -= 41;
+ rrj -= 41;
+ signi--;
+ signj--;
+ sum += *ph * *( ph + ii );
+ ph++;
+ *rri = *rrj = sum * *signi * *signj;
+ rri -= 41;
+ rrj -= 41;
+ signi--;
+ signj--;
+ }
+ sum += *ph * *( ph + ii );
+ ph++;
+ *rri = *rrj = sum * *signi * *signj;
+ rri -= 41;
+ rrj -= 41;
+ signi--;
+ signj--;
+ sum += *ph * *( ph + ii );
+ ph++;
+ *rri = *rrj = sum * *signi * *signj;
+ rri -= 41;
+ rrj -= 41;
+ signi--;
+ signj--;
+ sum += *ph * *( ph + ii );
+ *rri = *rrj = sum * *signi * *signj;
+ ii++;
+ rrj = rri = &rr[39][39];
+ rrj -= ii;
+ rri = ( rri - 40 * ii );
+ signi = signj = &sign[39];
+ signi -= ii;
+ sum = 0.0F;
+ ph = &h[0];
+
+ for ( four_loops = 0; four_loops < total_loops; four_loops++ ) {
+ sum += *ph * *( ph + ii );
+ ph++;
+ *rri = *rrj = sum * *signi * *signj;
+ rri -= 41;
+ rrj -= 41;
+ signi--;
+ signj--;
+ sum += *ph * *( ph + ii );
+ ph++;
+ *rri = *rrj = sum * *signi * *signj;
+ rri -= 41;
+ rrj -= 41;
+ signi--;
+ signj--;
+ sum += *ph * *( ph + ii );
+ ph++;
+ *rri = *rrj = sum * *signi * *signj;
+ rri -= 41;
+ rrj -= 41;
+ signi--;
+ signj--;
+ sum += *ph * *( ph + ii );
+ ph++;
+ *rri = *rrj = sum * *signi * *signj;
+ rri -= 41;
+ rrj -= 41;
+ signi--;
+ signj--;
+ }
+ sum += *ph * *( ph + ii );
+ ph++;
+ *rri = *rrj = sum * *signi * *signj;
+ rri -= 41;
+ rrj -= 41;
+ signi--;
+ signj--;
+ sum += *ph * *( ph + ii );
+ *rri = *rrj = sum * *signi * *signj;
+ ii++;
+ rrj = rri = &rr[39][39];
+ rrj -= ii;
+ rri = ( rri - 40 * ii );
+ signi = signj = &sign[39];
+ signi -= ii;
+ sum = 0.0F;
+ ph = &h[0];
+
+ for ( four_loops = 0; four_loops < total_loops; four_loops++ ) {
+ sum += *ph * *( ph + ii );
+ ph++;
+ *rri = *rrj = sum * *signi * *signj;
+ rri -= 41;
+ rrj -= 41;
+ signi--;
+ signj--;
+ sum += *ph * *( ph + ii );
+ ph++;
+ *rri = *rrj = sum * *signi * *signj;
+ rri -= 41;
+ rrj -= 41;
+ signi--;
+ signj--;
+ sum += *ph * *( ph + ii );
+ ph++;
+ *rri = *rrj = sum * *signi * *signj;
+ rri -= 41;
+ rrj -= 41;
+ signi--;
+ signj--;
+ sum += *ph * *( ph + ii );
+ ph++;
+ *rri = *rrj = sum * *signi * *signj;
+ rri -= 41;
+ rrj -= 41;
+ signi--;
+ signj--;
+ }
+ sum += *ph * *( ph + ii );
+ *rri = *rrj = sum * *signi * *signj;
+ ii++;
+ rrj = rri = &rr[39][39];
+ rrj -= ii;
+ rri = ( rri - 40 * ii );
+ signi = signj = &sign[39];
+ signi -= ii;
+ sum = 0.0F;
+ ph = &h[0];
+
+ for ( four_loops = 0; four_loops < total_loops; four_loops++ ) {
+ sum += *ph * *( ph + ii );
+ ph++;
+ *rri = *rrj = sum * ( *signi ) * ( *signj );
+ rri -= 41;
+ rrj -= 41;
+ signi--;
+ signj--;
+ sum += *ph * *( ph + ii );
+ ph++;
+ *rri = *rrj = sum * *signi * *signj;
+ rri -= 41;
+ rrj -= 41;
+ signi--;
+ signj--;
+ sum += *ph * *( ph + ii );
+ ph++;
+ *rri = *rrj = sum * *signi * *signj;
+ rri -= 41;
+ rrj -= 41;
+ signi--;
+ signj--;
+ sum += *ph * *( ph + ii );
+ ph++;
+ *rri = *rrj = sum * *signi * *signj;
+ rri -= 41;
+ rrj -= 41;
+ signi--;
+ signj--;
+ }
+ ii++;
+ }
+ return;
+}
+
+
+/*
+ * search_2i40_9bits
+ *
+ *
+ * Parameters:
+ * subNr I: subframe number
+ * dn I: correlation between target and h[]
+ * rr I: matrix of autocorrelation
+ * codvec O: algebraic codebook vector
+ *
+ * Function:
+ * Search the best codevector; determine positions of the 2 pulses
+ * in the 40-sample frame.
+ *
+ * First subframe:
+ * first i0 : 0, 5, 10, 15, 20, 25, 30, 35.
+ * i1 : 2, 7, 12, 17, 22, 27, 32, 37.
+ * second i0 : 1, 6, 11, 16, 21, 26, 31, 36.
+ * i1 : 3, 8, 13, 18, 23, 28, 33, 38.
+ *
+ * Second subframe:
+ * first i0 : 0, 5, 10, 15, 20, 25, 30, 35.
+ * i1 : 3, 8, 13, 18, 23, 28, 33, 38.
+ * second i0 : 2, 7, 12, 17, 22, 27, 32, 37.
+ * i1 : 4, 9, 14, 19, 24, 29, 34, 39.
+ *
+ * Third subframe:
+ * first i0 : 0, 5, 10, 15, 20, 25, 30, 35.
+ * i1 : 2, 7, 12, 17, 22, 27, 32, 37.
+ * second i0 : 1, 6, 11, 16, 21, 26, 31, 36.
+ * i1 : 4, 9, 14, 19, 24, 29, 34, 39.
+ *
+ * Fourth subframe:
+ * first i0 : 0, 5, 10, 15, 20, 25, 30, 35.
+ * i1 : 3, 8, 13, 18, 23, 28, 33, 38.
+ * second i0 : 1, 6, 11, 16, 21, 26, 31, 36.
+ * i1 : 4, 9, 14, 19, 24, 29, 34, 39.
+ *
+ * Returns:
+ * void
+ */
+static void search_2i40_9bits( Word16 subNr, Float32 dn[], Float32 rr[][L_CODE],
+ Word32 codvec[] )
+{
+ Float32 ps0, ps1, psk, alp, alp0, alp1, alpk, sq, sq1;
+ Word32 i0, i1, ix, i;
+ Word16 ipos[2];
+ Word16 track1;
+
+
+ psk = -1;
+ alpk = 1;
+
+ for ( i = 0; i < 2; i++ ) {
+ codvec[i] = i;
+ }
+
+ /* main loop: try 2x4 tracks */
+ for ( track1 = 0; track1 < 2; track1++ ) {
+ ipos[0] = startPos[( subNr << 1 ) + ( track1 << 3 )];
+ ipos[1] = startPos[( subNr << 1 ) + 1 + ( track1 << 3 )];
+
+ /* i0 loop: try 8 positions */
+ for ( i0 = ipos[0]; i0 < L_CODE; i0 += STEP ) {
+ ps0 = dn[i0];
+ alp0 = rr[i0][i0];
+
+ /* i1 loop: 8 positions */
+ sq = -1;
+ alp = 1;
+ ix = ipos[1];
+
+ for ( i1 = ipos[1]; i1 < L_CODE; i1 += STEP ) {
+ ps1 = ps0 + dn[i1];
+ alp1 = alp0 + rr[i1][i1] + 2.0F * rr[i0][i1];
+ sq1 = ps1 * ps1;
+
+ if ( ( alp * sq1 ) > ( sq * alp1 ) ) {
+ sq = sq1;
+ alp = alp1;
+ ix = i1;
+ }
+ }
+
+ /* memorise codevector if this one is better than the last one */
+ if ( ( alpk * sq ) > ( psk * alp ) ) {
+ psk = sq;
+ alpk = alp;
+ codvec[0] = i0;
+ codvec[1] = ix;
+ }
+ }
+ }
+ return;
+}
+
+
+/*
+ * build_code_2i40_9bits
+ *
+ *
+ * Parameters:
+ * subNr I: subframe number
+ * codvec I: position of pulses
+ * dn_sign I: sign of pulses
+ * cod O: algebraic codebook vector
+ * h I: impulse response of weighted synthesis filter
+ * y I: filtered innovative code
+ * anap O: analysis parameters
+ *
+ * Function:
+ * Builds the codeword, the filtered codeword and index of the
+ * codevector, based on the signs and positions of 2 pulses.
+ *
+ * Returns:
+ * void
+ */
+static void build_code_2i40_9bits( Word16 subNr, Word32 codvec[], Float32
+ dn_sign[], Float32 cod[], Float32 h[], Float32 y[], Word16 *anap )
+{
+ Float32 s;
+ Float32 *p0, *p1;
+ Word32 _sign[2];
+ Word32 i, j, k, track, index, indx = 0, rsign = 0;
+ Word8 first, *pt;
+
+
+ pt = &trackTable[subNr + ( subNr << 2 )];
+ memset( cod, 0, 160 );
+
+ for ( k = 0; k < 2; k++ ) {
+ /* read pulse position */
+ i = codvec[k];
+
+ /* read sign */
+ j = ( Word32 )dn_sign[i];
+
+ /* index = pos/5 */
+ index = i / 5;
+
+ /* track = pos%5 */
+ track = i % 5;
+ first = pt[track];
+
+ if ( first == 0 ) {
+ if ( k == 0 ) {
+ /* position of 1st pulse */
+ track = 0;
+ }
+ else {
+ track = 1;
+
+ /* position of 2nd pulse */
+ index <<= 3;
+ }
+ }
+ else {
+ if ( k == 0 ) {
+ track = 0;
+
+ /* position of 1st pulse, subset 2 */
+ index += 64;
+ }
+ else {
+ track = 1;
+ index <<= 3;
+ }
+ }
+
+ if ( j > 0 ) {
+ cod[i] = 0.9998779296875F;
+ _sign[k] = 1;
+
+ /* sign information */
+ rsign = rsign + ( 1 << track );
+ }
+ else {
+ cod[i] = -1;
+ _sign[k] = -1;
+ }
+ indx = indx + index;
+ }
+ p0 = h - codvec[0];
+ p1 = h - codvec[1];
+
+ for ( i = 0; i < L_CODE; i++ ) {
+ s = *p0++ * _sign[0];
+ s += *p1++ * _sign[1];
+ y[i] = s;
+ }
+ anap[0] = ( Word16 )indx;
+ anap[1] = ( Word16 )rsign;
+}
+
+
+/*
+ * code_2i40_9bits
+ *
+ *
+ * Parameters:
+ * subNr I: subframe number
+ * x I: target vector
+ * h I: impulse response of weighted synthesis filter
+ * T0 I: Pitch lag
+ * pitch_sharp I: Last quantized pitch gain
+ * code O: innovative codebook
+ * y O: filtered fixed codebook excitation
+ * anap O: analysis parameters
+ *
+ * Function:
+ * Searches a 9 bit algebraic codebook containing 2 pulses
+ * in a frame of 40 samples.
+ *
+ * The code length is 40, containing 2 nonzero pulses: i0...i1.
+ * All pulses can have two possible amplitudes: +1 or -1.
+ * Pulse i0 can have 8 possible positions, pulse i1 can have
+ * 8 positions. Also coded is which track pair should be used,
+ * i.e. first or second pair. Where each pair contains 2 tracks.
+ *
+ * Returns:
+ * void
+ */
+static void code_2i40_9bits( Word16 subNr, Float32 x[], Float32 h[], Word32 T0,
+ Float32 pitch_sharp, Float32 code[], Float32 y[], Word16 *anap )
+{
+ Float32 rr[L_CODE][L_CODE];
+ Float32 dn[L_CODE], dn_sign[L_CODE], dn2[L_CODE];
+ Word32 codvec[2];
+ Word32 i;
+
+
+ if ( ( T0 < L_CODE ) && ( pitch_sharp != 0.0F ) )
+ for ( i = T0; i < L_CODE; i++ ) {
+ h[i] += h[i - T0] * pitch_sharp;
+ }
+ cor_h_x( h, x, dn );
+ set_sign( dn, dn_sign, dn2, 8 );
+ cor_h( h, dn_sign, rr );
+ search_2i40_9bits( subNr, dn, rr, codvec );
+ build_code_2i40_9bits( subNr, codvec, dn_sign, code, h, y, anap );
+
+ /*
+ * Compute innovation vector gain.
+ * Include fixed-gain pitch contribution into code[].
+ */
+ if ( ( T0 < L_CODE ) && ( pitch_sharp != 0.0F ) )
+ for ( i = T0; i < L_CODE; i++ ) {
+ code[i] += code[i - T0] * pitch_sharp;
+ }
+}
+
+
+/*
+ * search_2i40_11bits
+ *
+ *
+ * Parameters:
+ * dn I: correlation between target and h[]
+ * rr I: matrix of autocorrelation
+ * codvec O: algebraic codebook vector
+ *
+ * Function:
+ * Search the best codevector; determine positions of the 2 pulses
+ * in the 40-sample frame.
+ *
+ * Returns:
+ * void
+ */
+static void search_2i40_11bits( Float32 dn[], Float32 rr[][L_CODE], Word32
+ codvec[] )
+{
+ Float64 alpk, alp, alp0, alp1;
+ Float32 psk, ps0, ps1, sq, sq1;
+ Word32 i, i0, i1, ix = 0;
+ Word16 ipos[2];
+ Word16 track1, track2;
+
+
+ psk = -1;
+ alpk = 1;
+
+ for ( i = 0; i < 2; i++ ) {
+ codvec[i] = i;
+ }
+
+ /*
+ * main loop: try 2x4 tracks.
+ */
+ for ( track1 = 0; track1 < 2; track1++ ) {
+ for ( track2 = 0; track2 < 4; track2++ ) {
+ /* fix starting position */
+ ipos[0] = startPos1[track1];
+ ipos[1] = startPos2[track2];
+
+ /*
+ * i0 loop: try 8 positions.
+ */
+ for ( i0 = ipos[0]; i0 < L_CODE; i0 += STEP ) {
+ ps0 = dn[i0];
+ alp0 = rr[i0][i0] * 0.25F;
+
+ /*
+ * i1 loop: 8 positions.
+ */
+ sq = -1;
+ alp = 1;
+ ix = ipos[1];
+
+ for ( i1 = ipos[1]; i1 < L_CODE; i1 += STEP ) {
+ ps1 = ps0 + dn[i1];
+
+ /* alp1 = alp0 + rr[i0][i1] + 1/2*rr[i1][i1]; */
+ alp1 = alp0 + rr[i1][i1] * 0.25F;
+ alp1 += rr[i0][i1] * 0.5F;
+ sq1 = ps1 * ps1;
+
+ if ( ( alp * sq1 ) > ( sq * alp1 ) ) {
+ sq = sq1;
+ alp = alp1;
+ ix = i1;
+ }
+ }
+
+ /*
+ * memorise codevector if this one is better than the last one.
+ */
+ if ( ( alpk * sq ) > ( psk * alp ) ) {
+ psk = sq;
+ alpk = alp;
+ codvec[0] = i0;
+ codvec[1] = ix;
+ }
+ }
+ }
+ }
+ return;
+}
+
+
+/*
+ * build_code_2i40_11bits
+ *
+ *
+ * Parameters:
+ * codvec I: position of pulses
+ * dn_sign I: sign of pulses
+ * cod O: algebraic codebook vector
+ * h I: impulse response of weighted synthesis filter
+ * y O: filtered innovative code
+ * anap O: analysis parameters
+ *
+ * Function:
+ * Builds the codeword, the filtered codeword and index of the
+ * codevector, based on the signs and positions of 2 pulses.
+ *
+ * Returns:
+ * void
+ */
+static void build_code_2i40_11bits( Word32 codvec[], Float32 dn_sign[], Float32
+ cod[], Float32 h[], Float32 y[], Word16 *anap )
+{
+ Float64 s;
+ Float32 *p0, *p1;
+ Word32 _sign[2];
+ Word32 i, j, k, track, index, indx = 0, rsign = 0;
+
+
+ memset( cod, 0, 160 );
+
+ for ( k = 0; k < 2; k++ ) {
+ i = codvec[k]; /* read pulse position */
+ j = ( Word16 )dn_sign[i]; /* read sign */
+ index = i / 5; /* index = pos/5 */
+
+ /* track = pos%5 */
+ track = i % 5;
+
+ if ( track == 0 ) {
+ track = 1;
+ index = index << 6;
+ }
+ else if ( track == 1 ) {
+ if ( k == 0 ) {
+ track = 0;
+ index = index << 1;
+ }
+ else {
+ track = 1;
+ index = ( index << 6 ) + 16;
+ }
+ }
+ else if ( track == 2 ) {
+ track = 1;
+ index = ( index << 6 ) + 32;
+ }
+ else if ( track == 3 ) {
+ track = 0;
+ index = ( index << 1 ) + 1;
+ }
+ else if ( track == 4 ) {
+ track = 1;
+ index = ( index << 6 ) + 48;
+ }
+
+ if ( j > 0 ) {
+ cod[i] = 0.9998779296875F;
+ _sign[k] = 1;
+ rsign = rsign + ( 1 << track );
+ }
+ else {
+ cod[i] = -1;
+ _sign[k] = -1;
+ }
+ indx = indx + index;
+ }
+ p0 = h - codvec[0];
+ p1 = h - codvec[1];
+
+ for ( i = 0; i < L_CODE; i++ ) {
+ s = *p0++ * _sign[0];
+ s += *p1++ * _sign[1];
+ y[i] = ( Float32 )s;
+ }
+ anap[0] = ( Word16 )indx;
+ anap[1] = ( Word16 )rsign;
+}
+
+
+/*
+ * code_2i40_11bits
+ *
+ *
+ * Parameters:
+ * x I: target vector
+ * h I: impulse response of weighted synthesis filter
+ * T0 I: Pitch lag
+ * pitch_sharp I: Last quantized pitch gain
+ * code O: innovative codebook
+ * y O: filtered fixed codebook excitation
+ * anap O: analysis parameters
+ *
+ * Function:
+ * Searches a 11 bit algebraic codebook containing 2 pulses
+ * in a frame of 40 samples.
+ *
+ * The code length is 40, containing 2 nonzero pulses: i0...i1.
+ * All pulses can have two possible amplitudes: +1 or -1.
+ * Pulse i0 can have 2x8=16 possible positions, pulse i1 can have
+ * 4x8=32 positions.
+ *
+ * i0 : 1, 6, 11, 16, 21, 26, 31, 36.
+ * 3, 8, 13, 18, 23, 28, 33, 38.
+ * i1 : 0, 5, 10, 15, 20, 25, 30, 35.
+ * 1, 6, 11, 16, 21, 26, 31, 36.
+ * 2, 7, 12, 17, 22, 27, 32, 37.
+ * 4, 9, 14, 19, 24, 29, 34, 39.
+ *
+ * Returns:
+ * void
+ */
+static void code_2i40_11bits( Float32 x[], Float32 h[], Word32 T0, Float32
+ pitch_sharp, Float32 code[], Float32 y[], Word16 *anap )
+{
+ Float32 rr[L_CODE][L_CODE];
+ Float32 dn[L_CODE], dn2[L_CODE], dn_sign[L_CODE];
+ Word32 codvec[2];
+ Word32 i;
+
+
+ if ( ( T0 < L_CODE ) && ( pitch_sharp != 0.0F ) ) {
+ for ( i = T0; i < L_CODE; i++ ) {
+ h[i] = h[i] + ( h[i - T0] * pitch_sharp );
+ }
+ }
+ cor_h_x( h, x, dn );
+ set_sign( dn, dn_sign, dn2, 8 );
+ cor_h( h, dn_sign, rr );
+ search_2i40_11bits( dn, rr, codvec );
+ build_code_2i40_11bits( codvec, dn_sign, code, h, y, anap );
+
+ /*
+ * Compute innovation vector gain.
+ * Include fixed-gain pitch contribution into code[].
+ */
+ if ( ( T0 < L_CODE ) && ( pitch_sharp != 0.0F ) ) {
+ for ( i = T0; i < L_CODE; i++ ) {
+ code[i] = code[i] + code[i - T0] * pitch_sharp;
+ }
+ }
+}
+
+
+/*
+ * search_3i40
+ *
+ *
+ * Parameters:
+ * dn I: correlation between target and h[]
+ * dn2 I: maximum of corr. in each track
+ * rr I: matrix of autocorrelation
+ * codvec O: algebraic codebook vector
+ *
+ * Function:
+ * Searches a 14 bit algebraic codebook containing 3 pulses in
+ * a frame of 40 samples.
+ *
+ * Returns:
+ * void
+ */
+static void search_3i40( Float32 dn[], Float32 dn2[], Float32 rr[][L_CODE],
+ Word32 codvec[] )
+{
+ Float32 psk, ps0, ps1, sq, sq1, alpk, alp, alp0, alp1, ps = 0.0F;
+ Float32 *rr2, *rr1, *rr0, *pdn, *pdn_max;
+ Word32 ipos[3];
+ Word32 i0, i1, i2, ix, i, pos, track1, track2;
+
+
+ psk = -1.0F;
+ alpk = 1.0F;
+
+ for ( track1 = 1; track1 < 4; track1 += 2 ) {
+ for ( track2 = 2; track2 < 5; track2 += 2 ) {
+ /* fix starting position */
+ ipos[0] = 0;
+ ipos[1] = track1;
+ ipos[2] = track2;
+
+ /* main loop: try 3 tracks */
+ for ( i = 0; i < 3; i++ ) {
+ /* i0 loop: try 8 positions */
+ for ( i0 = ipos[0]; i0 < L_CODE; i0 += STEP ) {
+ if ( dn2[i0] >= 0 ) {
+ ps0 = dn[i0];
+ alp0 = rr[i0][i0];
+
+ /* i1 loop: 8 positions */
+ sq = -1.0F;
+ alp = 1.0F;
+ ps = 0.0F;
+ ix = ipos[1];
+ i1 = ipos[1];
+ rr1 = &rr[i1][i1];
+ rr0 = &rr[i0][i1];
+ pdn = &dn[i1];
+ pdn_max = &dn[L_CODE];
+
+ do {
+ ps1 = ps0 + *pdn;
+ alp1 = alp0 + *rr1 + 2.0F * *rr0;
+ sq1 = ps1 * ps1;
+
+ if ( ( alp * sq1 ) > ( sq * alp1 ) ) {
+ sq = sq1;
+ ps = ps1;
+ alp = alp1;
+ ix = ( Word16 )( pdn - dn );
+ }
+ pdn += STEP;
+ rr1 += ( 40 * STEP + STEP );
+ rr0 += STEP;
+ } while ( pdn < pdn_max );
+ i1 = ix;
+
+ /* i2 loop: 8 positions */
+ ps0 = ps;
+ alp0 = alp;
+ sq = -1.0F;
+ alp = 1.0F;
+ ps = 0.0F;
+ ix = ipos[2];
+ i2 = ipos[2];
+ rr2 = &rr[i2][i2];
+ rr1 = &rr[i1][i2];
+ rr0 = &rr[i0][i2];
+ pdn = &dn[i2];
+
+ do {
+ ps1 = ps0 + *pdn;
+ alp1 = alp0 + *rr2 + 2.0F * ( *rr1 + *rr0 );
+ sq1 = ps1 * ps1;
+
+ if ( ( alp * sq1 ) > ( sq * alp1 ) ) {
+ sq = sq1;
+ ps = ps1;
+ alp = alp1;
+ ix = ( Word16 )( pdn - dn );
+ }
+ pdn += STEP;
+ rr2 += ( 40 * STEP + STEP );
+ rr1 += STEP;
+ rr0 += STEP;
+ } while ( pdn < pdn_max );
+ i2 = ix;
+
+ /* memorise codevector if this one is better than the last one */
+ if ( ( alpk * sq ) > ( psk * alp ) ) {
+ psk = sq;
+ alpk = alp;
+ codvec[0] = i0;
+ codvec[1] = i1;
+ codvec[2] = i2;
+ }
+ }
+ }
+
+ /* Cyclic permutation of i0, i1 and i2 */
+ pos = ipos[2];
+ ipos[2] = ipos[1];
+ ipos[1] = ipos[0];
+ ipos[0] = pos;
+ }
+ }
+ }
+ return;
+}
+
+
+/*
+ * build_code_3i40_14bits
+ *
+ *
+ * Parameters:
+ * codvec I: position of pulses
+ * dn_sign I: sign of pulses
+ * cod O: algebraic codebook vector
+ * h I: impulse response of weighted synthesis filter
+ * y I: filtered innovative code
+ * anap O: analysis parameters
+ *
+ * Function:
+ * Builds the codeword, the filtered codeword and index of the
+ * codevector, based on the signs and positions of 3 pulses.
+ *
+ * Returns:
+ * void
+ */
+static void build_code_3i40_14bits( Word32 codvec[], Float32 dn_sign[], Float32
+ cod[], Float32 h[], Float32 y[], Word16 *anap )
+{
+ Float64 s;
+ Float32 _sign[3];
+ Float32 *p0, *p1, *p2;
+ Word32 i, j, k, track, index, indx, rsign;
+
+
+ memset( cod, 0, 160 );
+ indx = 0;
+ rsign = 0;
+
+ for ( k = 0; k < 3; k++ ) {
+ /* read pulse position */
+ i = codvec[k];
+
+ /* read sign */
+ j = ( Word16 )dn_sign[i];
+
+ /* index = pos/5 */
+ index = i / 5;
+
+ /* track = pos%5 */
+ track = i % 5;
+
+ if ( track == 1 )
+ index = index << 4;
+ else if ( track == 2 ) {
+ track = 2;
+ index = index << 8;
+ }
+ else if ( track == 3 ) {
+ track = 1;
+ index = ( index << 4 ) + 8;
+ }
+ else if ( track == 4 ) {
+ track = 2;
+ index = ( index << 8 ) + 128;
+ }
+
+ if ( j > 0 ) {
+ cod[i] = 0.9998779296875F;
+ _sign[k] = 1.0F;
+ rsign = rsign + ( 1 << track );
+ }
+ else {
+ cod[i] = -1.0F;
+ _sign[k] = -1.0F;
+ }
+ indx = indx + index;
+ }
+ p0 = h - codvec[0];
+ p1 = h - codvec[1];
+ p2 = h - codvec[2];
+
+ for ( i = 0; i < L_CODE; i++ ) {
+ s = *p0++ * _sign[0];
+ s += *p1++ * _sign[1];
+ s += *p2++ * _sign[2];
+ y[i] = ( Float32 )s;
+ }
+ anap[0] = ( Word16 )indx;
+ anap[1] = ( Word16 )rsign;
+}
+
+
+/*
+ * code_3i40_14bits
+ *
+ *
+ * Parameters:
+ * x I: target vector
+ * h I: impulse response of weighted synthesis filter
+ * T0 I: Pitch lag
+ * pitch_sharp I: Last quantized pitch gain
+ * code O: innovative codebook
+ * y O: filtered fixed codebook excitation
+ * anap O: analysis parameters
+ *
+ * Function:
+ * Searches a 14 bit algebraic codebook containing 3 pulses
+ * in a frame of 40 samples.
+ *
+ * The code length is 40, containing 3 nonzero pulses: i0...i2.
+ * All pulses can have two possible amplitudes: +1 or -1.
+ * Pulse i0 can have 8 possible positions, pulses i1 and i2 can have
+ * 2x8=16 positions.
+ *
+ * i0 : 0, 5, 10, 15, 20, 25, 30, 35.
+ * i1 : 1, 6, 11, 16, 21, 26, 31, 36.
+ * 3, 8, 13, 18, 23, 28, 33, 38.
+ * i2 : 2, 7, 12, 17, 22, 27, 32, 37.
+ * 4, 9, 14, 19, 24, 29, 34, 39.
+ *
+ * Returns:
+ * void
+ */
+static void code_3i40_14bits( Float32 x[], Float32 h[], Word32 T0, Float32
+ pitch_sharp, Float32 code[], Float32 y[], Word16 *anap )
+{
+ Float32 rr[L_CODE][L_CODE];
+ Float32 dn[L_CODE], dn2[L_CODE], dn_sign[L_CODE];
+ Word32 codvec[3];
+ Word32 i;
+
+
+ if ( ( T0 < L_CODE ) && ( pitch_sharp != 0 ) ) {
+ for ( i = T0; i < L_CODE; i++ ) {
+ h[i] = h[i] + ( h[i - T0] * pitch_sharp );
+ }
+ }
+ cor_h_x( h, x, dn );
+ set_sign( dn, dn_sign, dn2, 6 );
+ cor_h( h, dn_sign, rr );
+ search_3i40( dn, dn2, rr, codvec );
+
+ /* function result */
+ build_code_3i40_14bits( codvec, dn_sign, code, h, y, anap );
+
+ /*
+ * Compute innovation vector gain.
+ * Include fixed-gain pitch contribution into code[].
+ */
+ if ( ( T0 < L_CODE ) && ( pitch_sharp != 0 ) ) {
+ for ( i = T0; i < L_CODE; i++ ) {
+ code[i] = code[i] + ( code[i - T0] * pitch_sharp );
+ }
+ }
+}
+
+
+/*
+ * search_4i40
+ *
+ *
+ * Parameters:
+ * dn I: correlation between target and h[]
+ * dn2 I: maximum of corr. in each track.
+ * rr I: matrix of autocorrelation
+ * codvec O: algebraic codebook vector
+ *
+ * Function:
+ * Search the best codevector; determine positions of the 4 pulses
+ * in the 40-sample frame.
+ *
+ * Returns:
+ * void
+ */
+static void search_4i40( Float32 dn[], Float32 dn2[], Float32 rr[][L_CODE],
+ Word32 codvec[] )
+{
+ Float64 alpk, alp, alp0, alp1;
+ Float32 ps, psk, ps0, ps1, sq, sq1;
+ Word32 ipos[4];
+ Word32 i0, i1, i2, i3, ix, i, pos, track;
+
+
+ /* Default value */
+ psk = -1;
+ alpk = 1;
+
+ for ( i = 0; i < 4; i++ ) {
+ codvec[i] = i;
+ }
+
+ for ( track = 3; track < 5; track++ ) {
+ /* fix starting position */
+ ipos[0] = 0;
+ ipos[1] = 1;
+ ipos[2] = 2;
+ ipos[3] = track;
+
+ /*
+ * main loop: try 4 tracks.
+ */
+ for ( i = 0; i < 4; i++ ) {
+ /*
+ * i0 loop: try 4 positions (use position with max of corr.).
+ */
+ for ( i0 = ipos[0]; i0 < L_CODE; i0 += STEP ) {
+ if ( dn2[i0] >= 0 ) {
+ ps0 = dn[i0];
+ alp0 = rr[i0][i0] * 0.25F;
+
+ /*
+ * i1 loop: 8 positions.
+ */
+ sq = -1;
+ alp = 1;
+ ps = 0;
+ ix = ipos[1];
+
+ for ( i1 = ipos[1]; i1 < L_CODE; i1 += STEP ) {
+ ps1 = ps0 + dn[i1];
+
+ /* alp1 = alp0 + rr[i0][i1] + 1/2*rr[i1][i1]; */
+ alp1 = alp0 + rr[i1][i1] * 0.25F;
+ alp1 = alp1 + rr[i0][i1] * 0.5F;
+ sq1 = ps1 * ps1;
+
+ if ( ( alp * sq1 ) > ( sq * alp1 ) ) {
+ sq = sq1;
+ ps = ps1;
+ alp = alp1;
+ ix = i1;
+ }
+ }
+ i1 = ix;
+
+ /*
+ * i2 loop: 8 positions.
+ */
+ ps0 = ps;
+ alp0 = alp * 0.25F;
+ sq = -1;
+ alp = 1;
+ ps = 0;
+ ix = ipos[2];
+
+ for ( i2 = ipos[2]; i2 < L_CODE; i2 += STEP ) {
+ ps1 = ps0 + dn[i2];
+
+ /* alp1 = alp0 + rr[i0][i2] + rr[i1][i2] + 1/2*rr[i2][i2]; */
+ alp1 = alp0 + rr[i2][i2] * 0.0625F;
+ alp1 += rr[i1][i2] * 0.125F;
+ alp1 += rr[i0][i2] * 0.125F;
+ sq1 = ps1 * ps1;
+
+ if ( ( alp * sq1 ) > ( sq * alp1 ) ) {
+ sq = sq1;
+ ps = ps1;
+ alp = alp1;
+ ix = i2;
+ }
+ }
+ i2 = ix;
+
+ /*
+ * i3 loop: 8 positions
+ */
+ ps0 = ps;
+ alp0 = alp;
+ sq = -1;
+ alp = 1;
+ ps = 0;
+ ix = ipos[3];
+
+ for ( i3 = ipos[3]; i3 < L_CODE; i3 += STEP ) {
+ ps1 = ps0 + dn[i3];
+
+ /* alp1 = alp0 + rr[i0][i3] + rr[i1][i3] + rr[i2][i3] + 1/2*rr[i3][i3]; */
+ alp1 = alp0 + rr[i3][i3] * 0.0625F;
+ alp1 += rr[i2][i3] * 0.125F;
+ alp1 += rr[i1][i3] * 0.125F;
+ alp1 += rr[i0][i3] * 0.125F;
+ sq1 = ps1 * ps1;
+
+ if ( ( alp * sq1 ) > ( sq * alp1 ) ) {
+ sq = sq1;
+ ps = ps1;
+ alp = alp1;
+ ix = i3;
+ }
+ }
+
+ /*
+ * memorise codevector if this one is better than the last one.
+ */
+ if ( ( alpk * sq ) > ( psk * alp ) ) {
+ psk = sq;
+ alpk = alp;
+ codvec[0] = i0;
+ codvec[1] = i1;
+ codvec[2] = i2;
+ codvec[3] = ix;
+ }
+ }
+ }
+
+ /*
+ * Cyclic permutation of i0,i1,i2 and i3.
+ */
+ pos = ipos[3];
+ ipos[3] = ipos[2];
+ ipos[2] = ipos[1];
+ ipos[1] = ipos[0];
+ ipos[0] = pos;
+ }
+ }
+ return;
+}
+
+
+/*
+ * build_code_4i40
+ *
+ *
+ * Parameters:
+ * codvec I: position of pulses
+ * dn_sign I: sign of pulses
+ * cod O: algebraic codebook vector
+ * h I: impulse response of weighted synthesis filter
+ * y O: filtered innovative code
+ * anap O: analysis parameters
+ *
+ * Function:
+ * Builds the codeword, the filtered codeword and index of the
+ * codevector, based on the signs and positions of 4 pulses.
+ *
+ * Returns:
+ * void
+ */
+static void build_code_4i40( Word32 codvec[], Float32 dn_sign[], Float32 cod[],
+ Float32 h[], Float32 y[], Word16 *anap )
+{
+ Float64 s;
+ Float32 *p0, *p1, *p2, *p3;
+ Word32 _sign[4];
+ Word32 i, j, k, track, index, indx = 0, rsign = 0;
+
+
+ memset( cod, 0, 160 );
+
+ for ( k = 0; k < 4; k++ ) {
+ /* read pulse position */
+ i = codvec[k];
+
+ /* read sign */
+ j = ( Word16 )dn_sign[i];
+ index = i / 5;
+ track = i % 5;
+ index = gray[index];
+
+ if ( track == 1 )
+ index = index << 3;
+ else if ( track == 2 ) {
+ index = index << 6;
+ }
+ else if ( track == 3 ) {
+ index = index << 10;
+ }
+ else if ( track == 4 ) {
+ track = 3;
+ index = ( index << 10 ) + 512;
+ }
+
+ if ( j > 0 ) {
+ cod[i] = 0.9998779296875F;
+ _sign[k] = 1;
+ rsign = rsign + ( 1 << track );
+ }
+ else {
+ cod[i] = -1;
+ _sign[k] = -1;
+ }
+ indx = indx + index;
+ }
+ p0 = h - codvec[0];
+ p1 = h - codvec[1];
+ p2 = h - codvec[2];
+ p3 = h - codvec[3];
+
+ for ( i = 0; i < L_CODE; i++ ) {
+ s = *p0++ * _sign[0];
+ s += *p1++ * _sign[1];
+ s += *p2++ * _sign[2];
+ s += *p3++ * _sign[3];
+ y[i] = ( Float32 )( s );
+ }
+ anap[0] = ( Word16 )indx;
+ anap[1] = ( Word16 )rsign;
+}
+
+
+/*
+ * code_4i40_17bits
+ *
+ *
+ * Parameters:
+ * x I: target vector
+ * h I: impulse response of weighted synthesis filter
+ * T0 I: Pitch lag
+ * pitch_sharp I: Last quantized pitch gain
+ * code O: innovative codebook
+ * y O: filtered fixed codebook excitation
+ * anap O: analysis parameters
+ *
+ * Function:
+ * Searches a 17 bit algebraic codebook containing 4 pulses
+ * in a frame of 40 samples.
+ *
+ * The code length is 40, containing 4 nonzero pulses: i0...i3.
+ * All pulses can have two possible amplitudes: +1 or -1.
+ * Pulse i0 to i2 can have 8 possible positions, pulse i3 can have
+ * 2x8=16 positions.
+ *
+ * i0 : 0, 5, 10, 15, 20, 25, 30, 35.
+ * i1 : 1, 6, 11, 16, 21, 26, 31, 36.
+ * i2 : 2, 7, 12, 17, 22, 27, 32, 37.
+ * i3 : 3, 8, 13, 18, 23, 28, 33, 38.
+ * 4, 9, 14, 19, 24, 29, 34, 39.
+ *
+ * Returns:
+ * void
+ */
+static void code_4i40_17bits( Float32 x[], Float32 h[], Word32 T0, Float32
+ pitch_sharp, Float32 code[], Float32 y[], Word16 *anap )
+{
+ Float32 rr[L_CODE][L_CODE];
+ Float32 dn[L_CODE], dn2[L_CODE], dn_sign[L_CODE];
+ Word32 codvec[4];
+ Word32 i;
+
+
+ if ( ( T0 < L_CODE ) && ( pitch_sharp != 0 ) ) {
+ for ( i = T0; i < L_CODE; i++ ) {
+ h[i] = h[i] + h[i - T0] * pitch_sharp;
+ }
+ }
+ cor_h_x( h, x, dn );
+ set_sign( dn, dn_sign, dn2, 4 );
+ cor_h( h, dn_sign, rr );
+ search_4i40( dn, dn2, rr, codvec );
+ build_code_4i40( codvec, dn_sign, code, h, y, anap );
+
+ /*
+ * Compute innovation vector gain.
+ * Include fixed-gain pitch contribution into code[].
+ */
+ if ( ( T0 < L_CODE ) && ( pitch_sharp != 0 ) ) {
+ for ( i = T0; i < L_CODE; i++ ) {
+ code[i] = code[i] + ( code[i - T0] * pitch_sharp );
+ }
+ }
+}
+
+
+/*
+ * set_sign12k2
+ *
+ *
+ * Parameters:
+ * dn B: correlation between target and h[]
+ * cn I: residual after long term prediction
+ * sign O: sign of dn[]
+ * pos_max O: position of maximum correlation
+ * nb_track I: number of tracks
+ * ipos O: starting position for each pulse
+ * step I: the step size in the tracks
+ *
+ * Function:
+ * Builds sign[] vector according to "dn[]" and "cn[]", and modifies
+ * dn[] to include the sign information (dn[i]=sign[i]*dn[i]).
+ * Also finds the position of maximum of correlation in each track
+ * and the starting position for each pulse.
+ *
+ *
+ * cn[n] dn[n]
+ * b(n) = ----------------------- + ----------------------- ;n = 0,..,39
+ * 39 39
+ * sqrt( SUM cn[i]*cn[i] ) sqrt( SUM dn[i]*dn[i] )
+ * i=0 i=0
+ *
+ * sign[n] = sign(b[n])
+ *
+ * d'[n] = sign[n] * d[n]
+ *
+ * Returns:
+ * void
+ */
+static void set_sign12k2( Float32 dn[], Float32 cn[], Float32 sign[], Word32
+ pos_max[], Word16 nb_track, Word32 ipos[], Word16 step )
+{
+ Float32 b[L_CODE];
+ Float32 val, cor, k_cn, k_dn, max, max_of_all, sum;
+ Word32 i, j, pos = 0;
+
+
+ /* calculate energy for normalization of cn[] and dn[] */
+ sum = 0.01F;
+ sum += (Float32)Dotproduct40( cn, cn );
+ k_cn = ( Float32 )( 1 / sqrt( sum ) );
+ sum = 0.01F;
+ sum += (Float32)Dotproduct40( dn, dn );
+ k_dn = ( Float32 )( 1 / sqrt( sum ) );
+
+ for ( i = 0; i < L_CODE; i++ ) {
+ val = dn[i];
+ cor = ( k_cn * cn[i] ) + ( k_dn * val );
+
+ /* sign = +1 */
+ sign[i] = 1;
+
+ if ( cor < 0 ) {
+ /* sign = -1 */
+ sign[i] = -1;
+ cor = -cor;
+ val = -val;
+ }
+
+ /* modify dn[] according to the fixed sign */
+ dn[i] = val;
+ b[i] = cor;
+ }
+ max_of_all = -1;
+
+ for ( i = 0; i < nb_track; i++ ) {
+ max = -1;
+
+ for ( j = i; j < L_CODE; j += step ) {
+ cor = b[j];
+ val = cor - max;
+
+ if ( val > 0 ) {
+ max = cor;
+ pos = j;
+ }
+ }
+
+ /* store maximum correlation position in track */
+ pos_max[i] = pos;
+ val = max - max_of_all;
+
+ if ( val > 0 ) {
+ /* store maximum correlation of all tracks */
+ max_of_all = max;
+
+ /* starting position for i0 */
+ ipos[0] = i;
+ }
+ }
+
+ /* Set starting position of each pulse */
+ pos = ipos[0];
+ ipos[nb_track] = pos;
+
+ for ( i = 1; i < nb_track; i++ ) {
+ pos++;
+
+ if ( pos >= nb_track ) {
+ pos = 0;
+ }
+ ipos[i] = pos;
+ ipos[i + nb_track] = pos;
+ }
+}
+
+
+/*
+ * search_4i40
+ *
+ *
+ * Parameters:
+ * dn I: correlation between target and h[]
+ * rr I: matrix of autocorrelation
+ * ipos I: starting position for each pulse
+ * pos_max I: maximum of correlation position
+ * codvec O: algebraic codebook vector
+ *
+ * Function:
+ * Search the best codevector; determine positions of the 8 pulses
+ * in the 40-sample frame.
+ *
+ * Returns:
+ * void
+ */
+static void search_8i40( Float32 dn[], Float32 rr[][L_CODE], Word32 ipos[],
+ Word32 pos_max[], Word32 codvec[] )
+{
+ Float32 rrv[L_CODE];
+ Float32 psk, ps, ps0, ps1, ps2, sq, sq2, alpk, alp, alp0, alp1, alp2;
+ Float32 *p_r, *p_r0, *p_r1, *p_r2, *p_r3, *p_r4, *p_r5, *p_r6, *p_r7, *p_r8;
+ Float32 *p_rrv, *p_rrv0, *p_dn, *p_dn0, *p_dn1, *p_dn_max;
+ Word32 i0, i1, i2, i3, i4, i5, i6, i7, j, k, ia, ib, i, pos;
+
+ p_dn_max = &dn[39];
+
+ /* fix i0 on maximum of correlation position */
+ i0 = pos_max[ipos[0]];
+ ia = ib = 0;
+ ps = 0;
+
+ /* i1 loop */
+ /* Default value */
+ psk = -1;
+ alpk = 1;
+
+ for ( i = 0; i < 8; i++ ) {
+ codvec[i] = i;
+ }
+ p_r = &rr[i0][i0];
+
+ for ( i = 1; i < 5; i++ ) {
+ i1 = pos_max[ipos[1]];
+ i2 = ipos[2];
+ i3 = ipos[3];
+ i4 = ipos[4];
+ i5 = ipos[5];
+ i6 = ipos[6];
+ i7 = ipos[7];
+ ps0 = dn[i0] + dn[i1];
+ alp0 = *p_r + rr[i1][i1] + 2.0F * rr[i0][i1];
+
+ /* i2 and i3 loop */
+ p_rrv = &rrv[i3];
+ p_r0 = &rr[i0][i3];
+ p_r1 = &rr[i1][i3];
+ p_r3 = &rr[i3][i3];
+ *p_rrv = *p_r3 + 2.0F * ( *p_r0 + *p_r1 );
+ *( p_rrv + 4 ) = *( p_r3 + 164 ) + 2.0F * ( *( p_r0 + 4 ) + *( p_r1 + 4 )
+ );
+ *( p_rrv + 8 ) = *( p_r3 + 328 ) + 2.0F * ( *( p_r0 + 8 ) + *( p_r1 + 8 )
+ );
+ *( p_rrv + 12 ) = *( p_r3 + 492 ) + 2.0F * ( *( p_r0 + 12 ) + *( p_r1 + 12
+ ) );
+ *( p_rrv + 16 ) = *( p_r3 + 656 ) + 2.0F * ( *( p_r0 + 16 ) + *( p_r1 + 16
+ ) );
+ *( p_rrv + 20 ) = *( p_r3 + 820 ) + 2.0F * ( *( p_r0 + 20 ) + *( p_r1 + 20
+ ) );
+ *( p_rrv + 24 ) = *( p_r3 + 984 ) + 2.0F * ( *( p_r0 + 24 ) + *( p_r1 + 24
+ ) );
+ *( p_rrv + 28 ) = *( p_r3 + 1148 ) + 2.0F * ( *( p_r0 + 28 ) + *( p_r1 +
+ 28 ) );
+ *( p_rrv + 32 ) = *( p_r3 + 1312 ) + 2.0F * ( *( p_r0 + 32 ) + *( p_r1 +
+ 32 ) );
+ *( p_rrv + 36 ) = *( p_r3 + 1476 ) + 2.0F * ( *( p_r0 + 36 ) + *( p_r1 +
+ 36 ) );
+ sq = -1;
+ alp = 1;
+ ps = 0;
+ ia = i2;
+ ib = i3;
+ p_rrv = rrv + i3;
+ p_r0 = &rr[i0][i2];
+ p_r1 = &rr[i1][i2];
+ p_r2 = &rr[i2][i2];
+ p_r3 = &rr[i2][i3];
+ p_dn0 = dn + i2;
+ p_dn1 = dn + i3;
+ p_rrv0 = rrv + i3;
+
+ do {
+ ps1 = ps0 + *p_dn0;
+ alp1 = alp0 + *p_r2 + 2.0F * ( *p_r0 + *p_r1 );
+ p_rrv = p_rrv0;
+ p_dn = p_dn1;
+ p_r4 = p_r3;
+
+ do {
+ ps2 = ps1 + *p_dn;
+ sq2 = ps2 * ps2;
+ alp2 = alp1 + *p_rrv + 2.0F * *p_r4;
+
+ if ( ( alp * sq2 ) > ( sq * alp2 ) ) {
+ sq = sq2;
+ ps = ps2;
+ alp = alp2;
+ ia = p_dn0 - dn;
+ ib = p_dn - dn;
+ }
+ p_rrv += 4;
+ p_dn += 4;
+ p_r4 += 4;
+ } while ( p_dn < p_dn_max );
+ p_dn0 += 4;
+ p_r0 += 4;
+ p_r1 += 4;
+ p_r2 += 164;
+ p_r3 += 160;
+ } while ( p_dn0 <= p_dn_max );
+ i2 = ia;
+ i3 = ib;
+
+ /* i4 and i5 loop */
+ p_rrv = rrv + i5;
+ p_r0 = &rr[i0][i5];
+ p_r1 = &rr[i1][i5];
+ p_r2 = &rr[i2][i5];
+ p_r3 = &rr[i3][i5];
+ p_r5 = &rr[i5][i5];
+ *p_rrv = *p_r5 + 2.0F * ( *p_r0 + *p_r1 + *p_r2 + *p_r3 );
+ *( p_rrv + 4 ) = *( p_r5 + 164 ) + 2.0F * ( *( p_r0 + 4 ) + *( p_r1 + 4 )
+ + *( p_r2 + 4 ) + *( p_r3 + 4 ) );
+ *( p_rrv + 8 ) = *( p_r5 + 328 ) + 2.0F * ( *( p_r0 + 8 ) + *( p_r1 + 8 )
+ + *( p_r2 + 8 ) + *( p_r3 + 8 ) );
+ *( p_rrv + 12 ) = *( p_r5 + 492 ) + 2.0F * ( *( p_r0 + 12 ) + *( p_r1 + 12
+ ) + *( p_r2 + 12 ) + *( p_r3 + 12 ) );
+ *( p_rrv + 16 ) = *( p_r5 + 656 ) + 2.0F * ( *( p_r0 + 16 ) + *( p_r1 + 16
+ ) + *( p_r2 + 16 ) + *( p_r3 + 16 ) );
+ *( p_rrv + 20 ) = *( p_r5 + 820 ) + 2.0F * ( *( p_r0 + 20 ) + *( p_r1 + 20
+ ) + *( p_r2 + 20 ) + *( p_r3 + 20 ) );
+ *( p_rrv + 24 ) = *( p_r5 + 984 ) + 2.0F * ( *( p_r0 + 24 ) + *( p_r1 + 24
+ ) + *( p_r2 + 24 ) + *( p_r3 + 24 ) );
+ *( p_rrv + 28 ) = *( p_r5 + 1148 ) + 2.0F * ( *( p_r0 + 28 ) + *( p_r1 +
+ 28 ) + *( p_r2 + 28 ) + *( p_r3 + 28 ) );
+ *( p_rrv + 32 ) = *( p_r5 + 1312 ) + 2.0F * ( *( p_r0 + 32 ) + *( p_r1 +
+ 32 ) + *( p_r2 + 32 ) + *( p_r3 + 32 ) );
+ *( p_rrv + 36 ) = *( p_r5 + 1476 ) + 2.0F * ( *( p_r0 + 36 ) + *( p_r1 +
+ 36 ) + *( p_r2 + 36 ) + *( p_r3 + 36 ) );
+
+ /* Default value */
+ ps0 = ps;
+ alp0 = alp;
+ sq = -1;
+ alp = 1;
+ ps = 0;
+ ia = i4;
+ ib = i5;
+ p_dn0 = dn + i4;
+ p_dn1 = dn + i5;
+ p_r0 = &rr[i0][i4];
+ p_r1 = &rr[i1][i4];
+ p_r2 = &rr[i2][i4];
+ p_r3 = &rr[i3][i4];
+ p_r4 = &rr[i4][i4];
+ p_r5 = &rr[i4][i5];
+ p_rrv0 = rrv + i5;
+
+ do {
+ ps1 = ps0 + *p_dn0;
+ alp1 = alp0 + *p_r4 + 2.0F * ( *p_r0 + *p_r1 + *p_r2 + *p_r3 );
+ p_dn = p_dn1;
+ p_r6 = p_r5;
+ p_rrv = p_rrv0;
+
+ do {
+ ps2 = ps1 + *p_dn;
+ sq2 = ps2 * ps2;
+ alp2 = alp1 + *p_rrv + 2.0F * *p_r6;
+
+ if ( ( alp * sq2 ) > ( sq * alp2 ) ) {
+ sq = sq2;
+ ps = ps2;
+ alp = alp2;
+ ia = p_dn0 - dn;
+ ib = p_dn - dn;
+ }
+ p_dn += 4;
+ p_rrv += 4;
+ p_r6 += 4;
+ } while ( p_dn <= p_dn_max );
+ p_r0 += 4;
+ p_r1 += 4;
+ p_r2 += 4;
+ p_r3 += 4;
+ p_r4 += 164;
+ p_r5 += 160;
+ p_dn0 += 4;
+ } while ( p_dn0 < p_dn_max );
+ i4 = ia;
+ i5 = ib;
+
+ /* i6 and i7 loop */
+ p_rrv = rrv + i7;
+ p_r0 = &rr[i0][i7];
+ p_r1 = &rr[i1][i7];
+ p_r2 = &rr[i2][i7];
+ p_r3 = &rr[i3][i7];
+ p_r4 = &rr[i4][i7];
+ p_r5 = &rr[i5][i7];
+ p_r7 = &rr[i7][i7];
+ *p_rrv = *p_r7 + 2.0F * ( *p_r0 + *p_r1 + *p_r2 + *p_r3 + *p_r4 + *p_r5 );
+ *( p_rrv + 4 ) = *( p_r7 + 164 ) + 2.0F * ( *( p_r0 + 4 ) + *( p_r1 + 4 )
+ + *( p_r2 + 4 ) + *( p_r3 + 4 ) + *( p_r4 + 4 ) + *( p_r5 + 4 ) );
+ *( p_rrv + 8 ) = *( p_r7 + 328 ) + 2.0F * ( *( p_r0 + 8 ) + *( p_r1 + 8 )
+ + *( p_r2 + 8 ) + *( p_r3 + 8 ) + *( p_r4 + 8 ) + *( p_r5 + 8 ) );
+ *( p_rrv + 12 ) = *( p_r7 + 492 ) + 2.0F * ( *( p_r0 + 12 ) + *( p_r1 + 12
+ ) + *( p_r2 + 12 ) + *( p_r3 + 12 ) + *( p_r4 + 12 ) + *( p_r5 + 12
+ ) );
+ *( p_rrv + 16 ) = *( p_r7 + 656 ) + 2.0F * ( *( p_r0 + 16 ) + *( p_r1 + 16
+ ) + *( p_r2 + 16 ) + *( p_r3 + 16 ) + *( p_r4 + 16 ) + *( p_r5 + 16
+ ) );
+ *( p_rrv + 20 ) = *( p_r7 + 820 ) + 2.0F * ( *( p_r0 + 20 ) + *( p_r1 + 20
+ ) + *( p_r2 + 20 ) + *( p_r3 + 20 ) + *( p_r4 + 20 ) + *( p_r5 + 20
+ ) );
+ *( p_rrv + 24 ) = *( p_r7 + 984 ) + 2.0F * ( *( p_r0 + 24 ) + *( p_r1 + 24
+ ) + *( p_r2 + 24 ) + *( p_r3 + 24 ) + *( p_r4 + 24 ) + *( p_r5 + 24
+ ) );
+ *( p_rrv + 28 ) = *( p_r7 + 1148 ) + 2.0F * ( *( p_r0 + 28 ) + *( p_r1 +
+ 28 ) + *( p_r2 + 28 ) + *( p_r3 + 28 ) + *( p_r4 + 28 ) + *( p_r5 +
+ 28 ) );
+ *( p_rrv + 32 ) = *( p_r7 + 1312 ) + 2.0F * ( *( p_r0 + 32 ) + *( p_r1 +
+ 32 ) + *( p_r2 + 32 ) + *( p_r3 + 32 ) + *( p_r4 + 32 ) + *( p_r5 +
+ 32 ) );
+ *( p_rrv + 36 ) = *( p_r7 + 1476 ) + 2.0F * ( *( p_r0 + 36 ) + *( p_r1 +
+ 36 ) + *( p_r2 + 36 ) + *( p_r3 + 36 ) + *( p_r4 + 36 ) + *( p_r5 +
+ 36 ) );
+
+ /* Default value */
+ ps0 = ps;
+ alp0 = alp;
+ sq = -1;
+ alp = 1;
+ ps = 0;
+ ia = i6;
+ ib = i7;
+ p_dn0 = dn + i6;
+ p_dn1 = dn + i7;
+ p_r0 = &rr[i0][i6];
+ p_r1 = &rr[i1][i6];
+ p_r2 = &rr[i2][i6];
+ p_r3 = &rr[i3][i6];
+ p_r4 = &rr[i4][i6];
+ p_r5 = &rr[i5][i6];
+ p_r6 = &rr[i6][i6];
+ p_r7 = &rr[i6][i7];
+ p_rrv0 = rrv + i7;
+
+ do {
+ ps1 = ps0 + *p_dn0;
+ alp1 = alp0 + *p_r6 + 2.0F * ( *p_r0 + *p_r1 + *p_r2 + *p_r3 + *p_r4 +
+ *p_r5 );
+ p_dn = p_dn1;
+ p_r8 = p_r7;
+ p_rrv = p_rrv0;
+
+ do {
+ ps2 = ps1 + *p_dn;
+ sq2 = ps2 * ps2;
+ alp2 = alp1 + *p_rrv + 2.0F * *p_r8;
+
+ if ( ( alp * sq2 ) > ( sq * alp2 ) ) {
+ sq = sq2;
+ ps = ps2;
+ alp = alp2;
+ ia = p_dn0 - dn;
+ ib = p_dn - dn;
+ }
+ p_dn += 4;
+ p_rrv += 4;
+ p_r8 += 4;
+ } while ( p_dn <= p_dn_max );
+ p_r0 += 4;
+ p_r1 += 4;
+ p_r2 += 4;
+ p_r3 += 4;
+ p_r4 += 4;
+ p_r5 += 4;
+ p_r6 += 164;
+ p_r7 += 160;
+ p_dn0 += 4;
+ } while ( p_dn0 < p_dn_max );
+
+ /*
+ * now finished searching a set of 8 pulses
+ * test and memorise if this combination is better than the last one.
+ */
+ if ( ( alpk * sq ) > ( psk * alp ) ) {
+ psk = sq;
+ alpk = alp;
+ codvec[0] = ( Word16 )i0;
+ codvec[1] = ( Word16 )i1;
+ codvec[2] = ( Word16 )i2;
+ codvec[3] = ( Word16 )i3;
+ codvec[4] = ( Word16 )i4;
+ codvec[5] = ( Word16 )i5;
+ codvec[6] = ( Word16 )ia;
+ codvec[7] = ( Word16 )ib;
+ }
+
+ /*
+ * Cyclic permutation of i1,i2,i3,i4,i5,i6,i7,(i8 and i9).
+ */
+ pos = ipos[1];
+
+ for ( j = 1, k = 2; k < 8; j++, k++ ) {
+ ipos[j] = ipos[k];
+ }
+ ipos[7] = pos;
+ } /* end 1..nb_tracks loop*/
+}
+
+
+/*
+ * build_code_8i40_31bits
+ *
+ *
+ * Parameters:
+ * codvec I: position of pulses
+ * dn_sign I: sign of pulses
+ * cod O: algebraic codebook vector
+ * h I: impulse response of weighted synthesis filter
+ * y O: filtered innovative code
+ * sign_indx O: signs of 4 pulses (signs only)
+ * pos_indx O: position index of 8 pulses (position only)
+ *
+ * Function:
+ * Builds the codeword, the filtered codeword and a
+ * linear uncombined version of the index of the
+ * codevector, based on the signs and positions of 8 pulses.
+ *
+ * Returns:
+ * void
+ */
+static void build_code_8i40_31bits( Word32 codvec[], Float32 dn_sign[], Float32
+ cod[], Float32 h[], Float32 y[], Word32 sign_indx[], Word32 pos_indx[] )
+{
+ Float64 s;
+ Float32 *p0, *p1, *p2, *p3, *p4, *p5, *p6, *p7;
+ Word32 sign[8];
+ Word32 i, j, k, track, sign_index, pos_index;
+
+
+ memset( cod, 0, L_CODE <<2 );
+
+ for ( i = 0; i < NB_TRACK_MR102; i++ ) {
+ pos_indx[i] = -1;
+ sign_indx[i] = -1;
+ }
+
+ for ( k = 0; k < 8; k++ ) {
+ /* read pulse position */
+ i = codvec[k];
+
+ /* read sign */
+ j = ( Word32 )dn_sign[i];
+
+ /* index = pos/4 */
+ pos_index = i >> 2;
+
+ /* track = pos%4 */
+ track = i & 3;
+
+ if ( j > 0 ) {
+ cod[i] = cod[i] + 0.99987792968750F;
+ sign[k] = 1;
+
+ /* bit=0 -> positive pulse */
+ sign_index = 0;
+ }
+ else {
+ cod[i] = cod[i] - 0.99987792968750F;
+ sign[k] = -1;
+
+ /* bit=1 => negative pulse */
+ sign_index = 1;
+ }
+
+ /* first set first NB_TRACK pulses */
+ if ( pos_indx[track] < 0 ) {
+ pos_indx[track] = pos_index;
+ sign_indx[track] = sign_index;
+ }
+
+ /* 2nd row of pulses , test if positions needs to be switched */
+ else {
+ if ( ( ( sign_index ^ sign_indx[track] ) & 1 ) == 0 ) {
+ /* sign of 1st pulse == sign of 2nd pulse */
+ if ( pos_indx[track] <= pos_index ) {
+ /* no swap */
+ pos_indx[track + NB_TRACK_MR102] = pos_index;
+ }
+ else {
+ /* swap*/
+ pos_indx[track + NB_TRACK_MR102] = pos_indx[track];
+ pos_indx[track] = pos_index;
+ sign_indx[track] = sign_index;
+ }
+ }
+ else {
+ /* sign of 1st pulse != sign of 2nd pulse */
+ if ( pos_indx[track] <= pos_index ) { /*swap*/
+ pos_indx[track + NB_TRACK_MR102] = pos_indx[track];
+ pos_indx[track] = pos_index;
+ sign_indx[track] = sign_index;
+ }
+ else {
+ /*no swap */
+ pos_indx[track + NB_TRACK_MR102] = pos_index;
+ }
+ }
+ }
+ }
+ p0 = h - codvec[0];
+ p1 = h - codvec[1];
+ p2 = h - codvec[2];
+ p3 = h - codvec[3];
+ p4 = h - codvec[4];
+ p5 = h - codvec[5];
+ p6 = h - codvec[6];
+ p7 = h - codvec[7];
+
+ for ( i = 0; i < L_CODE; i++ ) {
+ s = *p0++ * sign[0];
+ s += *p1++ * sign[1];
+ s += *p2++ * sign[2];
+ s += *p3++ * sign[3];
+ s += *p4++ * sign[4];
+ s += *p5++ * sign[5];
+ s += *p6++ * sign[6];
+ s += *p7++ * sign[7];
+ y[i] = ( Float32 )( s );
+ }
+}
+
+
+/*
+ * compress10
+ *
+ *
+ * Parameters:
+ * pos_indxA I: signs of 4 pulses (signs only)
+ * pos_indxB I: position index of 8 pulses (pos only)
+ * pos_indxC I: position and sign of 8 pulses (compressed)
+ * Function:
+ * Compression of three indeces [0..9] to one 10 bit index
+ * minimizing the phase shift of a bit error.
+ *
+ * Returns:
+ * indx
+ */
+static Word16 compress10( Word32 pos_indxA, Word32 pos_indxB, Word32
+ pos_indxC )
+{
+ Word32 indx, ia, ib, ic;
+
+
+ ia = pos_indxA >> 1;
+ ib = ( ( pos_indxB >> 1 ) * 5 );
+ ic = ( ( pos_indxC >> 1 ) * 25 );
+ indx = ( ia + ( ib + ic ) ) << 3;
+ ia = pos_indxA & 1;
+ ib = ( pos_indxB & 1 ) << 1;
+ ic = ( pos_indxC & 1 ) << 2;
+ indx = indx + ( ia + ( ib + ic ) );
+ return( Word16 )indx;
+}
+
+
+/*
+ * compress_code
+ *
+ *
+ * Parameters:
+ * sign_indx I: signs of 4 pulses (signs only)
+ * pos_indx I: position index of 8 pulses (pos only)
+ * indx O: position and sign of 8 pulses (compressed)
+ * Function:
+ * Compression of the linear codewords to 4+three indeces one bit from each
+ * pulse is made robust to errors by minimizing the phase shift of a bit error.
+ * 4 signs (one for each track)
+ * i0,i4,i1 => one index (7+3) bits, 3 LSBs more robust
+ * i2,i6,i5 => one index (7+3) bits, 3 LSBs more robust
+ * i3,i7 => one index (5+2) bits, 2-3 LSBs more robust
+ *
+ * Returns:
+ * void
+ */
+static void compress_code( Word32 sign_indx[], Word32 pos_indx[], Word16 indx[]
+ )
+{
+ Word32 i, ia, ib, ic;
+
+
+ for ( i = 0; i < NB_TRACK_MR102; i++ ) {
+ indx[i] = ( Word16 )sign_indx[i];
+ }
+
+ /*
+ * First index
+ * indx[NB_TRACK] = (ia/2+(ib/2)*5 +(ic/2)*25)*8 + ia%2 + (ib%2)*2 + (ic%2)*4;
+ */
+ indx[NB_TRACK_MR102] = compress10( pos_indx[0], pos_indx[4], pos_indx[1] );
+
+ /*
+ * Second index
+ * indx[NB_TRACK+1] = (ia/2+(ib/2)*5 +(ic/2)*25)*8 + ia%2 + (ib%2)*2 + (ic%2)*4;
+ */
+ indx[NB_TRACK_MR102 + 1] = compress10( pos_indx[2], pos_indx[6], pos_indx[5]
+ );
+
+ /*
+ * Third index
+ * if ((ib/2)%2 == 1)
+ * indx[NB_TRACK+2] = ((((4-ia/2) + (ib/2)*5)*32+12)/25)*4 + ia%2 + (ib%2)*2;
+ * else
+ * indx[NB_TRACK+2] = ((((ia/2) + (ib/2)*5)*32+12)/25)*4 + ia%2 + (ib%2)*2;
+ */
+ ib = ( pos_indx[7] >> 1 ) & 1;
+
+ if ( ib == 1 )
+ ia = 4 - ( pos_indx[3] >> 1 );
+ else
+ ia = pos_indx[3] >> 1;
+ ib = ( ( pos_indx[7] >> 1 ) * 5 );
+ ib = ( ( ia + ib ) << 5 ) + 12;
+ ic = ( ( ib * 1311 ) >> 15 ) << 2;
+ ia = pos_indx[3] & 1;
+ ib = ( pos_indx[7] & 1 ) << 1;
+ indx[NB_TRACK_MR102 + 2] = ( Word16 )( ia + ( ib + ic ) );
+}
+
+
+/*
+ * code_8i40_31bits
+ *
+ *
+ * Parameters:
+ * x I: target vector
+ * cn I: residual after long term prediction
+ * h I: impulse response of weighted synthesis filter
+ * T0 I: Pitch lag
+ * pitch_sharp I: Last quantized pitch gain
+ * code O: algebraic (fixed) codebook excitation
+ * y O: filtered fixed codebook excitation
+ * anap O: 7 Word16, index of 8 pulses (signs+positions)
+ *
+ * Function:
+ * Searches a 31 bit algebraic codebook containing 8 pulses
+ * in a frame of 40 samples.
+ *
+ * The code contains 8 nonzero pulses: i0...i7.
+ * All pulses can have two possible amplitudes: +1 or -1.
+ * The 40 positions in a subframe are divided into 4 tracks of
+ * interleaved positions. Each track contains two pulses.
+ * The pulses can have the following possible positions:
+ *
+ * i0, i4 : 0, 4, 8, 12, 16, 20, 24, 28, 32, 36
+ * i1, i5 : 1, 5, 9, 13, 17, 21, 25, 29, 33, 37
+ * i2, i6 : 2, 6, 10, 14, 18, 22, 26, 30, 34, 38
+ * i3, i7 : 3, 7, 11, 15, 19, 23, 27, 31, 35, 39
+ *
+ * Each pair of pulses require 1 bit for their signs. The positions
+ * are encoded together 3,3 and 2 resulting in
+ * (7+3) + (7+3) + (5+2) bits for their
+ * positions. This results in a 31 (4 sign and 27 pos) bit codebook.
+ * The function determines the optimal pulse signs and positions, builds
+ * the codevector, and computes the filtered codevector.
+ *
+ * Returns:
+ * void
+ */
+static void code_8i40_31bits( Float32 x[], Float32 cn[], Float32 h[],
+ Word32 T0, Float32 pitch_sharp, Float32 code[],
+ Float32 y[], Word16 anap[] )
+{
+ Float32 rr[L_CODE][L_CODE];
+ Float32 dn[L_CODE], sign[L_CODE];
+ Word32 ipos[8], pos_max[NB_TRACK_MR102], codvec[8], linear_signs[
+ NB_TRACK_MR102], linear_codewords[8];
+ Word32 i;
+
+ if ( pitch_sharp > 1.0F )
+ pitch_sharp = 1.0F;
+
+ /* include pitch contribution into impulse resp. */
+ if ( pitch_sharp != 0 ) {
+ for ( i = T0; i < L_SUBFR; i++ ) {
+ h[i] += h[i - T0] * pitch_sharp;
+ }
+ }
+
+ cor_h_x( h, x, dn );
+ set_sign12k2( dn, cn, sign, pos_max, NB_TRACK_MR102, ipos, STEP_MR102 );
+ cor_h( h, sign, rr );
+ search_8i40( dn, rr, ipos, pos_max, codvec );
+ build_code_8i40_31bits( codvec, sign, code, h, y, linear_signs,
+ linear_codewords );
+ compress_code( linear_signs, linear_codewords, anap );
+
+ /* Add the pitch contribution to code[]. */
+ if ( pitch_sharp != 0 ) {
+ for ( i = T0; i < L_SUBFR; i++ ) {
+ code[i] += code[i - T0] * pitch_sharp;
+ }
+ }
+ return;
+}
+
+
+/*
+ * search_10i40
+ *
+ *
+ * Parameters:
+ * dn I: correlation between target and h[]
+ * rr I: matrix of autocorrelation
+ * ipos I: starting position for each pulse
+ * pos_max I: maximum of correlation position
+ * codvec O: algebraic codebook vector
+ *
+ * Function:
+ * Search the best codevector; determine positions of the 10
+ * pulses in the 40-sample frame.
+ *
+ * First, for each of the five tracks the pulse positions with maximum
+ * absolute values of b(n) are searched. From these the global maximum value
+ * for all the pulse positions is selected. The first pulse i0 is always set
+ * into the position corresponding to the global maximum value.
+ * Next, four iterations are carried out. During each iteration the position
+ * of pulse i1 is set to the local maximum of one track.
+ * The rest of the pulses are searched in pairs by sequentially searching
+ * each of the pulse pairs {i2,i3}, {i4,i5}, {i6,i7} and {i8,i9}
+ * in nested loops. Every pulse has 8 possible positions, i.e., there are
+ * four 8x8-loops, resulting in 256 different combinations of
+ * pulse positions for each iteration. In each iteration all the 9 pulse
+ * starting positions are cyclically shifted, so that the pulse pairs are
+ * changed and the pulse i1 is placed in a local maximum of
+ * a different track. The rest of the pulses are searched also for
+ * the other positions in the tracks. At least one pulse is located in
+ * a position corresponding to the global maximum and one pulse is
+ * located in a position corresponding to one of the 4 local maxima.
+ *
+ * Returns:
+ * void
+ */
+static void search_10i40( Float32 dn[], Float32 rr[][L_CODE], Word32 ipos[],
+ Word32 pos_max[], Word32 codvec[] )
+{
+ Float32 rrv[L_CODE];
+ Float32 psk, ps, ps0, ps1, ps2, sq, sq2, alpk, alp, alp0, alp1, alp2;
+ Float32 *p_r, *p_r0, *p_r1, *p_r2, *p_r3, *p_r4, *p_r5, *p_r6, *p_r7, *p_r8,
+ *p_r9, *p_r10;
+ Float32 *p_rrv, *p_rrv0, *p_dn, *p_dn0, *p_dn1, *p_dn_max;
+ Word32 i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, j, k, ia, ib, i, pos;
+
+ p_dn_max = &dn[39];
+
+ /* fix i0 on maximum of correlation position */
+ i0 = pos_max[ipos[0]];
+ ia = ib = 0;
+ ps = 0;
+
+ /* i1 loop */
+ psk = -1;
+ alpk = 1;
+
+ for ( i = 0; i < 10; i++ ) {
+ codvec[i] = i;
+ }
+ p_r = &rr[i0][i0];
+
+ for ( i = 1; i < 5; i++ ) {
+ i1 = pos_max[ipos[1]];
+ i2 = ipos[2];
+ i3 = ipos[3];
+ i4 = ipos[4];
+ i5 = ipos[5];
+ i6 = ipos[6];
+ i7 = ipos[7];
+ i8 = ipos[8];
+ i9 = ipos[9];
+ ps0 = dn[i0] + dn[i1];
+ alp0 = *p_r + rr[i1][i1] + 2.0F * rr[i0][i1];
+
+ /* i2 and i3 loop */
+ p_rrv = &rrv[i3];
+ p_r0 = &rr[i0][i3];
+ p_r1 = &rr[i1][i3];
+ p_r3 = &rr[i3][i3];
+ *p_rrv = *p_r3 + 2.0F * ( *p_r0 + *p_r1 );
+ *( p_rrv + 5 ) = *( p_r3 + 205 ) + 2.0F * ( *( p_r0 + 5 ) + *( p_r1 + 5 )
+ );
+ *( p_rrv + 10 ) = *( p_r3 + 410 ) + 2.0F * ( *( p_r0 + 10 ) + *( p_r1 + 10
+ ) );
+ *( p_rrv + 15 ) = *( p_r3 + 615 ) + 2.0F * ( *( p_r0 + 15 ) + *( p_r1 + 15
+ ) );
+ *( p_rrv + 20 ) = *( p_r3 + 820 ) + 2.0F * ( *( p_r0 + 20 ) + *( p_r1 + 20
+ ) );
+ *( p_rrv + 25 ) = *( p_r3 + 1025 ) + 2.0F * ( *( p_r0 + 25 ) + *( p_r1 +
+ 25 ) );
+ *( p_rrv + 30 ) = *( p_r3 + 1230 ) + 2.0F * ( *( p_r0 + 30 ) + *( p_r1 +
+ 30 ) );
+ *( p_rrv + 35 ) = *( p_r3 + 1435 ) + 2.0F * ( *( p_r0 + 35 ) + *( p_r1 +
+ 35 ) );
+ sq = -1;
+ alp = 1;
+ ps = 0;
+ ia = i2;
+ ib = i3;
+ p_rrv = rrv + i3;
+ p_r0 = &rr[i0][i2];
+ p_r1 = &rr[i1][i2];
+ p_r2 = &rr[i2][i2];
+ p_r3 = &rr[i2][i3];
+ p_dn0 = dn + i2;
+ p_dn1 = dn + i3;
+ p_rrv0 = rrv + i3;
+
+ do {
+ ps1 = ps0 + *p_dn0;
+ alp1 = alp0 + *p_r2 + 2.0F * ( *p_r0 + *p_r1 );
+ p_rrv = p_rrv0;
+ p_dn = p_dn1;
+ p_r4 = p_r3;
+
+ do {
+ ps2 = ps1 + *p_dn;
+ sq2 = ps2 * ps2;
+ alp2 = alp1 + *p_rrv + 2.0F * *p_r4;
+
+ if ( ( alp * sq2 ) > ( sq * alp2 ) ) {
+ sq = sq2;
+ ps = ps2;
+ alp = alp2;
+ ia = ( Word16 )( p_dn0 - dn );
+ ib = ( Word16 )( p_dn - dn );
+ }
+ p_rrv += 5;
+ p_dn += 5;
+ p_r4 += 5;
+ } while ( p_dn < p_dn_max );
+ p_dn0 += 5;
+ p_r0 += 5;
+ p_r1 += 5;
+ p_r2 += 205;
+ p_r3 += 200;
+ } while ( p_dn0 <= p_dn_max );
+ i2 = ia;
+ i3 = ib;
+
+ /* i4 and i5 loop */
+ p_rrv = rrv + i5;
+ p_r0 = &rr[i0][i5];
+ p_r1 = &rr[i1][i5];
+ p_r2 = &rr[i2][i5];
+ p_r3 = &rr[i3][i5];
+ p_r5 = &rr[i5][i5];
+ *p_rrv = *p_r5 + 2.0F * ( *p_r0 + *p_r1 + *p_r2 + *p_r3 );
+ *( p_rrv + 5 ) = *( p_r5 + 205 ) + 2.0F * ( *( p_r0 + 5 ) + *( p_r1 + 5 )
+ + *( p_r2 + 5 ) + *( p_r3 + 5 ) );
+ *( p_rrv + 10 ) = *( p_r5 + 410 ) + 2.0F * ( *( p_r0 + 10 ) + *( p_r1 + 10
+ ) + *( p_r2 + 10 ) + *( p_r3 + 10 ) );
+ *( p_rrv + 15 ) = *( p_r5 + 615 ) + 2.0F * ( *( p_r0 + 15 ) + *( p_r1 + 15
+ ) + *( p_r2 + 15 ) + *( p_r3 + 15 ) );
+ *( p_rrv + 20 ) = *( p_r5 + 820 ) + 2.0F * ( *( p_r0 + 20 ) + *( p_r1 + 20
+ ) + *( p_r2 + 20 ) + *( p_r3 + 20 ) );
+ *( p_rrv + 25 ) = *( p_r5 + 1025 ) + 2.0F * ( *( p_r0 + 25 ) + *( p_r1 +
+ 25 ) + *( p_r2 + 25 ) + *( p_r3 + 25 ) );
+ *( p_rrv + 30 ) = *( p_r5 + 1230 ) + 2.0F * ( *( p_r0 + 30 ) + *( p_r1 +
+ 30 ) + *( p_r2 + 30 ) + *( p_r3 + 30 ) );
+ *( p_rrv + 35 ) = *( p_r5 + 1435 ) + 2.0F * ( *( p_r0 + 35 ) + *( p_r1 +
+ 35 ) + *( p_r2 + 35 ) + *( p_r3 + 35 ) );
+
+ /* Default value */
+ ps0 = ps;
+ alp0 = alp;
+ sq = -1;
+ alp = 1;
+ ps = 0;
+ ia = i4;
+ ib = i5;
+ p_dn0 = dn + i4;
+ p_dn1 = dn + i5;
+ p_r0 = &rr[i0][i4];
+ p_r1 = &rr[i1][i4];
+ p_r2 = &rr[i2][i4];
+ p_r3 = &rr[i3][i4];
+ p_r4 = &rr[i4][i4];
+ p_r5 = &rr[i4][i5];
+ p_rrv0 = rrv + i5;
+
+ do {
+ ps1 = ps0 + *p_dn0;
+ alp1 = alp0 + *p_r4 + 2.0F * ( *p_r0 + *p_r1 + *p_r2 + *p_r3 );
+ p_dn = p_dn1;
+ p_r6 = p_r5;
+ p_rrv = p_rrv0;
+
+ do {
+ ps2 = ps1 + *p_dn;
+ sq2 = ps2 * ps2;
+ alp2 = alp1 + *p_rrv + 2.0F * *p_r6;
+
+ if ( ( alp * sq2 ) > ( sq * alp2 ) ) {
+ sq = sq2;
+ ps = ps2;
+ alp = alp2;
+ ia = ( Word16 )( p_dn0 - dn );
+ ib = ( Word16 )( p_dn - dn );
+ }
+ p_dn += 5;
+ p_rrv += 5;
+ p_r6 += 5;
+ } while ( p_dn <= p_dn_max );
+ p_r0 += 5;
+ p_r1 += 5;
+ p_r2 += 5;
+ p_r3 += 5;
+ p_r4 += 205;
+ p_r5 += 200;
+ p_dn0 += 5;
+ } while ( p_dn0 < p_dn_max );
+ i4 = ia;
+ i5 = ib;
+
+ /* i6 and i7 loop */
+ p_rrv = rrv + i7;
+ p_r0 = &rr[i0][i7];
+ p_r1 = &rr[i1][i7];
+ p_r2 = &rr[i2][i7];
+ p_r3 = &rr[i3][i7];
+ p_r4 = &rr[i4][i7];
+ p_r5 = &rr[i5][i7];
+ p_r7 = &rr[i7][i7];
+ *p_rrv = *p_r7 + 2.0F * ( *p_r0 + *p_r1 + *p_r2 + *p_r3 + *p_r4 + *p_r5 );
+ *( p_rrv + 5 ) = *( p_r7 + 205 ) + 2.0F * ( *( p_r0 + 5 ) + *( p_r1 + 5 )
+ + *( p_r2 + 5 ) + *( p_r3 + 5 ) + *( p_r4 + 5 ) + *( p_r5 + 5 ) );
+ *( p_rrv + 10 ) = *( p_r7 + 410 ) + 2.0F * ( *( p_r0 + 10 ) + *( p_r1 + 10
+ ) + *( p_r2 + 10 ) + *( p_r3 + 10 ) + *( p_r4 + 10 ) + *( p_r5 + 10
+ ) );
+ *( p_rrv + 15 ) = *( p_r7 + 615 ) + 2.0F * ( *( p_r0 + 15 ) + *( p_r1 + 15
+ ) + *( p_r2 + 15 ) + *( p_r3 + 15 ) + *( p_r4 + 15 ) + *( p_r5 + 15
+ ) );
+ *( p_rrv + 20 ) = *( p_r7 + 820 ) + 2.0F * ( *( p_r0 + 20 ) + *( p_r1 + 20
+ ) + *( p_r2 + 20 ) + *( p_r3 + 20 ) + *( p_r4 + 20 ) + *( p_r5 + 20
+ ) );
+ *( p_rrv + 25 ) = *( p_r7 + 1025 ) + 2.0F * ( *( p_r0 + 25 ) + *( p_r1 +
+ 25 ) + *( p_r2 + 25 ) + *( p_r3 + 25 ) + *( p_r4 + 25 ) + *( p_r5 +
+ 25 ) );
+ *( p_rrv + 30 ) = *( p_r7 + 1230 ) + 2.0F * ( *( p_r0 + 30 ) + *( p_r1 +
+ 30 ) + *( p_r2 + 30 ) + *( p_r3 + 30 ) + *( p_r4 + 30 ) + *( p_r5 +
+ 30 ) );
+ *( p_rrv + 35 ) = *( p_r7 + 1435 ) + 2.0F * ( *( p_r0 + 35 ) + *( p_r1 +
+ 35 ) + *( p_r2 + 35 ) + *( p_r3 + 35 ) + *( p_r4 + 35 ) + *( p_r5 +
+ 35 ) );
+
+ /* Default value */
+ ps0 = ps;
+ alp0 = alp;
+ sq = -1;
+ alp = 1;
+ ps = 0;
+ ia = i6;
+ ib = i7;
+ p_dn0 = dn + i6;
+ p_dn1 = dn + i7;
+ p_r0 = &rr[i0][i6];
+ p_r1 = &rr[i1][i6];
+ p_r2 = &rr[i2][i6];
+ p_r3 = &rr[i3][i6];
+ p_r4 = &rr[i4][i6];
+ p_r5 = &rr[i5][i6];
+ p_r6 = &rr[i6][i6];
+ p_r7 = &rr[i6][i7];
+ p_rrv0 = rrv + i7;
+
+ do {
+ ps1 = ps0 + *p_dn0;
+ alp1 = alp0 + *p_r6 + 2.0F * ( *p_r0 + *p_r1 + *p_r2 + *p_r3 + *p_r4 +
+ *p_r5 );
+ p_dn = p_dn1;
+ p_r8 = p_r7;
+ p_rrv = p_rrv0;
+
+ do {
+ ps2 = ps1 + *p_dn;
+ sq2 = ps2 * ps2;
+ alp2 = alp1 + *p_rrv + 2.0F * *p_r8;
+
+ if ( ( alp * sq2 ) > ( sq * alp2 ) ) {
+ sq = sq2;
+ ps = ps2;
+ alp = alp2;
+ ia = ( Word16 )( p_dn0 - dn );
+ ib = ( Word16 )( p_dn - dn );
+ }
+ p_dn += 5;
+ p_rrv += 5;
+ p_r8 += 5;
+ } while ( p_dn <= p_dn_max );
+ p_r0 += 5;
+ p_r1 += 5;
+ p_r2 += 5;
+ p_r3 += 5;
+ p_r4 += 5;
+ p_r5 += 5;
+ p_r6 += 205;
+ p_r7 += 200;
+ p_dn0 += 5;
+ } while ( p_dn0 < p_dn_max );
+ i6 = ia;
+ i7 = ib;
+
+ /* i8 and i9 loop */
+ p_rrv = rrv + i9;
+ p_r0 = &rr[i0][i9];
+ p_r1 = &rr[i1][i9];
+ p_r2 = &rr[i2][i9];
+ p_r3 = &rr[i3][i9];
+ p_r4 = &rr[i4][i9];
+ p_r5 = &rr[i5][i9];
+ p_r6 = &rr[i6][i9];
+ p_r7 = &rr[i7][i9];
+ p_r9 = &rr[i9][i9];
+ *p_rrv = *p_r9 + 2.0F * ( *p_r0 + *p_r1 + *p_r2 + *p_r3 + *p_r4 + *p_r5 +
+ *p_r6 + *p_r7 );
+ *( p_rrv + 5 ) = *( p_r9 + 205 ) + 2.0F * ( *( p_r0 + 5 ) + *( p_r1 + 5 )
+ + *( p_r2 + 5 ) + *( p_r3 + 5 ) + *( p_r4 + 5 ) + *( p_r5 + 5 ) + *(
+ p_r6 + 5 ) + *( p_r7 + 5 ) );
+ *( p_rrv + 10 ) = *( p_r9 + 410 ) + 2.0F * ( *( p_r0 + 10 ) + *( p_r1 + 10
+ ) + *( p_r2 + 10 ) + *( p_r3 + 10 ) + *( p_r4 + 10 ) + *( p_r5 + 10
+ ) + *( p_r6 + 10 ) + *( p_r7 + 10 ) );
+ *( p_rrv + 15 ) = *( p_r9 + 615 ) + 2.0F * ( *( p_r0 + 15 ) + *( p_r1 + 15
+ ) + *( p_r2 + 15 ) + *( p_r3 + 15 ) + *( p_r4 + 15 ) + *( p_r5 + 15
+ ) + *( p_r6 + 15 ) + *( p_r7 + 15 ) );
+ *( p_rrv + 20 ) = *( p_r9 + 820 ) + 2.0F * ( *( p_r0 + 20 ) + *( p_r1 + 20
+ ) + *( p_r2 + 20 ) + *( p_r3 + 20 ) + *( p_r4 + 20 ) + *( p_r5 + 20
+ ) + *( p_r6 + 20 ) + *( p_r7 + 20 ) );
+ *( p_rrv + 25 ) = *( p_r9 + 1025 ) + 2.0F * ( *( p_r0 + 25 ) + *( p_r1 +
+ 25 ) + *( p_r2 + 25 ) + *( p_r3 + 25 ) + *( p_r4 + 25 ) + *( p_r5 +
+ 25 ) + *( p_r6 + 25 ) + *( p_r7 + 25 ) );
+ *( p_rrv + 30 ) = *( p_r9 + 1230 ) + 2.0F * ( *( p_r0 + 30 ) + *( p_r1 +
+ 30 ) + *( p_r2 + 30 ) + *( p_r3 + 30 ) + *( p_r4 + 30 ) + *( p_r5 +
+ 30 ) + *( p_r6 + 30 ) + *( p_r7 + 30 ) );
+ *( p_rrv + 35 ) = *( p_r9 + 1435 ) + 2.0F * ( *( p_r0 + 35 ) + *( p_r1 +
+ 35 ) + *( p_r2 + 35 ) + *( p_r3 + 35 ) + *( p_r4 + 35 ) + *( p_r5 +
+ 35 ) + *( p_r6 + 35 ) + *( p_r7 + 35 ) );
+
+ /* Default value */
+ ps0 = ps;
+ alp0 = alp;
+ sq = -1;
+ alp = 1;
+ ps = 0;
+ ia = i8;
+ ib = i9;
+ p_dn0 = dn + i8;
+ p_dn1 = dn + i9;
+ p_r0 = &rr[i0][i8];
+ p_r1 = &rr[i1][i8];
+ p_r2 = &rr[i2][i8];
+ p_r3 = &rr[i3][i8];
+ p_r4 = &rr[i4][i8];
+ p_r5 = &rr[i5][i8];
+ p_r6 = &rr[i6][i8];
+ p_r7 = &rr[i7][i8];
+ p_r8 = &rr[i8][i8];
+ p_r9 = &rr[i8][i9];
+ p_rrv0 = rrv + i9;
+
+ do {
+ ps1 = ps0 + *p_dn0;
+ alp1 = alp0 + *p_r8 + 2.0F * ( *p_r0 + *p_r1 + *p_r2 + *p_r3 + *p_r4 +
+ *p_r5 + *p_r6 + *p_r7 );
+ p_dn = p_dn1;
+ p_r10 = p_r9;
+ p_rrv = p_rrv0;
+
+ do {
+ ps2 = ps1 + *p_dn;
+ sq2 = ps2 * ps2;
+ alp2 = alp1 + *p_rrv + 2.0F * *p_r10;
+
+ if ( ( alp * sq2 ) > ( sq * alp2 ) ) {
+ sq = sq2;
+ ps = ps2;
+ alp = alp2;
+ ia = ( Word16 )( p_dn0 - dn );
+ ib = ( Word16 )( p_dn - dn );
+ }
+ p_dn += 5;
+ p_rrv += 5;
+ p_r10 += 5;
+ } while ( p_dn <= p_dn_max );
+ p_r0 += 5;
+ p_r1 += 5;
+ p_r2 += 5;
+ p_r3 += 5;
+ p_r4 += 5;
+ p_r5 += 5;
+ p_r6 += 5;
+ p_r7 += 5;
+ p_r8 += 205;
+ p_r9 += 200;
+ p_dn0 += 5;
+ } while ( p_dn0 < p_dn_max );
+
+ /*
+ * test and memorise if this combination is better than the last one.
+ */
+ if ( ( alpk * sq ) > ( psk * alp ) ) {
+ psk = sq;
+ alpk = alp;
+ codvec[0] = ( Word16 )i0;
+ codvec[1] = ( Word16 )i1;
+ codvec[2] = ( Word16 )i2;
+ codvec[3] = ( Word16 )i3;
+ codvec[4] = ( Word16 )i4;
+ codvec[5] = ( Word16 )i5;
+ codvec[6] = ( Word16 )i6;
+ codvec[7] = ( Word16 )i7;
+ codvec[8] = ( Word16 )ia;
+ codvec[9] = ( Word16 )ib;
+ }
+
+ /*
+ * Cyclic permutation of i1,i2,i3,i4,i5,i6,i7,(i8 and i9).
+ */
+ pos = ipos[1];
+
+ for ( j = 1, k = 2; k < 10; j++, k++ ) {
+ ipos[j] = ipos[k];
+ }
+ ipos[9] = pos;
+ } /* end 1..nb_tracks loop*/
+}
+
+
+/*
+ * build_code_10i40_35bits
+ *
+ *
+ * Parameters:
+ * codvec I: position of pulses
+ * dn_sign I: sign of pulses
+ * cod O: algebraic codebook vector
+ * h I: impulse response of weighted synthesis filter
+ * y O: filtered innovative code
+ * indx O: index of 10 pulses (sign+position)
+ *
+ * Function:
+ * Builds the codeword, the filtered codeword and index of the
+ * codevector, based on the signs and positions of 10 pulses.
+ *
+ * Returns:
+ * void
+ */
+static void build_code_10i40_35bits( Word32 codvec[], Float32 dn_sign[], Float32
+ cod[], Float32 h[], Float32 y[], Word16 indx[] )
+{
+ Word32 i, j, k, track, index, sign[10];
+ Float32 *p0, *p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8, *p9;
+ Float64 s;
+
+
+ memset( cod, 0, 160 );
+ memset( y, 0, 160 );
+
+ for ( i = 0; i < NB_TRACK; i++ ) {
+ indx[i] = -1;
+ }
+
+ for ( k = 0; k < 10; k++ ) {
+ /* read pulse position */
+ i = codvec[k];
+
+ /* read sign */
+ j = ( Word16 )dn_sign[i];
+
+ /* index = pos/5 */
+ index = ( Word16 )( i / 5 );
+
+ /* track = pos%5 */
+ track = ( Word16 )( i % 5 );
+
+ if ( j > 0 ) {
+ cod[i] = cod[i] + 1;
+ sign[k] = 1;
+ }
+ else {
+ cod[i] = cod[i] - 1;
+ sign[k] = -1;
+ index = index + 8;
+ }
+
+ if ( indx[track] < 0 ) {
+ indx[track] = ( Word16 )index;
+ }
+ else {
+ if ( ( ( index ^ indx[track] ) & 8 ) == 0 ) {
+ /* sign of 1st pulse == sign of 2nd pulse */
+ if ( indx[track] <= index ) {
+ indx[track + 5] = ( Word16 )index;
+ }
+ else {
+ indx[track + 5] = ( Word16 )indx[track];
+ indx[track] = ( Word16 )index;
+ }
+ }
+ else {
+ /* sign of 1st pulse != sign of 2nd pulse */
+ if ( ( indx[track] & 7 ) <= ( index & 7 ) ) {
+ indx[track + 5] = ( Word16 )indx[track];
+ indx[track] = ( Word16 )index;
+ }
+ else {
+ indx[track + 5] = ( Word16 )index;
+ }
+ }
+ }
+ }
+ p0 = h - codvec[0];
+ p1 = h - codvec[1];
+ p2 = h - codvec[2];
+ p3 = h - codvec[3];
+ p4 = h - codvec[4];
+ p5 = h - codvec[5];
+ p6 = h - codvec[6];
+ p7 = h - codvec[7];
+ p8 = h - codvec[8];
+ p9 = h - codvec[9];
+
+ for ( i = 0; i < L_CODE; i++ ) {
+ s = *p0++ * sign[0];
+ s += *p1++ * sign[1];
+ s += *p2++ * sign[2];
+ s += *p3++ * sign[3];
+ s += *p4++ * sign[4];
+ s += *p5++ * sign[5];
+ s += *p6++ * sign[6];
+ s += *p7++ * sign[7];
+ s += *p8++ * sign[8];
+ s += *p9++ * sign[9];
+ y[i] = ( Float32 )( s );
+ }
+}
+
+
+/*
+ * q_p
+ *
+ *
+ * Parameters:
+ * ind B: Pulse position
+ * n I: Pulse number
+ *
+ * Function:
+ * Gray coding
+ *
+ * Returns:
+ * void
+ */
+static void q_p( Word16 *ind, Word32 n )
+{
+ Word16 tmp;
+
+
+ tmp = *ind;
+
+ if ( n < 5 ) {
+ *ind = ( Word16 )( ( tmp & 0x8 ) | gray[tmp & 0x7] );
+ }
+ else {
+ *ind = gray[tmp & 0x7];
+ }
+}
+
+
+/*
+ * code_10i40_35bits
+ *
+ *
+ * Parameters:
+ * x I: target vector
+ * cn I: residual after long term prediction
+ * h I: impulse response of weighted synthesis filter
+ * gain_pit I: quantified adaptive codebook gain
+ * code O: algebraic (fixed) codebook excitation
+ * y O: filtered fixed codebook excitation
+ * anap O: 7 Word16, index of 8 pulses (signs+positions)
+ *
+ * Function:
+ * Searches a 35 bit algebraic codebook containing 10 pulses
+ * in a frame of 40 samples.
+ *
+ * The code contains 10 nonzero pulses: i0...i9.
+ * All pulses can have two possible amplitudes: +1 or -1.
+ * The 40 positions in a subframe are divided into 5 tracks of
+ * interleaved positions. Each track contains two pulses.
+ * The pulses can have the following possible positions:
+ * Track Pulse Positions
+ * 1 i0, i5 0, 5, 10, 15, 20, 25, 30, 35.
+ * 2 i1, i6 1, 6, 11, 16, 21, 26, 31, 36.
+ * 3 i2, i 2, 7, 12, 17, 22, 27, 32, 37.
+ * 4 i3, i8 3, 8, 13, 18, 23, 28, 33, 38.
+ * 5 i4, i9 4, 9, 14, 19, 24, 29, 34, 39.
+ *
+ * Each pair of pulses require 1 bit for their signs and 6 bits for their
+ * positions (3 bits + 3 bits). This results in a 35 bit codebook.
+ * The function determines the optimal pulse signs and positions, builds
+ * the codevector, and computes the filtered codevector.
+ *
+ * The algebraic codebook is searched by minimizing the mean square error
+ * between the weighted input speech and the weighted synthesized speech.
+ * The target signal used in the closed-loop pitch search is updated by
+ * subtracting the adaptive codebook contribution. That is:
+ *
+ * x2(n) = x(n) - Gp' * y(n), n = 0, ..., 39
+ *
+ * where y(n) = v(n) * h(n) is the filtered adaptive codebook vector
+ * and Gp' is the quantified adaptive codebook gain. This is done
+ * already in function cl_ltp.
+ *
+ * If c(k) is the algebraic codevector at index k, then
+ * the algebraic codebook is searched by maximizing the term:
+ *
+ * A(k) = (C(k) * C(k)) / Ed(k) =
+ *
+ * 39
+ * [SUM sb(i)*d(i)]^2
+ * i=0
+ * ---------------------
+ * transpose(sb) * PI * sb
+ *
+ * where d(n) is the correlation between the target signal x2(n)
+ * and the impulse response h(n), H is a the lower triangular Toepliz
+ * convolution matrix with diagonal h(0) and lower diagonals
+ * h(1), ..., h(39), and PI = H_transpose * H is the matrix of
+ * correlations of h(n).
+ *
+ * The pulse amplitudes are preset by the mere quantization of an signal
+ * b(n) used for presetting the amplitudes.
+ *
+ * 39
+ * b(n) = res(n) / SQRT[ SUM[ res(i) * res(i) ] ]
+ * i=0
+ * 39
+ * + d(n) / SQRT[ SUM [ d(i) * d(i) ] ], n = 0, ..., 39,
+ * i=0
+ *
+ * where res(n) is normalized long-term prediction residual and
+ * d(n) is normalized vector.
+ *
+ * 39
+ * d(n) = SUM[ x2(i) * h(i-n) ], n = 0, ..., 39,
+ * i=n
+ *
+ * This is simply done by setting the amplitude of a pulse at
+ * a certain position equal to the sign of b(n) at that position.
+ * The simplification proceeds as follows (prior to the codebook search).
+ * First, the sign signal sb(n) = SIGN[ b(n) ] and
+ * the signal d'(n) = sb(n) * d(n) are computed.
+ *
+ * Returns:
+ * void
+ */
+static void code_10i40_35bits( Float32 x[], Float32 cn[], Float32 h[],
+ Word32 T0, Float32 gain_pit, Float32 code[],
+ Float32 y[], Word16 anap[] )
+ {
+ Float32 rr[L_CODE][L_CODE];
+ Float32 dn[L_CODE], sign[L_CODE];
+ Word32 ipos[10], pos_max[NB_TRACK], codvec[10];
+ Word32 i;
+
+ /* include pitch contribution into impulse resp. */
+ if ( gain_pit > 1.0F )
+ gain_pit = 1.0F;
+
+ if ( gain_pit != 0 ) {
+ for ( i = T0; i < L_SUBFR; i++ ) {
+ h[i] += h[i - T0] * gain_pit;
+ }
+ }
+ /*
+ * 39
+ * d(n) = SUM[ x2(i) * h(i-n) ], n = 0, ..., 39
+ * i=n
+ */
+ cor_h_x( h, x, dn );
+
+ /* sb(n) and d'(n) */
+ set_sign12k2( dn, cn, sign, pos_max, NB_TRACK, ipos, STEP );
+
+ /* Matrix of correlations */
+ cor_h( h, sign, rr );
+ search_10i40( dn, rr, ipos, pos_max, codvec );
+ build_code_10i40_35bits( codvec, sign, code, h, y, anap );
+
+ for ( i = 0; i < 10; i++ ) {
+ q_p( &anap[i], i );
+ }
+
+ /* Add the pitch contribution to code[]. */
+ if ( gain_pit != 0 ) {
+ for ( i = T0; i < L_SUBFR; i++ ) {
+ code[i] += code[i - T0] * gain_pit;
+ }
+ }
+ return;
+ }
+
+
+/*
+ * cbsearch
+ *
+ *
+ * Parameters:
+ * mode I: AMR mode
+ * subnr I: Subframe
+ * x I: Target vector
+ * h B: Impulse response of weighted synthesis filter
+ * T0 I: Pitch lag
+ * pitch_sharp I: Last quantized pitch gain
+ * gain_pit I: Algebraic codebook gain
+ * code O: Innovative codebook
+ * y O: Filtered fixed codebook excitation
+ * res2 I: residual after long term prediction
+ * anap O: Signs and positions of the pulses
+ *
+ * Function:
+ * Innovative codebook search (find index and gain)
+ *
+ * Returns:
+ * void
+ */
+static void cbsearch( enum Mode mode, Word16 subnr, Float32 x[],
+ Float32 h[], Word32 T0, Float32 pitch_sharp,
+ Float32 gain_pit, Float32 code[], Float32 y[],
+ Float32 *res2, Word16 **anap )
+{
+ switch (mode){
+ case MR475:
+ case MR515:
+ code_2i40_9bits( subnr, x, h, T0, pitch_sharp, code, y, *anap );
+ ( *anap ) += 2;
+ break;
+ case MR59:
+ code_2i40_11bits( x, h, T0, pitch_sharp, code, y, *anap );
+ ( *anap ) += 2;
+ break;
+ case MR67:
+ code_3i40_14bits( x, h, T0, pitch_sharp, code, y, *anap );
+ ( *anap ) += 2;
+ break;
+ case MR74:
+ case MR795:
+ code_4i40_17bits( x, h, T0, pitch_sharp, code, y, *anap );
+ ( *anap ) += 2;
+ break;
+ case MR102:
+ code_8i40_31bits( x, res2, h, T0, pitch_sharp, code, y, *anap );
+ *anap += 7;
+ break;
+ default:
+ code_10i40_35bits( x, res2, h, T0, gain_pit, code, y, *anap );
+ *anap += 10;
+ }
+}
+
+/*
+ * Log2_norm
+ *
+ *
+ * Parameters:
+ * x I: input value
+ * exp I: exponent
+ * exponent O: Integer part of Log2. (range: 0<=val<=30)
+ * fraction O: Fractional part of Log2. (range: 0<=val<1)
+ *
+ * Function:
+ * Computes log2
+ *
+ * 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.
+ *
+ * The function Log2(L_x) is approximated by a table and linear
+ * interpolation. The following steps are used to compute Log2(L_x)
+ *
+ * exponent = 30-normExponent
+ * i = bit25-b31 of L_x; 32<=i<=63 (because of normalization).
+ * a = bit10-b24
+ * i -=32
+ * fraction = table[i]<<16 - (table[i] - table[i+1]) * a * 2
+ *
+ * Returns:
+ * void
+ */
+static void Log2_norm( Word32 x, Word32 exp, Word32 *exponent, Word32 *
+ fraction )
+{
+ Word32 y, i, a;
+
+ if ( x <= 0 ) {
+ *exponent = 0;
+ *fraction = 0;
+ return;
+ }
+
+ /* Extract b25-b31 */
+ i = x >> 25;
+ i = i - 32;
+
+ /* Extract b10-b24 of fraction */
+ a = x >> 9;
+ a = a & 0xFFFE; /* 2a */
+
+ /* fraction */
+ y = ( log2_table[i] << 16 ) - a * ( log2_table[i] - log2_table[i + 1] );
+ *fraction = y >> 16;
+ *exponent = 30 - exp;
+ return;
+}
+
+/*
+ * Log2
+ *
+ *
+ * Parameters:
+ * x I: input value
+ * exponent O: Integer part of Log2. (range: 0<=val<=30)
+ * fraction O: Fractional part of Log2. (range: 0<=val<1)
+ *
+ * Function:
+ * Computes log2(L_x)
+ * If x is negative or zero, the result is 0.
+ *
+ * Returns:
+ * void
+ */
+static void Log2( Word32 x, Word32 *exponent, Word32 *fraction )
+{
+ int exp;
+
+
+ frexp( ( Float64 )x, &exp );
+ exp = 31 - exp;
+ Log2_norm( x <<exp, exp, exponent, fraction );
+}
+
+/*
+ * Pow2
+ *
+ *
+ * Parameters:
+ * exponent I: Integer part. (range: 0<=val<=30)
+ * fraction O: Fractional part. (range: 0.0<=val<1.0)
+ *
+ * Function:
+ * pow(2.0, exponent.fraction)
+ *
+ * The function Pow2(L_x) is approximated by a table and linear interpolation.
+ *
+ * i = bit10-b15 of fraction, 0 <= i <= 31
+ * a = biT0-b9 of fraction
+ * x = table[i]<<16 - (table[i] - table[i+1]) * a * 2
+ * x = L_x >> (30-exponent) (with rounding)
+ *
+ * Returns:
+ * result (range: 0<=val<=0x7fffffff)
+ */
+static Word32 Pow2( Word32 exponent, Word32 fraction )
+{
+ Word32 i, a, tmp, x, exp;
+
+ /* Extract b10-b16 of fraction */
+ i = fraction >> 10;
+
+ /* Extract b0-b9 of fraction */
+ a = ( fraction << 5 ) & 0x7fff;
+
+ /* table[i] << 16 */
+ x = pow2_table[i] << 16;
+
+ /* table[i] - table[i+1] */
+ tmp = pow2_table[i] - pow2_table[i + 1];
+
+ /* L_x -= tmp*a*2 */
+ x -= ( tmp * a ) << 1;
+
+ if ( exponent >= -1 ) {
+ exp = ( 30 - exponent );
+
+ /* Rounding */
+ if ( ( x & ( ( Word32 )1 << ( exp - 1 ) ) ) != 0 ) {
+ x = ( x >> exp ) + 1;
+ }
+ else
+ x = x >> exp;
+ }
+ else
+ x = 0;
+ return( x );
+}
+
+/*
+ * gc_pred
+ *
+ *
+ * Parameters:
+ * past_qua_en I: MA predictor
+ * mode I: AMR mode
+ * code I: innovative codebook vector
+ * gcode0 O: predicted gain factor
+ * en I: innovation energy (only calculated for MR795)
+ *
+ * Function:
+ * MA prediction of the innovation energy
+ *
+ * Mean removed innovation energy (dB) in subframe n
+ * N-1
+ * E(n) = 10*log(gc*gc * SUM[(code(i) * code(i)]/N) - E_mean
+ * i=0
+ * N=40
+ *
+ * Mean innovation energy (dB)
+ * N-1
+ * Ei(n) = 10*log(SUM[(code(i) * code(i)]/N)
+ * i=0
+ *
+ * Predicted energy
+ * 4
+ * Ep(n) = SUM[b(i) * R(n-i)]
+ * i=1
+ * b = [0.68 0.58 0.34 0.19]
+ * R(k) is quantified prediction error at subframe k
+ *
+ * E_Mean = 36 dB (MR122)
+ *
+ * Predicted gain gc is found by
+ *
+ * gc = POW[10, 0.05 * (Ep(n) + E_mean - Ei)]
+ *
+ * Returns:
+ * void
+ */
+static void gc_pred( Word32 *past_qua_en, enum Mode mode, Float32 *code,
+ Word32 *gcode0_exp, Word32 *gcode0_fra, Float32 *en )
+{
+ Float64 ener_code;
+ Word32 exp, frac, ener, ener_tmp, tmp;
+ int exp_code;
+
+
+ /* energy of code */
+ ener_code = Dotproduct40( code, code );
+
+ if ( mode == MR122 ) {
+
+ ener = (Word32)(ener_code * 33554432);
+ /* ener_code = ener_code / lcode; lcode = 40; 1/40 = 26214 Q20 */
+ ener = ( ( ener + 0x00008000L ) >> 16 ) * 52428;
+
+ Log2( ener, &exp, &frac );
+ ener = ( ( exp - 30 ) << 16 ) + ( frac << 1 );
+
+ ener_tmp = 44 * qua_gain_code_MR122[past_qua_en[0]];
+ ener_tmp += 37 * qua_gain_code_MR122[past_qua_en[1]];
+ ener_tmp += 22 * qua_gain_code_MR122[past_qua_en[2]];
+ ener_tmp += 12 * qua_gain_code_MR122[past_qua_en[3]];
+
+ ener_tmp = ener_tmp << 1;
+ ener_tmp += 783741L;
+
+ /*
+ * predicted codebook gain
+ * gc0 = Pow10( (ener*constant - ener_code*constant) / 20 )
+ * = Pow2(ener-ener_code)
+ * = Pow2(int(d)+frac(d))
+ */
+ ener = ( ener_tmp - ener ) >> 1; /* Q16 */
+ *gcode0_exp = ener >> 16;
+ *gcode0_fra = ( ener >> 1 ) - ( *gcode0_exp << 15 );
+ }
+ else {
+ ener = (Word32)(ener_code * 134217728);
+ if (ener < 0)
+ ener = 0x7fffffff;
+
+ frexp( ( Float64 )ener, &exp_code );
+ exp_code = 31 - exp_code;
+ ener <<= exp_code;
+
+ Log2_norm( ener, exp_code, &exp, &frac );
+
+ tmp = ( exp * ( -49320 ) ) + ( ( ( frac * ( -24660 ) ) >> 15 ) << 1 );
+
+ if ( mode == MR102 ) {
+ /* mean = 33 dB */
+ tmp += 2134784; /* Q14 */
+ }
+ else if ( mode == MR795 ) {
+ /* mean = 36 dB */
+ tmp += 2183936; /* Q14 */
+
+ *en = (Float32)ener_code;
+ }
+ else if ( mode == MR74 ) {
+ /* mean = 30 dB */
+ tmp += 2085632; /* Q14 */
+ }
+ else if ( mode == MR67 ) {
+ /* mean = 28.75 dB */
+ tmp += 2065152; /* Q14 */
+ }
+ else /* MR59, MR515, MR475 */ {
+ /* mean = 33 dB */
+ tmp += 2134784; /* Q14 */
+ }
+
+ tmp = tmp << 9;
+
+ tmp += 5571 * qua_gain_code[past_qua_en[0]];
+ tmp += 4751 * qua_gain_code[past_qua_en[1]];
+ tmp += 2785 * qua_gain_code[past_qua_en[2]];
+ tmp += 1556 * qua_gain_code[past_qua_en[3]];
+
+ tmp = tmp >> 15; /* Q8 */
+
+ /*
+ * gcode0 = pow(10.0, gcode0/20)
+ * = pow(2, 3.3219*gcode0/20)
+ * = pow(2, 0.166*gcode0)
+ */
+ /* 5439 Q15 = 0.165985 */
+ /* (correct: 1/(20*log10(2)) 0.166096 = 5443 Q15) */
+ /* For IS641 bitexactness */
+ if ( mode == MR74 ) {
+ /* Q8 * Q15 -> Q24 */
+ tmp = tmp * 10878;
+ }
+ else {
+ /* Q8 * Q15 -> Q24 */
+ tmp = tmp * 10886;
+ }
+ tmp = tmp >> 9; /* -> Q15 */
+
+ *gcode0_exp = tmp >> 15;
+ *gcode0_fra = tmp - ( *gcode0_exp * 32768 );
+ }
+}
+
+/*
+ * calc_filt_energies
+ *
+ *
+ * Parameters:
+ * mode I: AMR mode
+ * xn I: LTP target vector
+ * xn2 I: CB target vector
+ * y1 I: Adaptive codebook
+ * y2 I: Filtered innovative vector
+ * gCoeff I: Correlations <xn y1> <y1 y1>
+ * coeff O: energy coefficients
+ * cod_gain O: optimum codebook gain
+ *
+ * Function:
+ * Calculation of several energy coefficients for filtered excitation signals
+ *
+ * Compute coefficients need for the quantization and the optimum
+ * codebook gain gcu (for MR475 only).
+ *
+ * coeff[0] = y1 y1
+ * coeff[1] = -2 xn y1
+ * coeff[2] = y2 y2
+ * coeff[3] = -2 xn y2
+ * coeff[4] = 2 y1 y2
+ *
+ *
+ * gcu = <xn2, y2> / <y2, y2> (0 if <xn2, y2> <= 0)
+ *
+ * Product <y1 y1> and <xn y1> have been computed in G_pitch() and
+ * are in vector gCoeff[].
+ *
+ * Returns:
+ * void
+ */
+static void calc_filt_energies( enum Mode mode, Float32 xn[], Float32 xn2[],
+ Float32 y1[], Float32 y2[], Float32 gCoeff[], Float32 coeff[], Float32 *
+ cod_gain )
+{
+ Float32 sum, ener_init = 0.01F;
+
+
+ if ( ( mode == MR795 ) || ( mode == MR475 ) )
+ ener_init = 0;
+ coeff[0] = gCoeff[0];
+ coeff[1] = -2.0F * gCoeff[1];
+
+ /* Compute scalar product <y2[],y2[]> */
+ sum = (Float32)Dotproduct40( y2, y2 );
+ sum += ener_init;
+ coeff[2] = sum;
+
+ /* Compute scalar product -2*<xn[],y2[]> */
+ sum = (Float32)Dotproduct40( xn, y2 );
+ sum += ener_init;
+ coeff[3] = -2.0F * sum;
+
+ /* Compute scalar product 2*<y1[],y2[]> */
+ sum = (Float32)Dotproduct40( y1, y2 );
+ sum += ener_init;
+ coeff[4] = 2.0F * sum;
+
+ if ( ( mode == MR475 ) || ( mode == MR795 ) ) {
+ /* Compute scalar product <xn2[],y2[]> */
+ sum = (Float32)Dotproduct40( xn2, y2 );
+
+ if ( sum <= 0 ) {
+ *cod_gain = 0;
+ }
+ else {
+ /*
+ * gcu = <xn2, y2> / <y2, y2>
+ */
+ *cod_gain = sum / coeff[2];
+ }
+ }
+}
+
+
+/*
+ * MR475_update_unq_pred
+ *
+ *
+ * Parameters:
+ * past_qua_en I: MA predictor memory, 20*log10(qua_err)
+ * gcode0 I: predicted CB gain
+ * cod_gain I: optimum codebook gain
+ *
+ * Function:
+ * Use optimum codebook gain and update "unquantized"
+ * gain predictor with the (bounded) prediction error
+ *
+ * Prediction error is given by:
+ *
+ * R(n) = E(n) - E_pred(n) = 20 * log(cf),
+ *
+ * where correction factor cf between the gain Gc and
+ * the estimated pne Gc' is given by:
+ *
+ * cf = Gc/Gc'.
+ *
+ * Returns:
+ * void
+ */
+static void MR475_update_unq_pred( Word32 *past_qua_en, Float32 gcode0, Float32
+ cod_gain )
+{
+ Float32 qua_ener, pred_err_fact;
+ Word32 i, index, energy, max, s;
+
+
+ if ( cod_gain <= 0 ) {
+ /*MIN_QUA_ENER*/
+ qua_ener = -32.0F;
+ }
+ else {
+ if (gcode0 != 0) {
+ pred_err_fact = cod_gain / gcode0;
+ }
+ else {
+ pred_err_fact = 10.0F;
+ }
+
+ if ( pred_err_fact < 0.0251189F ) {
+ /*MIN_QUA_ENER*/
+ qua_ener = -32.0F;
+ }
+ else if ( pred_err_fact > 7.8125F ) {
+ /*MAX_QUA_ENER*/
+ qua_ener = 17.8558F;
+ }
+ else {
+ qua_ener = ( Float32 )( 20.0F*log10( pred_err_fact ) );
+ }
+ }
+ energy = (Word32)(qua_ener * 1024 + 0.5F);
+ max = abs(energy - qua_gain_code[0]);
+ index = 0;
+ /* find match from table */
+ for ( i = 1; i < NB_QUA_CODE+VQ_SIZE_HIGHRATES+VQ_SIZE_LOWRATES+MR475_VQ_SIZE*2+3; i++ )
+ {
+ s = abs(energy - qua_gain_code[i]);
+ if (s < max){
+ max = s;
+ index = i;
+ if (s == 0) {
+ break;
+ }
+ }
+ }
+ /* update MA predictor memory */
+ for ( i = 3; i > 0; i-- ) {
+ past_qua_en[i] = past_qua_en[i - 1];
+ }
+ past_qua_en[0] = index;
+}
+
+
+/*
+ * MR475_gain_quant
+ *
+ *
+ * Parameters:
+ * past_qua_en B: MA predictor memory, 20*log10(qua_err)
+ * sf0_gcode0_exp(fra) I: predicted CB gain from subframe 0 (or 2)
+ * sf0_coeff I: energy coeff. from subframe 0 (or 2)
+ * sf0_target_en I: target energy from subframe 0 (or 2)
+ * sf1_code_nosharp I: innovative codebook vector (L_SUBFR)
+ * (without pitch sharpening)
+ * from subframe 1 (or 3)
+ * sf1_gcode0_exp(fra) I: predicted CB gain from subframe 1 (or 3)
+ * sf1_coeff I: energy coeff. subframe 1 (or 3)
+ * sf1_target_en I: target energy from subframe 1 (or 3)
+ * gp_limit I: pitch gain limit
+ * sf0_gain_pit O: Pitch gain subframe 0 (or 2)
+ * sf0_gain_cod O: Code gain subframe 0 (or 2)
+ * sf1_gain_pit O: Pitch gain subframe 1 (or 3)
+ * sf1_gain_cod O: Code gain subframe 1 (or 3)
+ *
+ * Function:
+ * Quantization of pitch and codebook gains for two subframes
+ * (using predicted codebook gain)
+ *
+ * Returns:
+ * index index of quantization
+ */
+static Word16 MR475_gain_quant( Word32 *past_qua_en, Word32 sf0_gcode0_exp, Word32
+ sf0_gcode0_fra, Float32 sf0_coeff[], Float32 sf0_target_en,
+ Float32 sf1_code_nosharp[], Word32 sf1_gcode0_exp, Word32
+ sf1_gcode0_fra, Float32 sf1_coeff[], Float32 sf1_target_en,
+ Float32 gp_limit, Float32 *sf0_gain_pit, Float32
+ *sf0_gain_cod, Float32 *sf1_gain_pit, Float32 *sf1_gain_cod )
+{
+ Float32 temp, temp2, g_pitch, g2_pitch, g_code, g2_code, g_pit_cod, dist_min, sf0_gcode0, sf1_gcode0;
+ const Float32 *p;
+ Word32 i, tmp, g_code_tmp, gcode0, index = 0;
+
+ sf0_gcode0 = (Float32)Pow2(sf0_gcode0_exp, sf0_gcode0_fra);
+ sf1_gcode0 = (Float32)Pow2(sf1_gcode0_exp, sf1_gcode0_fra);
+
+ if ( ( sf0_target_en * 2.0F ) < sf1_target_en ) {
+ sf0_coeff[0] *= 2.0F;
+ sf0_coeff[1] *= 2.0F;
+ sf0_coeff[2] *= 2.0F;
+ sf0_coeff[3] *= 2.0F;
+ sf0_coeff[4] *= 2.0F;
+ }
+ else if ( sf0_target_en > ( sf1_target_en * 4.0F ) ) {
+ sf1_coeff[0] *= 2.0F;
+ sf1_coeff[1] *= 2.0F;
+ sf1_coeff[2] *= 2.0F;
+ sf1_coeff[3] *= 2.0F;
+ sf1_coeff[4] *= 2.0F;
+ }
+
+ /*
+ * Codebook search:
+ * For each pair (g_pitch, g_fac) in the table calculate the
+ * terms t[0..4] and sum them up; the result is the mean squared
+ * error for the quantized gains from the table. The index for the
+ * minimum MSE is stored and finally used to retrieve the quantized
+ * gains
+ */
+ dist_min = FLT_MAX;
+ p = &table_gain_MR475[0];
+
+ for ( i = 0; i < MR475_VQ_SIZE; i++ ) {
+ /* subframe 0 (and 2) calculations */
+ g_pitch = *p++;
+ g_code = *p++;
+ g_code *= sf0_gcode0;
+ g2_pitch = g_pitch * g_pitch;
+ g2_code = g_code * g_code;
+ g_pit_cod = g_code * g_pitch;
+ temp = sf0_coeff[0] * g2_pitch;
+ temp += sf0_coeff[1] * g_pitch;
+ temp += sf0_coeff[2] * g2_code;
+ temp += sf0_coeff[3] * g_code;
+ temp += sf0_coeff[4] * g_pit_cod;
+ temp2 = g_pitch - gp_limit;
+
+ /* subframe 1 (and 3) calculations */
+ g_pitch = *p++;
+ g_code = *p++;
+
+ if ( temp2 <= 0 && ( g_pitch <= gp_limit ) ) {
+ g_code *= sf1_gcode0;
+ g2_pitch = g_pitch * g_pitch;
+ g2_code = g_code * g_code;
+ g_pit_cod = g_code * g_pitch;
+ temp += sf1_coeff[0] * g2_pitch;
+ temp += sf1_coeff[1] * g_pitch;
+ temp += sf1_coeff[2] * g2_code;
+ temp += sf1_coeff[3] * g_code;
+ temp += sf1_coeff[4] * g_pit_cod;
+
+ /*
+ * store table index if MSE for this index is lower
+ * than the minimum MSE seen so far
+ */
+ if ( temp < dist_min ) {
+ dist_min = temp;
+ index = i;
+ }
+ }
+ }
+
+ /*
+ * read quantized gains and update MA predictor memories
+ *
+ * for subframe 0, the pre-calculated gcode0 is the same
+ * as one calculated from the "real" predictor using quantized gains
+ */
+ tmp = index << 2;
+ p = &table_gain_MR475[tmp];
+ *sf0_gain_pit = *p++;
+ g_code_tmp = (Word32)(*p++ * 4096 + 0.5F);
+
+ gcode0 = Pow2( 14, sf0_gcode0_fra );
+ if ( sf0_gcode0_exp < 11 ) {
+ *sf0_gain_cod = (Float32)(( g_code_tmp * gcode0 ) >> ( 25 - sf0_gcode0_exp ));
+ }
+ else {
+ i = ( ( g_code_tmp * gcode0 ) << ( sf0_gcode0_exp - 9 ) );
+
+ if ( ( i >> ( sf0_gcode0_exp - 9 ) ) != ( g_code_tmp * gcode0 ) ) {
+ *sf0_gain_cod = (Float32)0x7FFF;
+ }
+ else {
+ *sf0_gain_cod = (Float32)(i >> 16);
+ }
+ }
+
+ *sf0_gain_cod *= 0.5F;
+
+ for ( i = 3; i > 0; i-- ) {
+ past_qua_en[i] = past_qua_en[i - 1];
+ }
+ past_qua_en[0] = NB_QUA_CODE+VQ_SIZE_HIGHRATES+VQ_SIZE_LOWRATES + (index << 1);
+
+
+ /*
+ * calculate new predicted gain for subframe 1 (this time using
+ * the real, quantized gains)
+ */
+ gc_pred( past_qua_en, MR475, sf1_code_nosharp, &sf1_gcode0_exp, &sf1_gcode0_fra, &sf0_gcode0 );
+
+ tmp += 2;
+ p = &table_gain_MR475[tmp];
+ *sf1_gain_pit = *p++;
+ g_code_tmp = (Word32)(*p++ * 4096 + 0.5F);
+
+ gcode0 = Pow2( 14, sf1_gcode0_fra );
+ if ( sf1_gcode0_exp < 11 ) {
+ *sf1_gain_cod = (Float32)(( g_code_tmp * gcode0 ) >> ( 25 - sf1_gcode0_exp ));
+ }
+ else {
+ i = ( ( g_code_tmp * gcode0 ) << ( sf1_gcode0_exp - 9 ) );
+
+ if ( ( i >> ( sf1_gcode0_exp - 9 ) ) != ( g_code_tmp * gcode0 ) ) {
+ *sf1_gain_cod = (Float32)0x7FFF;
+ }
+ else {
+ *sf1_gain_cod = (Float32)(i >> 16);
+ }
+ }
+
+ *sf1_gain_cod *= 0.5F;
+
+ for ( i = 3; i > 0; i-- ) {
+ past_qua_en[i] = past_qua_en[i - 1];
+ }
+ past_qua_en[0] = NB_QUA_CODE+VQ_SIZE_HIGHRATES+VQ_SIZE_LOWRATES + (index << 1) + 1;
+
+ return( Word16 )index;
+}
+
+
+/*
+ * q_gain_code
+ *
+ *
+ * Parameters:
+ * gcode0 I: predicted CB gain
+ * gain B: quantized fixed codebook gain
+ * qua_ener_index O: quantized energy error index
+ *
+ * Function:
+ * Scalar quantization of the innovative codebook gain.
+ *
+ * A correction factor between the gain gc and the estimated one gc'
+ * is given by:
+ *
+ * cf = gc/gc'
+ *
+ * The quantization table search is performed by minimizing the error:
+ *
+ * Eq = POW[gc - cf' * gc', 2]
+ *
+ * Once the optimum value cf' is chosen,
+ * the quantified fixed codebook gain is given by
+ *
+ * gc_q = cf' * gc'
+ *
+ * Returns:
+ * index quantization index
+ */
+static Word16 q_gain_code( Float32 gcode0, Float32 *gain, Word32 *qua_ener_index)
+{
+ Float64 err_min, err;
+ const Float32 *p;
+ Word32 i, index;
+
+
+ p = &gain_factor[0];
+
+ /* using abs instead pow */
+ err_min = fabs( *gain - ( gcode0 * *p++ ) );
+ index = 0;
+
+ for ( i = 1; i < NB_QUA_CODE; i++ ) {
+ err = fabs( *gain - ( gcode0 * *p++ ) );
+
+ if ( err < err_min ) {
+ err_min = err;
+ index = i;
+ }
+ }
+ p = &gain_factor[index];
+ *gain = (Float32)floor(gcode0 * *p);
+ *qua_ener_index = index;
+
+ return( Word16 )index;
+}
+
+
+/*
+ * MR795_gain_code_quant3
+ *
+ *
+ * Parameters:
+ * gcode0 I: Predicted CB gain
+ * g_pitch_cand I: Pitch gain candidates (3)
+ * g_pitch_cind I: Pitch gain cand. indices (3)
+ * coeff I: Energy coefficients
+ * gain_pit O: Pitch gain
+ * gain_pit_ind O: Pitch gain index
+ * gain_cod O: Code gain
+ * gain_cod_ind O: Code gain index
+ * qua_ener_index O: quantized energy error index
+ *
+ * Function:
+ * Pre-quantization of codebook gains, given three possible
+ * LTP gains (using predicted codebook gain)
+ *
+ * Returns:
+ * void
+ */
+static void MR795_gain_code_quant3( Word32 gcode0_exp, Word32 gcode0_fra, Float32 g_pitch_cand[],
+ Word32 g_pitch_cind[], Float32 coeff[], Float32 *gain_pit, Word32 *
+ gain_pit_ind, Float32 *gain_cod, Word32 *gain_cod_ind, Word32 *qua_ener_index )
+{
+ Float32 gcode0, dist_min, g_pitch, g2_pitch, g_code, g2_code, g_pit_cod, tmp0, tmp;
+ const Float32 *p;
+ Word32 i, j, cod_ind, pit_ind, g_code0, g_code_tmp;
+
+ gcode0 = (Float32)Pow2( gcode0_exp, gcode0_fra);
+ /*
+ * The error energy (sum) to be minimized consists of five terms, t[0..4].
+ *
+ * t[0] = gp^2 * <y1 y1>
+ * t[1] = -2*gp * <xn y1>
+ * t[2] = gc^2 * <y2 y2>
+ * t[3] = -2*gc * <xn y2>
+ * t[4] = 2*gp*gc * <y1 y2>
+ */
+ /*
+ * Codebook search:
+ * For each of the candiates LTP gains in g_pitch_cand[], the terms
+ * t[0..4] are calculated from the values in the table (and the
+ * pitch gain candidate) and summed up; the result is the mean
+ * squared error for the LPT/CB gain pair. The index for the mini-
+ * mum MSE is stored and finally used to retrieve the quantized CB
+ * gain
+ */
+ dist_min = FLT_MAX;
+ cod_ind = 0;
+ pit_ind = 0;
+
+ /* loop through LTP gain candidates */
+ for ( j = 0; j < 3; j++ ) {
+ /* pre-calculate terms only dependent on pitch gain */
+ g_pitch = g_pitch_cand[j];
+ g2_pitch = g_pitch * g_pitch;
+ tmp0 = coeff[0] * g2_pitch;
+ tmp0 += coeff[1] * g_pitch;
+ p = &gain_factor[0];
+
+ for ( i = 0; i < NB_QUA_CODE; i++ ) {
+ /* this is g_fac */
+ g_code = *p++;
+ g_code = g_code * gcode0;
+ g2_code = g_code * g_code;
+ g_pit_cod = g_code * g_pitch;
+ tmp = tmp0 + coeff[2] * g2_code;
+ tmp += coeff[3] * g_code;
+ tmp += coeff[4] * g_pit_cod;
+
+ /*
+ * store table index if MSE for this index is lower
+ * than the minimum MSE seen so far; also store the
+ * pitch gain for this (so far) lowest MSE
+ */
+ if ( tmp < dist_min ) {
+ dist_min = tmp;
+ cod_ind = i;
+ pit_ind = j;
+ }
+ }
+ }
+
+ /*
+ * read quantized gains and new values for MA predictor memories
+ */
+ p = &gain_factor[cod_ind];
+ g_code_tmp = (Word32)(2048 * *p);
+ *qua_ener_index = cod_ind;
+
+ /*
+ * calculate final fixed codebook gain:
+ * gc = gc0 * g
+ */
+ g_code0 = Pow2( 14, gcode0_fra);
+ i = ( g_code_tmp * g_code0 ) << 1;
+ gcode0_exp = 9 - gcode0_exp;
+
+ if ( gcode0_exp > 0 )
+ i = i >> gcode0_exp;
+ else
+ i = i << ( -gcode0_exp );
+ *gain_cod = (Float32)(i >> 16);
+ if (*gain_cod > 32767)
+ *gain_cod = 32767;
+
+ *gain_cod *= 0.5F;
+
+ *gain_cod_ind = ( Word16 )cod_ind;
+ *gain_pit = g_pitch_cand[pit_ind];
+ *gain_pit_ind = g_pitch_cind[pit_ind];
+}
+
+
+/*
+ * calc_unfilt_energies
+ *
+ *
+ * Parameters:
+ * res I: LP residual
+ * exc I: LTP excitation (unfiltered)
+ * code I: CB innovation (unfiltered)
+ * gain_pit I: pitch gain
+ * en O: energy coefficients [4]
+ * ltpg O: LTP coding gain (log2())
+ *
+ * Function:
+ * Calculation of several energy coefficients for unfiltered
+ * excitation signals and the LTP coding gain
+ *
+ * en[0] = <res res> LP residual energy
+ * en[1] = <exc exc> LTP residual energy
+ * en[2] = <exc code> LTP/CB innovation dot product
+ * en[3] = <lres lres> LTP residual energy
+ * (lres = res - gain_pit*exc)
+ * ltpg = log2(LP_res_en / LTP_res_en)
+ *
+ * Returns:
+ * void
+ */
+static void calc_unfilt_energies( Float32 res[], Float32 exc[], Float32 code[],
+ Float32 gain_pit, Float32 en[], Float32 *ltpg )
+{
+ Float32 sum, pred_gain;
+ Word32 i;
+
+
+ /* Compute residual energy */
+ en[0] = (Float32)Dotproduct40( res, res );
+
+ /* ResEn := 0 if ResEn < 200.0 */
+ if ( en[0] < 200 ) {
+ en[0] = 0;
+ }
+
+ /* Compute ltp excitation energy */
+ en[1] = (Float32)Dotproduct40( exc, exc );
+
+ /* Compute scalar product <exc[],code[]> */
+ en[2] = (Float32)Dotproduct40( exc, code );
+
+ /* Compute energy of LTP residual */
+ en[3] = 0;
+
+ for ( i = 0; i < L_SUBFR; i++ ) {
+ /* LTP residual */
+ sum = res[i] - ( exc[i] * gain_pit );
+ en[3] += sum * sum;
+ }
+
+ /* calculate LTP coding gain, i.e. energy reduction LP res -> LTP res */
+ if ( en[3] > 0 && en[0] != 0 ) {
+ /* gain = ResEn / LTPResEn */
+ pred_gain = en[0] / en[3];
+ *ltpg = ( Float32 )( log10( pred_gain ) / log10( 2 ) );
+ }
+ else {
+ *ltpg = 0;
+ }
+}
+
+
+/*
+ * gmed_n_f
+ *
+ *
+ * Parameters:
+ * ind I: values
+ * n I: The number of gains
+ *
+ * Function:
+ * Calculates N-point median (float).
+ *
+ * Returns:
+ * index of the median value
+ */
+static Float32 gmed_n_f( Float32 ind[], Word16 n )
+{
+ Word32 medianIndex;
+ Word32 i, j, ix = 0;
+ Word32 tmp[9];
+ Float32 tmp2[9];
+ Float32 max;
+
+
+ for ( i = 0; i < n; i++ ) {
+ tmp2[i] = ind[i];
+ }
+
+ for ( i = 0; i < n; i++ ) {
+ max = -FLT_MAX;
+
+ for ( j = 0; j < n; j++ ) {
+ if ( tmp2[j] >= max ) {
+ max = tmp2[j];
+ ix = j;
+ }
+ }
+ tmp2[ix] = -FLT_MAX;
+ tmp[i] = ix;
+ }
+ medianIndex = tmp[n >> 1];
+ return( ind[medianIndex] );
+}
+
+
+/*
+ * gain_adapt
+ *
+ *
+ * Parameters:
+ * prev_gc B: previous code gain
+ * onset B: onset indicator
+ * ltpg_mem B: stored past LTP coding gains
+ * prev_alpha B: revious gain adaptation factor
+ * ltpg I: ltp coding gain (log2())
+ * gain_cod I: code gain
+ * alpha O: gain adaptation factor
+ *
+ * Function:
+ * Calculate pitch/codebook gain adaptation factor alpha
+ * (and update the adaptor state)
+ *
+ * If the coding gain ag is less than 1 dB, the modified criterion is
+ * employed, except when an onset is detected. An onset is said to be
+ * detected if the fixed codebook gain in the current subframe is more
+ * than twice the value of the fixed codebook gain in the previous
+ * subframe. A hangover of 8 subframes is used in the onset detection
+ * so that the modified criterion is not used for the next 7 subframes
+ * either if an onset is detected. The balance factor a is computed from
+ * the median filtered adaptive coding gain. The current and
+ * the ag-values for the previous 4 subframes are median filtered to get
+ * agm. The a-factor is computed by:
+ *
+ * / 0 , 2 < agm
+ * a = 0.5 * (1 - 0.5 * agm) , 0 < agm < 2
+ * \ 0.5 , agm < 0
+ *
+ * Returns:
+ * void
+ */
+static void gain_adapt( Float32 *prev_gc, Word16 *onset, Float32 *ltpg_mem,
+ Float32 *prev_alpha, Float32 ltpg, Float32 gain_cod, Float32 *alpha )
+{
+ Float32 result, filt; /* alpha factor, median-filtered LTP coding gain */
+ Word32 i;
+ Word16 adapt; /* adaptdation status; 0, 1, or 2 */
+
+
+ /* basic adaptation */
+ if ( ltpg <= 0.3321928F /*LTP_GAIN_THR1*/ ) {
+ adapt = 0;
+ }
+ else {
+ if ( ltpg <= 0.6643856 /*LTP_GAIN_THR2*/ ) {
+ adapt = 1;
+ }
+ else {
+ adapt = 2;
+ }
+ }
+
+ /*
+ * onset indicator:
+ */
+ if ( ( gain_cod > 2.0F * *prev_gc ) && ( gain_cod > 100 ) ) {
+ *onset = 8;
+ }
+ else {
+ if ( *onset != 0 ) {
+ (*onset)--;
+ }
+ }
+
+ /*
+ * if onset, increase adaptor state
+ */
+ if ( ( *onset != 0 ) && ( adapt < 2 ) ) {
+ adapt++;
+ }
+ ltpg_mem[0] = ltpg;
+ filt = gmed_n_f( ltpg_mem, 5 );
+
+ if ( adapt == 0 ) {
+ if ( filt > 0.66443 ) {
+ result = 0;
+ }
+ else {
+ if ( filt < 0 ) {
+ result = 0.5;
+ }
+ else {
+ result = ( Float32 )( 0.5-0.75257499*filt );
+ }
+ }
+ }
+ else {
+ result = 0;
+ }
+
+ /*
+ * if (prev_alpha == 0.0) result = 0.5 * (result + prev_alpha);
+ */
+ if ( *prev_alpha == 0 ) {
+ result = 0.5F * result;
+ }
+
+ /* store the result */
+ *alpha = result;
+
+ /* update adapter state memory */
+ *prev_alpha = result;
+ *prev_gc = gain_cod;
+
+ for ( i = LTPG_MEM_SIZE - 1; i > 0; i-- ) {
+ ltpg_mem[i] = ltpg_mem[i - 1];
+ }
+
+ /* mem[0] is just present for convenience in calling the gmed_n[5]
+ * function above. The memory depth is really LTPG_MEM_SIZE-1.
+ */
+}
+
+
+/*
+ * MR795_gain_code_quant_mod
+ *
+ *
+ * Parameters:
+ * gain_pit I: Pitch gain
+ * gcode0 I: Predicted CB gain
+ * en I: energy coefficients
+ * alpha I: gain adaptation factor
+ * gain_cod_unq I: Code gain (unquantized)
+ * gain_cod I: Code gain
+ * qua_ener_index O: quantized energy error index
+ *
+ * Function:
+ * Modified quantization of the MR795 codebook gain
+ *
+ * Uses pre-computed energy coefficients in frac_en[]/exp_en[]
+ *
+ * frac_en[0]*2^exp_en[0] = <res res> LP residual energy
+ * frac_en[1]*2^exp_en[1] = <exc exc> LTP residual energy
+ * frac_en[2]*2^exp_en[2] = <exc code> LTP/CB innovation dot product
+ * frac_en[3]*2^exp_en[3] = <code code> CB innovation energy
+ *
+ * Returns:
+ * index codebook index
+ */
+static Word16 MR795_gain_code_quant_mod( Float32 gain_pit, Word32 gcode0_exp, Word32 gcode0_fra,
+ Float32 en[], Float32 alpha, Float32 gain_cod_unq, Float32 *gain_cod,
+ Word32 *qua_ener_index )
+{
+ Float32 coeff[5];
+ Float32 gcode0, g2_pitch, g_code, g2_code, d2_code, dist_min, gain_code, tmp;
+ const Float32 *p;
+ Word32 i, index, g_code_tmp, g_code0;
+
+ gcode0 = (Float32)Pow2(gcode0_exp, gcode0_fra);
+
+ gain_code = *gain_cod;
+ g2_pitch = gain_pit * gain_pit;
+ coeff[0] = ( Float32 )( sqrt( alpha * en[0] ) );
+ coeff[1] = alpha * en[1] * g2_pitch;
+ coeff[2] = 2.0F * alpha * en[2] * gain_pit;
+ coeff[3] = alpha * en[3];
+ coeff[4] = ( 1.0F - alpha ) * en[3];
+
+ /* search the quantizer table for the lowest value of the search criterion */
+ dist_min = FLT_MAX;
+ index = 0;
+ p = &gain_factor[0];
+
+ for ( i = 0; i < NB_QUA_CODE; i++ ) {
+ /* this is g_fac */
+ g_code = *p++;
+ g_code = g_code * gcode0;
+
+ /*
+ * only continue if gc[i] < 2.0*gc
+ */
+ if ( g_code >= ( 2.0F * gain_code ) )
+ break;
+ g2_code = g_code * g_code;
+ d2_code = g_code - gain_cod_unq;
+ d2_code = d2_code * d2_code;
+ tmp = coeff[1] + coeff[2] * g_code;
+ tmp += coeff[3] * g2_code;
+ tmp = ( Float32 )sqrt( tmp );
+ tmp = tmp - coeff[0];
+ tmp = tmp * tmp;
+ tmp += coeff[4] * d2_code;
+
+ /*
+ * store table index if distance measure for this
+ * index is lower than the minimum seen so far
+ */
+ if ( tmp < dist_min ) {
+ dist_min = tmp;
+ index = i;
+ }
+ }
+
+ /*
+ * read quantized gains and new values for MA predictor memories
+ */
+ p = &gain_factor[index];
+ g_code_tmp = (Word32)(2048 * *p);
+ *qua_ener_index = index;
+
+ /* calculate final fixed codebook gain:
+ * gc = gc0 * g
+ */
+ g_code0 = Pow2( 14, gcode0_fra);
+ i = ( g_code_tmp * g_code0 ) << 1;
+ gcode0_exp = 9 - gcode0_exp;
+
+ if ( gcode0_exp > 0 )
+ i = i >> gcode0_exp;
+ else
+ i = i << ( -gcode0_exp );
+ *gain_cod = (Float32)(i >> 16);
+ if (*gain_cod > 32767)
+ *gain_cod = 32767;
+
+ *gain_cod *= 0.5F;
+ return( Word16 )index;
+}
+
+
+/*
+ * MR795_gain_quant
+ *
+ *
+ * Parameters:
+ * prev_gc B: previous code gain
+ * onset B: onset indicator
+ * ltpg_mem B: stored past LTP coding gains
+ * prev_alpha B: previous gain adaptation factor
+ * res I: LP residual
+ * exc I: LTP excitation (unfiltered)
+ * code I: CB innovation (unfiltered)
+ * coeff I: energy coefficients (5)
+ * code_en I: innovation energy
+ * gcode0 I: predicted CB gain
+ * cod_gain I: codebook gain
+ * gp_limit I: pitch gain limit
+ * gain_pit B: Pitch gain
+ * gain_cod O: Code gain
+ * qua_ener O: quantized energy error
+ * anap O: Index of quantization
+ * gain_pit I: Pitch gain
+ * gcode0 I: Predicted CB gain
+ * en I: energy coefficients
+ * alpha I: gain adaptation factor
+ * gain_cod_unq I: Code gain (unquantized)
+ * gain_cod I: Code gain
+ * qua_ener O: quantized energy error_index
+ *
+ * Function:
+ * Pitch and codebook quantization for MR795
+ *
+ * Returns:
+ * void
+ */
+static void MR795_gain_quant( Float32 *prev_gc, Word16 *onset, Float32 *ltpg_mem
+ , Float32 *prev_alpha, Float32 res[], Float32 exc[], Float32 code[],
+ Float32 coeff[], Float32 code_en, Word32 gcode0_exp, Word32 gcode0_fra, Float32 cod_gain,
+ Float32 gp_limit, Float32 *gain_pit, Float32 *gain_cod, Word32 *qua_ener_index,
+ Word16 **anap )
+{
+ Float32 en[4], g_pitch_cand[3];
+ Float32 ltpg, alpha, gain_cod_unq; /* code gain (unq.) */
+ Word32 g_pitch_cind[3]; /* pitch gain indices */
+ Word32 gain_pit_index, gain_cod_index;
+
+
+ /*
+ * get list of candidate quantized pitch gain values
+ * and corresponding quantization indices
+ */
+ gain_pit_index = q_gain_pitch( MR795, gp_limit, gain_pit, g_pitch_cand,
+ g_pitch_cind );
+
+ /*
+ * pre-quantization of codebook gain
+ * (using three pitch gain candidates);
+ * result: best guess of pitch gain and code gain
+ */
+ MR795_gain_code_quant3( gcode0_exp, gcode0_fra, g_pitch_cand, g_pitch_cind, coeff, gain_pit,
+ &gain_pit_index, gain_cod, &gain_cod_index, qua_ener_index );
+
+ /* calculation of energy coefficients and LTP coding gain */
+ calc_unfilt_energies( res, exc, code, *gain_pit, en, &ltpg );
+
+ /*
+ * run gain adaptor, calculate alpha factor to balance LTP/CB gain
+ * (this includes the gain adaptor update)
+ */
+ gain_adapt( prev_gc, onset, ltpg_mem, prev_alpha, ltpg, *gain_cod, &alpha );
+
+ /*
+ * if this is a very low energy signal (threshold: see
+ * calc_unfilt_energies) or alpha <= 0 then don't run the modified quantizer
+ */
+ if ( ( en[0] != 0 ) && ( alpha > 0 ) ) {
+ /*
+ * innovation energy <cod cod> was already computed in gc_pred()
+ * (this overwrites the LtpResEn which is no longer needed)
+ */
+ en[3] = code_en;
+
+ /*
+ * store optimum codebook gain
+ */
+ gain_cod_unq = cod_gain;
+
+ /* run quantization with modified criterion */
+ gain_cod_index = MR795_gain_code_quant_mod( *gain_pit, gcode0_exp, gcode0_fra, en, alpha,
+ gain_cod_unq, gain_cod, qua_ener_index );
+ }
+ *( *anap )++ = ( Word16 )gain_pit_index;
+ *( *anap )++ = ( Word16 )gain_cod_index;
+}
+
+
+/*
+ * Qua_gain
+ *
+ *
+ * Parameters:
+ * mode I: AMR mode
+ * gcode0 I: predicted CB gain
+ * coeff I: energy coefficients (5)
+ * gp_limit I: pitch gain limit
+ * gain_pit O: Pitch gain
+ * gain_cod O: Code gain
+ * qua_ener_index O: quantized energy error index
+ *
+ * Function:
+ * Quantization of pitch and codebook gains (using predicted codebook gain)
+ *
+ * Returns:
+ * index index of quantization
+ */
+static Word16 Qua_gain( enum Mode mode, Word32 gcode0_exp, Word32 gcode0_fra, Float32 coeff[], Float32
+ gp_limit, Float32 *gain_pit, Float32 *gain_cod, Word32 *qua_ener_index)
+{
+ Float32 g_pitch, g2_pitch, g_code, g2_code, g_pit_cod, tmp, dist_min, gcode0;
+ const Float32 *table_gain, *p;
+ Word32 i, index = 0, gcode_0, g_code_tmp;
+ Word16 table_len;
+
+ gcode0 = (Float32)Pow2( gcode0_exp, gcode0_fra );
+
+
+ if ( ( mode == MR102 ) || ( mode == MR74 ) || ( mode == MR67 ) ) {
+ table_len = VQ_SIZE_HIGHRATES;
+ table_gain = table_highrates;
+ *qua_ener_index = NB_QUA_CODE;
+ }
+ else {
+ table_len = VQ_SIZE_LOWRATES;
+ table_gain = table_lowrates;
+ *qua_ener_index = NB_QUA_CODE + VQ_SIZE_HIGHRATES;
+ }
+
+ /*
+ * Codebook search:
+ * For each pair (g_pitch, g_fac) in the table calculate the
+ * terms t[0..4] and sum them up; the result is the mean squared
+ * error for the quantized gains from the table. The index for the
+ * minimum MSE is stored and finally used to retrieve the quantized
+ * gains
+ */
+ dist_min = FLT_MAX;
+ p = &table_gain[0];
+
+ for ( i = 0; i < table_len; i++ ) {
+ g_pitch = *p++;
+
+ /* this is g_fac */
+ g_code = *p++;
+
+ if ( g_pitch <= gp_limit ) {
+ g_code *= gcode0;
+ g2_pitch = g_pitch * g_pitch;
+ g2_code = g_code * g_code;
+ g_pit_cod = g_code * g_pitch;
+ tmp = coeff[0] * g2_pitch;
+ tmp += coeff[1] * g_pitch;
+ tmp += coeff[2] * g2_code;
+ tmp += coeff[3] * g_code;
+ tmp += coeff[4] * g_pit_cod;
+
+ /*
+ * store table index if MSE for this index is lower
+ * than the minimum MSE seen so far
+ */
+ if ( tmp < dist_min ) {
+ dist_min = tmp;
+ index = i;
+ }
+ }
+ }
+
+ /*
+ * read quantized gains and new values for MA predictor memories
+ */
+ p = &table_gain[index << 1];
+ *gain_pit = *p++;
+ g_code_tmp = (Word32)(4096 * *p);
+
+ /*
+ * calculate final fixed codebook gain:
+ * gc = gc0 * g
+ */
+
+ gcode_0 = Pow2( 14, gcode0_fra );
+ if ( gcode0_exp < 11 ) {
+ *gain_cod = (Float32)((g_code_tmp * gcode_0) >> ( 25 - gcode0_exp ));
+ }
+ else {
+ i = ( ( g_code_tmp * gcode_0) << ( gcode0_exp - 9 ) );
+
+ if ( ( i >> ( gcode0_exp - 9 ) ) != ( g_code_tmp * gcode_0) ) {
+ *gain_cod = 0x7FFF;
+ }
+ else {
+ *gain_cod = (Float32)(i >> 16);
+ }
+ }
+ *gain_cod = *gain_cod * 0.5F;
+ *qua_ener_index += index;
+
+ return( Word16 )index;
+}
+
+
+/*
+ * gainQuant
+ *
+ *
+ * Parameters:
+ * gcode0 I: predicted CB gain
+ * coeff I: energy coefficients (5)
+ * gp_limit I: pitch gain limit
+ * gain_pit O: Pitch gain
+ * gain_cod O: Code gain
+ * qua_ener O: quantized energy error,
+ * mode I: AMR mode
+ * even_subframe I: even subframe indicator flag
+ * past_qua_en B: past quantized energies [4]
+ * past_qua_en_unq B: past energies [4]
+ * sf0_coeff B: energy coefficients subframe 0 (or 2)
+ * sf0_target_en B: target energy from subframe 0 (or 2)
+ * sf0_gcode0 B: predicted gain factor subframe 0 (or 2)
+ * gain_idx_ptr B: gain index pointer
+ * sf0_gain_pit B: Pitch gain subframe 0 (or 2)
+ * sf0_gain_cod B: Code gain subframe 0 (or 2)
+ * res I: LP residual
+ * exc I: LTP excitation (unfiltered)
+ * code I: innovative codebook vector
+ * xn I: Target vector
+ * xn2 I: CB target vector
+ * y1 I: Adaptive codebook
+ * y2 I: Filtered innovative vector
+ * gCoeff I: Correlations <xn y1> <y1 y1>
+ * gp_limit I: pitch gain limit
+ * gain_pit O: Pitch gain
+ * gain_cod O: Code gain
+ * prev_gc B: B: previous code gain
+ * onset B: onset indicator
+ * ltpg_mem B: stored past LTP coding gains
+ * prev_alpha B: previous gain adaptation factor
+ * anap B: Index of quantization
+ *
+ * Function:
+ * Quantization of gains
+ *
+ * Returns:
+ * index index of quantization
+ */
+static void gainQuant( enum Mode mode, Word32 even_subframe, Word32 *
+ past_qua_en, Word32 *past_qua_en_unq, Float32 *sf0_coeff, Float32 *
+ sf0_target_en, Word32 *sf0_gcode0_exp, Word32 *sf0_gcode0_fra,Word16 **gain_idx_ptr, Float32 *
+ sf0_gain_pit, Float32 *sf0_gain_cod, Float32 *res, Float32 *exc, Float32
+ code[], Float32 xn[], Float32 xn2[], Float32 y1[], Float32 y2[], Float32
+ gCoeff[], Float32 gp_limit, Float32 *gain_pit, Float32 *gain_cod, Float32
+ *prev_gc, Word16 *onset, Float32 *ltpg_mem, Float32 *prev_alpha, Word16 **
+ anap )
+{
+ Float32 coeff[5];
+ Float32 gcode0, cod_gain, en = 0;
+ Word32 i, exp, frac, qua_ener_index;
+
+
+ if ( mode == MR475 ) {
+ if ( even_subframe != 0 ) {
+ /*
+ * save position in output parameter stream and current
+ * state of codebook gain predictor
+ */
+ *gain_idx_ptr = ( *anap )++;
+ past_qua_en_unq[0] = past_qua_en[0];
+ past_qua_en_unq[1] = past_qua_en[1];
+ past_qua_en_unq[2] = past_qua_en[2];
+ past_qua_en_unq[3] = past_qua_en[3];
+
+ /*
+ * predict codebook gain (using "unquantized" predictor)
+ * (note that code[] is unsharpened in MR475)
+ */
+ gc_pred( past_qua_en, mode, code, sf0_gcode0_exp, sf0_gcode0_fra, &en );
+ gcode0 = (Float32)Pow2(*sf0_gcode0_exp, *sf0_gcode0_fra);
+
+ /*
+ * calculate energy coefficients for quantization
+ * and store them in state structure (will be used
+ * in next subframe when real quantizer is run)
+ */
+ calc_filt_energies( mode, xn, xn2, y1, y2, gCoeff, sf0_coeff, &cod_gain
+ );
+
+ /* store optimum codebook gain */
+ *gain_cod = cod_gain;
+ *sf0_target_en = (Float32)Dotproduct40( xn, xn );
+
+ /*
+ * calculate optimum codebook gain and update
+ * "unquantized" predictor
+ */
+ MR475_update_unq_pred( past_qua_en_unq, gcode0, cod_gain );
+
+ /* the real quantizer is not run here... */
+ }
+ else {
+ /*
+ * predict codebook gain (using "unquantized" predictor)
+ * (note that code[] is unsharpened in MR475)
+ */
+ gc_pred( past_qua_en_unq, mode, code, &exp, &frac, &en );
+
+ /* calculate energy coefficients for quantization */
+ calc_filt_energies( mode, xn, xn2, y1, y2, gCoeff, coeff, &cod_gain );
+ en = (Float32)Dotproduct40( xn, xn );
+
+ /* run real (4-dim) quantizer and update real gain predictor */
+ **gain_idx_ptr = MR475_gain_quant( past_qua_en, *sf0_gcode0_exp, *sf0_gcode0_fra, sf0_coeff,
+ *sf0_target_en, code, exp, frac, coeff, en, gp_limit, sf0_gain_pit,
+ sf0_gain_cod, gain_pit, gain_cod );
+ }
+ }
+ else {
+ /*
+ * predict codebook gain and quantize
+ * (also compute normalized CB innovation energy for MR795)
+ */
+ gc_pred( past_qua_en, mode, code, &exp, &frac, &en );
+
+ if ( mode == MR122 ) {
+ /*
+ * Compute the innovative codebook gain.
+ * The innovative codebook gain is given by
+ * g = <xn2[], y2[]> / <y2[], y2[]>
+ * where xn2[] is the target vector,
+ * y2[] is the filtered innovative
+ * codevector
+ */
+
+ gcode0 = (Float32)Pow2( exp, frac );
+ /* saturation at decoder */
+ if (gcode0 > 2047.9375F) gcode0 = 2047.9375F;
+
+ *gain_cod = (Float32)(Dotproduct40( xn2, y2 ) / ( Dotproduct40( y2, y2 )+ 0.01F ));
+
+ if ( *gain_cod < 0 )
+ *gain_cod = 0.0F;
+ *( *anap )++ = q_gain_code( gcode0, gain_cod,&qua_ener_index);
+ }
+ else {
+ /* calculate energy coefficients for quantization */
+ calc_filt_energies( mode, xn, xn2, y1, y2, gCoeff, coeff, &cod_gain );
+
+ if ( mode == MR795 ) {
+ MR795_gain_quant( prev_gc, onset, ltpg_mem, prev_alpha, res, exc,
+ code, coeff, en, exp, frac , cod_gain, gp_limit, gain_pit,
+ gain_cod, &qua_ener_index, anap );
+ }
+ else {
+
+ *( *anap )++ = Qua_gain( mode, exp, frac, coeff, gp_limit, gain_pit,
+ gain_cod, &qua_ener_index);
+ }
+ }
+
+ /*
+ * update table of past quantized energies
+ */
+ for ( i = 3; i > 0; i-- ) {
+ past_qua_en[i] = past_qua_en[i - 1];
+ }
+ past_qua_en[0] = qua_ener_index;
+
+ }
+}
+
+
+/*
+ * subframePostProc
+ *
+ *
+ * Parameters:
+ * speech I: Speech segment
+ * i_subfr I: Subframe number
+ * gain_pit I: Pitch gain
+ * gain_code I: Decoded innovation gain
+ * a_q I: A(z) quantized for the 4 subframes
+ * synth I: Local synthesis
+ * xn I: Target vector for pitch search
+ * code I: Fixed codebook exitation
+ * y1 I: Filtered adaptive exitation
+ * y2 I: Filtered fixed codebook excitation
+ * mem_syn B: memory of synthesis filter
+ * mem_err O: pointer to error signal
+ * mem_w0 O: memory of weighting filter
+ * exc O: long term prediction residual
+ * sharp O: pitch sharpening value
+ *
+ * Function:
+ * Subframe post processing
+ *
+ * Memory update (all modes)
+ * An update of the states of the synthesis and weighting filters is needed
+ * in order to compute the target signal in the next subframe.
+ * After the two gains are quantified, the excitation signal, u(n),
+ * in the present subframe is found by:
+ *
+ * u(n) = Gp_q * v(n) + Gc_q * c(n), n = 0, ..., 39,
+ *
+ * where Gp_q and Gc_q are the quantified adaptive and fixed codebook gains,
+ * respectively, v(n) the adaptive codebook vector
+ * (interpolated past excitation), and c(n) is the fixed codebook vector
+ * (algebraic code including pitch sharpening). The states of the filters
+ * can be updated by filtering the signal res_lp(n) - u(n)
+ * (difference between residual and excitation) through the filters
+ * 1 / A_q(z) and A(z/g1) / A(z/g2) for the 40-sample subframe and saving
+ * the states of the filters. This would require 3 filterings.
+ * A simpler approach which requires only one filtering is as follows.
+ * The local synthesized speech, S_s(n), is computed by filtering
+ * the excitation signal through 1 / A_q(z). The output of the filter
+ * due to the input res_lp(n) - u(n) is equivalent to e(n) = S(n) - S_s(n).
+ * So the states of the synthesis filter 1 / A_q(z) are given by
+ * e(n), n = 30, ..., 39. Updating the states of the filter A(z/g1) / A(z/g2)
+ * can be done by filtering the error signal e(n) through this filter
+ * to find the perceptually weighted error ew(n). However, the signal ew(n)
+ * can be equivalently found by:
+ *
+ * ew(n) = x(n) - Gp_q * y(n) - Gc_q(n) * z(n)
+ *
+ * Since the signals x(n), y(n) and z(n) are available, the states of
+ * the weighting filter are updated by computing ew(n) for n = 30, ..., 39.
+ * This saves two filterings.
+ *
+ * Returns:
+ * void
+ */
+static void subframePostProc( Float32 *speech, Word16 i_subfr, Float32 gain_pit,
+ Float32 gain_code, Float32 *a_q, Float32 synth[], Float32 xn[], Float32
+ code[], Float32 y1[], Float32 y2[], Float32 *mem_syn, Float32 *mem_err,
+ Float32 *mem_w0, Float32 *exc, Float32 *sharp )
+{
+ Word32 i, j;
+
+
+ /*
+ * Update pitch sharpening "sharp" with quantized gain_pit
+ */
+ *sharp = gain_pit;
+ if ( *sharp > 0.794556F ) {
+ *sharp = 0.794556F;
+ }
+
+ /* Find the total excitation */
+ for ( i = 0; i < L_SUBFR; i += 4 ) {
+ exc[i + i_subfr] = (Float32)floor((gain_pit * exc[i + i_subfr] + gain_code * code[i]) + 0.5F);
+ exc[i + i_subfr + 1] = (Float32)floor((gain_pit * exc[i + i_subfr + 1] + gain_code * code[i
+ + 1]) + 0.5F);
+ exc[i + i_subfr + 2] = (Float32)floor((gain_pit * exc[i + i_subfr + 2] + gain_code * code[
+ i + 2]) + 0.5F);
+ exc[i + i_subfr + 3] = (Float32)floor((gain_pit * exc[i + i_subfr + 3] + gain_code * code[
+ i + 3]) + 0.5F);
+ }
+
+
+ /* The local synthesis speech */
+ Syn_filt( a_q, &exc[i_subfr], &synth[i_subfr], mem_syn, 1 );
+
+ for ( i = L_SUBFR - M, j = 0; i < L_SUBFR; i++, j++ ) {
+ /* e(n) = S(n) - S_s(n) */
+ mem_err[j] = speech[i_subfr + i] - synth[i_subfr + i];
+
+ /* ew(n) = x(n) - Gp_q * y(n) - Gc_q(n) * z(n) */
+ mem_w0[j] = xn[i] - y1[i] * gain_pit - y2[i] * gain_code;
+ }
+}
+
+
+/*
+ * Convolve
+ *
+ *
+ * Parameters:
+ * x I: First input
+ * h I: second input
+ * y O: output
+ *
+ * Function:
+ * Convolution
+ *
+ * Returns:
+ * void
+ */
+static void Convolve( Float32 x[], Float32 h[], Float32 y[] )
+{
+ Word32 i, n;
+ Float32 s;
+
+
+ for ( n = 0; n < L_SUBFR; n++ ) {
+ s = 0.0F;
+
+ for ( i = 0; i <= n; i++ ) {
+ s += x[i] * h[n - i];
+ }
+ y[n] = s;
+ }
+ return;
+}
+
+
+/*
+ * tx_dtx_handler
+ *
+ *
+ * Parameters:
+ * vad_flag I:vad decision
+ * decAnaElapsedCount B: state machine that synch with the GSMEFR txDtx machine
+ * dtxHangoverCount B: dtx hangover counter
+ * used_mode O: used mode
+ *
+ * Function:
+ * Adds extra speech hangover to analyze speech on the decoding side
+ *
+ * Returns:
+ * compute_new_sid_possible
+ */
+static Word16 tx_dtx_handler( Word16 vad_flag, Word16 *decAnaElapsedCount,
+ Word16 *dtxHangoverCount, enum Mode *used_mode )
+{
+ Word16 compute_new_sid_possible;
+
+
+ /* this state machine is in synch with the GSMEFR txDtx machine */
+ *decAnaElapsedCount += 1;
+ compute_new_sid_possible = 0;
+
+ if ( vad_flag != 0 ) {
+ *dtxHangoverCount = DTX_HANG_CONST;
+ }
+
+ /* non-speech */
+ else {
+ /* out of decoder analysis hangover */
+ if ( *dtxHangoverCount == 0 ) {
+ *decAnaElapsedCount = 0;
+ *used_mode = MRDTX;
+ compute_new_sid_possible = 1;
+ }
+
+ /* in possible analysis hangover */
+ else {
+ *dtxHangoverCount -= 1;
+
+ /* decAnaElapsedCount + dtxHangoverCount < DTX_ELAPSED_FRAMES_THRESH */
+ if ( ( *decAnaElapsedCount + *dtxHangoverCount ) <
+ DTX_ELAPSED_FRAMES_THRESH ) {
+ *used_mode = MRDTX;
+
+ /* if short time since decoder update, do not add extra HO */
+ }
+
+ /*
+ * else
+ * override VAD and stay in
+ * speech mode *used_mode
+ * and add extra hangover
+ */
+ }
+ }
+ return compute_new_sid_possible;
+}
+
+
+/*
+ * dtx_buffer
+ *
+ *
+ * Parameters:
+ * hist_ptr B: Circular buffer pointer
+ * lsp_hist O: LSP history
+ * lsp_new I: LSP vector
+ * speech I: input speech
+ * log_en_hist O: frame energy
+ *
+ * Function:
+ * Handles the DTX buffer
+ *
+ * The frame energy is computed for each frame marked with VAD=0
+ * according to the equation:
+ *
+ * N-1
+ * en_log(i) = 0.5 * log2 ( (1 / N) * SUM[ s(n) * s(n) ] )
+ * N=0
+ *
+ * where s(n) is the HP-filtered input speech signal of
+ * the current frame i.
+ *
+ * Returns:
+ * void
+ */
+static void dtx_buffer( Word16 *hist_ptr, Float32 *lsp_hist, Float32 lsp_new[],
+ Float32 speech[], Float32 *log_en_hist )
+{
+ Float64 frame_en;
+
+
+ /* update pointer to circular buffer */
+ *hist_ptr += 1;
+
+ if ( *hist_ptr == DTX_HIST_SIZE ) {
+ *hist_ptr = 0;
+ }
+
+ /* copy lsp vector into buffer */
+ memcpy( &lsp_hist[ * hist_ptr * M], lsp_new, sizeof( Float32 )*M );
+
+ /* compute log energy based on frame energy */
+ frame_en = Dotproduct40( speech, speech );
+ frame_en += Dotproduct40( &speech[40], &speech[40] );
+ frame_en += Dotproduct40( &speech[80], &speech[80] );
+ frame_en += Dotproduct40( &speech[120], &speech[120] );
+
+ if ( frame_en > 1 ) {
+ log_en_hist[ * hist_ptr] = ( Float32 )( log10( frame_en * 0.00625F )*
+ 1.660964F );
+ }
+ else {
+ log_en_hist[ * hist_ptr] = -3.660965F;
+ }
+}
+
+
+/*
+ * dtx_enc
+ *
+ *
+ * Parameters:
+ * log_en_index O: logarithmic energy quantized
+ * log_en_hist I: history of logarithmic energy
+ * lsp_hist I: history of LSP
+ * lsp_index O: quantization indices of 3 LSP vectors
+ * init_lsf_vq_index O: init index for MA prediction
+ * compute_sid_flag I: SID flag
+ * past_rq I: past quantized residual
+ * past_qua_en O: gain predictor memory
+ * anap O: analysis parameters
+ *
+ * Function:
+ * DTX encoder
+ *
+ * The averaged logarithmic energy is computed by:
+ *
+ * 7
+ * en_log_mean(i) = (1 / 8) * SUM[ en_log(i - n) ]
+ * n=0
+ *
+ * The averaged logarithmic energy is quantized means of a 6 bit
+ * algorithmic quantizer. The 6 bits for the energy index are
+ * transmitted in the SID frame.
+ *
+ * Returns:
+ * void
+ */
+static Word32 dtx_enc( Word16 *log_en_index, Float32 log_en_hist[], Float32
+ lsp_hist[], Word16 *lsp_index, Word32 *init_lsf_vq_index, Word16
+ compute_sid_flag, Float32 past_rq[], Word32 *past_qua_en, Word16 **anap )
+{
+ Float32 log_en, lsf[M], lsp[M], lsp_q[M];
+ Word32 i, j;
+
+
+ /* VOX mode computation of SID parameters */
+ if ( ( compute_sid_flag != 0 ) ) {
+ /*
+ * compute new SID frame if safe i.e don't
+ * compute immediately after a talk spurt
+ */
+ log_en = 0;
+ memset( lsp, 0, sizeof( Float32 )*M );
+
+ /* average energy and lsp */
+ for ( i = 0; i < DTX_HIST_SIZE; i++ ) {
+ log_en += log_en_hist[i];
+
+ for ( j = 0; j < M; j++ ) {
+ lsp[j] += lsp_hist[i * M + j];
+ }
+ }
+ log_en = log_en * 0.125F;
+
+ for ( j = 0; j < M; j++ ) {
+ /* divide by 8 */
+ lsp[j] = lsp[j] * 0.125F;
+ }
+
+ /* quantize logarithmic energy to 6 bits */
+ log_en = log_en + 2.5F;
+ *log_en_index = ( Word16 )( ( log_en * 4 ) + 0.5F ); /* 6 bits */
+
+ /* *log_en_index = ( Word16 )( ( log_en + 2.5F + 0.125F ) * 4.0F ); */
+ if ( *log_en_index > 63 ) {
+ *log_en_index = 63;
+ }
+
+ if ( *log_en_index < 0 ) {
+ *log_en_index = 0;
+ }
+
+ if (*log_en_index > 46){
+ past_qua_en[0] = NB_QUA_CODE+VQ_SIZE_HIGHRATES+VQ_SIZE_LOWRATES+(MR475_VQ_SIZE*2) + 46;
+ past_qua_en[1] = NB_QUA_CODE+VQ_SIZE_HIGHRATES+VQ_SIZE_LOWRATES+(MR475_VQ_SIZE*2) + 46;
+ past_qua_en[2] = NB_QUA_CODE+VQ_SIZE_HIGHRATES+VQ_SIZE_LOWRATES+(MR475_VQ_SIZE*2) + 46;
+ past_qua_en[3] = NB_QUA_CODE+VQ_SIZE_HIGHRATES+VQ_SIZE_LOWRATES+(MR475_VQ_SIZE*2) + 46;
+ }
+ else {
+ past_qua_en[0] = NB_QUA_CODE+VQ_SIZE_HIGHRATES+VQ_SIZE_LOWRATES+(MR475_VQ_SIZE*2) + *log_en_index;
+ past_qua_en[1] = NB_QUA_CODE+VQ_SIZE_HIGHRATES+VQ_SIZE_LOWRATES+(MR475_VQ_SIZE*2) + *log_en_index;
+ past_qua_en[2] = NB_QUA_CODE+VQ_SIZE_HIGHRATES+VQ_SIZE_LOWRATES+(MR475_VQ_SIZE*2) + *log_en_index;
+ past_qua_en[3] = NB_QUA_CODE+VQ_SIZE_HIGHRATES+VQ_SIZE_LOWRATES+(MR475_VQ_SIZE*2) + *log_en_index;
+ }
+
+ /* make sure that LSP's are ordered */
+ Lsp_lsf( lsp, lsf );
+ Reorder_lsf( lsf, 0.00625F );
+ Lsf_lsp( lsf, lsp );
+
+ /* Quantize lsp and put on parameter list */
+ Q_plsf_3( MRDTX, past_rq, lsp, lsp_q, lsp_index, init_lsf_vq_index );
+ }
+
+ /* 3 bits */
+ *( *anap )++ = ( Word16 )*init_lsf_vq_index;
+
+ /* 8 bits */
+ *( *anap )++ = lsp_index[0];
+
+ /* 9 bits */
+ *( *anap )++ = lsp_index[1];
+
+ /* 9 bits */
+ *( *anap )++ = lsp_index[2];
+
+ /* 6 bits */
+ *( *anap )++ = *log_en_index;
+
+ /* = 35 bits */
+ return 0;
+}
+
+
+/*
+ * complex_estimate_adapt
+ *
+ *
+ * Parameters:
+ * st->best_corr_hp I: complex background detector
+ * st->corr_hp_fast B: long term complex signal estimate
+ * low_power I: very low level flag of the input frame
+ *
+ * Function:
+ * Update/adapt of complex signal estimate
+ *
+ * Returns:
+ * void
+ */
+#ifndef VAD2
+static void complex_estimate_adapt( vadState *st, Word16 low_power )
+{
+ Float32 alpha;
+
+
+ /* adapt speed on own state */
+ /* decrease */
+ if ( st->best_corr_hp < st->corr_hp_fast ) {
+ /* low state */
+ if ( st->corr_hp_fast < CVAD_THRESH_ADAPT_HIGH ) {
+ alpha = CVAD_ADAPT_FAST;
+ }
+
+ /* high state */
+ else {
+ alpha = CVAD_ADAPT_REALLY_FAST;
+ }
+ }
+
+ /* increase */
+ else {
+ if ( st->corr_hp_fast < CVAD_THRESH_ADAPT_HIGH ) {
+ alpha = CVAD_ADAPT_FAST;
+ }
+ else {
+ alpha = CVAD_ADAPT_SLOW;
+ }
+ }
+ st->corr_hp_fast = st->corr_hp_fast - alpha * st->corr_hp_fast + alpha * st->
+ best_corr_hp;
+
+ if ( st->corr_hp_fast < CVAD_MIN_CORR ) {
+ st->corr_hp_fast = CVAD_MIN_CORR;
+ }
+
+ if ( low_power != 0 ) {
+ st->corr_hp_fast = CVAD_MIN_CORR;
+ }
+}
+#endif
+
+/*
+ * complex_vad
+ *
+ *
+ * Parameters:
+ * st->complex_high B: 1 if (corr_hp_fast > CVAD_THRESH_ADAPT_HIGH)
+ * st->complex_low B: 1 if (corr_hp_fast > CVAD_THRESH_ADAPT_LOW)
+ * low_power I: flag power of the input frame
+ * st->best_corr_hp I: complex background detector
+ * st->corr_hp_fast B: long term complex signal estimate
+ * st->complex_hang_timer B: complex hang timer
+ *
+ *
+ * Function:
+ * Complex background decision
+ *
+ * Returns:
+ * void
+ */
+#ifndef VAD2
+static Word32 complex_vad( vadState *st, Word16 low_power )
+{
+ st->complex_high = st->complex_high >> 1;
+ st->complex_low = st->complex_low >> 1;
+
+ if ( low_power == 0 ) {
+ if ( st->corr_hp_fast > CVAD_THRESH_ADAPT_HIGH ) {
+ st->complex_high = st->complex_high | 0x00004000;
+ }
+
+ if ( st->corr_hp_fast > CVAD_THRESH_ADAPT_LOW ) {
+ st->complex_low = st->complex_low | 0x00004000;
+ }
+ }
+
+ if ( st->corr_hp_fast > CVAD_THRESH_HANG ) {
+ st->complex_hang_timer += 1;
+ }
+ else {
+ st->complex_hang_timer = 0;
+ }
+ return( Word16 )( ( ( st->complex_high & 0x00007f80 ) == 0x00007f80 ) || ( (
+ st->complex_low & 0x00007fff ) == 0x00007fff ) );
+}
+#endif
+
+/*
+ * complex_vad
+ *
+ *
+ * Parameters:
+ * st->complex_warning I: flags for complex detection
+ * st->stat_count B: stationary counter
+ * st->pitch I: flags for pitch detection
+ * st->tone I: flags indicating presence of a tone
+ * st->vadreg I: intermediate VAD flags
+ * level I: sub-band levels of the input frame
+ * st->ave_level B: Average amplitude estimate
+ *
+ * Function:
+ * Control update of the background noise estimate
+ *
+ * Returns:
+ * void
+ */
+#ifndef VAD2
+static void update_cntrl( vadState *st, Float32 level[] )
+{
+ Float32 stat_rat, num, denom;
+ Float32 alpha;
+ Word32 i;
+
+
+ /*
+ * handle highband complex signal input separately
+ * if ther has been highband correlation for some time
+ * make sure that the VAD update speed is low for a while
+ */
+ if ( st->complex_warning != 0 ) {
+ if ( st->stat_count < CAD_MIN_STAT_COUNT ) {
+ st->stat_count = CAD_MIN_STAT_COUNT;
+ }
+ }
+
+ /*
+ * NB stat_count is allowed to be decreased by one below again
+ * deadlock in speech is not possible unless the signal is very
+ * complex and need a high rate
+ * if fullband pitch or tone have been detected for a while, initialize stat_count
+ */
+ if ( ( ( st->pitch & 0x6000 ) == 0x6000 ) || ( ( st->tone & 0x00007c00 ) ==
+ 0x7c00 ) ) {
+ st->stat_count = STAT_COUNT;
+ }
+ else {
+ /* if 8 last vad-decisions have been "0", reinitialize stat_count */
+ if ( ( st->vadreg & 0x7f80 ) == 0 ) {
+ st->stat_count = STAT_COUNT;
+ }
+ else {
+ stat_rat = 0;
+
+ for ( i = 0; i < COMPLEN; i++ ) {
+ if ( level[i] > st->ave_level[i] ) {
+ num = level[i];
+ denom = st->ave_level[i];
+ }
+ else {
+ num = st->ave_level[i];
+ denom = level[i];
+ }
+
+ /* Limit nimimum value of num and denom to STAT_THR_LEVEL */
+ if ( num < STAT_THR_LEVEL ) {
+ num = STAT_THR_LEVEL;
+ }
+
+ if ( denom < STAT_THR_LEVEL ) {
+ denom = STAT_THR_LEVEL;
+ }
+ stat_rat += num / denom * 64;
+ }
+
+ /* compare stat_rat with a threshold and update stat_count */
+ if ( stat_rat > STAT_THR ) {
+ st->stat_count = STAT_COUNT;
+ }
+ else {
+ if ( ( st->vadreg & 0x4000 ) != 0 ) {
+ if ( st->stat_count != 0 ) {
+ st->stat_count -= 1;
+ }
+ }
+ }
+ }
+ }
+
+ /* Update average amplitude estimate for stationarity estimation */
+ alpha = ALPHA4;
+
+ if ( st->stat_count == STAT_COUNT ) {
+ alpha = 1.0F;
+ }
+ else if ( ( st->vadreg & 0x4000 ) == 0 ) {
+ alpha = ALPHA5;
+ }
+
+ for ( i = 0; i < COMPLEN; i++ ) {
+ st->ave_level[i] += alpha * ( level[i] - st->ave_level[i] );
+ }
+}
+#endif
+
+/*
+ * noise_estimate_update
+ *
+ *
+ * Parameters:
+ * st B: State struct
+ * level I: sub-band levels of the input frame
+ * st->vadreg I: intermediate VAD flags
+ * st->pitch I: flags for pitch detection
+ * st->complex_hang_count I: signal is too complex for VAD
+ * st->stat_count B: stationary counter
+ * st->old_level B: signal levels of the previous frame
+ * st->bckr_est B: noise estimate
+ *
+ * Function:
+ * Update of background noise estimate
+ *
+ * Returns:
+ * void
+ */
+#ifndef VAD2
+static void noise_estimate_update( vadState *st, Float32 level[] )
+{
+ Float32 alpha_up, alpha_down, bckr_add;
+ Word32 i;
+
+
+ /* Control update of bckr_est[] */
+ update_cntrl( st, level );
+
+ /* Choose update speed */
+ bckr_add = 2;
+
+ if ( ( ( 0x7800 & st->vadreg ) == 0 ) && ( ( st->pitch & 0x7800 ) == 0 ) && (
+ st->complex_hang_count == 0 ) ) {
+ alpha_up = ALPHA_UP1;
+ alpha_down = ALPHA_DOWN1;
+ }
+ else {
+ if ( ( st->stat_count == 0 ) && ( st->complex_hang_count == 0 ) ) {
+ alpha_up = ALPHA_UP2;
+ alpha_down = ALPHA_DOWN2;
+ }
+ else {
+ alpha_up = 0;
+ alpha_down = ALPHA3;
+ bckr_add = 0;
+ }
+ }
+
+ /* Update noise estimate (bckr_est) */
+ for ( i = 0; i < COMPLEN; i++ ) {
+ Float32 temp;
+
+
+ temp = st->old_level[i] - st->bckr_est[i];
+
+ /* update downwards*/
+ if ( temp < 0 ) {
+ st->bckr_est[i] = ( -2 + ( st->bckr_est[i] + ( alpha_down * temp ) ) );
+
+ /* limit minimum value of the noise estimate to NOISE_MIN */
+ if ( st->bckr_est[i] < NOISE_MIN ) {
+ st->bckr_est[i] = NOISE_MIN;
+ }
+ }
+
+ /* update upwards */
+ else {
+ st->bckr_est[i] = ( bckr_add + ( st->bckr_est[i] + ( alpha_up * temp )
+ ) );
+
+ /* limit maximum value of the noise estimate to NOISE_MAX */
+ if ( st->bckr_est[i] > NOISE_MAX ) {
+ st->bckr_est[i] = NOISE_MAX;
+ }
+ }
+ }
+
+ /* Update signal levels of the previous frame (old_level) */
+ for ( i = 0; i < COMPLEN; i++ ) {
+ st->old_level[i] = level[i];
+ }
+}
+#endif
+
+/*
+ * hangover_addition
+ *
+ *
+ * Parameters:
+ * noise_level I: average level of the noise estimates
+ * low_power I: flag power of the input frame
+ * st->burst_count O: counter for the length of speech bursts
+ * st->hang_count O: hangover counter
+ * st->complex_hang_count B: signal is too complex for VAD
+ * st->complex_hang_timer B: complex hang timer
+ * st->vadreg I: intermediate VAD flags
+ * st->corr_hp_fast I: long term complex signal estimate
+ *
+ * Function:
+ * Add hangover for complex signal or after speech bursts
+ *
+ * Returns:
+ * VAD_flag indicating final VAD decision
+ */
+#ifndef VAD2
+static Word16 hangover_addition( vadState *st, Float32 noise_level, Word16
+ low_power )
+{
+ Word16 hang_len, burst_len;
+
+
+ /*
+ * Calculate burst_len and hang_len
+ * burst_len: number of consecutive intermediate vad flags with "1"-decision
+ * required for hangover addition
+ * hang_len: length of the hangover
+ */
+ if ( noise_level > HANG_NOISE_THR ) {
+ burst_len = BURST_LEN_HIGH_NOISE;
+ hang_len = HANG_LEN_HIGH_NOISE;
+ }
+ else {
+ burst_len = BURST_LEN_LOW_NOISE;
+ hang_len = HANG_LEN_LOW_NOISE;
+ }
+
+ /*
+ * if the input power (pow_sum) is lower than a threshold, clear
+ * counters and set VAD_flag to "0" "fast exit"
+ */
+ if ( low_power != 0 ) {
+ st->burst_count = 0;
+ st->hang_count = 0;
+ st->complex_hang_count = 0;
+ st->complex_hang_timer = 0;
+ return 0;
+ }
+
+ if ( st->complex_hang_timer > CVAD_HANG_LIMIT ) {
+ if ( st->complex_hang_count < CVAD_HANG_LENGTH ) {
+ st->complex_hang_count = CVAD_HANG_LENGTH;
+ }
+ }
+
+ /* long time very complex signal override VAD output function */
+ if ( st->complex_hang_count != 0 ) {
+ st->burst_count = BURST_LEN_HIGH_NOISE;
+ st->complex_hang_count -= 1;
+ return 1;
+ }
+ else {
+ /* let hp_corr work in from a noise_period indicated by the VAD */
+ if ( ( ( st->vadreg & 0x3ff0 ) == 0 ) && ( st->corr_hp_fast >
+ CVAD_THRESH_IN_NOISE ) ) {
+ return 1;
+ }
+ }
+
+ /* update the counters (hang_count, burst_count) */
+ if ( ( st->vadreg & 0x4000 ) != 0 ) {
+ st->burst_count += 1;
+
+ if ( st->burst_count >= burst_len ) {
+ st->hang_count = hang_len;
+ }
+ return 1;
+ }
+ else {
+ st->burst_count = 0;
+
+ if ( st->hang_count > 0 ) {
+ st->hang_count -= 1;
+ return 1;
+ }
+ }
+ return 0;
+}
+#endif
+
+/*
+ * vad_decision
+ *
+ *
+ * Parameters:
+ * st B: State struct
+ * level I: sub-band levels of the input frame
+ * pow_sum I: power of the input frame
+ * st->bckr_est I: background noise components
+ * st->vadreg I: intermediate VAD flags
+ * st->complex_warning O: flags for complex detection
+ * st->speech_vad_decision O: speech VAD flag
+ *
+ * Function:
+ * Calculates VAD_flag
+ *
+ * Returns:
+ * VAD_flag indicating final VAD decision
+ */
+#ifndef VAD2
+static Word16 vad_decision( vadState *st, Float32 level[COMPLEN], Float32
+ pow_sum )
+{
+ Float32 snr_sum, temp, vad_thr, noise_level;
+ Word32 i;
+ Word16 low_power_flag;
+
+
+ /*
+ * Calculate squared sum of the input levels (level)
+ * divided by the background noise components (bckr_est).
+ */
+ snr_sum = 0;
+
+ for ( i = 0; i < COMPLEN; i++ ) {
+ temp = level[i] / st->bckr_est[i];
+ snr_sum += temp * temp;
+ }
+ snr_sum = snr_sum * 56.8889F;
+
+ /* Calculate average level of estimated background noise */
+ noise_level = st->bckr_est[0] + st->bckr_est[1] + st->bckr_est[2] + st->
+ bckr_est[3] + st->bckr_est[4] + st->bckr_est[5] + st->bckr_est[6] + st
+ ->bckr_est[7] + st->bckr_est[8];
+ noise_level = noise_level * 0.111111F;
+
+ /* Calculate VAD threshold */
+ vad_thr = VAD_SLOPE * ( noise_level - VAD_P1 ) + VAD_THR_HIGH;
+
+ if ( vad_thr < VAD_THR_LOW ) {
+ vad_thr = VAD_THR_LOW;
+ }
+
+ /* Shift VAD decision register */
+ st->vadreg >>= 1;
+
+ /* Make intermediate VAD decision */
+ if ( snr_sum > vad_thr ) {
+ st->vadreg = st->vadreg | 0x4000;
+ }
+
+ /*
+ * primary vad decision made
+ * check if the input power (pow_sum) is lower than a threshold"
+ */
+ if ( pow_sum < VAD_POW_LOW ) {
+ low_power_flag = 1;
+ }
+ else {
+ low_power_flag = 0;
+ }
+
+ /*
+ * update complex signal estimate st->corr_hp_fast and hangover reset timer using
+ * low_power_flag and corr_hp_fast and various adaptation speeds
+ */
+ complex_estimate_adapt( st, low_power_flag );
+
+ /* check multiple thresholds of the st->corr_hp_fast value */
+ st->complex_warning = complex_vad( st, low_power_flag );
+
+ /* Update speech subband vad background noise estimates */
+ noise_estimate_update( st, level );
+
+ /*
+ * Add speech and complex hangover and return speech VAD_flag
+ * long term complex hangover may be added
+ */
+ st->speech_vad_decision = hangover_addition( st, noise_level, low_power_flag
+ );
+ return( st->speech_vad_decision );
+}
+#endif
+
+/*
+ * level_calculation
+ *
+ *
+ * Parameters:
+ * data I: signal buffer
+ * sub_level B: level calculate at the end of the previous frame/
+ * level of signal calculated from the last
+ * (count2 - count1) samples
+ * count1 I: number of samples to be counted
+ * count2 I: number of samples to be counted
+ * ind_m I: step size for the index of the data buffer
+ * ind_a I: starting index of the data buffer
+ * scale I: scaling for the level calculation
+ *
+ * Function:
+ * Calculate signal level in a sub-band.
+ *
+ * Level is calculated by summing absolute values of the input data.
+ *
+ * Returns:
+ * signal level
+ */
+#ifndef VAD2
+static Float32 level_calculation( Float32 data[], Float32 *sub_level, Word16
+ count1, Word16 count2, Word16 ind_m, Word16 ind_a, Word16 scale )
+{
+ Float32 level, temp1;
+ Word32 i;
+
+
+ temp1 = 0;
+
+ for ( i = count1; i < count2; i++ ) {
+ temp1 += ( Float32 )fabs( data[ind_m * i + ind_a] );
+ }
+ level = temp1 + *sub_level;
+ *sub_level = temp1;
+
+ for ( i = 0; i < count1; i++ ) {
+ level += ( Float32 )fabs( data[ind_m * i + ind_a] );
+ }
+ return( scale * level );
+}
+#endif
+
+/*
+ * filter3
+ *
+ *
+ * Parameters:
+ * in0 B: input values; output low-pass part
+ * in1 B: input values; output high-pass part
+ * data B: updated filter memory
+ *
+ * Function:
+ * Third-order half-band lowpass/highpass filter pair.
+ *
+ * Returns:
+ * void
+ */
+#ifndef VAD2
+static void filter3( Float32 *in0, Float32 *in1, Float32 *data )
+{
+ Float32 temp1, temp2;
+
+
+ temp1 = *in1 - ( COEFF3 * *data );
+ temp2 = *data + ( COEFF3 * temp1 );
+ *data = temp1;
+ *in1 = ( *in0 - temp2 ) * 0.5F;
+ *in0 = ( *in0 + temp2 ) * 0.5F;
+}
+#endif
+
+/*
+ * filter5
+ *
+ *
+ * Parameters:
+ * in0 B: input values; output low-pass part
+ * in1 B: input values; output high-pass part
+ * data B: updated filter memory
+ *
+ * Function:
+ * Fifth-order half-band lowpass/highpass filter pair.
+ *
+ * Returns:
+ * void
+ */
+#ifndef VAD2
+static void filter5( Float32 *in0, Float32 *in1, Float32 data[] )
+{
+ Float32 temp0, temp1, temp2;
+
+
+ temp0 = *in0 - ( COEFF5_1 * data[0] );
+ temp1 = data[0] + ( COEFF5_1 * temp0 );
+ data[0] = temp0;
+ temp0 = *in1 - ( COEFF5_2 * data[1] );
+ temp2 = data[1] + ( COEFF5_2 * temp0 );
+ data[1] = temp0;
+ *in0 = ( temp1 + temp2 ) * 0.5F;
+ *in1 = ( temp1 - temp2 ) * 0.5F;
+}
+#endif
+
+/*
+ * first_filter_stage
+ *
+ *
+ * Parameters:
+ * in I: input signal
+ * out O: output values,
+ * every other output is low-pass part and
+ * every other output is high-pass part
+ * data B: updated filter memory
+ *
+ * Function:
+ * Calculate 5th order half-band lowpass/highpass filter pair
+ *
+ * Returns:
+ * void
+ */
+#ifndef VAD2
+static void first_filter_stage( Float32 in[], Float32 out[], Float32 data[] )
+{
+ Float32 temp0, temp1, temp2, temp3;
+ Float32 data0, data1;
+ Word32 i;
+
+
+ data0 = data[0];
+ data1 = data[1];
+
+ for ( i = 0; i < L_SUBFR; i++ ) {
+ temp0 = ( in[4 * i + 0] * 0.25F ) - ( COEFF5_1 * data0 );
+ temp1 = data0 + ( COEFF5_1 * temp0 );
+ temp3 = ( in[4*i+1]*0.25F )-( COEFF5_2 * data1 );
+ temp2 = data1 + ( COEFF5_2 * temp3 );
+ out[4 * i + 0] = temp1 + temp2;
+ out[4 * i + 1] = temp1 - temp2;
+ data0 = ( in[4 * i + 2] * 0.25F ) - ( COEFF5_1 * temp0 );
+ temp1 = temp0 + ( COEFF5_1 * data0 );
+ data1 = ( in[4 * i + 3] * 0.25F ) - ( COEFF5_2 * temp3 );
+ temp2 = temp3 + ( COEFF5_2 * data1 );
+ out[4 * i + 2] = temp1 + temp2;
+ out[4 * i + 3] = temp1 - temp2;
+ }
+ data[0] = data0;
+ data[1] = data1;
+}
+#endif
+
+/*
+ * filter_bank
+ *
+ *
+ * Parameters:
+ * in I: input frame
+ * st->a_data5 B: filter memory
+ * st->a_data3 B: filter memory
+ * st->sub_level B: level memory
+ * level O: signal levels at each band
+ *
+ * Function:
+ * Divides input signal into 9-bands and calcultes level of the signal in each band
+ *
+ * Returns:
+ * void
+ */
+#ifndef VAD2
+static void filter_bank( vadState *st, Float32 in[], Float32 level[] )
+{
+ Word32 i;
+ Float32 tmp_buf[FRAME_LEN];
+
+
+ /* calculate the filter bank */
+ first_filter_stage( in, tmp_buf, st->a_data5[0] );
+
+ for ( i = 0; i < FRAME_LEN / 4; i++ ) {
+ filter5( &tmp_buf[4 * i], &tmp_buf[4 * i + 2], st->a_data5[1] );
+ filter5( &tmp_buf[4 * i +1], &tmp_buf[4 * i + 3], st->a_data5[2] );
+ }
+
+ for ( i = 0; i < FRAME_LEN / 8; i++ ) {
+ filter3( &tmp_buf[8 * i + 0], &tmp_buf[8 * i + 4], &st->a_data3[0] );
+ filter3( &tmp_buf[8 * i + 2], &tmp_buf[8 * i + 6], &st->a_data3[1] );
+ filter3( &tmp_buf[8 * i + 3], &tmp_buf[8 * i + 7], &st->a_data3[4] );
+ }
+
+ for ( i = 0; i < FRAME_LEN / 16; i++ ) {
+ filter3( &tmp_buf[16 * i + 0], &tmp_buf[16 * i + 8], &st->a_data3[2] );
+ filter3( &tmp_buf[16 * i + 4], &tmp_buf[16 * i + 12], &st->a_data3[3] );
+ }
+
+ /* calculate levels in each frequency band */
+ /* 3000 - 4000 Hz*/
+ level[8] = level_calculation( tmp_buf, &st->sub_level[8], FRAME_LEN /4 - 8,
+ FRAME_LEN /4, 4, 1, 1 );
+
+ /* 2500 - 3000 Hz*/
+ level[7] = level_calculation( tmp_buf, &st->sub_level[7], FRAME_LEN /8 - 4,
+ FRAME_LEN /8, 8, 7, 2 );
+
+ /* 2000 - 2500 Hz*/
+ level[6] = level_calculation( tmp_buf, &st->sub_level[6], FRAME_LEN /8 - 4,
+ FRAME_LEN /8, 8, 3, 2 );
+
+ /* 1500 - 2000 Hz*/
+ level[5] = level_calculation( tmp_buf, &st->sub_level[5], FRAME_LEN /8 - 4,
+ FRAME_LEN /8, 8, 2, 2 );
+
+ /* 1000 - 1500 Hz*/
+ level[4] = level_calculation( tmp_buf, &st->sub_level[4], FRAME_LEN /8 - 4,
+ FRAME_LEN /8, 8, 6, 2 );
+
+ /* 750 - 1000 Hz*/
+ level[3] = level_calculation( tmp_buf, &st->sub_level[3], FRAME_LEN /16 - 2,
+ FRAME_LEN /16, 16, 4, 2 );
+
+ /* 500 - 750 Hz*/
+ level[2] = level_calculation( tmp_buf, &st->sub_level[2], FRAME_LEN /16 - 2,
+ FRAME_LEN /16, 16, 12, 2 );
+
+ /* 250 - 500 Hz*/
+ level[1] = level_calculation( tmp_buf, &st->sub_level[1], FRAME_LEN /16 - 2,
+ FRAME_LEN /16, 16, 8, 2 );
+
+ /* 0 - 250 Hz*/
+ level[0] = level_calculation( tmp_buf, &st->sub_level[0], FRAME_LEN /16 - 2,
+ FRAME_LEN /16, 16, 0, 2 );
+}
+#endif
+
+/*
+ * vad
+ *
+ *
+ * Parameters:
+ * in_buf I: samples of the input frame
+ * st B: State struct
+ * st->pitch B: flags for pitch detection
+ * st->complex_low B: complex flag
+ *
+ * Function:
+ * Voice Activity Detection (VAD)
+ *
+ * Returns:
+ * VAD Decision, 1 = speech, 0 = noise
+ */
+#ifndef VAD2
+static Word16 vad( vadState *st, Float32 in_buf[] )
+{
+ Float32 level[COMPLEN];
+ Float32 pow_sum;
+ Word32 i;
+
+
+ /* Calculate power of the input frame. */
+ pow_sum = 0L;
+
+ for ( i = -40; i < 120; i += 8 ) {
+ pow_sum += in_buf[i] * in_buf[i];
+ pow_sum += in_buf[i + 1] *in_buf[i + 1];
+ pow_sum += in_buf[i + 2] * in_buf[i + 2];
+ pow_sum += in_buf[i + 3] * in_buf[i + 3];
+ pow_sum += in_buf[i + 4] * in_buf[i + 4];
+ pow_sum += in_buf[i + 5] * in_buf[i + 5];
+ pow_sum += in_buf[i + 6] * in_buf[i + 6];
+ pow_sum += in_buf[i + 7] * in_buf[i + 7];
+ }
+
+ /*
+ * If input power is very low, clear pitch flag of the current frame
+ */
+ if ( pow_sum < POW_PITCH_THR ) {
+ st->pitch = ( Word16 )( st->pitch & 0x3fff );
+ }
+
+ /*
+ * If input power is very low, clear complex flag of the "current" frame
+ */
+ if ( pow_sum < POW_COMPLEX_THR ) {
+ st->complex_low = ( Word16 )( st->complex_low & 0x3fff );
+ }
+
+ /*
+ * Run the filter bank which calculates signal levels at each band
+ */
+ filter_bank( st, in_buf, level );
+ return( vad_decision( st, level, pow_sum ) );
+}
+#endif
+
+/*
+ * vad_pitch_detection
+ *
+ *
+ * Parameters:
+ * st->oldlag B: old LTP lag
+ * T_op I: speech encoder open loop lags
+ * st->pitch B: flags for pitch detection
+ * st B: State struct
+ * st->pitch B: flags for pitch detection
+ * st->oldlag_count B: lag count
+ *
+ * Function:
+ * Test if signal contains pitch or other periodic component.
+ *
+ * Returns:
+ * Boolean voiced / unvoiced decision in state variable
+ */
+#ifndef VAD2
+static void vad_pitch_detection( vadState *st, Word32 T_op[] )
+{
+ Word32 lagcount, i;
+
+
+ lagcount = 0;
+
+ for ( i = 0; i < 2; i++ ) {
+ if ( abs( st->oldlag - T_op[i] ) < LTHRESH ) {
+ lagcount += 1;
+ }
+
+ /* Save the current LTP lag */
+ st->oldlag = T_op[i];
+ }
+
+ /*
+ * Make pitch decision.
+ * Save flag of the pitch detection to the variable pitch.
+ */
+ st->pitch = st->pitch >> 1;
+
+ if ( ( st->oldlag_count + lagcount ) >= NTHRESH ) {
+ st->pitch = st->pitch | 0x4000;
+ }
+
+ /* Update oldlagcount */
+ st->oldlag_count = lagcount;
+}
+#endif
+
+
+#ifdef VAD2
+
+/***************************************************************************
+ *
+ * FUNCTION NAME: vad2()
+ *
+ * PURPOSE:
+ * This function provides the Voice Activity Detection function option 2
+ * for the Adaptive Multi-rate (AMR) codec.
+ *
+ * INPUTS:
+ *
+ * vadState
+ * pointer to vadState state structure
+ * farray_ptr
+ * pointer to Float32[80] input array
+ *
+ * OUTPUTS:
+ *
+ * state variables in vadState are updated
+ *
+ * RETURN VALUE:
+ *
+ * Word16
+ * VAD(m) - two successive calls to vad2() yield
+ * the VAD decision for the 20 ms frame:
+ * VAD_flag = VAD(m-1) || VAD(m)
+ *
+ *
+ *************************************************************************/
+
+int vad2 (vadState *st, Float32 *farray_ptr)
+{
+
+ /* Static variables */
+
+ /* The channel table is defined below. In this table, the
+ lower and higher frequency coefficients for each of the 16
+ channels are specified. The table excludes the coefficients
+ with numbers 0 (DC), 1, and 64 (Foldover frequency). For
+ these coefficients, the gain is always set at 1.0 (0 dB). */
+
+ static int ch_tbl [NUM_CHAN][2] = {
+
+ { 2, 3},
+ { 4, 5},
+ { 6, 7},
+ { 8, 9},
+ {10, 11},
+ {12, 13},
+ {14, 16},
+ {17, 19},
+ {20, 22},
+ {23, 26},
+ {27, 30},
+ {31, 35},
+ {36, 41},
+ {42, 48},
+ {49, 55},
+ {56, 63}
+
+ };
+
+ /* The voice metric table is defined below. It is a non-
+ linear table with a deadband near zero. It maps the SNR
+ index (quantized SNR value) to a number that is a measure
+ of voice quality. */
+
+ static int vm_tbl [90] = {
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 3, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 7, 7, 7,
+ 8, 8, 9, 9, 10, 10, 11, 12, 12, 13, 13, 14, 15,
+ 15, 16, 17, 17, 18, 19, 20, 20, 21, 22, 23, 24,
+ 24, 25, 26, 27, 28, 28, 29, 30, 31, 32, 33, 34,
+ 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 45,
+ 46, 47, 48, 49, 50, 50, 50, 50, 50, 50, 50, 50,
+ 50, 50
+ };
+
+ /* hangover as a function of peak SNR (3 dB steps) */
+ static Word16 hangover_table[20] =
+ {
+ 30, 30, 30, 30, 30, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 8, 8, 8
+ };
+
+ /* burst sensitivity as a function of peak SNR (3 dB steps) */
+ static Word16 burstcount_table[20] =
+ {
+ 8, 8, 8, 8, 8, 8, 8, 8, 7, 6, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4
+ };
+
+ /* voice metric sensitivity as a function of peak SNR (3 dB steps) */
+ static Word16 vm_threshold_table[20] =
+ {
+ 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 40, 51, 71, 100, 139, 191, 257, 337, 432
+ };
+
+
+ /* Automatic variables */
+
+ float data_buffer [FFT_LEN1], enrg, snr;
+ float tne, tce, ftmp;
+ int ch_snr [NUM_CHAN];
+ int i, j, j1, j2;
+ int vm_sum;
+ int update_flag;
+
+ float ch_enrg_dev; /* for forced update... */
+ float ch_enrg_db [NUM_CHAN];
+ float alpha;
+
+
+ /* For detecting sine waves */
+ float peak, avg, peak2avg;
+ int sine_wave_flag;
+
+ /* For computing frame SNR and long-term SNR */
+ float tce_db, tne_db;
+ float xt;
+
+ /* More VAD stuff */
+ int tsnrq;
+ int ivad;
+
+
+ /* Functions */
+
+ void real_fft (float *, int);
+
+
+ /****** Executable code starts here ******/
+
+ /* Increment frame counter */
+ st->Lframe_cnt++;
+
+ /* Preemphasize the input data and store in the data buffer with
+ appropriate delay */
+
+ for (i = 0; i < DELAY0; i++)
+ data_buffer [i] = 0.0;
+
+ data_buffer [DELAY0] = *farray_ptr + PRE_EMP_FAC1 * st->pre_emp_mem;
+
+ for (i = DELAY0+1, j = 1; i < DELAY0+FRM_LEN1; i++, j++)
+ data_buffer [i] = *(farray_ptr + j) + PRE_EMP_FAC1 *
+ *(farray_ptr + j - 1);
+
+ st->pre_emp_mem = *(farray_ptr + FRM_LEN1 - 1);
+
+ for (i = DELAY0+FRM_LEN1; i < FFT_LEN1; i++)
+ data_buffer [i] = 0.0;
+
+ /* Perform FFT on the data buffer */
+ real_fft (data_buffer, +1);
+
+ /* Estimate the energy in each channel */
+ alpha = (st->Lframe_cnt == 1) ? 1.0 : CEE_SM_FAC1;
+ for (i = LO_CHAN; i <= HI_CHAN; i++)
+ {
+ enrg = 0.0;
+ j1 = ch_tbl [i][0], j2 = ch_tbl [i][1];
+ for (j = j1; j <= j2; j++)
+ enrg += square(data_buffer [2*j]) + square(data_buffer [2*j+1]);
+ enrg /= (float) (j2 - j1 + 1);
+ st->ch_enrg [i] = (1 - alpha) * st->ch_enrg [i] + alpha * enrg;
+ if (st->ch_enrg [i] < MIN_CHAN_ENRG) st->ch_enrg [i] = MIN_CHAN_ENRG;
+ }
+
+ /* Compute the total channel energy estimate (tce) */
+ tce = 0.0;
+ for (i = LO_CHAN; i <= HI_CHAN; i++)
+ tce += st->ch_enrg [i];
+
+ /* Calculate spectral peak-to-average ratio */
+ peak = avg = 0.;
+ for (i = LO_CHAN; i <= HI_CHAN; i++) {
+ /* Sine waves not valid for low frequencies: */
+ if (i >= SINE_START_CHAN && st->ch_enrg [i] > peak)
+ peak = st->ch_enrg [i];
+ avg += st->ch_enrg [i];
+ }
+ avg /= HI_CHAN - LO_CHAN + 1;
+ peak2avg = (avg < 1./NORM_ENRG) ? 0. : 10.*log10 (peak/avg);
+
+ /* Detect sine waves */
+ if (peak2avg > 10.)
+ sine_wave_flag = TRUE;
+ else
+ sine_wave_flag = FALSE;
+
+ /* Initialize channel noise estimate to channel energy of first few frames
+ (if sufficiently low Peak-to-Average ratio) */
+ if (st->Lframe_cnt <= INIT_FRAMES) {
+ if (sine_wave_flag == TRUE) {
+ for (i = LO_CHAN; i <= HI_CHAN; i++)
+ st->ch_noise [i] = INE;
+ }
+ else {
+ for (i = LO_CHAN; i <= HI_CHAN; i++)
+ st->ch_noise [i] = max(st->ch_enrg [i], INE);
+ }
+ }
+
+ /* Compute the channel SNR indices */
+ for (i = LO_CHAN; i <= HI_CHAN; i++) {
+ snr = 10.0 * log10 ((double)st->ch_enrg [i] / st->ch_noise [i]);
+ if (snr < 0.0) snr = 0.0;
+ ch_snr [i] = (snr + 0.1875) / 0.375;
+ }
+
+ /* Compute the sum of voice metrics */
+ vm_sum = 0;
+ for (i = LO_CHAN; i <= HI_CHAN; i++) {
+ j = min(ch_snr[i],89);
+ vm_sum += vm_tbl [j];
+ }
+
+ /* Initialize voice energy to nominal value */
+ if (st->Lframe_cnt <= INIT_FRAMES || st->fupdate_flag == TRUE ) {
+#if NORM_ENERG==4
+ tce_db = 49.918;
+#elif NORM_ENERG==1
+ tce_db = 55.938;
+#else
+ tce_db = (96. - 22. - 10*log10 (FFT_LEN1/2) - 10.*log10 (NORM_ENRG));
+#endif
+
+ st->negSNRvar = 0.0;
+ st->negSNRbias = 0.0;
+
+ /* Compute the total noise energy estimate (tne) */
+ tne = 0.0;
+ for (i = LO_CHAN; i <= HI_CHAN; i++)
+ tne += st->ch_noise [i];
+
+ /* Get total noise in dB */
+ tne_db = 10 * log10 (tne);
+
+ /* Initialise instantaneous and long-term peak signal-to-noise ratios */
+ xt = tce_db - tne_db;
+ st->tsnr = xt;
+
+ }
+ else {
+
+ /* Calculate instantaneous signal-to-noise ratio */
+ xt = 0;
+ for (i=LO_CHAN; i<=HI_CHAN; i++)
+ xt += st->ch_enrg[i]/st->ch_noise[i];
+ xt = 10*log10(xt/NUM_CHAN);
+
+ /* Estimate long-term "peak" SNR */
+ if (xt > st->tsnr)
+ st->tsnr = 0.9*st->tsnr + 0.1*xt;
+ else if (xt > 0.625*st->tsnr)
+ st->tsnr = 0.998*st->tsnr + 0.002*xt;
+ }
+
+ /* Quantize the long-term SNR in 3 dB steps */
+ tsnrq = (int)(st->tsnr/3.);
+ tsnrq = min(19, max(0, tsnrq));
+
+ /* Calculate the negative SNR sensitivity bias */
+ if (xt < 0) {
+ st->negSNRvar = min (0.99*st->negSNRvar + 0.01*xt*xt, 4.0);
+ st->negSNRbias = max (12.0*(st->negSNRvar - 0.65), 0.0);
+ }
+
+ /* Determine VAD as a function of the voice metric sum and quantized SNR */
+ if (vm_sum > vm_threshold_table[tsnrq] + st->negSNRbias) {
+ ivad = 1;
+ if (++st->burstcount > burstcount_table[tsnrq]) {
+ st->hangover = hangover_table[tsnrq];
+ }
+ } else {
+ st->burstcount = 0;
+ if (--st->hangover <= 0) {
+ ivad = 0;
+ st->hangover = 0;
+ } else {
+ ivad = 1;
+ }
+ }
+
+ /* Calculate log spectral deviation */
+ for (i = LO_CHAN; i <= HI_CHAN; i++)
+ ch_enrg_db [i] = 10.*log10( st->ch_enrg [i] );
+
+ ch_enrg_dev = 0.;
+ if (st->Lframe_cnt == 1)
+ for (i = LO_CHAN; i <= HI_CHAN; i++)
+ st->ch_enrg_long_db [i] = ch_enrg_db [i];
+ else
+ for (i = LO_CHAN; i <= HI_CHAN; i++)
+ ch_enrg_dev += fabs( st->ch_enrg_long_db [i] - ch_enrg_db [i] );
+
+
+ /*
+ * Calculate long term integration constant as a function of instantaneous SNR
+ * (i.e., high SNR (tsnr dB) -> slower integration (alpha = HIGH_ALPHA),
+ * low SNR (0 dB) -> faster integration (alpha = LOW_ALPHA)
+ */
+
+ /* alpha = HIGH_ALPHA - ALPHA_RANGE * (tsnr - xt) / tsnr, low <= alpha <= high */
+ ftmp = st->tsnr - xt;
+ if (ftmp <= 0.0 || st->tsnr <= 0.0)
+ alpha = HIGH_ALPHA1;
+ else if (ftmp > st->tsnr)
+ alpha = LOW_ALPHA1;
+ else
+ alpha = HIGH_ALPHA1 - (ALPHA_RANGE1 * ftmp / st->tsnr);
+
+ /* Calc long term log spectral energy */
+ for (i = LO_CHAN; i <= HI_CHAN; i++) {
+ st->ch_enrg_long_db[i] = alpha*st->ch_enrg_long_db[i] + (1.-alpha)*ch_enrg_db[i];
+ }
+
+ /* Set or reset the update flag */
+ update_flag = FALSE;
+ st->fupdate_flag = FALSE;
+ if ((vm_sum <= UPDATE_THLD) ||
+ (st->Lframe_cnt <= INIT_FRAMES && sine_wave_flag == FALSE)) {
+ update_flag = TRUE;
+ st->update_cnt = 0;
+ }
+ else if (tce > NOISE_FLOOR && ch_enrg_dev < DEV_THLD1 &&
+ sine_wave_flag == FALSE && st->LTP_flag == FALSE) {
+ st->update_cnt++;
+ if (st->update_cnt >= UPDATE_CNT_THLD1) {
+ update_flag = TRUE;
+ st->fupdate_flag = TRUE;
+ }
+ }
+
+ if ( st->update_cnt == st->last_update_cnt )
+ st->hyster_cnt++;
+ else
+ st->hyster_cnt = 0;
+ st->last_update_cnt = st->update_cnt;
+
+ if ( st->hyster_cnt > HYSTER_CNT_THLD1 )
+ st->update_cnt = 0;
+
+ /* Update the channel noise estimates */
+ if (update_flag == TRUE) {
+ for (i = LO_CHAN; i <= HI_CHAN; i++) {
+ st->ch_noise [i] = (1.0 - CNE_SM_FAC1) * st->ch_noise [i] +
+ CNE_SM_FAC1 * st->ch_enrg [i];
+ if (st->ch_noise [i] < MIN_CHAN_ENRG) st->ch_noise [i] = MIN_CHAN_ENRG;
+ }
+ }
+
+ return (ivad);
+
+} /* end vad2 () */
+
+
+/**************************************************************************
+ *
+ * FUNCTION NAME: real_fft()
+ *
+ * PURPOSE: FFT/IFFT function for real sequences
+ *
+ **************************************************************************
+ *
+ * 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 Ediiton, Chapter 12.
+ *
+ * Input - There is two inputs to this function:
+ *
+ * 1) A float pointer to the input data array,
+ * 2) A control parameter (isign) specifying forward (+1) or
+ * inverse (-1) FFT.
+ *
+ * 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 VAD
+ * 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 stored in a ROM table.
+ *
+ * 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. This is somewhat different
+ * from the usual definition of FFT where the factor 1/N,
+ * i.e., 1/64, used for the IFFT and not the FFT. No factor
+ * is used in the r_fft function.
+ *
+ *************************************************************************/
+
+static double phs_tbl [SIZE]; /* holds the complex sinusoids */
+
+void real_fft (float *farray_ptr, int isign)
+{
+
+ float ftmp1_real, ftmp1_imag, ftmp2_real, ftmp2_imag;
+ int i, j;
+ static int first = TRUE;
+
+ void cmplx_fft (float *, int);
+ void fill_tbl ();
+
+ /* If this is the first call to the function, fill up the
+ phase table */
+ if (first == TRUE) {
+ fill_tbl ();
+ first = FALSE;
+ }
+
+ /* The FFT part */
+ if (isign == 1) {
+
+ /* Perform the complex FFT */
+ cmplx_fft (farray_ptr, isign);
+
+ /* First, handle the DC and foldover frequencies */
+ ftmp1_real = *farray_ptr;
+ ftmp2_real = *(farray_ptr + 1);
+ *farray_ptr = ftmp1_real + ftmp2_real;
+ *(farray_ptr + 1) = ftmp1_real - ftmp2_real;
+
+ /* Now, handle the remaining positive frequencies */
+ for (i = 2, j = SIZE - i; i <= SIZE_BY_TWO; i = i + 2, j = SIZE - i) {
+
+ ftmp1_real = *(farray_ptr + i) + *(farray_ptr + j);
+ ftmp1_imag = *(farray_ptr + i + 1) - *(farray_ptr + j + 1);
+ ftmp2_real = *(farray_ptr + i + 1) + *(farray_ptr + j + 1);
+ ftmp2_imag = *(farray_ptr + j) - *(farray_ptr + i);
+
+ *(farray_ptr + i) = (ftmp1_real + phs_tbl [i] * ftmp2_real -
+ phs_tbl [i + 1] * ftmp2_imag) / 2.0;
+ *(farray_ptr + i + 1) = (ftmp1_imag + phs_tbl [i] * ftmp2_imag +
+ phs_tbl [i + 1] * ftmp2_real) / 2.0;
+ *(farray_ptr + j) = (ftmp1_real + phs_tbl [j] * ftmp2_real +
+ phs_tbl [j + 1] * ftmp2_imag) / 2.0;
+ *(farray_ptr + j + 1) = (-ftmp1_imag - phs_tbl [j] * ftmp2_imag +
+ phs_tbl [j + 1] * ftmp2_real) / 2.0;
+ }
+ }
+
+ /* The IFFT part */
+ else {
+
+ /* First, handle the DC and foldover frequencies */
+
+ ftmp1_real = *farray_ptr;
+ ftmp2_real = *(farray_ptr + 1);
+ *farray_ptr = (ftmp1_real + ftmp2_real) / 2.0;
+ *(farray_ptr + 1) = (ftmp1_real - ftmp2_real) / 2.0;
+
+ /* Now, handle the remaining positive frequencies */
+
+ for (i = 2, j = SIZE - i; i <= SIZE_BY_TWO; i = i + 2, j = SIZE - i) {
+
+ ftmp1_real = *(farray_ptr + i) + *(farray_ptr + j);
+ ftmp1_imag = *(farray_ptr + i + 1) - *(farray_ptr + j + 1);
+ ftmp2_real = -(*(farray_ptr + i + 1) + *(farray_ptr + j + 1));
+ ftmp2_imag = -(*(farray_ptr + j) - *(farray_ptr + i));
+
+ *(farray_ptr + i) = (ftmp1_real + phs_tbl [i] * ftmp2_real +
+ phs_tbl [i + 1] * ftmp2_imag) / 2.0;
+ *(farray_ptr + i + 1) = (ftmp1_imag + phs_tbl [i] * ftmp2_imag -
+ phs_tbl [i + 1] * ftmp2_real) / 2.0;
+ *(farray_ptr + j) = (ftmp1_real + phs_tbl [j] * ftmp2_real -
+ phs_tbl [j + 1] * ftmp2_imag) / 2.0;
+ *(farray_ptr + j + 1) = (-ftmp1_imag - phs_tbl [j] * ftmp2_imag -
+ phs_tbl [j + 1] * ftmp2_real) / 2.0;
+ }
+
+ /* Perform the complex IFFT */
+ cmplx_fft (farray_ptr, isign);
+ }
+
+ return;
+} /* end real_fft () */
+
+
+
+/*
+ * FFT/IFFT function for complex sequences
+ *
+ * The decimation-in-time complex FFT/IFFT is implemented below.
+ * The input complex numbers are presented as real part followed by
+ * imaginary part for each sample. The counters are therefore
+ * incremented by two to access the complex valued samples.
+ */
+void cmplx_fft (float *farray_ptr, int isign)
+{
+ int i, j, k, ii, jj, kk, ji, kj;
+ float ftmp, ftmp_real, ftmp_imag;
+
+ /* Rearrange the input array in bit reversed order */
+ for (i = 0, j = 0; i < SIZE-2; i = i + 2) {
+ if (j > i) {
+ ftmp = *(farray_ptr+i);
+ *(farray_ptr+i) = *(farray_ptr+j);
+ *(farray_ptr+j) = ftmp;
+
+ ftmp = *(farray_ptr+i+1);
+ *(farray_ptr+i+1) = *(farray_ptr+j+1);
+ *(farray_ptr+j+1) = ftmp;
+ }
+ k = SIZE_BY_TWO;
+ while (j >= k) {
+ j -= k;
+ k >>= 1;
+ }
+ j += k;
+ }
+
+ /* The FFT part */
+ if (isign == 1) {
+ for (i = 0; i < NUM_STAGE; i++) { /* i is stage counter */
+ jj = (2 << i); /* FFT size */
+ kk = (jj << 1); /* 2 * FFT size */
+ ii = SIZE / jj; /* 2 * number of FFT's */
+ for (j = 0; j < jj; j = j + 2) { /* j is sample counter */
+ ji = j * ii; /* ji is phase table index */
+ for (k = j; k < SIZE; k = k + kk) { /* k is butterfly top */
+ kj = k + jj; /* kj is butterfly bottom */
+
+ /* Butterfly computations */
+ ftmp_real = *(farray_ptr + kj) * phs_tbl [ji] -
+ *(farray_ptr + kj + 1) * phs_tbl [ji + 1];
+
+ ftmp_imag = *(farray_ptr + kj + 1) * phs_tbl [ji] +
+ *(farray_ptr + kj) * phs_tbl [ji + 1];
+
+ *(farray_ptr + kj) = (*(farray_ptr + k) - ftmp_real) / 2.0;
+ *(farray_ptr + kj + 1) = (*(farray_ptr + k + 1) - ftmp_imag) / 2.0;
+
+ *(farray_ptr + k) = (*(farray_ptr + k) + ftmp_real) / 2.0;
+ *(farray_ptr + k + 1) = (*(farray_ptr + k + 1) + ftmp_imag) / 2.0;
+ }
+ }
+ }
+ }
+
+ /* The IFFT part */
+ else {
+ for (i = 0; i < NUM_STAGE; i++) { /* i is stage counter */
+ jj = (2 << i); /* FFT size */
+ kk = (jj << 1); /* 2 * FFT size */
+ ii = SIZE / jj; /* 2 * number of FFT's */
+ for (j = 0; j < jj; j = j + 2) { /* j is sample counter */
+ ji = j * ii; /* ji is phase table index */
+ for (k = j; k < SIZE; k = k + kk) { /* k is butterfly top */
+ kj = k + jj; /* kj is butterfly bottom */
+
+ /* Butterfly computations */
+ ftmp_real = *(farray_ptr + kj) * phs_tbl [ji] +
+ *(farray_ptr + kj + 1) * phs_tbl [ji + 1];
+
+ ftmp_imag = *(farray_ptr + kj + 1) * phs_tbl [ji] -
+ *(farray_ptr + kj) * phs_tbl [ji + 1];
+
+ *(farray_ptr + kj) = *(farray_ptr + k) - ftmp_real;
+ *(farray_ptr + kj + 1) = *(farray_ptr + k + 1) - ftmp_imag;
+
+ *(farray_ptr + k) = *(farray_ptr + k) + ftmp_real;
+ *(farray_ptr + k + 1) = *(farray_ptr + k + 1) + ftmp_imag;
+ }
+ }
+ }
+ }
+ return;
+} /* end of cmplx_fft () */
+
+
+/* Function to fill the phase table values
+ */
+
+void fill_tbl ()
+{
+ int i;
+ double delta_f, theta;
+
+ delta_f = - PI / (double) SIZE_BY_TWO;
+ for (i = 0; i < SIZE_BY_TWO; i++) {
+ theta = delta_f * (double) i;
+ phs_tbl[2*i] = cos(theta);
+ phs_tbl[2*i+1] = sin(theta);
+ }
+ return;
+} /* end fill_tbl () */
+
+
+/***************************************************************************
+ *
+ * FUNCTION NAME: LTP_flag_update
+ *
+ * PURPOSE:
+ * Set LTP_flag if the LTP gain > LTP_THRESHOLD, where the value of
+ * LTP_THRESHOLD depends on the LTP analysis window length.
+ *
+ * INPUTS:
+ *
+ * mode
+ * AMR mode
+ * vadState->R0
+ * LTP energy
+ * vadState->Rmax
+ * LTP maximum autocorrelation
+ * OUTPUTS:
+ *
+ * vadState->LTP_flag
+ * Set if LTP gain > LTP_THRESHOLD
+ *
+ * RETURN VALUE:
+ *
+ * none
+ *
+ *************************************************************************/
+
+void LTP_flag_update (vadState * st, Word16 mode)
+{
+ Float32 thresh;
+
+ if ((mode == MR475) || (mode == MR515))
+ thresh = 0.55;
+ else if (mode == MR102)
+ thresh = 0.60;
+ else
+ thresh = 0.65;
+
+ if (st->Rmax > thresh*st->R0)
+ st->LTP_flag = TRUE;
+ else
+ st->LTP_flag = FALSE;
+
+ return;
+}
+
+/***************************************************************************/
+#endif
+
+/*
+ * cod_amr
+ *
+ *
+ * Parameters:
+ * st B: state structure
+ * mode I: encoder mode
+ * new_speech I: input speech frame, size L_FRAME
+ * st B: State struct
+ * ana O: Analysis parameters
+ * used_mode B: In: -1 forces VAD on, Out:used encoder mode
+ * synth O: local synthesis, size L_FRAME
+ *
+ * Function:
+ * GSM adaptive multi rate speech encoder
+ *
+ * Returns:
+ * void
+ */
+static void cod_amr( cod_amrState *st, enum Mode mode, Float32 new_speech[],
+ Word16 ana[], enum Mode *used_mode, Float32 synth[] )
+{
+ /* LPC coefficients */
+ Float32 A_t[( MP1 ) * 4]; /* A(z) unquantized for the 4 subframes */
+ Float32 Aq_t[( MP1 ) * 4]; /* A(z) quantized for the 4 subframes */
+ Float32 *A, *Aq; /* Pointer on Aq_t */
+ Float32 lsp_new[M];
+
+
+ /* Other vectors */
+ Float32 xn[L_SUBFR]; /* Target vector for pitch search */
+ Float32 xn2[L_SUBFR]; /* Target vector for codebook search */
+ Float32 code[L_SUBFR]; /* Fixed codebook excitation */
+ Float32 y1[L_SUBFR]; /* Filtered adaptive excitation */
+ Float32 y2[L_SUBFR]; /* Filtered fixed codebook excitation */
+ Float32 gCoeff[3]; /* Correlations between xn, y1, & y2: */
+ Float32 res[L_SUBFR]; /* Short term (LPC) prediction residual */
+ Float32 res2[L_SUBFR]; /* Long term (LTP) prediction residual */
+
+
+ /* Vector and scalars needed for the MR475 */
+ Float32 xn_sf0[L_SUBFR]; /* Target vector for pitch search */
+ Float32 y2_sf0[L_SUBFR]; /* Filtered codebook innovation */
+ Float32 code_sf0[L_SUBFR]; /* Fixed codebook excitation */
+ Float32 h1_sf0[L_SUBFR]; /* The impulse response of sf0 */
+ Float32 mem_syn_save[M]; /* Filter memory */
+ Float32 mem_w0_save[M]; /* Filter memory */
+ Float32 mem_err_save[M]; /* Filter memory */
+ Float32 sharp_save = 0; /* Sharpening */
+ Float32 gain_pit_sf0; /* Quantized pitch gain for sf0 */
+ Float32 gain_code_sf0; /* Quantized codebook gain for sf0 */
+ Word16 i_subfr_sf0 = 0; /* Position in exc[] for sf0 */
+
+
+ /* Scalars & Flags */
+ Float32 gain_pit, gain_code;
+ Float32 gp_limit; /* pitch gain limit value */
+ Word32 T0_sf0 = 0; /* Integer pitch lag of sf0 */
+ Word32 T0_frac_sf0 = 0; /* Fractional pitch lag of sf0 */
+ Word32 T0, T0_frac;
+ Word32 T_op[2];
+ Word32 evenSubfr;
+ Word32 i;
+ Word16 i_subfr, subfrNr;
+ Word16 lsp_flag = 0; /* indicates resonance in LPC filter */
+ Word16 compute_sid_flag;
+ Word16 vad_flag;
+
+
+ memcpy( st->new_speech, new_speech, L_FRAME <<2 );
+
+ if ( st->dtx ) {
+#ifdef VAD2
+ /* Find VAD decision (option 2) */
+ vad_flag = vad2 (st->vadSt, st->new_speech);
+ vad_flag = vad2 (st->vadSt, st->new_speech+80) || vad_flag;
+#else
+ /* Find VAD decision (option 1) */
+ vad_flag = vad( st->vadSt, st->new_speech );
+#endif
+ /* force VAD on */
+ if ( *used_mode < 0 )
+ vad_flag = 1;
+ *used_mode = mode;
+
+ /* NB! used_mode may change here */
+ compute_sid_flag = tx_dtx_handler( vad_flag, &st->dtxEncSt->
+ decAnaElapsedCount, &st->dtxEncSt->dtxHangoverCount, used_mode );
+ }
+ else {
+ compute_sid_flag = 0;
+ *used_mode = mode;
+ }
+
+ /*
+ * Perform LPC analysis:
+ * Autocorrelation + Lag windowing.
+ * Levinson-durbin algorithm to find a[].
+ * Convert a[] to lsp[].
+ * Quantize and code the LSPs.
+ * find the interpolated LSPs and convert to a[] for all
+ * subframes (both quantized and unquantized).
+ */
+ /* LP analysis */
+ lpc( st->lpcSt->LevinsonSt->old_A, st->p_window, st->p_window_12k2, A_t, mode
+ );
+
+ /*
+ * The LP filter coefficients, are converted to
+ * the line spectral pair (LSP) representation for
+ * quantization and interpolation purposes.
+ */
+ lsp( mode, *used_mode, st->lspSt->lsp_old, st->lspSt->lsp_old_q, st->lspSt->
+ qSt->past_rq, A_t, Aq_t, lsp_new, &ana );
+
+ /* Buffer lsp's and energy */
+ dtx_buffer( &st->dtxEncSt->hist_ptr, st->dtxEncSt->lsp_hist, lsp_new, st->
+ new_speech, st->dtxEncSt->log_en_hist );
+
+ if ( *used_mode == MRDTX ) {
+ dtx_enc( &st->dtxEncSt->log_en_index, st->dtxEncSt->log_en_hist, st->
+ dtxEncSt->lsp_hist, st->dtxEncSt->lsp_index, &st->dtxEncSt->
+ init_lsf_vq_index, compute_sid_flag, &st->lspSt->qSt->past_rq[0], st
+ ->gainQuantSt->gc_predSt->past_qua_en, &ana );
+ memset( st->old_exc, 0, ( PIT_MAX + L_INTERPOL )<<2 );
+ memset( st->mem_w0, 0, M <<2 );
+ memset( st->mem_err, 0, M <<2 );
+ memset( st->zero, 0, L_SUBFR <<2 );
+ memset( st->hvec, 0, L_SUBFR <<2 );
+ memset( st->lspSt->qSt->past_rq, 0, M <<2 );
+ memcpy( st->lspSt->lsp_old, lsp_new, M <<2 );
+ memcpy( st->lspSt->lsp_old_q, lsp_new, M <<2 );
+
+ /* Reset clLtp states */
+ st->clLtpSt->pitchSt->T0_prev_subframe = 0;
+ st->sharp = 0;
+ }
+ else {
+ /* check resonance in the filter */
+ lsp_flag = check_lsp( &st->tonStabSt->count, st->lspSt->lsp_old );
+ }
+
+#ifdef VAD2
+ if (st->dtx) {
+ st->vadSt->Rmax = 0.0;
+ st->vadSt->R0 = 0.0;
+ }
+#endif
+
+ for ( subfrNr = 0, i_subfr = 0; subfrNr < 2; subfrNr++, i_subfr +=
+ L_FRAME_BY2 ) {
+ /*
+ * Pre-processing on 80 samples
+ * Find the weighted input speech for the whole speech frame
+ */
+ pre_big( mode, gamma1, gamma1_12k2, gamma2, A_t, i_subfr, st->speech, st->
+ mem_w, st->wsp );
+
+ /* Find open loop pitch lag for two subframes */
+ if ( ( mode != MR475 ) && ( mode != MR515 ) ) {
+ ol_ltp( mode, st->vadSt, &st->wsp[i_subfr], &T_op[subfrNr], st->
+ ol_gain_flg, &st->pitchOLWghtSt->old_T0_med, &st->pitchOLWghtSt->
+ wght_flg, &st->pitchOLWghtSt->ada_w, st->old_lags, st->dtx,
+ subfrNr );
+ }
+ }
+
+ if ( ( mode == MR475 ) || ( mode == MR515 ) ) {
+ /*
+ * Find open loop pitch lag for ONE FRAME ONLY
+ * search on 160 samples
+ */
+ ol_ltp( mode, st->vadSt, &st->wsp[0], &T_op[0], st->ol_gain_flg, &st->
+ pitchOLWghtSt->old_T0_med, &st->pitchOLWghtSt->wght_flg, &st->
+ pitchOLWghtSt->ada_w, st->old_lags, st->dtx, 1 );
+ T_op[1] = T_op[0];
+ }
+
+#ifdef VAD2
+ if (st->dtx) {
+ LTP_flag_update(st->vadSt, mode);
+ }
+#endif
+
+#ifndef VAD2
+ if ( st->dtx ) {
+ vad_pitch_detection( st->vadSt, T_op );
+ }
+#endif
+
+ if ( *used_mode == MRDTX ) {
+ goto the_end;
+ }
+
+ /*
+ * Loop for every subframe in the analysis frame
+ *
+ * To find the pitch and innovation parameters. The subframe size is
+ * L_SUBFR and the loop is repeated L_FRAME/L_SUBFR times.
+ * - find the weighted LPC coefficients
+ * - find the LPC residual signal res[]
+ * - compute the target signal for pitch search
+ * - compute impulse response of weighted synthesis filter (h1[])
+ * - find the closed-loop pitch parameters
+ * - encode the pitch dealy
+ * - update the impulse response h1[] by including fixed-gain pitch
+ * - find target vector for codebook search
+ * - codebook search
+ * - encode codebook address
+ * - VQ of pitch and codebook gains
+ * - find synthesis speech
+ * - update states of weighting filter
+ */
+ /* pointer to interpolated LPC parameters */
+ A = A_t;
+
+ /* pointer to interpolated quantized LPC parameters */
+ Aq = Aq_t;
+ evenSubfr = 0;
+ subfrNr = -1;
+
+ for ( i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR ) {
+ subfrNr += 1;
+ evenSubfr = 1 - evenSubfr;
+
+ if ( ( evenSubfr != 0 ) && ( *used_mode == MR475 ) ) {
+ memcpy( mem_syn_save, st->mem_syn, M <<2 );
+ memcpy( mem_w0_save, st->mem_w0, M <<2 );
+ memcpy( mem_err_save, st->mem_err, M <<2 );
+ sharp_save = st->sharp;
+ }
+
+ /* Preprocessing of subframe */
+ if ( *used_mode != MR475 ) {
+ subframePreProc( *used_mode, gamma1, gamma1_12k2, gamma2, A, Aq, &st->
+ speech[i_subfr], st->mem_err, st->mem_w0, st->zero, st->ai_zero,
+ &st->exc[i_subfr], st->h1, xn, res, st->error );
+ }
+
+ /* MR475 */
+ else {
+ subframePreProc( *used_mode, gamma1, gamma1_12k2, gamma2, A, Aq, &st->
+ speech[i_subfr], st->mem_err, mem_w0_save, st->zero, st->ai_zero,
+ &st->exc[i_subfr], st->h1, xn, res, st->error );
+
+ if ( evenSubfr != 0 ) {
+ memcpy( h1_sf0, st->h1, L_SUBFR <<2 );
+ }
+ }
+
+ /* copy the LP residual (res2 is modified in the CL LTP search) */
+ memcpy( res2, res, L_SUBFR <<2 );
+
+ /* Closed-loop LTP search */
+ cl_ltp( &st->clLtpSt->pitchSt->T0_prev_subframe, st->tonStabSt->gp, *
+ used_mode, i_subfr, T_op, st->h1, &st->exc[i_subfr], res2, xn,
+ lsp_flag, xn2, y1, &T0, &T0_frac, &gain_pit, gCoeff, &ana, &gp_limit
+ );
+
+ /* update LTP lag history */
+ if ( ( subfrNr == 0 ) && ( st->ol_gain_flg[0] > 0 ) ) {
+ st->old_lags[1] = T0;
+ }
+
+ if ( ( subfrNr == 3 ) && ( st->ol_gain_flg[1] > 0 ) ) {
+ st->old_lags[0] = T0;
+ }
+
+ /* Innovative codebook search (find index and gain) */
+ cbsearch( *used_mode, subfrNr, xn2, st->h1, T0, st->sharp, gain_pit, code,
+ y2, res2, &ana );
+
+ /* Quantization of gains. */
+ gainQuant( *used_mode, evenSubfr, st->gainQuantSt->gc_predSt->past_qua_en,
+ st->gainQuantSt->gc_predUncSt->past_qua_en, st->gainQuantSt->
+ sf0_coeff, &st->gainQuantSt->sf0_target_en, &st->gainQuantSt->
+ sf0_gcode0_exp, &st->gainQuantSt->
+ sf0_gcode0_fra, &st->gainQuantSt->gain_idx_ptr, &gain_pit_sf0, &
+ gain_code_sf0, res, &st->exc[i_subfr], code, xn, xn2, y1, y2, gCoeff
+ , gp_limit, &gain_pit, &gain_code, &st->gainQuantSt->adaptSt->
+ prev_gc, &st->gainQuantSt->adaptSt->onset, st->gainQuantSt->adaptSt
+ ->ltpg_mem, &st->gainQuantSt->adaptSt->prev_alpha, &ana );
+
+ /* update gain history */
+ for ( i = 0; i < N_FRAME - 1; i++ ) {
+ st->tonStabSt->gp[i] = st->tonStabSt->gp[i + 1];
+ }
+ st->tonStabSt->gp[N_FRAME - 1] = gain_pit;
+
+ /* Subframe Post Processing */
+ if ( *used_mode != MR475 ) {
+ subframePostProc( st->speech, i_subfr, gain_pit, gain_code, Aq, synth,
+ xn, code, y1, y2, st->mem_syn, st->mem_err, st->mem_w0, st->exc,
+ &st->sharp );
+ }
+ else {
+ if ( evenSubfr != 0 ) {
+ i_subfr_sf0 = i_subfr;
+ memcpy( xn_sf0, xn, L_SUBFR <<2 );
+ memcpy( y2_sf0, y2, L_SUBFR <<2 );
+ memcpy( code_sf0, code, L_SUBFR <<2 );
+ T0_sf0 = T0;
+ T0_frac_sf0 = T0_frac;
+
+ /* Subframe Post Porcessing */
+ subframePostProc( st->speech, i_subfr, gain_pit, gain_code, Aq,
+ synth, xn, code, y1, y2, mem_syn_save, st->mem_err,
+ mem_w0_save, st->exc, &st->sharp );
+ st->sharp = sharp_save;
+ }
+ else {
+ /*
+ * update both subframes for the MR475
+ * Restore states for the MR475 mode
+ */
+ memcpy( st->mem_err, mem_err_save, M <<2 );
+
+ /* re-build excitation for sf 0 */
+ Pred_lt_3or6( &st->exc[i_subfr_sf0], T0_sf0, T0_frac_sf0, 1 );
+ Convolve( &st->exc[i_subfr_sf0], h1_sf0, y1 );
+ Aq -= MP1;
+ subframePostProc( st->speech, i_subfr_sf0, gain_pit_sf0,
+ gain_code_sf0, Aq, synth, xn_sf0, code_sf0, y1, y2_sf0, st->
+ mem_syn, st->mem_err, st->mem_w0, st->exc, &sharp_save );
+
+ /* overwrites sharp_save */
+ Aq += MP1;
+
+ /*
+ * re-run pre-processing to get xn right (needed by postproc)
+ * (this also reconstructs the unsharpened h1 for sf 1)
+ */
+ subframePreProc( *used_mode, gamma1, gamma1_12k2, gamma2, A, Aq, &st
+ ->speech[i_subfr], st->mem_err, st->mem_w0, st->zero, st->
+ ai_zero, &st->exc[i_subfr], st->h1, xn, res, st->error );
+
+ /* re-build excitation sf 1 (changed if lag < L_SUBFR) */
+ Pred_lt_3or6( &st->exc[i_subfr], T0, T0_frac, 1 );
+ Convolve( &st->exc[i_subfr], st->h1, y1 );
+ subframePostProc( st->speech, i_subfr, gain_pit, gain_code, Aq,
+ synth, xn, code, y1, y2, st->mem_syn, st->mem_err, st->mem_w0,
+ st->exc, &st->sharp );
+ }
+ }
+
+ /* interpolated LPC parameters for next subframe */
+ A += MP1;
+ Aq += MP1;
+ }
+the_end:
+
+ /* Update signal for next frame. */
+ for ( i = 0; i < PIT_MAX; i++ ) {
+ st->old_wsp[i] = st->old_wsp[L_FRAME + i];
+ }
+
+ for ( i = 0; i < PIT_MAX + L_INTERPOL; i++ ) {
+ st->old_exc[i] = st->old_exc[L_FRAME + i];
+ }
+
+ for ( i = 0; i < L_TOTAL - L_FRAME; i++ ) {
+ st->old_speech[i] = st->old_speech[L_FRAME + i];
+ }
+}
+
+
+/*
+ * Pre_Process_reset
+ *
+ *
+ * Parameters:
+ * state O: state structure
+ *
+ * Function:
+ * Initializes state memory to zero
+ *
+ * Returns:
+ *
+ */
+static Word32 Pre_Process_reset( Pre_ProcessState *state )
+{
+ if ( state == ( Pre_ProcessState * )NULL ) {
+ fprintf( stderr, "Pre_Process_reset: invalid parameter\n" );
+ return-1;
+ }
+ state->y2 = 0;
+ state->y1 = 0;
+ state->x0 = 0;
+ state->x1 = 0;
+ return 0;
+}
+
+
+/*
+ * Pre_Process_exit
+ *
+ *
+ * Parameters:
+ * state I: state structure
+ *
+ * Function:
+ * The memory used for state memory is freed
+ *
+ * Returns:
+ * Void
+ */
+static void Pre_Process_exit( Pre_ProcessState **state )
+{
+ if ( state == NULL || *state == NULL )
+ return;
+
+ /* deallocate memory */
+ free( *state );
+ *state = NULL;
+ return;
+}
+
+
+/*
+ * Pre_Process_init
+ *
+ *
+ * Parameters:
+ * state O: state structure
+ *
+ * Function:
+ * Allocates state memory and initializes state memory
+ *
+ * Returns:
+ * succeed = 0
+ */
+static Word32 Pre_Process_init( Pre_ProcessState **state )
+{
+ Pre_ProcessState * s;
+
+ if ( state == ( Pre_ProcessState * * )NULL ) {
+ fprintf( stderr, "Pre_Process_init: invalid parameter\n" );
+ return-1;
+ }
+ *state = NULL;
+
+ /* allocate memory */
+ if ( ( s = ( Pre_ProcessState * ) malloc( sizeof( Pre_ProcessState ) ) ) ==
+ NULL ) {
+ fprintf( stderr, "Pre_Process_init: can not malloc state structure\n" );
+ return-1;
+ }
+ Pre_Process_reset( s );
+ *state = s;
+ return 0;
+}
+
+
+/*
+ * Pre_Process
+ *
+ *
+ * Parameters:
+ * y2, y1, x0, x1 B: filter memory
+ * speech I: speech vector to be processed
+ * fspeech O: processed vector
+ * size I: size of the vector
+ *
+ * Function:
+ * Pre-processing
+ *
+ * Two pre-processing functions are applied prior to
+ * the encoding process: high-pass filtering and signal down-scaling.
+ * Down-scaling consists of dividing the input by a factor of 2
+ * to reduce the possibility of overflows in the fixed-point
+ * implementation. The high-pass filter serves as a precaution
+ * against undesired low frequency components. A filter with
+ * a cut off frequency of 80 Hz is used, and it is given by:
+ *
+ * 0.927246093 - 1.8544941z^-1 + 0.927246903z^-2
+ * H(z) = -----------------------------------------------
+ * 1 - 1.906005859z^-1 + 0.911376953z^-2
+ *
+ * Down-scaling and high-pass filtering are combined by dividing
+ * the coefficients at the numerator by 2.
+ *
+ * Returns:
+ * void
+ */
+static void Pre_Process( Float32 *y2, Float32 *y1, Float32 *x0, Float32
+ *x1, Word16 *speech, Float32 *f_speech )
+{
+ Word32 i;
+ Float32 x2;
+ Float32 tmp;
+
+
+ for ( i = 0; i < 160; i++ ) {
+ x2 = *x1;
+ *x1 = *x0;
+ *x0 = speech[i];
+ tmp = ( Float32 )( 0.4636230465* *x0 - 0.92724705 * *x1 + 0.4636234515 *
+ x2 + 1.906005859 * *y1 - 0.911376953 * *y2 );
+ f_speech[i] = tmp;
+ *y2 = *y1;
+ *y1 = tmp;
+ }
+
+ if ( ( fabs( *y1 )+fabs( *y2 ) ) < 0.0000000001 )
+ *y2 = *y1 = 0;
+}
+
+
+/*
+ * cod_amr_reset
+ *
+ *
+ * Parameters:
+ * s B: state structure
+ * dtx I: dtx on/off
+ *
+ * Function:
+ * Resets state memory
+ *
+ * Returns:
+ * void
+ */
+static void cod_amr_reset( cod_amrState *s, Word32 dtx )
+{
+ Word32 i;
+
+
+ /* reset DTX */
+ s->dtx = dtx;
+
+ /* reset Pitch_frState */
+ s->clLtpSt->pitchSt->T0_prev_subframe = 0;
+
+ /* reset Q_plsfState */
+ memset( s->lspSt->qSt->past_rq, 0, sizeof( Float32 )*M );
+ memcpy( s->lspSt->lsp_old, lsp_init_data, sizeof( lsp_init_data ) );
+ memcpy( s->lspSt->lsp_old_q, lsp_init_data, sizeof( lsp_init_data ) );
+
+ /* reset gc_predState */
+ for ( i = 0; i < NPRED; i++ ) {
+ s->gainQuantSt->gc_predSt->past_qua_en[i] = NB_QUA_CODE+VQ_SIZE_HIGHRATES+VQ_SIZE_LOWRATES+MR475_VQ_SIZE*2+DTX_VQ_SIZE;
+ s->gainQuantSt->gc_predUncSt->past_qua_en[i] = NB_QUA_CODE+VQ_SIZE_HIGHRATES+VQ_SIZE_LOWRATES+MR475_VQ_SIZE*2+DTX_VQ_SIZE;
+ }
+
+ /* reset gain_adaptState */
+ s->gainQuantSt->adaptSt->onset = 0;
+ s->gainQuantSt->adaptSt->prev_alpha = 0.0F;
+ s->gainQuantSt->adaptSt->prev_gc = 0.0F;
+ memset( s->gainQuantSt->adaptSt->ltpg_mem, 0, sizeof( Float32 )*LTPG_MEM_SIZE
+ );
+ s->gainQuantSt->sf0_gcode0_exp = 0;
+ s->gainQuantSt->sf0_gcode0_fra = 0;
+ s->gainQuantSt->sf0_target_en = 0.0F;
+ memset( s->gainQuantSt->sf0_coeff, 0, sizeof( Float32 )*5 );
+ s->gainQuantSt->gain_idx_ptr = NULL;
+
+ /* reset pitchOLWghtState */
+ s->pitchOLWghtSt->old_T0_med = 40;
+ s->pitchOLWghtSt->ada_w = 0.0F;
+ s->pitchOLWghtSt->wght_flg = 0;
+
+ /* reset tonStabState */
+ s->tonStabSt->count = 0;
+ memset( s->tonStabSt->gp, 0, sizeof( Float32 )*N_FRAME );
+
+ /* reset LevinsonState */
+ s->lpcSt->LevinsonSt->old_A[0] = 1.0F;
+ memset( &s->lpcSt->LevinsonSt->old_A[1], 0, sizeof( Float32 )*M );
+
+#ifdef VAD2
+ /* reset vadState */
+ s->vadSt->pre_emp_mem = 0.0;
+ s->vadSt->update_cnt = 0;
+ s->vadSt->hyster_cnt = 0;
+ s->vadSt->last_update_cnt = 0;
+ for ( i = 0; i < NUM_CHAN; i++ ) {
+ s->vadSt->ch_enrg_long_db[i] = 0.0;
+ s->vadSt->ch_enrg[i] = 0.0;
+ s->vadSt->ch_noise[i] = 0.0;
+ }
+ s->vadSt->Lframe_cnt = 0L;
+ s->vadSt->tsnr = 0.0;
+ s->vadSt->hangover = 0;
+ s->vadSt->burstcount = 0;
+ s->vadSt->fupdate_flag = 0;
+ s->vadSt->negSNRvar = 0.0;
+ s->vadSt->negSNRbias = 0.0;
+ s->vadSt->R0 = 0.0;
+ s->vadSt->Rmax = 0.0;
+ s->vadSt->LTP_flag = 0;
+#else
+ /* reset vadState */
+ s->vadSt->oldlag_count = 0;
+ s->vadSt->oldlag = 0;
+ s->vadSt->pitch = 0;
+ s->vadSt->tone = 0;
+ s->vadSt->complex_high = 0;
+ s->vadSt->complex_low = 0;
+ s->vadSt->complex_hang_timer = 0;
+ s->vadSt->vadreg = 0;
+ s->vadSt->burst_count = 0;
+ s->vadSt->hang_count = 0;
+ s->vadSt->complex_hang_count = 0;
+
+ /* initialize memory used by the filter bank */
+ for ( i = 0; i < 3; i++ ) {
+ s->vadSt->a_data5[i][0] = 0;
+ s->vadSt->a_data5[i][1] = 0;
+ }
+
+ for ( i = 0; i < 5; i++ ) {
+ s->vadSt->a_data3[i] = 0;
+ }
+
+ /* reset dtx_encState */
+ /* initialize the rest of the memory */
+ for ( i = 0; i < COMPLEN; i++ ) {
+ s->vadSt->bckr_est[i] = NOISE_INIT;
+ s->vadSt->old_level[i] = NOISE_INIT;
+ s->vadSt->ave_level[i] = NOISE_INIT;
+ s->vadSt->sub_level[i] = 0;
+ }
+ s->vadSt->best_corr_hp = CVAD_LOWPOW_RESET;
+ s->vadSt->speech_vad_decision = 0;
+ s->vadSt->complex_warning = 0;
+ s->vadSt->sp_burst_count = 0;
+ s->vadSt->corr_hp_fast = CVAD_LOWPOW_RESET;
+#endif
+
+ s->dtxEncSt->hist_ptr = 0;
+ s->dtxEncSt->log_en_index = 0;
+ s->dtxEncSt->init_lsf_vq_index = 0;
+ s->dtxEncSt->lsp_index[0] = 0;
+ s->dtxEncSt->lsp_index[1] = 0;
+ s->dtxEncSt->lsp_index[2] = 0;
+
+ for ( i = 0; i < DTX_HIST_SIZE; i++ ) {
+ memcpy( &s->dtxEncSt->lsp_hist[i * M], lsp_init_data, sizeof( Float32 )*M
+ );
+ }
+ memset( s->dtxEncSt->log_en_hist, 0, M * sizeof( Float32 ) );
+ s->dtxEncSt->dtxHangoverCount = DTX_HANG_CONST;
+ s->dtxEncSt->decAnaElapsedCount = DTX_ELAPSED_FRAMES_THRESH;
+
+ /* init speech pointers */
+ /* New speech */
+ s->new_speech = s->old_speech + L_TOTAL - L_FRAME;
+
+ /* Present frame */
+ s->speech = s->new_speech - L_NEXT;
+ s->p_window = s->old_speech + L_TOTAL - L_WINDOW;
+
+ /* For LPC window */
+ s->p_window_12k2 = s->p_window - L_NEXT;
+
+ /* Initialize static pointers */
+ s->wsp = s->old_wsp + PIT_MAX;
+ s->exc = s->old_exc + PIT_MAX + L_INTERPOL;
+ s->zero = s->ai_zero + MP1;
+ s->error = s->mem_err + M;
+ s->h1 = &s->hvec[L_SUBFR];
+
+ /* Static vectors to zero */
+ memset( s->old_speech, 0, sizeof( Float32 )*L_TOTAL );
+ memset( s->old_exc, 0, sizeof( Float32 )*( PIT_MAX + L_INTERPOL ) );
+ memset( s->old_wsp, 0, sizeof( Float32 )*PIT_MAX );
+ memset( s->mem_syn, 0, sizeof( Float32 )*M );
+ memset( s->mem_w, 0, sizeof( Float32 )*M );
+ memset( s->mem_w0, 0, sizeof( Float32 )*M );
+ memset( s->mem_err, 0, sizeof( Float32 )*M );
+ memset( s->ai_zero, 0, sizeof( Float32 )*L_SUBFR );
+ memset( s->hvec, 0, sizeof( Float32 )*L_SUBFR );
+
+ for ( i = 0; i < 5; i++ ) {
+ s->old_lags[i] = 40;
+ }
+ s->sharp = 0.0F;
+}
+
+
+/*
+ * cod_amr_init
+ *
+ *
+ * Parameters:
+ * state O: state structure
+ * dtx I: dtx mode used
+ *
+ * Function:
+ * Allocates state memory and initializes state memory
+ *
+ * Returns:
+ * succeed = 0
+ */
+static Word32 cod_amr_init( cod_amrState **state, Word32 dtx )
+{
+ cod_amrState * s;
+
+ if ( ( s = ( cod_amrState * ) malloc( sizeof( cod_amrState ) ) ) == NULL ) {
+ fprintf( stderr, "can not malloc state structure\n" );
+ return-1;
+ }
+
+ /* init clLtpState */
+ if ( ( s->clLtpSt = ( clLtpState * ) malloc( sizeof( clLtpState ) ) ) == NULL
+ ) {
+ fprintf( stderr, "can not malloc state structure\n" );
+ return-1;
+ }
+
+ /* init Pitch_frState */
+ if ( ( s->clLtpSt->pitchSt = ( Pitch_frState * ) malloc( sizeof(
+ Pitch_frState ) ) ) == NULL ) {
+ fprintf( stderr, "can not malloc state structure\n" );
+ return-1;
+ }
+
+ /* init lspState */
+ if ( ( s->lspSt = ( lspState * ) malloc( sizeof( lspState ) ) ) == NULL ) {
+ fprintf( stderr, "can not malloc state structure\n" );
+ return-1;
+ }
+
+ /* init Q_plsfState */
+ if ( ( s->lspSt->qSt = ( Q_plsfState * ) malloc( sizeof( Q_plsfState ) ) ) ==
+ NULL ) {
+ fprintf( stderr, "can not malloc state structure\n" );
+ return-1;
+ }
+
+ /* init gainQuantState */
+ if ( ( s->gainQuantSt = ( gainQuantState * ) malloc( sizeof( gainQuantState )
+ ) ) == NULL ) {
+ fprintf( stderr, "can not malloc state structure\n" );
+ return-1;
+ }
+
+ /* init gc_predState x2 */
+ if ( ( s->gainQuantSt->gc_predSt = ( gc_predState * ) malloc( sizeof(
+ gc_predState ) ) ) == NULL ) {
+ fprintf( stderr, "can not malloc state structure\n" );
+ return-1;
+ }
+
+ if ( ( s->gainQuantSt->gc_predUncSt = ( gc_predState * ) malloc( sizeof(
+ gc_predState ) ) ) == NULL ) {
+ fprintf( stderr, "can not malloc state structure\n" );
+ return-1;
+ }
+
+ /* init gain_adaptState */
+ if ( ( s->gainQuantSt->adaptSt = ( gain_adaptState * ) malloc( sizeof(
+ gain_adaptState ) ) ) == NULL ) {
+ fprintf( stderr, "can not malloc state structure\n" );
+ return-1;
+ }
+
+ /* init pitchOLWghtState */
+ if ( ( s->pitchOLWghtSt = ( pitchOLWghtState * ) malloc( sizeof(
+ pitchOLWghtState ) ) ) == NULL ) {
+ fprintf( stderr, "can not malloc state structure\n" );
+ return-1;
+ }
+
+ /* init tonStabState */
+ if ( ( s->tonStabSt = ( tonStabState * ) malloc( sizeof( tonStabState ) ) )
+ == NULL ) {
+ fprintf( stderr, "can not malloc state structure\n" );
+ return-1;
+ }
+
+ /* init lpcState */
+ if ( ( s->lpcSt = ( lpcState * ) malloc( sizeof( lpcState ) ) ) == NULL ) {
+ fprintf( stderr, "can not malloc state structure\n" );
+ return-1;
+ }
+
+ /* init LevinsonState */
+ if ( ( s->lpcSt->LevinsonSt = ( LevinsonState * ) malloc( sizeof(
+ LevinsonState ) ) ) == NULL ) {
+ fprintf( stderr, "can not malloc state structure\n" );
+ return-1;
+ }
+
+ if ( ( s->vadSt = ( vadState * ) malloc( sizeof( vadState ) ) ) == NULL ) {
+ fprintf( stderr, "can not malloc state structure\n" );
+ return-1;
+ }
+
+ /* Init dtx_encState */
+ if ( ( s->dtxEncSt = ( dtx_encState * ) malloc( sizeof( dtx_encState ) ) ) ==
+ NULL ) {
+ fprintf( stderr, "can not malloc state structure\n" );
+ return-1;
+ }
+ cod_amr_reset( s, dtx );
+ *state = s;
+ return 0;
+}
+
+
+/*
+ * cod_amr_exit
+ *
+ *
+ * Parameters:
+ * state I: state structure
+ *
+ * Function:
+ * The memory used for state memory is freed
+ *
+ * Returns:
+ * Void
+ */
+static void cod_amr_exit( cod_amrState **state )
+{
+ if ( state == NULL || *state == NULL )
+ return;
+
+ /* deallocate memory */
+ free( ( *state )->vadSt );
+ free( ( *state )->gainQuantSt->gc_predSt );
+ free( ( *state )->gainQuantSt->gc_predUncSt );
+ free( ( *state )->gainQuantSt->adaptSt );
+ free( ( *state )->clLtpSt->pitchSt );
+ free( ( *state )->lspSt->qSt );
+ free( ( *state )->lpcSt->LevinsonSt );
+ free( ( *state )->lpcSt );
+ free( ( *state )->lspSt );
+ free( ( *state )->clLtpSt );
+ free( ( *state )->gainQuantSt );
+ free( ( *state )->pitchOLWghtSt );
+ free( ( *state )->tonStabSt );
+ free( ( *state )->dtxEncSt );
+ free( *state );
+ *state = NULL;
+ return;
+}
+
+
+/*
+ * Speech_Encode_Frame_init
+ *
+ *
+ * Parameters:
+ * state O: state structure
+ * dtx I: dtx mode used
+ *
+ * Function:
+ * Allocates state memory and initializes state memory
+ *
+ * Returns:
+ * succeed = 0
+ */
+void * Speech_Encode_Frame_init( int dtx )
+{
+ Speech_Encode_FrameState * s;
+
+ /* allocate memory */
+ if ( ( s = ( Speech_Encode_FrameState * ) malloc( sizeof(
+ Speech_Encode_FrameState ) ) ) == NULL ) {
+ fprintf( stderr, "Speech_Encode_Frame_init: can not malloc state "
+ "structure\n" );
+ return NULL;
+ }
+ s->pre_state = NULL;
+ s->cod_amr_state = NULL;
+ s->dtx = dtx;
+
+ if ( Pre_Process_init( &s->pre_state ) || cod_amr_init( &s->cod_amr_state,
+ dtx ) ) {
+ Speech_Encode_Frame_exit( ( void ** )( &s ) );
+ return NULL;
+ }
+ return s;
+}
+
+
+/*
+ * Speech_Encode_Frame_reset
+ *
+ *
+ * Parameters:
+ * state O: state structure
+ *
+ * Function:
+ * Resets state memory
+ *
+ * Returns:
+ *
+ */
+int Speech_Encode_Frame_reset( void *st, int dtx )
+{
+ Speech_Encode_FrameState * state;
+ state = ( Speech_Encode_FrameState * )st;
+
+ if ( ( Speech_Encode_FrameState * )state == NULL ) {
+ fprintf( stderr, "Speech_Encode_Frame_reset: invalid parameter\n" );
+ return-1;
+ }
+ Pre_Process_reset( state->pre_state );
+ cod_amr_reset( state->cod_amr_state, dtx );
+ return 0;
+}
+
+
+/*
+ * Speech_Encode_Frame_exit
+ *
+ *
+ * Parameters:
+ * state I: state structure
+ *
+ * Function:
+ * The memory used for state memory is freed
+ *
+ * Returns:
+ * Void
+ */
+void Speech_Encode_Frame_exit( void **st )
+{
+ if ( ( Speech_Encode_FrameState * )( *st ) == NULL )
+ return;
+ Pre_Process_exit( &( ( ( Speech_Encode_FrameState * )( *st ) )->pre_state ) )
+ ;
+ cod_amr_exit( &( ( ( Speech_Encode_FrameState * )( *st ) )->cod_amr_state ) )
+ ;
+
+ /* deallocate memory */
+ free( *st );
+ *st = NULL;
+ return;
+}
+
+
+/*
+ * Speech_Encode_Frame
+ *
+ *
+ * Parameters:
+ * st B: state structure
+ * mode I: speech coder mode
+ * new_speech I: speech input, size L_FRAME
+ * prm O: Analysis parameters
+ * used_mode B: force VAD/used_mode
+ * Function:
+ * Encode one frame
+ *
+ * Returns:
+ * Void
+ */
+void Speech_Encode_Frame( void *st, enum Mode mode, Word16 *new_speech, Word16 *
+ prm, enum Mode *used_mode )
+{
+ Float32 syn[L_FRAME]; /* Buffer for synthesis speech */
+ Float32 speech[160];
+ Word32 i;
+
+
+ Speech_Encode_FrameState * state;
+ state = ( Speech_Encode_FrameState * )st;
+
+ for ( i = 0; i < 160; i++ ) {
+ new_speech[i] = ( Word16 )( new_speech[i] & 0xfff8 );
+ }
+
+ /* filter + downscaling */
+ Pre_Process( &state->pre_state->y2, &state->pre_state->y1, &state->pre_state
+ ->x0, &state->pre_state->x1, new_speech, speech );
+
+ /* Call the speech encoder */
+ cod_amr( state->cod_amr_state, mode, speech, prm, used_mode, syn );
+
+}
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/sp_enc.h b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/sp_enc.h
new file mode 100644
index 000000000..25f9e6480
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/sp_enc.h
@@ -0,0 +1,74 @@
+/*
+ * ===================================================================
+ * TS 26.104
+ * REL-5 V5.4.0 2004-03
+ * REL-6 V6.1.0 2004-03
+ * 3GPP AMR Floating-point Speech Codec
+ * ===================================================================
+ *
+ */
+
+/*
+ * sp_enc.h
+ *
+ *
+ * Project:
+ * AMR Floating-Point Codec
+ *
+ * Contains:
+ * Defines interface to AMR encoder
+ *
+ */
+#ifndef _SP_ENC_H
+#define _SP_ENC_H
+
+/*
+ * include files
+ */
+#include "typedef.h"
+
+/*
+ * definition of modes for encoder
+ */
+enum Mode { MR475 = 0,
+ MR515,
+ MR59,
+ MR67,
+ MR74,
+ MR795,
+ MR102,
+ MR122,
+ MRDTX
+};
+
+/*
+ * Function prototypes
+ */
+
+/*
+ * initialize one instance of the speech encoder
+ * Stores pointer to filter status struct in *st. This pointer has to
+ * be passed to Speech_Encode_Frame in each call.
+ * returns 0 on success
+ */
+void *Speech_Encode_Frame_init (int dtx);
+/*
+ * reset speech encoder (i.e. set state memory to zero)
+ * returns 0 on success
+ */
+int Speech_Encode_Frame_reset(void *st, int dtx);
+
+/*
+ * de-initialize speech encoder (i.e. free status struct)
+ * stores NULL in *st
+ */
+void Speech_Encode_Frame_exit (void **st);
+
+/*
+ * Encodes one speech frame
+ * Returns analysis parameters
+ */
+void Speech_Encode_Frame (void *st, enum Mode mode, short *newSpeech,
+ short *prm, enum Mode *usedMode);
+
+#endif
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/typedef.h b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/typedef.h
new file mode 100644
index 000000000..b25d92baf
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrnb/typedef.h
@@ -0,0 +1,22 @@
+/*
+ * ===================================================================
+ * TS 26.104
+ * REL-5 V5.4.0 2004-03
+ * REL-6 V6.1.0 2004-03
+ * 3GPP AMR Floating-point Speech Codec
+ * ===================================================================
+ *
+ */
+/* This is valid for PC */
+
+#ifndef _TYPEDEF_H
+#define _TYPEDEF_H
+
+typedef char Word8;
+typedef unsigned char UWord8;
+typedef short Word16;
+typedef long Word32;
+typedef float Float32;
+typedef double Float64;
+
+#endif
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec.h b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec.h
new file mode 100644
index 000000000..ca4bd2a8d
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec.h
@@ -0,0 +1,18 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef DEC_H
+#define DEC_H
+
+#include "typedef.h"
+
+void D_MAIN_reset(void *st, Word16 reset_all);
+Word32 D_MAIN_init(void **spd_state);
+void D_MAIN_close(void **spd_state);
+Word32 D_MAIN_decode(Word16 mode, Word16 prms[], Word16 synth16k[],
+ void *spd_state, UWord8 frame_type);
+
+#endif
+
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_acelp.c b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_acelp.c
new file mode 100644
index 000000000..cabc3c099
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_acelp.c
@@ -0,0 +1,692 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#include <memory.h>
+#include "typedef.h"
+#include "dec_util.h"
+
+#define L_SUBFR 64 /* Subframe size */
+#define PRED_ORDER 4
+#define MEAN_ENER 30 /* average innovation energy */
+extern const Word16 D_ROM_ph_imp_low[];
+extern const Word16 D_ROM_ph_imp_mid[];
+
+
+/*
+ * D_ACELP_add_pulse
+ *
+ * Parameters:
+ * pos I: position of pulse
+ * nb_pulse I: number of pulses
+ * track I: track
+ * code O: fixed codebook
+ *
+ * Function:
+ * Add pulses to fixed codebook
+ *
+ * Returns:
+ * void
+ */
+static void D_ACELP_add_pulse(Word32 pos[], Word32 nb_pulse,
+ Word32 track, Word16 code[])
+{
+ Word32 i, k;
+
+ for(k = 0; k < nb_pulse; k++)
+ {
+ /* i = ((pos[k] & (16-1))*NB_TRACK) + track; */
+ i = ((pos[k] & (16 - 1)) << 2) + track;
+
+ if((pos[k] & 16) == 0)
+ {
+ code[i] = (Word16)(code[i] + 512);
+ }
+ else
+ {
+ code[i] = (Word16)(code[i] - 512);
+ }
+ }
+
+ return;
+}
+
+
+/*
+ * D_ACELP_decode_1p_N1
+ *
+ * Parameters:
+ * index I: pulse index
+ * N I: number of bits for position
+ * offset I: offset
+ * pos O: position of the pulse
+
+ *
+ * Function:
+ * Decode 1 pulse with N+1 bits
+ *
+ * Returns:
+ * void
+ */
+static void D_ACELP_decode_1p_N1(Word32 index, Word32 N,
+ Word32 offset, Word32 pos[])
+{
+ Word32 i, pos1, mask;
+
+ mask = ((1 << N) - 1);
+
+ /*
+ * Decode 1 pulse with N+1 bits
+ */
+ pos1 = ((index & mask) + offset);
+ i = ((index >> N) & 1);
+
+ if(i == 1)
+ {
+ pos1 += 16;
+ }
+
+ pos[0] = pos1;
+
+ return;
+}
+
+
+/*
+ * D_ACELP_decode_2p_2N1
+ *
+ * Parameters:
+ * index I: pulse index
+ * N I: number of bits for position
+ * offset I: offset
+ * pos O: position of the pulse
+ *
+ * Function:
+ * Decode 2 pulses with 2*N+1 bits
+ *
+ * Returns:
+ * void
+ */
+static void D_ACELP_decode_2p_2N1(Word32 index, Word32 N,
+ Word32 offset, Word32 pos[])
+{
+ Word32 i, pos1, pos2;
+ Word32 mask;
+
+ mask = ((1 << N) - 1);
+
+ /*
+ * Decode 2 pulses with 2*N+1 bits
+ */
+ pos1 = (((index >> N) & mask) + offset);
+ i = (index >> (2 * N)) & 1;
+ pos2 = ((index & mask) + offset);
+
+ if((pos2 - pos1) < 0)
+ {
+ if(i == 1)
+ {
+ pos1 += 16;
+ }
+ else
+ {
+ pos2 += 16;
+ }
+ }
+ else
+ {
+ if(i == 1)
+ {
+ pos1 += 16;
+ pos2 += 16;
+ }
+ }
+
+ pos[0] = pos1;
+ pos[1] = pos2;
+
+ return;
+}
+
+
+/*
+ * D_ACELP_decode_3p_3N1
+ *
+ * Parameters:
+ * index I: pulse index
+ * N I: number of bits for position
+ * offset I: offset
+ * pos O: position of the pulse
+ *
+ * Function:
+ * Decode 3 pulses with 3*N+1 bits
+ *
+ * Returns:
+ * void
+ */
+static void D_ACELP_decode_3p_3N1(Word32 index, Word32 N,
+ Word32 offset, Word32 pos[])
+{
+ Word32 j, mask, idx;
+
+ /*
+ * Decode 3 pulses with 3*N+1 bits
+ */
+ mask = ((1 << ((2 * N) - 1)) - 1);
+ idx = index & mask;
+ j = offset;
+
+ if(((index >> ((2 * N) - 1)) & 1) == 1)
+ {
+ j += (1 << (N - 1));
+ }
+
+ D_ACELP_decode_2p_2N1(idx, N - 1, j, pos);
+ mask = ((1 << (N + 1)) - 1);
+ idx = (index >> (2 * N)) & mask;
+ D_ACELP_decode_1p_N1(idx, N, offset, pos + 2);
+
+ return;
+}
+
+
+/*
+ * D_ACELP_decode_4p_4N1
+ *
+ * Parameters:
+ * index I: pulse index
+ * N I: number of bits for position
+ * offset I: offset
+ * pos O: position of the pulse
+ *
+ * Function:
+ * Decode 4 pulses with 4*N+1 bits
+ *
+ * Returns:
+ * void
+ */
+static void D_ACELP_decode_4p_4N1(Word32 index, Word32 N,
+ Word32 offset, Word32 pos[])
+{
+ Word32 j, mask, idx;
+
+ /*
+ * Decode 4 pulses with 4*N+1 bits
+ */
+ mask = ((1 << ((2 * N) - 1)) - 1);
+ idx = index & mask;
+ j = offset;
+
+ if(((index >> ((2 * N) - 1)) & 1) == 1)
+ {
+ j += (1 << (N - 1));
+ }
+
+ D_ACELP_decode_2p_2N1(idx, N - 1, j, pos);
+ mask = ((1 << ((2 * N) + 1)) - 1);
+ idx = (index >> (2 * N)) & mask;
+ D_ACELP_decode_2p_2N1(idx, N, offset, pos + 2);
+
+ return;
+}
+
+
+/*
+ * D_ACELP_decode_4p_4N
+ *
+ * Parameters:
+ * index I: pulse index
+ * N I: number of bits for position
+ * offset I: offset
+ * pos O: position of the pulse
+ *
+ * Function:
+ * Decode 4 pulses with 4*N bits
+ *
+ * Returns:
+ * void
+ */
+static void D_ACELP_decode_4p_4N(Word32 index, Word32 N,
+ Word32 offset, Word32 pos[])
+{
+ Word32 j, n_1;
+
+ /*
+ * Decode 4 pulses with 4*N bits
+ */
+ n_1 = N - 1;
+ j = offset + (1 << n_1);
+
+ switch((index >> ((4 * N) - 2)) & 3)
+ {
+ case 0:
+ if(((index >> ((4 * n_1) + 1)) & 1) == 0)
+ {
+ D_ACELP_decode_4p_4N1(index, n_1, offset, pos);
+ }
+ else
+ {
+ D_ACELP_decode_4p_4N1(index, n_1, j, pos);
+ }
+ break;
+
+ case 1:
+ D_ACELP_decode_1p_N1((index >> ((3 * n_1) + 1)), n_1, offset, pos);
+ D_ACELP_decode_3p_3N1(index, n_1, j, pos + 1);
+ break;
+
+ case 2:
+ D_ACELP_decode_2p_2N1((index >> ((2 * n_1) + 1)), n_1, offset, pos);
+ D_ACELP_decode_2p_2N1(index, n_1, j, pos + 2);
+ break;
+
+ case 3:
+ D_ACELP_decode_3p_3N1((index >> (n_1 + 1)), n_1, offset, pos);
+ D_ACELP_decode_1p_N1(index, n_1, j, pos + 3);
+ break;
+ }
+
+ return;
+}
+
+
+/*
+ * D_ACELP_decode_5p_5N
+ *
+ * Parameters:
+ * index I: pulse index
+ * N I: number of bits for position
+ * offset I: offset
+ * pos O: position of the pulse
+ *
+ * Function:
+ * Decode 5 pulses with 5*N bits
+ *
+ * Returns:
+ * void
+ */
+static void D_ACELP_decode_5p_5N(Word32 index, Word32 N,
+ Word32 offset, Word32 pos[])
+{
+ Word32 j, n_1;
+ Word32 idx;
+
+ /*
+ * Decode 5 pulses with 5*N bits
+ */
+ n_1 = N - 1;
+ j = offset + (1 << n_1);
+ idx = (index >> ((2 * N) + 1));
+
+ if(((index >> ((5 * N) - 1)) & 1) == 0)
+ {
+ D_ACELP_decode_3p_3N1(idx, n_1, offset, pos);
+ D_ACELP_decode_2p_2N1(index, N, offset, pos + 3);
+ }
+ else
+ {
+ D_ACELP_decode_3p_3N1(idx, n_1, j, pos);
+ D_ACELP_decode_2p_2N1(index, N, offset, pos + 3);
+ }
+
+ return;
+}
+
+
+/*
+ * D_ACELP_decode_6p_6N_2
+ *
+ * Parameters:
+ * index I: pulse index
+ * N I: number of bits for position
+ * offset I: offset
+ * pos O: position of the pulse
+ *
+ * Function:
+ * Decode 6 pulses with 6*N-2 bits
+ *
+ * Returns:
+ * void
+ */
+static void D_ACELP_decode_6p_6N_2(Word32 index, Word32 N,
+ Word32 offset, Word32 pos[])
+{
+ Word32 j, n_1, offsetA, offsetB;
+
+ n_1 = N - 1;
+ j = offset + (1 << n_1);
+ offsetA = offsetB = j;
+
+ if(((index >> ((6 * N) - 5)) & 1) == 0)
+ {
+ offsetA = offset;
+ }
+ else
+ {
+ offsetB = offset;
+ }
+
+ switch((index >> ((6 * N) - 4)) & 3)
+ {
+ case 0:
+ D_ACELP_decode_5p_5N(index >> N, n_1, offsetA, pos);
+ D_ACELP_decode_1p_N1(index, n_1, offsetA, pos + 5);
+ break;
+
+ case 1:
+ D_ACELP_decode_5p_5N(index >> N, n_1, offsetA, pos);
+ D_ACELP_decode_1p_N1(index, n_1, offsetB, pos + 5);
+ break;
+
+ case 2:
+ D_ACELP_decode_4p_4N(index >> ((2 * n_1) + 1), n_1, offsetA, pos);
+ D_ACELP_decode_2p_2N1(index, n_1, offsetB, pos + 4);
+ break;
+
+ case 3:
+ D_ACELP_decode_3p_3N1(index >> ((3 * n_1) + 1), n_1, offset, pos);
+ D_ACELP_decode_3p_3N1(index, n_1, j, pos + 3);
+ break;
+ }
+
+ return;
+}
+
+
+/*
+ * D_ACELP_decode_2t
+ *
+ * Parameters:
+ * index I: 12 bits index
+ * code O: (Q9) algebraic (fixed) codebook excitation
+ *
+ * Function:
+ * 12 bits algebraic codebook decoder.
+ * 2 tracks x 32 positions per track = 64 samples.
+ *
+ * 12 bits --> 2 pulses in a frame of 64 samples.
+ *
+ * All pulses can have two (2) possible amplitudes: +1 or -1.
+ * Each pulse can have 32 possible positions.
+ *
+ * codevector length 64
+ * number of track 2
+ * number of position 32
+ *
+ * Returns:
+ * void
+ */
+void D_ACELP_decode_2t(Word16 index, Word16 code[])
+{
+ Word32 i0, i1;
+
+ memset(code, 0, 64 * sizeof(Word16));
+
+ /* decode the positions and signs of pulses and build the codeword */
+ i0 = (index >> 5) & 0x0000003E;
+ i1 = ((index & 0x0000001F) << 1) + 1;
+
+ if(((index >> 6) & 32) == 0)
+ {
+ code[i0] = 512;
+ }
+ else
+ {
+ code[i0] = -512;
+ }
+
+ if((index & 32) == 0)
+ {
+ code[i1] = 512;
+ }
+ else
+ {
+ code[i1] = -512;
+ }
+
+ return;
+}
+
+
+/*
+ * D_ACELP_decode_4t
+ *
+ * Parameters:
+ * index I: index
+ * mode I: speech mode
+ * code I: (Q9) algebraic (fixed) codebook excitation
+ *
+ * Function:
+ * 20, 36, 44, 52, 64, 72, 88 bits algebraic codebook.
+ * 4 tracks x 16 positions per track = 64 samples.
+ *
+ * 20 bits 5+5+5+5 --> 4 pulses in a frame of 64 samples.
+ * 36 bits 9+9+9+9 --> 8 pulses in a frame of 64 samples.
+ * 44 bits 13+9+13+9 --> 10 pulses in a frame of 64 samples.
+ * 52 bits 13+13+13+13 --> 12 pulses in a frame of 64 samples.
+ * 64 bits 2+2+2+2+14+14+14+14 --> 16 pulses in a frame of 64 samples.
+ * 72 bits 10+2+10+2+10+14+10+14 --> 18 pulses in a frame of 64 samples.
+ * 88 bits 11+11+11+11+11+11+11+11 --> 24 pulses in a frame of 64 samples.
+ *
+ * All pulses can have two (2) possible amplitudes: +1 or -1.
+ * Each pulse can sixteen (16) possible positions.
+ *
+ * codevector length 64
+ * number of track 4
+ * number of position 16
+ *
+ * Returns:
+ * void
+ */
+void D_ACELP_decode_4t(Word16 index[], Word16 nbbits, Word16 code[])
+{
+ Word32 k, L_index, pos[6];
+
+ memset(code, 0, 64 * sizeof(Word16));
+
+ /* decode the positions and signs of pulses and build the codeword */
+ if(nbbits == 20)
+ {
+ for(k = 0; k < 4; k++)
+ {
+ L_index = index[k];
+ D_ACELP_decode_1p_N1(L_index, 4, 0, pos);
+ D_ACELP_add_pulse(pos, 1, k, code);
+ }
+ }
+ else if(nbbits == 36)
+ {
+ for(k = 0; k < 4; k++)
+ {
+ L_index = index[k];
+ D_ACELP_decode_2p_2N1(L_index, 4, 0, pos);
+ D_ACELP_add_pulse(pos, 2, k, code);
+ }
+ }
+ else if(nbbits == 44)
+ {
+ for(k = 0; k < 4 - 2; k++)
+ {
+ L_index = index[k];
+ D_ACELP_decode_3p_3N1(L_index, 4, 0, pos);
+ D_ACELP_add_pulse(pos, 3, k, code);
+ }
+
+ for(k = 2; k < 4; k++)
+ {
+ L_index = index[k];
+ D_ACELP_decode_2p_2N1(L_index, 4, 0, pos);
+ D_ACELP_add_pulse(pos, 2, k, code);
+ }
+ }
+ else if(nbbits == 52)
+ {
+ for(k = 0; k < 4; k++)
+ {
+ L_index = index[k];
+ D_ACELP_decode_3p_3N1(L_index, 4, 0, pos);
+ D_ACELP_add_pulse(pos, 3, k, code);
+ }
+ }
+ else if(nbbits == 64)
+ {
+ for(k = 0; k < 4; k++)
+ {
+ L_index = ((index[k] << 14) + index[k + 4]);
+ D_ACELP_decode_4p_4N(L_index, 4, 0, pos);
+ D_ACELP_add_pulse(pos, 4, k, code);
+ }
+ }
+ else if(nbbits == 72)
+ {
+ for(k = 0; k < 4 - 2; k++)
+ {
+ L_index = ((index[k] << 10) + index[k + 4]);
+ D_ACELP_decode_5p_5N(L_index, 4, 0, pos);
+ D_ACELP_add_pulse(pos, 5, k, code);
+ }
+
+ for(k = 2; k < 4; k++)
+ {
+ L_index = ((index[k] << 14) + index[k + 4]);
+ D_ACELP_decode_4p_4N(L_index, 4, 0, pos);
+ D_ACELP_add_pulse(pos, 4, k, code);
+ }
+ }
+ else if(nbbits == 88)
+ {
+ for(k = 0; k < 4; k++)
+ {
+ L_index = ((index[k] << 11) + index[k + 4]);
+ D_ACELP_decode_6p_6N_2(L_index, 4, 0, pos);
+ D_ACELP_add_pulse(pos, 6, k, code);
+ }
+ }
+ return;
+}
+
+
+/*
+ * D_ACELP_phase_dispersion
+ *
+ * Parameters:
+ * gain_code I: (Q0) gain of code
+ * gain_pit I: (Q14) gain of pitch
+ * code I/O: code vector
+ * mode I: level, 0=hi, 1=lo, 2=off
+ * disp_mem I/O: static memory (size = 8)
+ *
+ * Function:
+ * An adaptive anti-sparseness post-processing procedure is
+ * applied to the fixed codebook vector in order to
+ * reduce perceptual artifacts arising from the sparseness
+ * of the algebraic fixed codebook vectors with only
+ * a few non-zero samples per subframe.
+ *
+ * Returns:
+ * void
+ */
+void D_ACELP_phase_dispersion(Word16 gain_code, Word16 gain_pit, Word16 code[],
+ Word16 mode, Word16 disp_mem[])
+{
+ Word32 code2[2 * L_SUBFR] = {0};
+ Word32 i, j, state;
+ Word16 *prev_gain_pit, *prev_gain_code, *prev_state;
+
+ prev_state = disp_mem;
+ prev_gain_code = disp_mem + 1;
+ prev_gain_pit = disp_mem + 2;
+
+ if(gain_pit < 9830) /* 0.6 in Q14 */
+ {
+ state = 0;
+ }
+ else if(gain_pit < 14746) /* 0.9 in Q14 */
+ {
+ state = 1;
+ }
+ else
+ {
+ state = 2;
+ }
+
+ for(i = 5; i > 0; i--)
+ {
+ prev_gain_pit[i] = prev_gain_pit[i - 1];
+ }
+ prev_gain_pit[0] = gain_pit;
+
+ if((gain_code - *prev_gain_code) > (*prev_gain_code << 1))
+ {
+ /* onset */
+ if(state < 2)
+ {
+ state = state + 1;
+ }
+ }
+ else
+ {
+ j = 0;
+
+ for(i = 0; i < 6; i++)
+ {
+ if(prev_gain_pit[i] < 9830) /* 0.6 in Q14 */
+ j = (j + 1);
+ }
+
+ if(j > 2)
+ {
+ state = 0;
+ }
+
+ if((state - *prev_state) > 1)
+ {
+ state = state - 1;
+ }
+ }
+ *prev_gain_code = gain_code;
+ *prev_state = (Word16)state;
+
+ /* circular convolution */
+ state = state + mode; /* level of dispersion */
+
+ if(state == 0)
+ {
+ for(i = 0; i < L_SUBFR; i++)
+ {
+ if(code[i] != 0)
+ {
+ for(j = 0; j < L_SUBFR; j++)
+ {
+ code2[i + j] = code2[i + j] +
+ (((code[i] * D_ROM_ph_imp_low[j]) + 0x4000) >> 15);
+ }
+ }
+ }
+ }
+ else if(state == 1)
+ {
+ for(i = 0; i < L_SUBFR; i++)
+ {
+ if(code[i] != 0)
+ {
+ for(j = 0; j < L_SUBFR; j++)
+ {
+ code2[i + j] = code2[i + j] +
+ (((code[i] * D_ROM_ph_imp_mid[j]) + 0x4000) >> 15);
+ }
+ }
+ }
+ }
+
+ if(state < 2)
+ {
+ for(i = 0; i < L_SUBFR; i++)
+ {
+ code[i] = (Word16)(code2[i] + code2[i + L_SUBFR]);
+ }
+ }
+
+ return;
+}
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_acelp.h b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_acelp.h
new file mode 100644
index 000000000..2133cd954
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_acelp.h
@@ -0,0 +1,17 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef DEC_ACELP_H
+#define DEC_ACELP_H
+
+#include "typedef.h"
+
+void D_ACELP_decode_2t(Word16 index, Word16 code[]);
+void D_ACELP_decode_4t(Word16 index[], Word16 nbbits, Word16 code[]);
+void D_ACELP_phase_dispersion(Word16 gain_code, Word16 gain_pit, Word16 code[],
+ Word16 mode, Word16 disp_mem[]);
+
+#endif
+
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_dtx.c b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_dtx.c
new file mode 100644
index 000000000..a52bd7521
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_dtx.c
@@ -0,0 +1,748 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#include <stdlib.h>
+#include <memory.h>
+#include <math.h>
+#include "typedef.h"
+#include "dec_dtx.h"
+#include "dec_lpc.h"
+#include "dec_util.h"
+
+#define MAX_31 (Word32)0x3FFFFFFF
+#define L_FRAME 256 /* Frame size */
+#define RX_SPEECH_LOST 2
+#define RX_SPEECH_BAD 3
+#define RX_SID_FIRST 4
+#define RX_SID_UPDATE 5
+#define RX_SID_BAD 6
+#define RX_NO_DATA 7
+#define ISF_GAP 128 /* 50 */
+#define D_DTX_MAX_EMPTY_THRESH 50
+#define GAIN_FACTOR 75
+#define ISF_FACTOR_LOW 256
+#define ISF_FACTOR_STEP 2
+#define ISF_DITH_GAP 448
+#define D_DTX_HANG_CONST 7 /* yields eight frames of SP HANGOVER */
+#define D_DTX_ELAPSED_FRAMES_THRESH (24 + 7 - 1)
+#define RANDOM_INITSEED 21845 /* own random init value */
+
+
+/*
+ * D_DTX_reset
+ *
+ * Parameters:
+ * st O: state struct
+ *
+ * Function:
+ * Initializes state memory
+ *
+ * Returns:
+ * non-zero with error, zero for ok
+ */
+int D_DTX_reset(D_DTX_State *st, const Word16 *isf_init)
+{
+ Word32 i;
+
+ if(st == (D_DTX_State*)NULL)
+ {
+ return(-1);
+ }
+ st->mem_since_last_sid = 0;
+ st->mem_true_sid_period_inv = (1 << 13); /* 0.25 in Q15 */
+ st->mem_log_en = 3500;
+ st->mem_log_en_prev = 3500;
+
+ /* low level noise for better performance in DTX handover cases */
+ st->mem_cng_seed = RANDOM_INITSEED;
+ st->mem_hist_ptr = 0;
+
+ /* Init isf_hist[] and decoder log frame energy */
+ memcpy(st->mem_isf, isf_init, M * sizeof(Word16));
+ memcpy(st->mem_isf_prev, isf_init, M * sizeof(Word16));
+
+ for(i = 0; i < D_DTX_HIST_SIZE; i++)
+ {
+ memcpy(&st->mem_isf_buf[i * M], isf_init, M * sizeof(Word16));
+ st->mem_log_en_buf[i] = 3500;
+ }
+ st->mem_dtx_hangover_count = D_DTX_HANG_CONST;
+ st->mem_dec_ana_elapsed_count = 127;
+ st->mem_sid_frame = 0;
+ st->mem_valid_data = 0;
+ st->mem_dtx_hangover_added = 0;
+ st->mem_dtx_global_state = SPEECH;
+ st->mem_data_updated = 0;
+ st->mem_dither_seed = RANDOM_INITSEED;
+ st->mem_cn_dith = 0;
+
+ return(0);
+}
+
+
+/*
+ * D_DTX_init
+ *
+ * Parameters:
+ * st I/O: state struct
+ *
+ * Function:
+ * Allocates state memory and initializes state memory
+ *
+ * Returns:
+ * non-zero with error, zero for ok
+ */
+int D_DTX_init(D_DTX_State **st, const Word16 *isf_init)
+{
+ D_DTX_State *s;
+
+ if(st == (D_DTX_State**)NULL)
+ {
+ return(-1);
+ }
+
+ *st = NULL;
+
+ /* allocate memory */
+ if((s = (D_DTX_State*)malloc(sizeof(D_DTX_State))) == NULL)
+ {
+ return(-1);
+ }
+
+ D_DTX_reset(s, isf_init);
+ *st = s;
+
+ return(0);
+}
+
+
+/*
+ * D_DTX_exit
+ *
+ * Parameters:
+ * state I/0: State struct
+ *
+ * Function:
+ * The memory used for state memory is freed
+ *
+ * Returns:
+ * void
+ */
+void D_DTX_exit(D_DTX_State **st)
+{
+ if(st == NULL || *st == NULL)
+ {
+ return;
+ }
+
+ /* deallocate memory */
+ free(*st);
+ *st = NULL;
+
+ return;
+}
+
+
+/*
+ * D_DTX_rx_handler
+ *
+ * Parameters:
+ * st I/O: State struct
+ * frame_type I: Frame type
+ *
+ * Function:
+ * Analyze received frame
+ *
+ * Table of new SPD synthesis states
+ *
+ * | previous SPD_synthesis_state
+ * Incoming |
+ * frame_type | SPEECH | DTX | D_DTX_MUTE
+ * ---------------------------------------------------------------
+ * RX_SPEECH_GOOD , | | |
+ * RX_SPEECH_PR_DEGRADED | SPEECH | SPEECH | SPEECH
+ * ----------------------------------------------------------------
+ * RX_SPEECH_BAD, | SPEECH | DTX | D_DTX_MUTE
+ * ----------------------------------------------------------------
+ * RX_SID_FIRST, | DTX | DTX/(D_DTX_MUTE)| D_DTX_MUTE
+ * ----------------------------------------------------------------
+ * RX_SID_UPDATE, | DTX | DTX | DTX
+ * ----------------------------------------------------------------
+ * RX_SID_BAD, | DTX | DTX/(D_DTX_MUTE)| D_DTX_MUTE
+ * ----------------------------------------------------------------
+ * RX_NO_DATA, | SPEECH | DTX/(D_DTX_MUTE)| D_DTX_MUTE
+ * RX_SPARE |(class2 garb.)| |
+ * ----------------------------------------------------------------
+ *
+ * Returns:
+ * new state
+ */
+UWord8 D_DTX_rx_handler(D_DTX_State *st, UWord8 frame_type)
+{
+ UWord8 newState;
+ UWord8 encState;
+
+ /* DTX if SID frame or previously in DTX{_MUTE}
+ * and (NO_RX OR BAD_SPEECH)
+ */
+ if((frame_type == RX_SID_FIRST) | (frame_type == RX_SID_UPDATE) |
+ (frame_type == RX_SID_BAD) | (((st->mem_dtx_global_state == DTX) |
+ (st->mem_dtx_global_state == D_DTX_MUTE)) & ((frame_type == RX_NO_DATA) |
+ (frame_type == RX_SPEECH_BAD) | (frame_type == RX_SPEECH_LOST))))
+ {
+ newState = DTX;
+
+ /* stay in mute for these input types */
+ if((st->mem_dtx_global_state == D_DTX_MUTE) &
+ ((frame_type == RX_SID_BAD) | (frame_type == RX_SID_FIRST) |
+ (frame_type == RX_SPEECH_LOST) | (frame_type == RX_NO_DATA)))
+ {
+ newState = D_DTX_MUTE;
+ }
+
+ /* evaluate if noise parameters are too old */
+ /* since_last_sid is reset when CN parameters have been updated */
+ st->mem_since_last_sid = D_UTIL_saturate(st->mem_since_last_sid + 1);
+
+ /* no update of sid parameters in DTX for a Word32 while */
+ if(st->mem_since_last_sid > D_DTX_MAX_EMPTY_THRESH)
+ {
+ newState = D_DTX_MUTE;
+ }
+ }
+ else
+ {
+ newState = SPEECH;
+ st->mem_since_last_sid = 0;
+ }
+
+ /*
+ * reset the decAnaElapsed Counter when receiving CNI data the first
+ * time, to robustify counter missmatch after handover
+ * this might delay the bwd CNI analysis in the new decoder slightly.
+ */
+ if((st->mem_data_updated == 0) & (frame_type == RX_SID_UPDATE))
+ {
+ st->mem_dec_ana_elapsed_count = 0;
+ }
+
+ /*
+ * update the SPE-SPD DTX hangover synchronization
+ * to know when SPE has added dtx hangover
+ */
+ st->mem_dec_ana_elapsed_count++;
+
+ /* saturate */
+ if(st->mem_dec_ana_elapsed_count > 127)
+ {
+ st->mem_dec_ana_elapsed_count = 127;
+ }
+
+ st->mem_dtx_hangover_added = 0;
+
+ if((frame_type == RX_SID_FIRST) | (frame_type == RX_SID_UPDATE) |
+ (frame_type == RX_SID_BAD) | (frame_type == RX_NO_DATA))
+ {
+ encState = DTX;
+ }
+ else
+ {
+ encState = SPEECH;
+ }
+
+ if(encState == SPEECH)
+ {
+ st->mem_dtx_hangover_count = D_DTX_HANG_CONST;
+ }
+ else
+ {
+ if(st->mem_dec_ana_elapsed_count > D_DTX_ELAPSED_FRAMES_THRESH)
+ {
+ st->mem_dtx_hangover_added = 1;
+ st->mem_dec_ana_elapsed_count = 0;
+ st->mem_dtx_hangover_count = 0;
+ }
+ else if(st->mem_dtx_hangover_count == 0)
+ {
+ st->mem_dec_ana_elapsed_count = 0;
+ }
+ else
+ {
+ st->mem_dtx_hangover_count--;
+ }
+ }
+
+ if(newState != SPEECH)
+ {
+ /*
+ * DTX or D_DTX_MUTE
+ * CN data is not in a first SID, first SIDs are marked as SID_BAD
+ * but will do backwards analysis if a hangover period has been added
+ * according to the state machine above
+ */
+ st->mem_sid_frame = 0;
+ st->mem_valid_data = 0;
+
+ if(frame_type == RX_SID_FIRST)
+ {
+ st->mem_sid_frame = 1;
+ }
+ else if(frame_type == RX_SID_UPDATE)
+ {
+ st->mem_sid_frame = 1;
+ st->mem_valid_data = 1;
+ }
+ else if(frame_type == RX_SID_BAD)
+ {
+ st->mem_sid_frame = 1;
+ st->mem_dtx_hangover_added = 0; /* use old data */
+ }
+ }
+
+ return newState;
+
+ /* newState is used by both SPEECH AND DTX synthesis routines */
+}
+
+
+/*
+ * D_DTX_cn_dithering
+ *
+ * Parameters:
+ * isf I/O: CN ISF vector
+ * L_log_en_int I/O: energy parameter
+ * dither_seed I/O: random seed
+ *
+ * Function:
+ * Confort noise dithering
+ *
+ * Returns:
+ * void
+ */
+static void D_DTX_cn_dithering(Word16 isf[M], Word32 *L_log_en_int,
+ Word16 *dither_seed)
+{
+ Word32 temp, temp1, i, dither_fac, rand_dith,rand_dith2;
+
+ /* Insert comfort noise dithering for energy parameter */
+ rand_dith = D_UTIL_random(dither_seed) >> 1;
+ rand_dith2 = D_UTIL_random(dither_seed) >>1;
+ rand_dith = rand_dith + rand_dith2;
+ *L_log_en_int = *L_log_en_int + ((rand_dith * GAIN_FACTOR) << 1);
+
+ if(*L_log_en_int < 0)
+ {
+ *L_log_en_int = 0;
+ }
+
+ /* Insert comfort noise dithering for spectral parameters (ISF-vector) */
+ dither_fac = ISF_FACTOR_LOW;
+ rand_dith = D_UTIL_random(dither_seed) >> 1;
+ rand_dith2 = D_UTIL_random(dither_seed) >> 1;
+ rand_dith = rand_dith + rand_dith2;
+ temp = isf[0] + (((rand_dith * dither_fac) + 0x4000) >> 15);
+
+ /* Make sure that isf[0] will not get negative values */
+ if(temp < ISF_GAP)
+ {
+ isf[0] = ISF_GAP;
+ }
+ else
+ {
+ isf[0] = (Word16)temp;
+ }
+
+ for(i = 1; i < M - 1; i++)
+ {
+ dither_fac = dither_fac + ISF_FACTOR_STEP;
+ rand_dith = D_UTIL_random(dither_seed) >> 1;
+ rand_dith2 = D_UTIL_random(dither_seed) >> 1;
+ rand_dith = rand_dith + rand_dith2;
+ temp = isf[i] + (((rand_dith * dither_fac) + 0x4000) >> 15);
+ temp1 = temp - isf[i - 1];
+
+ /* Make sure that isf spacing remains at least ISF_DITH_GAP Hz */
+ if(temp1 < ISF_DITH_GAP)
+ {
+ isf[i] = (Word16)(isf[i - 1] + ISF_DITH_GAP);
+ }
+ else
+ {
+ isf[i] = (Word16)temp;
+ }
+ }
+
+ /* Make sure that isf[M-2] will not get values above 16384 */
+ if(isf[M - 2] > 16384)
+ {
+ isf[M - 2] = 16384;
+ }
+
+ return;
+}
+
+
+/*
+ * D_DTX_exe
+ *
+ * Parameters:
+ * st I/O: state struct
+ * exc2 O: CN excitation
+ * new_state I: New DTX state
+ * prms I: Vector of synthesis parameters
+ * isf O: CN ISF vector
+ *
+ * Function:
+ * Confort noise generation
+ *
+ * Returns:
+ * void
+ */
+void D_DTX_exe(D_DTX_State *st, Word16 *exc2, Word16 new_state, Word16 isf[],
+ Word16 **prms)
+{
+
+ Word32 i, j, L_tmp, ptr;
+ Word32 exp0, int_fac;
+ Word32 gain;
+ Word32 L_isf[M], L_log_en_int, level32, ener32;
+ Word16 log_en_index;
+ Word16 tmp_int_length;
+ Word16 exp, log_en_int_e, log_en_int_m, level;
+
+
+ /*
+ * This function is called if synthesis state is not SPEECH.
+ * The globally passed inputs to this function are
+ * st->sid_frame
+ * st->valid_data
+ * st->dtxHangoverAdded
+ * new_state (SPEECH, DTX, D_DTX_MUTE)
+ */
+ if((st->mem_dtx_hangover_added != 0) & (st->mem_sid_frame != 0))
+ {
+ /* sid_first after dtx hangover period
+ * or sid_upd after dtxhangover
+ * consider twice the last frame
+ */
+ ptr = st->mem_hist_ptr + 1;
+
+ if(ptr == D_DTX_HIST_SIZE)
+ {
+ ptr = 0;
+ }
+
+ memcpy(&st->mem_isf_buf[ptr * M], &st->mem_isf_buf[st->mem_hist_ptr * M],
+ M * sizeof(Word16));
+
+ st->mem_log_en_buf[ptr] = st->mem_log_en_buf[st->mem_hist_ptr];
+
+ /* compute mean log energy and isf from decoded signal (SID_FIRST) */
+ st->mem_log_en = 0;
+ memset(L_isf, 0, M * sizeof(Word32));
+
+ /* average energy and isf */
+ for(i = 0; i < D_DTX_HIST_SIZE; i++)
+ {
+ /*
+ * Division by D_DTX_HIST_SIZE = 8 has been done in dtx_buffer log_en
+ * is in Q10
+ */
+ st->mem_log_en = (Word16)(st->mem_log_en + st->mem_log_en_buf[i]);
+
+ for(j = 0; j < M; j++)
+ {
+ L_isf[j] = L_isf[j] + st->mem_isf_buf[i * M + j];
+ }
+ }
+
+ /* st->log_en in Q9 */
+ st->mem_log_en = (Word16)(st->mem_log_en >> 1);
+
+ /*
+ * Add 2 in Q9, in order to have only positive values for Pow2
+ * this value is subtracted back after Pow2 function
+ */
+ st->mem_log_en = (Word16)(st->mem_log_en + 1024);
+
+ if(st->mem_log_en < 0)
+ {
+ st->mem_log_en = 0;
+ }
+
+ for(j = 0; j < M; j++)
+ {
+ st->mem_isf[j] = (Word16)(L_isf[j]>>3); /* divide by 8 */
+ }
+ }
+
+ if(st->mem_sid_frame != 0)
+ {
+ /*
+ * Set old SID parameters, always shift
+ * even if there is no new valid_data
+ */
+ memcpy(st->mem_isf_prev, st->mem_isf, M * sizeof(Word16));
+ st->mem_log_en_prev = st->mem_log_en;
+
+ if(st->mem_valid_data != 0) /* new data available (no CRC) */
+ {
+ /* st->true_sid_period_inv = 1.0f/st->since_last_sid; */
+
+ /*
+ * Compute interpolation factor, since the division only works
+ * for values of since_last_sid < 32 we have to limit
+ * the interpolation to 32 frames
+ */
+ tmp_int_length = st->mem_since_last_sid;
+
+ if(tmp_int_length > 32)
+ {
+ tmp_int_length = 32;
+ }
+
+ if(tmp_int_length >= 2)
+ {
+ st->mem_true_sid_period_inv =
+ (Word16)(0x2000000 / (tmp_int_length << 10));
+ }
+ else
+ {
+ st->mem_true_sid_period_inv = 1 << 14; /* 0.5 it Q15 */
+ }
+
+ D_LPC_isf_noise_d(*prms, st->mem_isf);
+ (*prms) += 5;
+ log_en_index = *(*prms)++;
+
+ /* read background noise stationarity information */
+ st->mem_cn_dith = *(*prms)++;
+
+ /*
+ * st->log_en = (Float32)log_en_index / 2.625 - 2.0;
+ * log2(E) in Q9 (log2(E) lies in between -2:22)
+ */
+ st->mem_log_en = (Word16)(log_en_index << (15 - 6));
+
+ /* Divide by 2.625 */
+ st->mem_log_en = (Word16)((st->mem_log_en * 12483) >> 15);
+
+ /*
+ * Subtract 2 in Q9 is done later, after Pow2 function
+ * no interpolation at startup after coder reset
+ * or when SID_UPD has been received right after SPEECH
+ */
+ if((st->mem_data_updated == 0) ||
+ (st->mem_dtx_global_state == SPEECH))
+ {
+ memcpy(st->mem_isf_prev, st->mem_isf, M * sizeof(Word16));
+ st->mem_log_en_prev = st->mem_log_en;
+ }
+ } /* endif valid_data */
+ } /* endif sid_frame */
+
+ if((st->mem_sid_frame != 0) && (st->mem_valid_data != 0))
+ {
+ st->mem_since_last_sid = 0;
+ }
+
+ /* Interpolate SID info */
+ if(st->mem_since_last_sid < 32)
+ {
+ int_fac = st->mem_since_last_sid << 10; /* Q10 */
+ }
+ else
+ {
+ int_fac = 32767;
+ }
+ /* Q10 * Q15 -> Q10 */
+ int_fac = (int_fac * st->mem_true_sid_period_inv) >> 15;
+
+ /* Maximize to 1.0 in Q10 */
+ if(int_fac > 1024)
+ {
+ int_fac = 1024;
+ }
+ int_fac = int_fac << 4; /* Q10 -> Q14 */
+ L_log_en_int = (int_fac * st->mem_log_en) << 1; /* Q14 * Q9 -> Q24 */
+
+ for(i = 0; i < M; i++)
+ {
+ /* Q14 * Q15 -> Q14 */
+ isf[i] = (Word16)((int_fac * st->mem_isf[i]) >> 15);
+ }
+ int_fac = 16384 - int_fac; /* 1-k in Q14 */
+
+ /* ( Q14 * Q9 -> Q24 ) + Q24 -> Q24 */
+ L_log_en_int = L_log_en_int + ((int_fac * st->mem_log_en_prev) << 1);
+
+ for(i = 0; i < M; i++)
+ {
+ /* Q14 + (Q14 * Q15 -> Q14) -> Q14 */
+ L_tmp = isf[i] + ((int_fac * st->mem_isf_prev[i]) >> 15);
+ isf[i] = (Word16)(L_tmp << 1); /* Q14 -> Q15 */
+ }
+
+ /* If background noise is non-stationary, insert comfort noise dithering */
+ if(st->mem_cn_dith != 0)
+ {
+ D_DTX_cn_dithering(isf, &L_log_en_int, &st->mem_dither_seed);
+ }
+
+ /* L_log_en_int corresponds to log2(E)+2 in Q24, i.e log2(gain)+1 in Q25 */
+ L_log_en_int = (L_log_en_int >> 9); /* Q25 -> Q16 */
+
+ /* Find integer part */
+ log_en_int_e = (Word16)((L_log_en_int)>>16);
+
+ /* Find fractional part */
+ log_en_int_m = (Word16)((L_log_en_int - (log_en_int_e << 16)) >> 1);
+
+ /*
+ * Subtract 2 from L_log_en_int in Q9,
+ * i.e divide the gain by 2 (energy by 4)
+ * Add 16 in order to have the result of pow2 in Q16
+ */
+ log_en_int_e = (Word16)(log_en_int_e + (16 - 1));
+
+ /* level = (Float32)( pow( 2.0f, log_en ) ); */
+ level32 = D_UTIL_pow2(log_en_int_e, log_en_int_m); /* Q16 */
+ exp0 = D_UTIL_norm_l(level32);
+ level32 = (level32 << exp0); /* level in Q31 */
+ exp0 = (15 - exp0);
+ level = (Word16)(level32 >> 16); /* level in Q15 */
+
+ /* generate white noise vector */
+ for(i = 0; i < L_FRAME; i++)
+ {
+ exc2[i] = (Word16)((D_UTIL_random(&(st->mem_cng_seed)) >> 4));
+ }
+
+ /* gain = level / sqrt(ener) * sqrt(L_FRAME) */
+ /* energy of generated excitation */
+ ener32 = D_UTIL_dot_product12(exc2, exc2, L_FRAME, &exp);
+ D_UTIL_normalised_inverse_sqrt(&ener32, &exp);
+ gain = ener32 >>16;
+ gain = (level * gain) >> 15; /* gain in Q15 */
+
+ /* Multiply by sqrt(L_FRAME)=16, i.e. shift left by 4 */
+ exp = (Word16)(exp0 + exp + 4);
+
+ if(exp >= 0)
+ {
+ for(i = 0; i < L_FRAME; i++)
+ {
+ L_tmp = (exc2[i] * gain) >> 15; /* Q0 * Q15 */
+ exc2[i] = (Word16)(L_tmp << exp);
+ }
+ }
+ else
+ {
+ exp = (Word16)-exp;
+
+ for(i = 0; i < L_FRAME; i++)
+ {
+ L_tmp = (exc2[i] * gain) >> 15; /* Q0 * Q15 */
+ exc2[i] = (Word16)(L_tmp >> exp);
+ }
+ }
+
+ if(new_state == D_DTX_MUTE)
+ {
+ /*
+ * mute comfort noise as it has been quite a long time since
+ * last SID update was performed
+ */
+ tmp_int_length = st->mem_since_last_sid;
+
+ if(tmp_int_length > 32)
+ {
+ tmp_int_length = 32;
+ }
+
+ st->mem_true_sid_period_inv = D_UTIL_saturate((0x02000000 / (tmp_int_length << 10)));
+ st->mem_since_last_sid = 0;
+ st->mem_log_en_prev = st->mem_log_en;
+
+ /* subtract 1/8 in Q9 (energy), i.e -3/8 dB */
+ st->mem_log_en = D_UTIL_saturate(st->mem_log_en - 64);
+ }
+
+ /* reset interpolation length timer if data has been updated. */
+ if((st->mem_sid_frame != 0) && ((st->mem_valid_data != 0) ||
+ ((st->mem_valid_data == 0) && (st->mem_dtx_hangover_added) != 0)))
+ {
+ st->mem_since_last_sid = 0;
+ st->mem_data_updated = 1;
+ }
+
+ return;
+}
+
+
+/*
+ * D_DTX_activity_update
+ *
+ * Parameters:
+ * st I/O: state struct
+ * isf O: ISF vector
+ * exc O: excitation
+ *
+ * Function:
+ * Confort noise generation
+ *
+ * Returns:
+ * void
+ */
+void D_DTX_activity_update(D_DTX_State *st, Word16 isf[], Word16 exc[])
+{
+
+ Word32 L_frame_en, log_en;
+ Word32 i;
+ Word16 log_en_e, log_en_m;
+
+ st->mem_hist_ptr = (Word16)(st->mem_hist_ptr + 1);
+
+ if(st->mem_hist_ptr == D_DTX_HIST_SIZE)
+ {
+ st->mem_hist_ptr = 0;
+ }
+
+ memcpy(&st->mem_isf_buf[st->mem_hist_ptr * M], isf, M * sizeof(Word16));
+
+ /* compute log energy based on excitation frame energy in Q0 */
+ L_frame_en = 0;
+
+ for(i = 0; i < L_FRAME; i++)
+ {
+ L_frame_en = L_frame_en + (exc[i] * exc[i]);
+ if (L_frame_en > MAX_31)
+ {
+ L_frame_en = MAX_31;
+ break;
+ }
+ }
+
+ /*
+ * log_en =
+ * (Float32)log10(L_frame_en/(Float32)L_FRAME)/(Float32)log10(2.0f);
+ */
+ D_UTIL_log2(L_frame_en, &log_en_e, &log_en_m);
+
+ /*
+ * convert exponent and mantissa to Word16 Q7.
+ * Q7 is used to simplify averaging in dtx_enc
+ */
+ log_en = log_en_e << 7; /* Q7 */
+ log_en = log_en + (log_en_m >> (15 - 7));
+
+ /* Divide by L_FRAME = 256, i.e subtract 8 in Q7 = 1024 */
+ log_en = log_en - 1024;
+
+ /* insert into log energy buffer */
+ st->mem_log_en_buf[st->mem_hist_ptr] = (Word16)log_en;
+
+ return;
+}
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_dtx.h b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_dtx.h
new file mode 100644
index 000000000..3ff4c0171
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_dtx.h
@@ -0,0 +1,49 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef DEC_DTX_H
+#define DEC_DTX_H
+
+#include "typedef.h"
+
+#define M 16 /* Order of LP filter */
+#define SPEECH 0
+#define DTX 1
+#define D_DTX_MUTE 2
+#define D_DTX_HIST_SIZE 8
+
+typedef struct {
+ Word16 mem_isf_buf[M * D_DTX_HIST_SIZE]; /* ISF vector history (8 frames)*/
+ Word16 mem_isf[M]; /* ISF vector */
+ Word16 mem_isf_prev[M]; /* Previous ISF vector */
+ Word16 mem_log_en_buf[D_DTX_HIST_SIZE];/* logarithmic frame energy history*/
+ Word16 mem_true_sid_period_inv; /* inverse of true SID update rate */
+ Word16 mem_log_en; /* logarithmic frame energy */
+ Word16 mem_log_en_prev; /* previous logarithmic frame energy */
+ Word16 mem_cng_seed; /* Comfort noise excitation seed */
+ Word16 mem_hist_ptr; /* index to beginning of LSF history */
+ Word16 mem_dither_seed; /* comfort noise dithering seed */
+ Word16 mem_cn_dith; /* background noise stationarity information*/
+ Word16 mem_since_last_sid; /* number of frames since last SID frame */
+
+ UWord8 mem_dec_ana_elapsed_count;/* counts elapsed speech frames after DTX*/
+ UWord8 mem_dtx_global_state; /* DTX state flags */
+ UWord8 mem_data_updated; /* flags CNI updates */
+ UWord8 mem_dtx_hangover_count;/* counts down in hangover period */
+ UWord8 mem_sid_frame; /* flags SID frames */
+ UWord8 mem_valid_data; /* flags SID frames containing valid data */
+ UWord8 mem_dtx_hangover_added;/* flags hangover period at end of speech */
+
+} D_DTX_State;
+
+int D_DTX_init(D_DTX_State **st, const Word16 *isf_init);
+int D_DTX_reset(D_DTX_State *st, const Word16 *isf_init);
+void D_DTX_exit(D_DTX_State **st);
+UWord8 D_DTX_rx_handler(D_DTX_State *st, UWord8 frame_type);
+void D_DTX_exe(D_DTX_State *st, Word16 *exc2, Word16 new_state,
+ Word16 isf[], Word16 **prms);
+void D_DTX_activity_update(D_DTX_State *st, Word16 isf[], Word16 exc[]);
+
+#endif
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_gain.c b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_gain.c
new file mode 100644
index 000000000..db7a79b9a
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_gain.c
@@ -0,0 +1,963 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#include <memory.h>
+#include "typedef.h"
+#include "dec_util.h"
+
+#define L_SUBFR 64 /* Subframe size */
+#define L_LTPHIST 5
+#define ONE_PER_3 10923
+#define ONE_PER_LTPHIST 6554
+#define UP_SAMP 4
+#define L_INTERPOL2 16
+
+extern const Word16 D_ROM_inter4_2[];
+extern const Word16 D_ROM_pdown_unusable[];
+extern const Word16 D_ROM_pdown_usable[];
+extern const Word16 D_ROM_cdown_unusable[];
+extern const Word16 D_ROM_cdown_usable[];
+extern const Word16 D_ROM_qua_gain6b[];
+extern const Word16 D_ROM_qua_gain7b[];
+
+/*
+ * D_GAIN_init
+ *
+ * Parameters:
+ * mem O: static memory
+ *
+ * Function:
+ * Initialisation of 2nd order quantiser energy predictor.
+ *
+ * Returns:
+ * void
+ */
+void D_GAIN_init(Word16 *mem)
+{
+
+ /* 4nd order quantizer energy predictor (init to -14.0 in Q10) */
+ mem[0] = -14336; /* past_qua_en[0] */
+ mem[1] = -14336; /* past_qua_en[1] */
+ mem[2] = -14336; /* past_qua_en[2] */
+ mem[3] = -14336; /* past_qua_en[3] */
+ /*
+ * mem[4] = 0; past_gain_pit
+ * mem[5] = 0; past_gain_code
+ * mem[6] = 0; prev_gc
+ * mem[7 - 11] = 0; pbuf[i]
+ * mem[12 - 16] = 0; gbuf[i]
+ * mem[17 - 21] = 0; pbuf2[i]
+ */
+ memset(&mem[4], 0, 18 * sizeof(Word16));
+
+ mem[22] = 21845; /* seed */
+ return;
+}
+
+
+/*
+ * D_GAIN_median
+ *
+ * Parameters:
+ * buf I: previous gains
+ *
+ * Function:
+ * Median of gains
+ *
+ * Returns:
+ * median of 5 previous gains
+ */
+static Word16 D_GAIN_median(Word16 x[])
+{
+ Word16 x1, x2, x3, x4, x5;
+ Word16 tmp;
+ x1 = x[ - 2];
+ x2 = x[ - 1];
+ x3 = x[0];
+ x4 = x[1];
+ x5 = x[2];
+
+ if(x2 < x1)
+ {
+ tmp = x1;
+ x1 = x2;
+ x2 = tmp;
+ }
+
+ if(x3 < x1)
+ {
+ tmp = x1;
+ x1 = x3;
+ x3 = tmp;
+ }
+
+ if(x4 < x1)
+ {
+ tmp = x1;
+ x1 = x4;
+ x4 = tmp;
+ }
+
+ if(x5 < x1)
+ {
+ x5 = x1;
+ }
+
+ if(x3 < x2)
+ {
+ tmp = x2;
+ x2 = x3;
+ x3 = tmp;
+ }
+
+ if(x4 < x2)
+ {
+ tmp = x2;
+ x2 = x4;
+ x4 = tmp;
+ }
+
+ if(x5 < x2)
+ {
+ x5 = x2;
+ }
+
+ if(x4 < x3)
+ {
+ x3 = x4;
+ }
+
+ if(x5 < x3)
+ {
+ x3 = x5;
+ }
+
+ return(x3);
+}
+
+
+/*
+ * D_GAIN_decode
+ *
+ * Parameters:
+ * index I: Quantization index
+ * nbits I: number of bits (6 or 7)
+ * code I: Innovative code vector
+ * L_subfr I: Subframe size
+ * gain_pit O: (Q14) Quantized pitch gain
+ * gain_code O: (Q16) Quantized codebook gain
+ * bfi I: Bad frame indicator
+ * prev_bfi I: Previous BF indicator
+ * state I: State of BFH
+ * unusable_frame I: UF indicator
+ * vad_hist I: number of non-speech frames
+ * mem I/O: static memory (4 words)
+ *
+ *
+ * Function:
+ * Decoding of pitch and codebook gains
+ *
+ * Returns:
+ * void
+ */
+void D_GAIN_decode(Word16 index, Word16 nbits, Word16 code[], Word16 *gain_pit,
+ Word32 *gain_cod, Word16 bfi, Word16 prev_bfi,
+ Word16 state, Word16 unusable_frame, Word16 vad_hist,
+ Word16 *mem)
+{
+
+ Word32 gcode0, qua_ener, L_tmp;
+ const Word16 * p;
+ Word16 *past_gain_pit, *past_gain_code, *past_qua_en, *prev_gc;
+ Word16 *gbuf, *pbuf, *pbuf2;
+ Word16 i, tmp, exp, frac, exp_gcode0, gcode_inov;
+ Word16 g_code;
+
+ past_qua_en = mem;
+ past_gain_pit = mem + 4;
+ past_gain_code = mem + 5;
+ prev_gc = mem + 6;
+ pbuf = mem + 7;
+ gbuf = mem + 12;
+ pbuf2 = mem + 17;
+
+ /*
+ * Find energy of code and compute:
+ *
+ * L_tmp = 1.0 / sqrt(energy of code/ L_subfr)
+ */
+ L_tmp = D_UTIL_dot_product12(code, code, L_SUBFR, &exp);
+ exp = (Word16)(exp - (18 + 6)); /* exp: -18 (code in Q9), -6 (/L_subfr) */
+ D_UTIL_normalised_inverse_sqrt(&L_tmp, &exp);
+
+ if(exp > 3)
+ {
+ L_tmp <<= (exp - 3);
+ }
+ else
+ {
+ L_tmp >>= (3 - exp);
+ }
+
+ gcode_inov = (Word16)(L_tmp >>16); /* g_code_inov in Q12 */
+
+ /*
+ * Case of erasure.
+ */
+ if(bfi != 0)
+ {
+ tmp = D_GAIN_median(&pbuf[2]);
+ *past_gain_pit = tmp;
+
+ if(*past_gain_pit > 15565)
+ {
+ *past_gain_pit = 15565; /* 0.95 in Q14 */
+ }
+
+ if(unusable_frame != 0)
+ {
+ *gain_pit =
+ (Word16)((D_ROM_pdown_unusable[state] * *past_gain_pit) >> 15);
+ }
+ else
+ {
+ *gain_pit =
+ (Word16)((D_ROM_pdown_usable[state] * *past_gain_pit) >> 15);
+ }
+
+ tmp = D_GAIN_median(&gbuf[2]);
+
+ if(vad_hist > 2)
+ {
+ *past_gain_code = tmp;
+ }
+ else
+ {
+ if(unusable_frame != 0)
+ {
+ *past_gain_code =
+ (Word16)((D_ROM_cdown_unusable[state] * tmp) >> 15);
+ }
+ else
+ {
+ *past_gain_code =
+ (Word16)((D_ROM_cdown_usable[state] * tmp) >> 15);
+ }
+ }
+
+ /* update table of past quantized energies */
+ L_tmp = past_qua_en[0] + past_qua_en[1]+ past_qua_en[2] + past_qua_en[3];
+ qua_ener = L_tmp >> 2;
+ qua_ener = qua_ener - 3072; /* -3 in Q10 */
+
+ if(qua_ener < - 14336)
+ {
+ qua_ener = -14336; /* -14 in Q10 */
+ }
+
+ past_qua_en[3] = past_qua_en[2];
+ past_qua_en[2] = past_qua_en[1];
+ past_qua_en[1] = past_qua_en[0];
+ past_qua_en[0] = (Word16)qua_ener;
+
+ for(i = 1; i < 5; i++)
+ {
+ gbuf[i - 1] = gbuf[i];
+ }
+ gbuf[4] = *past_gain_code;
+
+ for(i = 1; i < 5; i++)
+ {
+ pbuf[i - 1] = pbuf[i];
+ }
+ pbuf[4] = *past_gain_pit;
+
+ /* adjust gain according to energy of code */
+ /* past_gain_code(Q3) * gcode_inov(Q12) => Q16 */
+ *gain_cod = (*past_gain_code * gcode_inov) << 1;
+
+ return;
+ }
+
+ /*
+ * Compute gcode0.
+ * = Sum(i=0,1) pred[i]*past_qua_en[i] + mean_ener - ener_code
+ */
+
+ /* MEAN_ENER in Q24 = 0x1e000000 */
+ /* MA prediction coeff = {0.5, 0.4, 0.3, 0.2} in Q13 */
+ L_tmp = 0xF000000 + (4096 * past_qua_en[0]); /* Q13*Q10 -> Q24 */
+ L_tmp = L_tmp + (3277 * past_qua_en[1]); /* Q13*Q10 -> Q24 */
+ L_tmp = L_tmp + (2458 * past_qua_en[2]); /* Q13*Q10 -> Q24 */
+ L_tmp = L_tmp + (1638 * past_qua_en[3]); /* Q13*Q10 -> Q24 */
+ gcode0 = L_tmp >> 15; /* From Q24 to Q8 */
+
+ /*
+ * gcode0 = pow(10.0, gcode0/20)
+ * = pow(2, 3.321928*gcode0/20)
+ * = pow(2, 0.166096*gcode0)
+ */
+ L_tmp = (gcode0 * 5443) >> 7;
+ /* *0.166096 in Q15 -> Q24, From Q24 to Q16 */
+ D_UTIL_l_extract(L_tmp, &exp_gcode0, &frac);
+ /* Extract exponant of gcode0 */
+ gcode0 = D_UTIL_pow2(14, frac); /* Put 14 as exponant so that */
+
+ /*
+ * output of Pow2() will be:
+ * 16384 < Pow2() <= 32767
+ */
+ exp_gcode0 = (Word16)(exp_gcode0 - 14);
+
+ /* Read the quantized gains */
+ if(nbits == 6)
+ {
+ p = &D_ROM_qua_gain6b[(index << 1)];
+ }
+ else
+ {
+ p = &D_ROM_qua_gain7b[(index << 1)];
+ }
+
+ *gain_pit = *p++; /* selected pitch gain in Q14 */
+ g_code = *p++; /* selected code gain in Q11 */
+ L_tmp = g_code * gcode0;
+ exp_gcode0 += 5;
+
+ if(exp_gcode0 >= 0)
+ {
+ *gain_cod = L_tmp << exp_gcode0; /* gain of code in Q16 */
+ }
+ else
+ {
+ *gain_cod = L_tmp >> -exp_gcode0; /* gain of code in Q16 */
+ }
+
+ if(prev_bfi == 1)
+ {
+ L_tmp = (*prev_gc * 5120) << 1; /* prev_gc(Q3) * 1.25(Q12) = Q16 */
+
+ /* if((*gain_cod > ((*prev_gc) * 1.25)) && (*gain_cod > 100.0)) */
+ if((*gain_cod > L_tmp) & (*gain_cod > 6553600))
+ {
+ *gain_cod = L_tmp;
+ }
+ }
+
+ /* keep past gain code in Q3 for frame erasure (can saturate) */
+ L_tmp = (*gain_cod + 0x1000) >> 13;
+
+ if(L_tmp < 32768)
+ {
+ *past_gain_code = (Word16)L_tmp;
+ }
+ else
+ {
+ *past_gain_code = 32767;
+ }
+
+ *past_gain_pit = *gain_pit;
+ *prev_gc = *past_gain_code;
+
+ for(i = 1; i < 5; i++)
+ {
+ gbuf[i - 1] = gbuf[i];
+ }
+ gbuf[4] = *past_gain_code;
+
+ for(i = 1; i < 5; i++)
+ {
+ pbuf[i - 1] = pbuf[i];
+ }
+ pbuf[4] = *past_gain_pit;
+
+ for(i = 1; i < 5; i++)
+ {
+ pbuf2[i - 1] = pbuf2[i];
+ }
+ pbuf2[4] = *past_gain_pit;
+
+ /* adjust gain according to energy of code */
+ D_UTIL_l_extract(*gain_cod, &exp, &frac);
+ L_tmp = D_UTIL_mpy_32_16(exp, frac, gcode_inov);
+
+ if(L_tmp < 0xFFFFFFF)
+ {
+ *gain_cod = (L_tmp << 3); /* gcode_inov in Q12 */
+ }
+ else
+ {
+ *gain_cod = 0x7FFFFFFF;
+ }
+
+ /*
+ * qua_ener = 20*log10(g_code)
+ * = 6.0206*log2(g_code)
+ * = 6.0206*(log2(g_codeQ11) - 11)
+ */
+ L_tmp = (Word32)(g_code);
+ D_UTIL_log2(L_tmp, &exp, &frac);
+ exp = (Word16)(exp - 11);
+ L_tmp = D_UTIL_mpy_32_16(exp, frac, 24660); /* x 6.0206 in Q12 */
+ qua_ener = L_tmp >>3; /* result in Q10 */
+
+ /* update table of past quantized energies */
+ past_qua_en[3] = past_qua_en[2];
+ past_qua_en[2] = past_qua_en[1];
+ past_qua_en[1] = past_qua_en[0];
+ past_qua_en[0] = (Word16)qua_ener;
+
+ return;
+}
+
+
+/*
+ * D_GAIN_adaptive_control
+ *
+ * Parameters:
+ * sig_in I: postfilter input signal
+ * sig_out I/O: postfilter output signal
+ * l_trm I: subframe size
+ *
+ * Function:
+ * Adaptive gain control is used to compensate for
+ * the gain difference between the non-emphasized excitation and
+ * emphasized excitation.
+ *
+ * Returns:
+ * void
+ */
+void D_GAIN_adaptive_control(Word16 *sig_in, Word16 *sig_out, Word16 l_trm)
+{
+ Word32 s, temp, i, exp;
+ Word32 gain_in, gain_out, g0;
+
+ /* calculate gain_out with exponent */
+ temp = sig_out[0] >> 2;
+ s = temp * temp;
+
+ for(i = 1; i < l_trm; i++)
+ {
+ temp = sig_out[i] >> 2;
+ s += temp * temp;
+ }
+
+ s <<= 1;
+
+ if(s == 0)
+ {
+ return;
+ }
+ exp = (D_UTIL_norm_l(s) - 1);
+
+ if(exp >= 0)
+ {
+ gain_out = ((s << exp) + 0x8000) >> 16;
+ }
+ else
+ {
+ gain_out = ((s >> -exp) + 0x8000) >> 16;
+ }
+
+ /* calculate gain_in with exponent */
+ temp = sig_in[0] >> 2;
+ s = temp * temp;
+
+ for(i = 1; i < l_trm; i++)
+ {
+ temp = sig_in[i] >> 2;
+ s += temp * temp;
+ }
+
+ s <<= 1;
+
+ if(s == 0)
+ {
+ g0 = 0;
+ }
+ else
+ {
+ i = D_UTIL_norm_l(s);
+ s = ((s << i) + 0x8000) >> 16;
+
+ if((s < 32768) & (s > 0))
+ {
+ gain_in = s;
+ }
+ else
+ {
+ gain_in = 32767;
+ }
+ exp = exp - i;
+
+ /*
+ * g0 = sqrt(gain_in/gain_out)
+ */
+ s = (gain_out << 15) / gain_in;
+ s = s << (7 - exp); /* s = gain_out / gain_in */
+ s = D_UTIL_inverse_sqrt(s);
+ g0 = ((s << 9) + 0x8000) >> 16;
+ }
+
+ /* sig_out(n) = gain(n) sig_out(n) */
+ for(i = 0; i < l_trm; i++)
+ {
+ s = (sig_out[i] * g0) >> 13;
+ sig_out[i] = D_UTIL_saturate(s);
+ }
+
+ return;
+}
+
+
+/*
+ * D_GAIN_insert_lag
+ *
+ * Parameters:
+ * array I/O: pitch lag history
+ * n I: history size
+ * x I: lag value
+ *
+ * Function:
+ * Insert lag into correct location
+ *
+ * Returns:
+ * void
+ */
+static void D_GAIN_insert_lag(Word16 array[], Word32 n, Word16 x)
+{
+ Word32 i;
+
+ for(i = n - 1; i >= 0; i--)
+ {
+ if(x < array[i])
+ {
+ array[i + 1] = array[i];
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ array[i + 1] = x;
+}
+
+
+/*
+ * D_GAIN_sort_lag
+ *
+ * Parameters:
+ * array I/O: pitch lag history
+ * n I: history size
+ *
+ * Function:
+ * Sorting of the lag history
+ *
+ * Returns:
+ * void
+ */
+static void D_GAIN_sort_lag(Word16 array[], Word16 n)
+{
+ Word32 i;
+
+ for(i = 0; i < n; i++)
+ {
+ D_GAIN_insert_lag(array, i, array[i]);
+ }
+}
+
+
+/*
+ * D_GAIN_lag_concealment_init
+ *
+ * Parameters:
+ * lag_hist O: pitch lag history
+ *
+ * Function:
+ * Initialise lag history to 64
+ *
+ * Returns:
+ * void
+ */
+void D_GAIN_lag_concealment_init(Word16 lag_hist[])
+{
+ Word32 i;
+
+ for(i = 0; i < L_LTPHIST; i++)
+ {
+ lag_hist[i] = 64;
+ }
+}
+
+
+/*
+ * D_GAIN_lag_concealment
+ *
+ * Parameters:
+ * gain_hist I: gain history
+ * lag_hist I: pitch lag history
+ * T0 O: current lag
+ * old_T0 I: previous lag
+ * seed I/O: seed for random
+ * unusable_frame I: lost frame
+ *
+ * Function:
+ * Concealment of LTP lags during bad frames
+ *
+ * Returns:
+ * void
+ */
+void D_GAIN_lag_concealment(Word16 gain_hist[], Word16 lag_hist[],
+ Word32 *T0, Word16 *old_T0, Word16 *seed,
+ Word16 unusable_frame)
+{
+ Word32 i, lagDif, tmp, tmp2, D2, meanLag = 0;
+ Word16 lag_hist2[L_LTPHIST] = {0};
+ Word16 maxLag, minLag, lastLag;
+ Word16 minGain, lastGain, secLastGain;
+ Word16 D;
+
+ /*
+ * Is lag index such that it can be aplied directly
+ * or does it has to be subtituted
+ */
+ lastGain = gain_hist[4];
+ secLastGain = gain_hist[3];
+ lastLag = lag_hist[0];
+
+ /* SMALLEST history lag */
+ minLag = lag_hist[0];
+
+ for(i = 1; i < L_LTPHIST; i++)
+ {
+ if(lag_hist[i] < minLag)
+ {
+ minLag = lag_hist[i];
+ }
+ }
+
+ /* BIGGEST history lag */
+ maxLag = lag_hist[0];
+
+ for(i = 1; i < L_LTPHIST; i++)
+ {
+ if(lag_hist[i] > maxLag)
+ {
+ maxLag = lag_hist[i];
+ }
+ }
+
+ /* SMALLEST history gain */
+ minGain = gain_hist[0];
+
+ for(i = 1; i < L_LTPHIST; i++)
+ {
+ if(gain_hist[i] < minGain)
+ {
+ minGain = gain_hist[i];
+ }
+ }
+
+ /* Difference between MAX and MIN lag */
+ lagDif = maxLag - minLag;
+
+ if(unusable_frame != 0)
+ {
+ /*
+ * LTP-lag for RX_SPEECH_LOST
+ * Recognition of the LTP-history
+ */
+ if((minGain > 8192) & (lagDif < 10))
+ {
+ *T0 = *old_T0;
+ }
+ else if((lastGain > 8192) && (secLastGain > 8192))
+ {
+ *T0 = lag_hist[0];
+ }
+ else
+ {
+ /*
+ * SORT
+ * The sorting of the lag history
+ */
+ for(i = 0; i < L_LTPHIST; i++)
+ {
+ lag_hist2[i] = lag_hist[i];
+ }
+ D_GAIN_sort_lag(lag_hist2, 5);
+
+ /*
+ * Lag is weighted towards bigger lags
+ * and random variation is added
+ */
+ lagDif = (lag_hist2[4] - lag_hist2[2]);
+
+ if(lagDif > 40)
+ {
+ lagDif = 40;
+ }
+
+ D = D_UTIL_random(seed); /* D={-1, ...,1} */
+
+ /* D2={-lagDif/2..lagDif/2} */
+ tmp = lagDif >> 1;
+ D2 = (tmp * D) >> 15;
+ tmp = (lag_hist2[2] + lag_hist2[3]) + lag_hist2[4];
+ *T0 = ((tmp * ONE_PER_3) >> 15) + D2;
+ }
+
+ /* New lag is not allowed to be bigger or smaller than last lag values */
+ if(*T0 > maxLag)
+ {
+ *T0 = maxLag;
+ }
+
+ if(*T0 < minLag)
+ {
+ *T0 = minLag;
+ }
+ }
+ else
+ {
+ /*
+ * LTP-lag for RX_BAD_FRAME
+ * MEAN lag
+ */
+ meanLag = 0;
+
+ for(i = 0; i < L_LTPHIST; i++)
+ {
+ meanLag = meanLag + lag_hist[i];
+ }
+
+ meanLag = (meanLag * ONE_PER_LTPHIST) >> 15;
+ tmp = *T0 - maxLag;
+ tmp2 = *T0 - lastLag;
+
+ if((lagDif < 10) & (*T0 > (minLag - 5)) & (tmp < 5))
+ {
+ *T0 = *T0;
+ }
+ else if((lastGain > 8192) & (secLastGain > 8192) & ((tmp2 > - 10)
+ & (tmp2 < 10)))
+ {
+ *T0 = *T0;
+ }
+ else if((minGain < 6554) & (lastGain == minGain) & ((*T0 > minLag)
+ & (*T0 < maxLag)))
+ {
+ *T0 = *T0;
+ }
+ else if((lagDif < 70) & (*T0 > minLag) & (*T0 < maxLag))
+ {
+ *T0 = *T0;
+ }
+ else if((*T0 > meanLag) & (*T0 < maxLag))
+ {
+ *T0 = *T0;
+ }
+ else
+ {
+ if((minGain > 8192) & (lagDif < 10))
+ {
+ *T0 = lag_hist[0];
+ }
+ else if((lastGain > 8192) & (secLastGain > 8192))
+ {
+ *T0 = lag_hist[0];
+ }
+ else
+ {
+ /*
+ * SORT
+ * The sorting of the lag history
+ */
+ for(i = 0; i < L_LTPHIST; i++)
+ {
+ lag_hist2[i] = lag_hist[i];
+ }
+
+ D_GAIN_sort_lag(lag_hist2, 5);
+
+ /*
+ * Lag is weighted towards bigger lags
+ * and random variation is added
+ */
+ lagDif = lag_hist2[4] - lag_hist2[2];
+
+ if(lagDif > 40)
+ {
+ lagDif = 40;
+ }
+
+ D = D_UTIL_random(seed); /* D={-1,.., 1} */
+
+ /* D2={-lagDif/2..lagDif/2} */
+ tmp = lagDif >> 1;
+ D2 = (tmp * D) >> 15;
+ tmp = (lag_hist2[2] + lag_hist2[3]) + lag_hist2[4];
+ *T0 = ((tmp * ONE_PER_3) >> 15) + D2;
+ }
+
+ /*
+ * New lag is not allowed to be bigger or
+ * smaller than last lag values
+ */
+ if(*T0 > maxLag)
+ {
+ *T0 = maxLag;
+ }
+
+ if(*T0 < minLag)
+ {
+ *T0 = minLag;
+ }
+ }
+ }
+}
+
+
+/*
+ * D_GAIN_adaptive_codebook_excitation
+ *
+ * Parameters:
+ * exc I/O: excitation buffer
+ * T0 I: integer pitch lag
+ * frac I: fraction of lag
+ *
+ * Function:
+ * Compute the result of Word32 term prediction with fractional
+ * interpolation of resolution 1/4.
+ *
+ * Returns:
+ * interpolated signal (adaptive codebook excitation)
+ */
+void D_GAIN_adaptive_codebook_excitation(Word16 exc[], Word32 T0, Word32 frac)
+{
+ Word32 i, j, k, sum;
+ Word16 *x;
+
+ x = &exc[ - T0];
+ frac = -(frac);
+
+ if(frac < 0)
+ {
+ frac = (frac + UP_SAMP);
+ x--;
+ }
+ x = x - L_INTERPOL2 + 1;
+
+ for(j = 0; j < L_SUBFR + 1; j++)
+ {
+ sum = 0L;
+
+ for(i = 0, k = ((UP_SAMP - 1) - frac); i < 2 * L_INTERPOL2; i++,
+ k += UP_SAMP)
+ {
+ sum += x[i] * D_ROM_inter4_2[k];
+ }
+ sum = (sum + 0x2000) >> 14;
+
+ exc[j] = D_UTIL_saturate(sum);
+
+ x++;
+ }
+ return;
+}
+
+
+/*
+ * D_GAIN_pitch_sharpening
+ *
+ * Parameters:
+ * x I/O: impulse response (or algebraic code)
+ * pit_lag I: pitch lag
+ * sharp I: (Q15) pitch sharpening factor
+ *
+ * Function:
+ * Performs Pitch sharpening routine for one subframe.
+ *
+ * Returns:
+ * void
+ */
+void D_GAIN_pitch_sharpening(Word16 *x, Word32 pit_lag, Word16 sharp)
+{
+ Word32 i;
+ Word32 tmp;
+
+ for(i = pit_lag; i < L_SUBFR; i++)
+ {
+ tmp = x[i] << 15;
+ tmp += x[i - pit_lag] * sharp;
+ x[i] = (Word16)((tmp + 0x4000) >> 15);
+ }
+ return;
+}
+
+
+/*
+ * D_GAIN_find_voice_factor
+ *
+ * Parameters:
+ * exc I: pitch excitation
+ * Q_exc I: exc format
+ * gain_pit I: (Q14) gain of pitch
+ * code I: (Q9) fixed codebook excitation
+ * gain_code I: (Q0) gain of code
+ * L_subfr I: subframe length
+ *
+ * Function:
+ * Find the voicing factor.
+ *
+ * Returns:
+ * (Q15) 1=voice to -1=unvoiced
+ */
+Word16 D_GAIN_find_voice_factor(Word16 exc[], Word16 Q_exc,
+ Word16 gain_pit, Word16 code[],
+ Word16 gain_code, Word16 L_subfr)
+{
+
+ Word32 tmp, ener1, ener2, i;
+ Word16 exp, exp1, exp2;
+
+ ener1 = (D_UTIL_dot_product12(exc, exc, L_subfr, &exp1)) >> 16;
+ exp1 = (Word16)(exp1 - (Q_exc + Q_exc));
+ tmp = (gain_pit * gain_pit) << 1;
+ exp = D_UTIL_norm_l(tmp);
+ tmp = (tmp << exp) >> 16;
+ ener1 = (ener1 * tmp) >> 15;
+ exp1 = (Word16)((exp1 - exp) - 10); /* 10 -> gain_pit Q14 to Q9 */
+ ener2 = D_UTIL_dot_product12(code, code, L_subfr, &exp2) >> 16;
+ exp = D_UTIL_norm_s(gain_code);
+ tmp = gain_code << exp;
+ tmp = (tmp * tmp) >> 15;
+ ener2 = (ener2 * tmp) >> 15;
+ exp2 = (Word16)(exp2 - (exp << 1));
+ i = exp1 - exp2;
+
+ if(i >= 0)
+ {
+ ener1 = ener1 >> 1;
+ ener2 = ener2 >> (i + 1);
+ }
+ else if(i > (-16))
+ {
+ ener1 = ener1 >> (1 - i);
+ ener2 = ener2 >> 1;
+ }
+ else
+ {
+ ener1 = 0;
+ ener2 = ener2 >> 1;
+ }
+
+ tmp = ener1 - ener2;
+ ener1 = (ener1 + ener2) + 1;
+ tmp = (tmp << 15) / ener1;
+
+ return((Word16)tmp);
+}
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_gain.h b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_gain.h
new file mode 100644
index 000000000..99164686c
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_gain.h
@@ -0,0 +1,28 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef DEC_GAIN_H
+#define DEC_GAIN_H
+
+#include "typedef.h"
+
+void D_GAIN_init(Word16 *mem);
+void D_GAIN_decode(Word16 index, Word16 nbits, Word16 code[], Word16 *gain_pit,
+ Word32 *gain_cod, Word16 bfi, Word16 prev_bfi,
+ Word16 state, Word16 unusable_frame, Word16 vad_hist,
+ Word16 *mem);
+void D_GAIN_adaptive_control(Word16 *sig_in, Word16 *sig_out, Word16 l_trm);
+void D_GAIN_lag_concealment_init(Word16 lag_hist[]);
+void D_GAIN_lag_concealment(Word16 gain_hist[], Word16 lag_hist[], Word32 *T0,
+ Word16 *old_T0, Word16 *seed,
+ Word16 unusable_frame);
+void D_GAIN_adaptive_codebook_excitation(Word16 exc[], Word32 T0, Word32 frac);
+void D_GAIN_pitch_sharpening(Word16 *x, Word32 pit_lag, Word16 sharp);
+Word16 D_GAIN_find_voice_factor(Word16 exc[], Word16 Q_exc, Word16 gain_pit,
+ Word16 code[], Word16 gain_code,
+ Word16 L_subfr);
+
+#endif
+
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_if.c b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_if.c
new file mode 100644
index 000000000..4210fc99f
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_if.c
@@ -0,0 +1,970 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#include <stdlib.h>
+#include <memory.h>
+#include "typedef.h"
+#include "dec_if.h"
+#include "if_rom.h"
+#include "dec.h"
+
+#define L_FRAME16k 320 /* Frame size at 16kHz */
+#define MODE_7k 0 /* modes */
+#define MODE_9k 1
+#define MODE_12k 2
+#define MODE_14k 3
+#define MODE_16k 4
+#define MODE_18k 5
+#define MODE_20k 6
+#define MODE_23k 7
+#define MODE_24k 8
+#define MRDTX 9
+#define NUM_OF_MODES 10
+#define LOST_FRAME 14
+#define MRNO_DATA 15
+#define EHF_MASK (Word16)0x0008 /* homing frame pattern */
+
+typedef struct
+{
+ Word16 reset_flag_old; /* previous was homing frame */
+ Word16 prev_ft; /* previous frame type */
+ Word16 prev_mode; /* previous mode */
+ void *decoder_state; /* Points decoder state */
+} WB_dec_if_state;
+
+Word16 nb_of_param_first[NUM_OF_SPMODES]=
+{
+ 9, 14, 15,
+ 15, 15, 19,
+ 19, 19, 19
+};
+
+extern const Word16 mode_7k[];
+extern const Word16 mode_9k[];
+extern const Word16 mode_12k[];
+extern const Word16 mode_14k[];
+extern const Word16 mode_16k[];
+extern const Word16 mode_18k[];
+extern const Word16 mode_20k[];
+extern const Word16 mode_23k[];
+extern const Word16 mode_24k[];
+extern const Word16 mode_DTX[];
+
+extern const Word16 nb_of_param[];
+
+extern const Word16 dfh_M7k[];
+extern const Word16 dfh_M9k[];
+extern const Word16 dfh_M12k[];
+extern const Word16 dfh_M14k[];
+extern const Word16 dfh_M16k[];
+extern const Word16 dfh_M18k[];
+extern const Word16 dfh_M20k[];
+extern const Word16 dfh_M23k[];
+extern const Word16 dfh_M24k[];
+
+/* overall table with the parameters of the
+ decoder homing frames for all modes */
+
+extern const Word16 *dhf[10];
+
+/*
+ * Decoder_Interface_Homing_Frame_test
+ *
+ * Parameters:
+ * input_frame I: input parameters
+ * mode I: speech mode
+ *
+ * Function:
+ * Check parameters for matching homing frame
+ *
+ * Returns:
+ * If homing frame
+ */
+Word16 D_IF_homing_frame_test(Word16 input_frame[], Word16 mode)
+{
+
+ if (mode != MODE_24k)
+ {
+ /* perform test for COMPLETE parameter frame */
+ return (Word16)!memcmp(input_frame, dhf[mode], nb_of_param[mode] * sizeof(Word16));
+ }
+ else
+ {
+ /* discard high-band energy */
+ return (Word16)!(
+ (memcmp(input_frame, dhf[MODE_24k], 19 * sizeof(Word16))) |
+ (memcmp(input_frame + 20, dhf[MODE_24k] + 20, 11 * sizeof(Word16))) |
+ (memcmp(input_frame + 32, dhf[MODE_24k] + 32, 11 * sizeof(Word16))) |
+ (memcmp(input_frame + 44, dhf[MODE_24k] + 44, 11 * sizeof(Word16))) );
+
+ }
+}
+
+
+Word16 D_IF_homing_frame_test_first(Word16 input_frame[], Word16 mode)
+{
+ /* perform test for FIRST SUBFRAME of parameter frame ONLY */
+ return (Word16)!memcmp(input_frame, dhf[mode], nb_of_param_first[mode] * sizeof(Word16));
+}
+
+#ifdef IF2
+/*
+ * D_IF_conversion
+ *
+ *
+ * Parameters:
+ * param O: AMR parameters
+ * stream I: input bitstream
+ * frame_type O: frame type
+ * speech_mode O: speech mode in DTX
+ * fqi O: frame quality indicator
+ *
+ * Function:
+ * Unpacks IF2 octet stream
+ *
+ * Returns:
+ * mode used mode
+ */
+Word16 D_IF_conversion(Word16 *param, UWord8 *stream, UWord8 *frame_type,
+ Word16 *speech_mode, Word16 *fqi)
+{
+ Word32 mode;
+ Word32 j;
+ Word16 const *mask;
+
+ memset(param, 0, PRMNO_24k << 1);
+ mode = *stream >> 4;
+ /* SID indication IF2 corresponds to mode 10 */
+ if (mode == 9)
+ {
+ mode ++;
+ }
+
+ *fqi = (Word16)((*stream >> 3) & 0x1);
+ *stream <<= (HEADER_SIZE - 1);
+
+ switch (mode)
+ {
+ case MRDTX:
+ mask = mode_DTX;
+
+ for (j = HEADER_SIZE; j < T_NBBITS_SID; j++)
+ {
+ if (*stream & 0x80)
+ {
+ param[*mask] = (Word16)(param[*mask] + *(mask + 1));
+ }
+
+ mask += 2;
+
+ if ( j % 8 )
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ /* get SID type bit */
+
+ *frame_type = RX_SID_FIRST;
+
+ if (*stream & 0x80)
+ {
+ *frame_type = RX_SID_UPDATE;
+ }
+
+ *stream <<= 1;
+
+ /* speech mode indicator */
+ *speech_mode = (Word16)(*stream >> 4);
+ break;
+
+ case MRNO_DATA:
+ *frame_type = RX_NO_DATA;
+ break;
+
+ case LOST_FRAME:
+ *frame_type = RX_SPEECH_LOST;
+ break;
+
+ case MODE_7k:
+ mask = mode_7k;
+
+ for (j = HEADER_SIZE; j < T_NBBITS_7k; j++)
+ {
+ if ( *stream & 0x80 )
+ {
+ param[*mask] = (Word16)(param[*mask] + *(mask + 1));
+ }
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_9k:
+ mask = mode_9k;
+
+ for (j = HEADER_SIZE; j < T_NBBITS_9k; j++)
+ {
+ if (*stream & 0x80)
+ {
+ param[*mask] = (Word16)(param[*mask] + *(mask + 1));
+ }
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_12k:
+ mask = mode_12k;
+
+ for (j = HEADER_SIZE; j < T_NBBITS_12k; j++)
+ {
+ if (*stream & 0x80)
+ {
+ param[*mask] = (Word16)(param[*mask] + *(mask + 1));
+ }
+ mask += 2;
+
+ if ( j % 8 )
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_14k:
+ mask = mode_14k;
+
+ for (j = HEADER_SIZE; j < T_NBBITS_14k; j++)
+ {
+ if (*stream & 0x80)
+ {
+ param[*mask] = (Word16)(param[*mask] + *(mask + 1));
+ }
+
+ mask += 2;
+
+ if ( j % 8 )
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_16k:
+ mask = mode_16k;
+
+ for (j = HEADER_SIZE; j < T_NBBITS_16k; j++)
+ {
+ if (*stream & 0x80)
+ {
+ param[*mask] = (Word16)(param[*mask] + *(mask + 1));
+ }
+
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_18k:
+ mask = mode_18k;
+
+ for (j = HEADER_SIZE; j < T_NBBITS_18k; j++)
+ {
+ if (*stream & 0x80)
+ {
+ param[*mask] = (Word16)(param[*mask] + *(mask + 1));
+ }
+
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_20k:
+ mask = mode_20k;
+
+ for (j = HEADER_SIZE; j < T_NBBITS_20k; j++)
+ {
+ if (*stream & 0x80)
+ {
+ param[*mask] = (Word16)(param[*mask] + *(mask + 1));
+ }
+
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_23k:
+ mask = mode_23k;
+
+ for (j = HEADER_SIZE; j < T_NBBITS_23k; j++)
+ {
+ if (*stream & 0x80)
+ {
+ param[*mask] = (Word16)(param[*mask] + *(mask + 1));
+ }
+
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_24k:
+ mask = mode_24k;
+
+ for (j = HEADER_SIZE; j < T_NBBITS_24k; j++)
+ {
+ if (*stream & 0x80)
+ {
+ param[*mask] = (Word16)(param[*mask] + *(mask + 1));
+ }
+
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ default:
+ *frame_type = RX_SPEECH_LOST;
+ *fqi = 0;
+ break;
+
+ }
+
+ if (*fqi == 0)
+ {
+ if (*frame_type == RX_SPEECH_GOOD)
+ {
+ *frame_type = RX_SPEECH_BAD;
+ }
+ if ((*frame_type == RX_SID_FIRST) | (*frame_type == RX_SID_UPDATE))
+ {
+ *frame_type = RX_SID_BAD;
+ }
+ }
+
+ return (Word16)mode;
+}
+
+#else
+
+/*
+ * D_IF_mms_conversion
+ *
+ *
+ * Parameters:
+ * param O: AMR parameters
+ * stream I: input bitstream
+ * frame_type O: frame type
+ * speech_mode O: speech mode in DTX
+ * fqi O: frame quality indicator
+ *
+ * Function:
+ * Unpacks MMS formatted octet stream (see RFC 3267, section 5.3)
+ *
+ * Returns:
+ * mode used mode
+ */
+Word16 D_IF_mms_conversion(Word16 *param, UWord8 *stream, UWord8 *frame_type,
+ Word16 *speech_mode, Word16 *fqi)
+{
+ Word32 mode;
+ Word32 j;
+ Word16 const *mask;
+
+ memset(param, 0, PRMNO_24k << 1);
+
+ *fqi = (Word16)((*stream >> 2) & 0x01);
+ mode = (Word32)((*stream >> 3) & 0x0F);
+
+ /* SID indication IF2 corresponds to mode 10 */
+ if (mode == 9)
+ {
+ mode ++;
+ }
+
+ stream++;
+
+ switch (mode)
+ {
+ case MRDTX:
+ mask = mode_DTX;
+
+ for (j = 1; j <= NBBITS_SID; j++)
+ {
+ if (*stream & 0x80)
+ {
+ param[*mask] = (Word16)(param[*mask] + *(mask + 1));
+ }
+
+ mask += 2;
+
+ if ( j % 8 )
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ /* get SID type bit */
+
+ *frame_type = RX_SID_FIRST;
+
+ if (*stream & 0x80)
+ {
+ *frame_type = RX_SID_UPDATE;
+ }
+
+ *stream <<= 1;
+
+ /* speech mode indicator */
+ *speech_mode = (Word16)(*stream >> 4);
+ break;
+
+ case MRNO_DATA:
+ *frame_type = RX_NO_DATA;
+ break;
+
+ case LOST_FRAME:
+ *frame_type = RX_SPEECH_LOST;
+ break;
+
+ case MODE_7k:
+ mask = mode_7k;
+
+ for (j = 1; j <= NBBITS_7k; j++)
+ {
+ if ( *stream & 0x80 )
+ {
+ param[*mask] = (Word16)(param[*mask] + *(mask + 1));
+ }
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_9k:
+ mask = mode_9k;
+
+ for (j = 1; j <= NBBITS_9k; j++)
+ {
+ if (*stream & 0x80)
+ {
+ param[*mask] = (Word16)(param[*mask] + *(mask + 1));
+ }
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_12k:
+ mask = mode_12k;
+
+ for (j = 1; j <= NBBITS_12k; j++)
+ {
+ if (*stream & 0x80)
+ {
+ param[*mask] = (Word16)(param[*mask] + *(mask + 1));
+ }
+ mask += 2;
+
+ if ( j % 8 )
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_14k:
+ mask = mode_14k;
+
+ for (j = 1; j <= NBBITS_14k; j++)
+ {
+ if (*stream & 0x80)
+ {
+ param[*mask] = (Word16)(param[*mask] + *(mask + 1));
+ }
+
+ mask += 2;
+
+ if ( j % 8 )
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_16k:
+ mask = mode_16k;
+
+ for (j = 1; j <= NBBITS_16k; j++)
+ {
+ if (*stream & 0x80)
+ {
+ param[*mask] = (Word16)(param[*mask] + *(mask + 1));
+ }
+
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_18k:
+ mask = mode_18k;
+
+ for (j = 1; j <= NBBITS_18k; j++)
+ {
+ if (*stream & 0x80)
+ {
+ param[*mask] = (Word16)(param[*mask] + *(mask + 1));
+ }
+
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_20k:
+ mask = mode_20k;
+
+ for (j = 1; j <= NBBITS_20k; j++)
+ {
+ if (*stream & 0x80)
+ {
+ param[*mask] = (Word16)(param[*mask] + *(mask + 1));
+ }
+
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_23k:
+ mask = mode_23k;
+
+ for (j = 1; j <= NBBITS_23k; j++)
+ {
+ if (*stream & 0x80)
+ {
+ param[*mask] = (Word16)(param[*mask] + *(mask + 1));
+ }
+
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ case MODE_24k:
+ mask = mode_24k;
+
+ for (j = 1; j <= NBBITS_24k; j++)
+ {
+ if (*stream & 0x80)
+ {
+ param[*mask] = (Word16)(param[*mask] + *(mask + 1));
+ }
+
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+
+ }
+
+ *frame_type = RX_SPEECH_GOOD;
+ break;
+
+ default:
+ *frame_type = RX_SPEECH_LOST;
+ *fqi = 0;
+ break;
+
+ }
+
+ if (*fqi == 0)
+ {
+ if (*frame_type == RX_SPEECH_GOOD)
+ {
+ *frame_type = RX_SPEECH_BAD;
+ }
+ if ((*frame_type == RX_SID_FIRST) | (*frame_type == RX_SID_UPDATE))
+ {
+ *frame_type = RX_SID_BAD;
+ }
+ }
+
+ return (Word16)mode;
+}
+
+#endif
+
+/*
+ * D_IF_decode
+ *
+ *
+ * Parameters:
+ * st B: pointer to state structure
+ * bits I: bitstream form the encoder
+ * synth O: decoder output
+ * lfi I: lost frame indicator
+ * _good_frame, _bad_frame, _lost_frame, _no_frame
+ *
+ * Function:
+ * Decoding one frame of speech. Lost frame indicator can be used
+ * to inform encoder about the problems in the received frame.
+ * _good_frame:good speech or sid frame is received.
+ * _bad_frame: frame with possible bit errors
+ * _lost_frame:speech of sid frame is lost in transmission
+ * _no_frame: indicates non-received frames in dtx-operation
+ * Returns:
+ *
+ */
+void D_IF_decode( void *st, UWord8 *bits, Word16 *synth, Word32 lfi)
+{
+ Word32 i;
+ Word16 mode = 0; /* AMR mode */
+ Word16 speech_mode = MODE_7k; /* speech mode */
+ Word16 fqi; /* frame quality indicator */
+
+ Word16 prm[PRMNO_24k]; /* AMR parameters */
+
+ UWord8 frame_type; /* frame type */
+ Word16 reset_flag = 0; /* reset flag */
+ WB_dec_if_state * s; /* pointer to structure */
+
+ s = (WB_dec_if_state*)st;
+
+ /* bits -> param, if needed */
+ if ((lfi == _good_frame) | (lfi == _bad_frame))
+ {
+ /* add fqi data */
+#ifdef IF2
+ *bits = (UWord8)((Word32)*bits & ~(lfi << 3));
+#else
+ *bits = (UWord8)((Word32)*bits & ~(lfi << 2));
+#endif
+ /*
+ * extract mode information and frame_type,
+ * octets to parameters
+ */
+#ifdef IF2
+ mode = D_IF_conversion( prm, bits, &frame_type, &speech_mode, &fqi);
+#else
+ mode = D_IF_mms_conversion( prm, bits, &frame_type, &speech_mode, &fqi);
+#endif
+
+ }
+ else if (lfi == _no_frame)
+ {
+ frame_type = RX_NO_DATA;
+ }
+ else
+ {
+ frame_type = RX_SPEECH_LOST;
+ }
+
+ /*
+ * if no mode information
+ * guess one from the previous frame
+ */
+ if ((frame_type == RX_SPEECH_LOST) | (frame_type == RX_NO_DATA))
+ {
+ mode = s->prev_mode;
+ }
+
+ if (mode == MRDTX)
+ {
+ mode = speech_mode;
+ }
+
+ /* if homed: check if this frame is another homing frame */
+ if (s->reset_flag_old == 1)
+ {
+ /* only check until end of first subframe */
+ reset_flag = D_IF_homing_frame_test_first(prm, mode);
+ }
+
+ /* produce encoder homing frame if homed & input=decoder homing frame */
+ if ((reset_flag != 0) && (s->reset_flag_old != 0))
+ {
+ for (i = 0; i < L_FRAME16k; i++)
+ {
+ synth[i] = EHF_MASK;
+ }
+ }
+ else
+ {
+ D_MAIN_decode(mode, prm, synth, s->decoder_state, frame_type);
+ }
+
+ for (i = 0; i < L_FRAME16k; i++) /* Delete the 2 LSBs (14-bit input) */
+ {
+ synth[i] = (Word16) (synth[i] & 0xfffC);
+ }
+
+ /* if not homed: check whether current frame is a homing frame */
+ if ((s->reset_flag_old == 0) & (mode < 9))
+ {
+ /* check whole frame */
+ reset_flag = D_IF_homing_frame_test(prm, mode);
+ }
+ /* reset decoder if current frame is a homing frame */
+ if (reset_flag != 0)
+ {
+ D_MAIN_reset(s->decoder_state, 1);
+ }
+ s->reset_flag_old = reset_flag;
+
+ s->prev_ft = frame_type;
+ s->prev_mode = mode;
+}
+
+/*
+ * D_IF_reset
+ *
+ * Parameters:
+ * st O: state struct
+ *
+ * Function:
+ * Reset homing frame counter
+ *
+ * Returns:
+ * void
+ */
+void D_IF_reset(WB_dec_if_state *st)
+{
+ st->reset_flag_old = 1;
+ st->prev_ft = RX_SPEECH_GOOD;
+ st->prev_mode = MODE_7k; /* minimum bitrate */
+}
+
+/*
+ * D_IF_init
+ *
+ * Parameters:
+ *
+ * Function:
+ * Allocates state memory and initializes state memory
+ *
+ * Returns:
+ * pointer to encoder interface structure
+ */
+void *D_IF_init( void)
+{
+ WB_dec_if_state *s = NULL;
+
+ /* allocate memory */
+ if ((s = (WB_dec_if_state*) malloc(sizeof(WB_dec_if_state))) == NULL)
+ {
+ return NULL;
+ }
+
+ D_MAIN_init(&(s->decoder_state));
+ if (s->decoder_state == NULL)
+ {
+ free(s);
+ return NULL;
+ }
+
+ D_IF_reset(s);
+
+ return s;
+}
+
+/*
+ * D_IF_exit
+ *
+ * Parameters:
+ * state I: state structure
+ *
+ * Function:
+ * The memory used for state memory is freed
+ *
+ * Returns:
+ * Void
+ */
+void D_IF_exit(void *state)
+{
+ WB_dec_if_state *s;
+
+ s = (WB_dec_if_state *)state;
+
+ /* free memory */
+ D_MAIN_close(&s->decoder_state);
+ free(s);
+ state = NULL;
+}
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_if.h b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_if.h
new file mode 100644
index 000000000..cdc945220
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_if.h
@@ -0,0 +1,23 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef DEC_IF_H
+#define DEC_IF_H
+
+#include "typedef.h"
+
+#define NB_SERIAL_MAX 61 /* max serial size */
+#define L_FRAME16k 320 /* Frame size at 16kHz */
+
+#define _good_frame 0
+#define _bad_frame 1
+#define _lost_frame 2
+#define _no_frame 3
+
+void D_IF_decode(void *st, UWord8 *bits, Word16 *synth, Word32 bfi);
+void * D_IF_init(void);
+void D_IF_exit(void *state);
+
+#endif
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_lpc.c b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_lpc.c
new file mode 100644
index 000000000..99781b3be
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_lpc.c
@@ -0,0 +1,873 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#include <math.h>
+#include "typedef.h"
+#include "dec_util.h"
+
+#define M 16 /* Order of LP filter */
+#define MP1 (M + 1)
+#define M16k 20
+#define NC16k (M16k / 2)
+#define MU 10923 /* Prediction factor (1.0/3.0) in Q15 */
+#define L_MEANBUF 3
+#define ALPHA 29491 /* 0. 9 in Q15 */
+#define ONE_ALPHA (32768-ALPHA) /* (1.0 - ALPHA) in Q15 */
+#define ORDER 16 /* order of linear prediction filter */
+#define ISF_GAP 128 /* 50 Hz */
+#define INV_LENGTH 2731 /* 1/12 */
+
+extern const Word16 D_ROM_dico1_isf[];
+extern const Word16 D_ROM_dico2_isf[];
+extern const Word16 D_ROM_dico21_isf_36b[];
+extern const Word16 D_ROM_dico22_isf_36b[];
+extern const Word16 D_ROM_dico23_isf_36b[];
+extern const Word16 D_ROM_dico21_isf[];
+extern const Word16 D_ROM_dico22_isf[];
+extern const Word16 D_ROM_dico23_isf[];
+extern const Word16 D_ROM_dico24_isf[];
+extern const Word16 D_ROM_dico25_isf[];
+extern const Word16 D_ROM_dico1_isf_noise[];
+extern const Word16 D_ROM_dico2_isf_noise[];
+extern const Word16 D_ROM_dico3_isf_noise[];
+extern const Word16 D_ROM_dico4_isf_noise[];
+extern const Word16 D_ROM_dico5_isf_noise[];
+extern const Word16 D_ROM_mean_isf[];
+extern const Word16 D_ROM_mean_isf_noise[];
+extern const Word16 D_ROM_cos[];
+
+
+/*
+ * D_LPC_isf_reorder
+ *
+ * Parameters:
+ * isf I/O: vector of isfs
+ * min_dist I: quantized ISFs (in frequency domain)
+ * n I: LPC order
+ *
+ * Function:
+ * To make sure that the isfs are properly order and to keep a certain
+ * minimum distance between consecutive isfs.
+ *
+ * Returns:
+ * void
+ */
+static void D_LPC_isf_reorder(Word16 *isf, Word16 min_dist, Word16 n)
+{
+ Word32 i, isf_min;
+
+ isf_min = min_dist;
+
+ for(i = 0; i < n - 1; i++)
+ {
+ if(isf[i] < isf_min)
+ {
+ isf[i] = (Word16)isf_min;
+ }
+ isf_min = isf[i] + min_dist;
+ }
+
+ return;
+}
+
+
+/*
+ * D_LPC_isf_noise_d
+ *
+ * Parameters:
+ * indice I: indices of the selected codebook entries
+ * isf_q O: quantized ISFs (in frequency domain)
+ *
+ * Function:
+ * Decoding of ISF parameters
+ *
+ * Returns:
+ * void
+ */
+void D_LPC_isf_noise_d(Word16 *indice, Word16 *isf_q)
+{
+ Word32 i;
+
+ for(i = 0; i < 2; i++)
+ {
+ isf_q[i] = D_ROM_dico1_isf_noise[indice[0] * 2 + i];
+ }
+
+ for(i = 0; i < 3; i++)
+ {
+ isf_q[i + 2] = D_ROM_dico2_isf_noise[indice[1] * 3 + i];
+ }
+
+ for(i = 0; i < 3; i++)
+ {
+ isf_q[i + 5] = D_ROM_dico3_isf_noise[indice[2] * 3 + i];
+ }
+
+ for(i = 0; i < 4; i++)
+ {
+ isf_q[i + 8] = D_ROM_dico4_isf_noise[indice[3] * 4 + i];
+ }
+
+ for(i = 0; i < 4; i++)
+ {
+ isf_q[i + 12] = D_ROM_dico5_isf_noise[indice[4] * 4 + i];
+ }
+
+ for(i = 0; i < ORDER; i++)
+ {
+ isf_q[i] = (Word16)(isf_q[i]+ D_ROM_mean_isf_noise[i]);
+ }
+
+ D_LPC_isf_reorder(isf_q, ISF_GAP, ORDER);
+
+ return;
+}
+
+
+/*
+ * D_LPC_isf_isp_conversion
+ *
+ * Parameters:
+ * isp O: (Q15) isp[m] (range: -1<=val<1)
+ * isf I: (Q15) isf[m] normalized (range: 0.0 <= val <= 0.5)
+ * m I: LPC order
+ *
+ * Function:
+ * Transformation isf to isp
+ *
+ * ISP are immitance spectral pair in cosine domain (-1 to 1).
+ * ISF are immitance spectral pair in frequency domain (0 to 6400).
+ * Returns:
+ * void
+ */
+void D_LPC_isf_isp_conversion(Word16 isf[], Word16 isp[], Word16 m)
+{
+ Word32 i, ind, offset, tmp;
+
+ for(i = 0; i < m - 1; i++)
+ {
+ isp[i] = isf[i];
+ }
+ isp[m - 1] = (Word16)(isf[m - 1] << 1);
+
+ for(i = 0; i < m; i++)
+ {
+ ind = isp[i] >> 7; /* ind = b7-b15 of isf[i] */
+ offset = isp[i] & 0x007f; /* offset = b0-b6 of isf[i] */
+
+ /* isp[i] = table[ind]+ ((table[ind+1]-table[ind])*offset) / 128 */
+ tmp = (D_ROM_cos[ind + 1] - D_ROM_cos[ind]) * offset;
+ isp[i] = (Word16)(D_ROM_cos[ind] + (tmp >> 7));
+ }
+ return;
+}
+
+
+/*
+ * D_LPC_isp_pol_get
+ *
+ * Parameters:
+ * isp I: Immitance spectral pairs (cosine domaine)
+ * f O: the coefficients of F1 or F2
+ * n I: no of coefficients (m/2)
+ * k16 I: 16k flag
+ *
+ * Function:
+ * Find the polynomial F1(z) or F2(z) from the ISPs.
+ * This is performed by expanding the product polynomials:
+ *
+ * F1(z) = product ( 1 - 2 isp_i z^-1 + z^-2 )
+ * i=0,2,4,6,8
+ * F2(z) = product ( 1 - 2 isp_i z^-1 + z^-2 )
+ * i=1,3,5,7
+ *
+ * where isp_i are the ISPs in the cosine domain.
+ *
+ * Returns:
+ * void
+ */
+static void D_LPC_isp_pol_get(Word16 *isp, Word32 *f, Word32 n, Word16 k16)
+{
+ Word32 i, j, t0, s1, s2;
+ Word16 hi, lo;
+
+ s1 = 8388608;
+ s2 = 512;
+
+ if(k16)
+ {
+ s1 >>= 2;
+ s2 >>= 2;
+ }
+
+ /* All computation in Q23 */
+ f[0] = s1; /* f[0] = 1.0; in Q23 */
+ f[1] = isp[0] * (-s2); /* f[1] = -2.0*isp[0] in Q23 */
+ f += 2; /* Advance f pointer */
+ isp += 2; /* Advance isp pointer */
+
+ for(i = 2; i <= n; i++)
+ {
+ *f = f[ - 2];
+
+ for(j = 1; j < i; j++, f--)
+ {
+ D_UTIL_l_extract(f[- 1], &hi, &lo);
+ t0 = D_UTIL_mpy_32_16(hi, lo, *isp); /* t0 = f[-1] * isp */
+ t0 = (t0 << 1);
+ *f = (*f - t0); /* *f -= t0 */
+ *f = (*f + f[ - 2]); /* *f += f[-2] */
+ }
+
+ *f = *f - (*isp * s2); /* *f -= isp << 8 */
+ f += i; /* Advance f pointer */
+ isp += 2; /* Advance isp pointer */
+ }
+
+ return;
+}
+
+
+/*
+ * D_LPC_isp_a_conversion
+ *
+ * Parameters:
+ * isp I: (Q15) Immittance spectral pairs
+ * a O: (Q12) Predictor coefficients (order = M)
+ * m I: order of LP filter
+ *
+ * Function:
+ * Convert ISPs to predictor coefficients a[]
+ *
+ * Returns:
+ * void
+ */
+void D_LPC_isp_a_conversion(Word16 isp[], Word16 a[], Word32 adaptive_scaling,
+ Word16 m)
+{
+ Word32 j, i, nc, tmax, q, q_sug, r;
+ Word32 f1[NC16k + 1], f2[NC16k];
+ Word32 t0;
+ Word16 hi, lo;
+
+ nc = m >> 1;
+
+ if(nc > 8)
+ {
+ D_LPC_isp_pol_get(&isp[0], f1, nc, 1);
+
+ for(i = 0; i <= nc; i++)
+ {
+ f1[i] = (f1[i] << 2);
+ }
+ }
+ else
+ {
+ D_LPC_isp_pol_get(&isp[0], f1, nc, 0);
+ }
+
+ if(nc > 8)
+ {
+ D_LPC_isp_pol_get(&isp[1], f2, nc - 1, 1);
+
+ for(i = 0; i <= nc - 1; i++)
+ {
+ f2[i] = (f2[i] << 2);
+ }
+ }
+ else
+ {
+ D_LPC_isp_pol_get(&isp[1], f2, nc - 1, 0);
+ }
+
+ /*
+ * Multiply F2(z) by (1 - z^-2)
+ */
+ for(i = nc - 1; i > 1; i--)
+ {
+ f2[i] = f2[i] - f2[i - 2]; /* f2[i] -= f2[i-2]; */
+ }
+
+ /*
+ * 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]); */
+ D_UTIL_l_extract(f1[i], &hi, &lo);
+ t0 = D_UTIL_mpy_32_16(hi, lo, isp[m - 1]);
+ f1[i] = f1[i] + t0;
+
+ /* f2[i] *= (1.0 - isp[M-1]); */
+ D_UTIL_l_extract(f2[i], &hi, &lo);
+ t0 = D_UTIL_mpy_32_16(hi, lo, isp[m - 1]);
+ f2[i] = f2[i] - t0;
+ }
+
+ /*
+ * A(z) = (F1(z)+F2(z))/2
+ * F1(z) is symmetric and F2(z) is antisymmetric
+ */
+
+ /* a[0] = 1.0; */
+ a[0] = 4096;
+ tmax = 1;
+
+ for(i = 1, j = m - 1; i < nc; i++, j--)
+ {
+ /* a[i] = 0.5*(f1[i] + f2[i]); */
+ t0 = f1[i] + f2[i]; /* f1[i] + f2[i] */
+ tmax |= labs(t0);
+ a[i] = (Word16)((t0 + 0x800) >> 12); /* from Q23 to Q12 and * 0.5 */
+
+ /* a[j] = 0.5*(f1[i] - f2[i]); */
+ t0 = (f1[i] - f2[i]); /* f1[i] - f2[i] */
+ tmax |= labs(t0);
+ a[j] = (Word16)((t0 + 0x800) >> 12); /* from Q23 to Q12 and * 0.5 */
+ }
+
+ /* rescale data if overflow has occured and reprocess the loop */
+
+ if (adaptive_scaling)
+ {
+ q = 4 - D_UTIL_norm_l(tmax); /* adaptive scaling enabled */
+ }
+ else
+ {
+ q = 0; /* adaptive scaling disabled */
+ }
+
+ if (q > 0)
+ {
+ q_sug = 12 + q;
+ r = 1 << (q_sug - 1);
+
+ for (i = 1, j = m - 1; i < nc; i++, j--)
+ {
+ /* a[i] = 0.5*(f1[i] + f2[i]); */
+ t0 = f1[i] + f2[i]; /* f1[i] + f2[i] */
+ a[i] = (Word16)((t0 + r) >> q_sug); /* from Q23 to Q12 and * 0.5 */
+
+ /* a[j] = 0.5*(f1[i] - f2[i]); */
+ t0 = f1[i] - f2[i]; /* f1[i] - f2[i] */
+ a[j] = (Word16)((t0 + r) >> q_sug); /* from Q23 to Q12 and * 0.5 */
+ }
+ a[0] = (Word16)(a[0] >> q);
+ }
+ else
+ {
+ q_sug = 12;
+ r = 1 << (q_sug - 1);
+ q = 0;
+ }
+
+ /* a[NC] = 0.5*f1[NC]*(1.0 + isp[M-1]); */
+ D_UTIL_l_extract(f1[nc], &hi, &lo);
+ t0 = D_UTIL_mpy_32_16(hi, lo, isp[m - 1]);
+ t0 = f1[nc] + t0;
+ a[nc] = (Word16)((t0 + r) >> q_sug); /* from Q23 to Q12 and * 0.5 */
+
+ /* a[m] = isp[m-1]; */
+ a[m] = (Word16)((isp[m - 1] >> (2 + q)) + 1); /* from Q15 to Q12 */
+ a[m] = (Word16)(a[m] >> 1);
+
+ return;
+}
+
+
+/*
+ * D_LPC_a_weight
+ *
+ * Parameters:
+ * a I: LP filter coefficients
+ * ap O: weighted LP filter coefficients
+ * gamma I: weighting factor
+ * m I: order of LP filter
+ *
+ * Function:
+ * Weighting of LP filter coefficients, ap[i] = a[i] * (gamma^i).
+ *
+ * Returns:
+ * void
+ */
+void D_LPC_a_weight(Word16 a[], Word16 ap[], Word16 gamma, Word16 m)
+{
+ Word32 i, fac;
+
+ ap[0] = a[0];
+ fac = gamma;
+
+ for(i = 1; i < m; i++)
+ {
+ ap[i] = (Word16)(((a[i] * fac) + 0x4000) >> 15);
+ fac = ((fac * gamma) + 0x4000) >> 15;
+ }
+
+ ap[m] = (Word16)(((a[m] * fac) + 0x4000) >> 15);
+
+ return;
+}
+
+
+/*
+ * D_LPC_isf_2s3s_decode
+ *
+ * Parameters:
+ * indice I: quantisation indices
+ * isf_q O: quantised ISFs in the cosine domain
+ * past_isfq I/O: past ISF quantizer
+ * isfold I: past quantised ISF
+ * isf_buf O: isf buffer
+ * bfi I: Bad frame indicator
+ *
+ * Function:
+ * Decoding of ISF parameters.
+ *
+ * Returns:
+ * void
+ */
+void D_LPC_isf_2s3s_decode(Word16 *indice, Word16 *isf_q, Word16 *past_isfq,
+ Word16 *isfold, Word16 *isf_buf, Word16 bfi)
+{
+
+ Word32 ref_isf[M];
+ Word32 L_tmp, i, j;
+ Word16 tmp;
+
+ if(bfi == 0) /* Good frame */
+ {
+ for(i = 0; i < 9; i++)
+ {
+ isf_q[i] = D_ROM_dico1_isf[indice[0] * 9 + i];
+ }
+
+ for(i = 0; i < 7; i++)
+ {
+ isf_q[i + 9] = D_ROM_dico2_isf[indice[1] * 7 + i];
+ }
+
+ for(i = 0; i < 5; i++)
+ {
+ isf_q[i] =
+ (Word16)(isf_q[i] + D_ROM_dico21_isf_36b[indice[2] * 5 + i]);
+ }
+
+ for(i = 0; i < 4; i++)
+ {
+ isf_q[i + 5] =
+ (Word16)(isf_q[i + 5] + D_ROM_dico22_isf_36b[indice[3] * 4 + i]);
+ }
+
+ for(i = 0; i < 7; i++)
+ {
+ isf_q[i + 9] =
+ (Word16)(isf_q[i + 9] + D_ROM_dico23_isf_36b[indice[4] * 7 + i]);
+ }
+
+ for(i = 0; i < ORDER; i++)
+ {
+ tmp = isf_q[i];
+ isf_q[i] =
+ (Word16)((tmp + D_ROM_mean_isf[i]) + ((MU * past_isfq[i]) >> 15));
+ past_isfq[i] = tmp;
+ }
+
+ for(i = 0; i < M; i++)
+ {
+ for(j = (L_MEANBUF - 1); j > 0; j--)
+ {
+ isf_buf[j * M + i] = isf_buf[(j - 1) * M + i];
+ }
+ isf_buf[i] = isf_q[i];
+ }
+
+ }
+ else
+ { /* bad frame */
+
+ for(i = 0; i < M; i++)
+ {
+ L_tmp = D_ROM_mean_isf[i];
+
+ for(j = 0; j < L_MEANBUF; j++)
+ {
+ L_tmp = L_tmp + isf_buf[j * M + i];
+ }
+ ref_isf[i] = (L_tmp + 0x1) >> 2;
+ }
+
+ /* use the past ISFs slightly shifted towards their mean */
+ for(i = 0; i < ORDER; i++)
+ {
+ isf_q[i] = (Word16)((((ALPHA * isfold[i]) >> 15) +
+ ((ONE_ALPHA * ref_isf[i]) >> 15)));
+ }
+
+ /* estimate past quantized residual to be used in next frame */
+ for(i = 0; i < ORDER; i++)
+ {
+ /* predicted ISF */
+ L_tmp = ref_isf[i] + ((past_isfq[i] * MU) >> 15);
+ /* past_isfq[i] *= 0.5 */
+ past_isfq[i] = (Word16)((isf_q[i] - L_tmp) >> 1);
+ }
+ }
+
+ D_LPC_isf_reorder(isf_q, ISF_GAP, ORDER);
+
+ return;
+}
+
+
+/*
+ * D_LPC_isf_2s5s_decode
+ *
+ * Parameters:
+ * indice I: quantization indices
+ * isf_q O: quantized ISFs in the cosine domain
+ * past_isfq I/O: past ISF quantizer
+ * isfold I: past quantized ISF
+ * isf_buf O: isf buffer
+ * bfi I: Bad frame indicator
+ *
+ * Function:
+ * Decoding of ISF parameters.
+ *
+ * Returns:
+ * void
+ */
+void D_LPC_isf_2s5s_decode(Word16 *indice, Word16 *isf_q, Word16 *past_isfq,
+ Word16 *isfold, Word16 *isf_buf, Word16 bfi)
+{
+ Word32 ref_isf[M];
+ Word32 i, j, L_tmp;
+ Word16 tmp;
+
+ if(bfi == 0) /* Good frame */
+ {
+ for(i = 0; i < 9; i++)
+ {
+ isf_q[i] = D_ROM_dico1_isf[indice[0] * 9 + i];
+ }
+
+ for(i = 0; i < 7; i++)
+ {
+ isf_q[i + 9] = D_ROM_dico2_isf[indice[1] * 7 + i];
+ }
+
+ for(i = 0; i < 3; i++)
+ {
+ isf_q[i] = (Word16)(isf_q[i] + D_ROM_dico21_isf[indice[2] * 3 + i]);
+ }
+
+ for(i = 0; i < 3; i++)
+ {
+ isf_q[i + 3] =
+ (Word16)(isf_q[i + 3] + D_ROM_dico22_isf[indice[3] * 3 + i]);
+ }
+
+ for(i = 0; i < 3; i++)
+ {
+ isf_q[i + 6] =
+ (Word16)(isf_q[i + 6] + D_ROM_dico23_isf[indice[4] * 3 + i]);
+ }
+
+ for(i = 0; i < 3; i++)
+ {
+ isf_q[i + 9] =
+ (Word16)(isf_q[i + 9] + D_ROM_dico24_isf[indice[5] * 3 + i]);
+ }
+
+ for(i = 0; i < 4; i++)
+ {
+ isf_q[i + 12] =
+ (Word16)(isf_q[i + 12] + D_ROM_dico25_isf[indice[6] * 4 + i]);
+ }
+
+ for(i = 0; i < ORDER; i++)
+ {
+ tmp = isf_q[i];
+ isf_q[i] =
+ (Word16)((tmp + D_ROM_mean_isf[i]) + ((MU * past_isfq[i]) >> 15));
+ past_isfq[i] = tmp;
+ }
+
+
+ for(i = 0; i < M; i++)
+ {
+ for(j = (L_MEANBUF - 1); j > 0; j--)
+ {
+ isf_buf[j * M + i] = isf_buf[(j - 1) * M + i];
+ }
+ isf_buf[i] = isf_q[i];
+ }
+
+ }
+ else
+ { /* bad frame */
+
+ for(i = 0; i < M; i++)
+ {
+ L_tmp = D_ROM_mean_isf[i];
+
+ for(j = 0; j < L_MEANBUF; j++)
+ {
+ L_tmp = L_tmp + isf_buf[j * M + i];
+ }
+
+ ref_isf[i] = (L_tmp + 0x1) >> 2;
+ }
+
+ /* use the past ISFs slightly shifted towards their mean */
+ for(i = 0; i < ORDER; i++)
+ {
+ isf_q[i] = (Word16)(((ALPHA * isfold[i]) >> 15) +
+ ((ONE_ALPHA * ref_isf[i]) >> 15));
+ }
+
+ /* estimate past quantized residual to be used in next frame */
+ for(i = 0; i < ORDER; i++)
+ {
+ /* predicted ISF */
+ L_tmp = ref_isf[i] + ((past_isfq[i] * MU) >> 15);
+ /* past_isfq[i] *= 0.5 */
+ past_isfq[i] = (Word16)((isf_q[i] - L_tmp) >> 1);
+ }
+ }
+
+ D_LPC_isf_reorder(isf_q, ISF_GAP, ORDER);
+
+ return;
+}
+
+
+/*
+ * D_LPC_int_isp_find
+ *
+ * Parameters:
+ * isp_old I: isps from past frame
+ * isp_new I: isps from present frame
+ * frac I: (Q15) fraction for 3 first subfr
+ * Az O: LP coefficients in 4 subframes
+ *
+ * Function:
+ * Find the interpolated ISP parameters for all subframes.
+ *
+ * Returns:
+ * void
+ */
+void D_LPC_int_isp_find(Word16 isp_old[], Word16 isp_new[],
+ const Word16 frac[], Word16 Az[])
+{
+ Word32 tmp, i, k, fac_old, fac_new;
+ Word16 isp[M];
+
+ for(k = 0; k < 3; k++)
+ {
+ fac_new = frac[k];
+ fac_old = (32767 - fac_new) + 1; /* 1.0 - fac_new */
+
+ for(i = 0; i < M; i++)
+ {
+ tmp = isp_old[i] * fac_old;
+ tmp += isp_new[i] * fac_new;
+ isp[i] = (Word16)((tmp + 0x4000) >> 15);
+ }
+
+ D_LPC_isp_a_conversion(isp, Az, 0, M);
+ Az += MP1;
+ }
+
+ /* 4th subframe: isp_new (frac=1.0) */
+ D_LPC_isp_a_conversion(isp_new, Az, 0, M);
+
+ return;
+}
+
+
+/*
+ * D_LPC_isf_extrapolation
+ *
+ * Parameters:
+ * HfIsf I/O: ISF vector
+ *
+ * Function:
+ * Conversion of 16th-order 12.8kHz ISF vector
+ * into 20th-order 16kHz ISF vector
+ *
+ * Returns:
+ * void
+ */
+void D_LPC_isf_extrapolation(Word16 HfIsf[])
+{
+ Word32 IsfDiff[M - 2];
+ Word32 IsfCorr[3];
+ Word32 tmp, tmp2, tmp3, mean, i;
+ Word32 MaxCorr, exp, exp2, coeff;
+ Word16 hi, lo;
+
+ HfIsf[M16k - 1] = HfIsf[M - 1];
+
+ /* Difference vector */
+ for(i = 1; i < M - 1; i++)
+ {
+ IsfDiff[i - 1] = HfIsf[i] - HfIsf[i - 1];
+ }
+
+ tmp = 0;
+
+ /* Mean of difference vector */
+ for(i = 3; i < (M - 1); i++)
+ {
+ tmp = tmp + (IsfDiff[i - 1] * INV_LENGTH);
+ }
+
+ mean = (tmp + 0x4000) >> 15;
+ IsfCorr[0] = 0;
+ IsfCorr[1] = 0;
+ IsfCorr[2] = 0;
+ tmp = 0;
+
+ for(i = 0; i < M - 2; i++)
+ {
+ if(IsfDiff[i] > tmp)
+ {
+ tmp = IsfDiff[i];
+ }
+ }
+
+ exp = D_UTIL_norm_s((Word16)tmp);
+
+ for(i = 0; i < M - 2; i++)
+ {
+ IsfDiff[i] = IsfDiff[i] << exp;
+ }
+
+ mean = mean << exp;
+
+ for(i = 7; i < M - 2; i++)
+ {
+ tmp2 = IsfDiff[i] - mean;
+ tmp3 = IsfDiff[i - 2] - mean;
+ tmp = (tmp2 * tmp3) << 1;
+ D_UTIL_l_extract(tmp, &hi, &lo);
+ tmp = D_UTIL_mpy_32(hi, lo, hi, lo);
+ IsfCorr[0] = (IsfCorr[0] + tmp);
+ }
+
+ for(i = 7; i < M - 2; i++)
+ {
+ tmp2 = IsfDiff[i] - mean;
+ tmp3 = IsfDiff[i - 3] - mean;
+ tmp = (tmp2 * tmp3) << 1;
+ D_UTIL_l_extract(tmp, &hi, &lo);
+ tmp = D_UTIL_mpy_32(hi, lo, hi, lo);
+ IsfCorr[1] = (IsfCorr[1] + tmp);
+ }
+
+ for(i = 7; i < M - 2; i++)
+ {
+ tmp2 = IsfDiff[i] - mean;
+ tmp3 = IsfDiff[i - 4] - mean;
+ tmp = (tmp2 * tmp3) << 1;
+ D_UTIL_l_extract(tmp, &hi, &lo);
+ tmp = D_UTIL_mpy_32(hi, lo, hi, lo);
+ IsfCorr[2] = (IsfCorr[2] + tmp);
+ }
+
+ if(IsfCorr[0] > IsfCorr[1])
+ {
+ MaxCorr = 0;
+ }
+ else
+ {
+ MaxCorr = 1;
+ }
+
+ if(IsfCorr[2] > IsfCorr[MaxCorr])
+ {
+ MaxCorr = 2;
+ }
+
+ MaxCorr = MaxCorr + 1; /* Maximum correlation of difference vector */
+
+ for(i = M - 1; i < (M16k - 1); i++)
+ {
+ tmp = (HfIsf[i - 1 - MaxCorr] - HfIsf[i - 2 - MaxCorr]);
+ HfIsf[i] = (Word16)(HfIsf[i - 1] + tmp);
+ }
+
+ /* tmp=7965+(HfIsf[2]-HfIsf[3]-HfIsf[4])/6; */
+ tmp = HfIsf[4] + HfIsf[3];
+ tmp = HfIsf[2] - tmp;
+ tmp = (tmp * 5461) >> 15;
+ tmp = tmp + 20390;
+
+ if(tmp > 19456)
+ { /* Maximum value of ISF should be at most 7600 Hz */
+ tmp = 19456;
+ }
+
+ tmp = tmp - HfIsf[M - 2];
+ tmp2 = HfIsf[M16k - 2] - HfIsf[M - 2];
+ exp2 = D_UTIL_norm_s((Word16)tmp2);
+ exp = D_UTIL_norm_s((Word16)tmp);
+ exp = exp - 1;
+ tmp = tmp << exp;
+ tmp2 = tmp2 << exp2;
+ coeff = (tmp << 15) / tmp2; /* Coefficient for stretching the ISF vector */
+ exp = exp2 - exp;
+
+ if(exp >= 0)
+ {
+ for(i = M - 1; i < M16k - 1; i++)
+ {
+ tmp = ((HfIsf[i] - HfIsf[i - 1]) * coeff) >> 15;
+ IsfDiff[i - (M - 1)] = tmp << exp;
+ }
+ }
+ else
+ {
+ exp = 15 - exp;
+
+ for(i = M - 1; i < M16k - 1; i++)
+ {
+ IsfDiff[i - (M - 1)] = ((HfIsf[i] - HfIsf[i - 1]) * coeff) >> exp;
+ }
+ }
+
+ for(i = M; i < (M16k - 1); i++)
+ {
+ /* The difference between ISF(n) and ISF(n-2) should be at least 500 Hz */
+ tmp = ((IsfDiff[i - (M - 1)] + IsfDiff[i - M]) - 1280);
+
+ if(tmp < 0)
+ {
+ if(IsfDiff[i - (M - 1)] > IsfDiff[i - M])
+ {
+ IsfDiff[i - M] = (1280 - IsfDiff[i - (M - 1)]);
+ }
+ else
+ {
+ IsfDiff[i - (M - 1)] = (1280 - IsfDiff[i - M]);
+ }
+ }
+ }
+
+ for(i = M - 1; i < M16k - 1; i++)
+ {
+ HfIsf[i] = (Word16)(HfIsf[i - 1] + IsfDiff[i - (M - 1)]);
+ }
+
+ for(i = 0; i < M16k - 1; i++)
+ {
+ HfIsf[i] = (Word16)((HfIsf[i] * 13107) >> 14);
+ /* Scale the ISF vector correctly for 16000 kHz */
+ }
+
+ D_LPC_isf_isp_conversion(HfIsf, HfIsf, M16k);
+
+ return;
+}
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_lpc.h b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_lpc.h
new file mode 100644
index 000000000..8a1ec01cf
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_lpc.h
@@ -0,0 +1,25 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef DEC_LPC_H
+#define DEC_LPC_H
+
+#include "typedef.h"
+
+void D_LPC_isf_noise_d(Word16 *indice, Word16 *isf_q);
+void D_LPC_isf_isp_conversion(Word16 isf[], Word16 isp[], Word16 m);
+void D_LPC_isp_a_conversion(Word16 isp[], Word16 a[], Word32 adaptive_scaling,
+ Word16 m);
+void D_LPC_a_weight(Word16 a[], Word16 ap[], Word16 gamma, Word16 m);
+void D_LPC_isf_2s3s_decode(Word16 *indice, Word16 *isf_q, Word16* past_isfq,
+ Word16 *isfold, Word16 *isf_buf, Word16 bfi);
+void D_LPC_isf_2s5s_decode(Word16 *indice, Word16 *isf_q, Word16 *past_isfq,
+ Word16 *isfold, Word16 *isf_buf, Word16 bfi);
+void D_LPC_int_isp_find(Word16 isp_old[], Word16 isp_new[],
+ const Word16 frac[], Word16 Az[]);
+void D_LPC_isf_extrapolation(Word16 HfIsf[]);
+
+#endif
+
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_main.c b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_main.c
new file mode 100644
index 000000000..879a859f5
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_main.c
@@ -0,0 +1,970 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#include <stdlib.h>
+#include <math.h>
+#include <memory.h>
+#include <string.h>
+#include "typedef.h"
+#include "dec_main.h"
+#include "dec_dtx.h"
+#include "dec_acelp.h"
+#include "dec_gain.h"
+#include "dec_lpc.h"
+#include "dec_util.h"
+
+#define MAX_16 (Word16)0x7fff
+#define MIN_16 (Word16)0x8000
+
+#define L_FRAME 256 /* Frame size */
+#define NB_SUBFR 4 /* Number of subframe per frame */
+#define L_SUBFR 64 /* Subframe size */
+#define MODE_7k 0 /* modes */
+#define MODE_9k 1
+#define MODE_12k 2
+#define MODE_14k 3
+#define MODE_16k 4
+#define MODE_18k 5
+#define MODE_20k 6
+#define MODE_23k 7
+#define MODE_24k 8
+#define RX_SPEECH_PROBABLY_DEGRADED 1 /* rx types */
+#define RX_SPEECH_LOST 2
+#define RX_SPEECH_BAD 3
+#define RX_NO_DATA 7
+#define Q_MAX 8 /* scaling max for signal */
+#define PIT_SHARP 27853 /* pitch sharpening factor = 0.85 Q15 */
+#define PIT_MIN 34 /* Minimum pitch lag with resolution 1/4 */
+#define PIT_FR2 128 /* Minimum pitch lag with resolution 1/2 */
+#define PIT_FR1_9b 160 /* Minimum pitch lag with resolution 1 */
+#define PIT_FR1_8b 92 /* Minimum pitch lag with resolution 1 */
+
+extern const Word16 D_ROM_isp[];
+extern const Word16 D_ROM_isf[];
+extern const Word16 D_ROM_interpol_frac[];
+
+#ifdef WIN32
+#pragma warning( disable : 4310)
+#endif
+
+/*
+ * Decoder_reset
+ *
+ * Parameters:
+ * st I/O: pointer to state structure
+ * reset_all I: perform full reset
+ *
+ * Function:
+ * Initialisation of variables for the decoder section.
+ *
+ *
+ * Returns:
+ * void
+ */
+void D_MAIN_reset(void *st, Word16 reset_all)
+{
+ Word32 i;
+
+ Decoder_State *dec_state;
+
+ dec_state = (Decoder_State*)st;
+ memset(dec_state->mem_exc, 0, (PIT_MAX + L_INTERPOL) * sizeof(Word16));
+ memset(dec_state->mem_isf_q, 0, M * sizeof(Word16));
+ dec_state->mem_T0_frac = 0; /* old pitch value = 64.0 */
+ dec_state->mem_T0 = 64;
+ dec_state->mem_first_frame = 1;
+ dec_state->mem_gc_thres = 0;
+ dec_state->mem_tilt_code = 0;
+ memset(dec_state->mem_ph_disp, 0, 8 * sizeof(Word16));
+
+ /* scaling memories for excitation */
+ dec_state->mem_q = Q_MAX;
+ dec_state->mem_subfr_q[3] = Q_MAX;
+ dec_state->mem_subfr_q[2] = Q_MAX;
+ dec_state->mem_subfr_q[1] = Q_MAX;
+ dec_state->mem_subfr_q[0] = Q_MAX;
+
+ if(reset_all != 0)
+ {
+ /* routines initialization */
+ D_GAIN_init(dec_state->mem_gain);
+ memset(dec_state->mem_oversamp, 0, (2 * 12) * sizeof(Word16));
+ memset(dec_state->mem_sig_out, 0, 6 * sizeof(Word16));
+ memset(dec_state->mem_hf, 0, (31 - 1) * sizeof(Word16));
+ memset(dec_state->mem_hf3, 0, (31 - 1) * sizeof(Word16));
+ memset(dec_state->mem_hp400, 0, 6 * sizeof(Word16));
+ D_GAIN_lag_concealment_init(dec_state->mem_lag);
+
+ /* isp initialization */
+ memcpy(dec_state->mem_isp, D_ROM_isp, M * sizeof(Word16));
+ memcpy(dec_state->mem_isf, D_ROM_isf, M * sizeof(Word16));
+
+ for(i = 0; i < L_MEANBUF; i++)
+ {
+ memcpy(&dec_state->mem_isf_buf[i * M], D_ROM_isf, M * sizeof(Word16));
+ }
+
+ /* variable initialization */
+ dec_state->mem_deemph = 0;
+ dec_state->mem_seed = 21845; /* init random with 21845 */
+ dec_state->mem_seed2 = 21845;
+ dec_state->mem_seed3 = 21845;
+ dec_state->mem_state = 0;
+ dec_state->mem_bfi = 0;
+
+ /* Static vectors to zero */
+ memset(dec_state->mem_syn_hf, 0, M16k * sizeof(Word16));
+ memset(dec_state->mem_syn_hi, 0, M * sizeof(Word16));
+ memset(dec_state->mem_syn_lo, 0, M * sizeof(Word16));
+ D_DTX_reset(dec_state->dtx_decSt, D_ROM_isf);
+ dec_state->mem_vad_hist = 0;
+ }
+
+ return;
+}
+
+
+/*
+ * Decoder_init
+ *
+ * Parameters:
+ * spd_state O: pointer to state structure
+ *
+ * Function:
+ * Initialization of variables for the decoder section.
+ * Memory allocation.
+ *
+ * Returns:
+ * return zero if succesful
+ */
+Word32 D_MAIN_init(void **spd_state)
+{
+ /* Decoder states */
+ Decoder_State *st;
+
+ *spd_state = NULL;
+
+ /*
+ * Memory allocation for coder state.
+ */
+ if((st = (Decoder_State*)malloc(sizeof(Decoder_State))) == NULL)
+ {
+ return(-1);
+ }
+
+ st->dtx_decSt = NULL;
+ D_DTX_init(&st->dtx_decSt, D_ROM_isf);
+ D_MAIN_reset((void *)st, 1);
+ *spd_state = (void *)st;
+
+ return(0);
+}
+
+
+/*
+ * Decoder_close
+ *
+ * Parameters:
+ * spd_state I: pointer to state structure
+ *
+ * Function:
+ * Free coder memory.
+ *
+ * Returns:
+ * void
+ */
+void D_MAIN_close(void **spd_state)
+{
+ D_DTX_exit(&(((Decoder_State *)(*spd_state))->dtx_decSt));
+ free(*spd_state);
+
+ return;
+}
+
+
+/*
+ * Decoder_exe
+ *
+ * Parameters:
+ * mode I: used mode
+ * prms I: parameter vector
+ * synth_out O: synthesis speech
+ * spe_state B: state structure
+ * frame_type I: received frame type
+ *
+ * Function:
+ * Main decoder routine.
+ *
+ * Returns:
+ * 0 if successful
+ */
+Word32 D_MAIN_decode(Word16 mode, Word16 prms[], Word16 synth16k[],
+ void *spd_state, UWord8 frame_type)
+{
+
+ Word32 code2[L_SUBFR]; /* algebraic codevector */
+ Word32 L_tmp, L_tmp2, L_gain_code, L_stab_fac;
+ Word32 i, j, i_subfr, pit_flag;
+ Word32 T0, T0_frac, T0_max, select, T0_min = 0;
+
+ Word16 exc2[L_FRAME]; /* excitation vector */
+ Word16 Aq[NB_SUBFR * (M + 1)]; /* A(z) quantized for the 4 subframes */
+ Word16 code[L_SUBFR]; /* algebraic codevector */
+ Word16 excp[L_SUBFR]; /* excitation vector */
+ Word16 HfIsf[M16k];
+ Word16 ispnew[M]; /* immittance spectral pairs at 4nd sfr*/
+ Word16 isf[M]; /* ISF (frequency domain) at 4nd sfr */
+ Word16 isf_tmp[M]; /* ISF tmp */
+ Word16 ind[8]; /* quantization indices */
+
+ Word16 index, fac, voice_fac, max, Q_new = 0;
+ Word16 gain_pit, gain_code, gain_code_lo, tmp;
+ Word16 corr_gain = 0;
+ UWord16 pit_sharp = 0;
+
+ Word16 *exc; /* Excitation vector */
+ Word16 *p_Aq; /* ptr to A(z) for the 4 subframes */
+ Word16 *p_isf; /* prt to isf */
+
+ Decoder_State *st; /* Decoder states */
+ UWord8 newDTXState, bfi, unusable_frame;
+ UWord8 vad_flag;
+
+ st = (Decoder_State*)spd_state;
+
+ /* find the new DTX state SPEECH OR DTX */
+ newDTXState = D_DTX_rx_handler(st->dtx_decSt, frame_type);
+
+ if(newDTXState != SPEECH)
+ {
+ D_DTX_exe(st->dtx_decSt, exc2, newDTXState, isf, &prms);
+ }
+
+ /* SPEECH action state machine */
+ if((frame_type == RX_SPEECH_BAD) |
+ (frame_type == RX_SPEECH_PROBABLY_DEGRADED))
+ {
+ /* bfi for all index, bits are not usable */
+ bfi = 1;
+ unusable_frame = 0;
+ }
+ else if((frame_type == RX_NO_DATA) | (frame_type == RX_SPEECH_LOST))
+ {
+ /* bfi only for lsf, gains and pitch period */
+ bfi = 1;
+ unusable_frame = 1;
+ }
+ else
+ {
+ bfi = 0;
+ unusable_frame = 0;
+ }
+
+ if(bfi != 0)
+ {
+ st->mem_state = (UWord8)(st->mem_state + 1);
+
+ if(st->mem_state > 6)
+ {
+ st->mem_state = 6;
+ }
+ }
+ else
+ {
+ st->mem_state = (UWord8)(st->mem_state >> 1);
+ }
+
+ /*
+ * If this frame is the first speech frame after CNI period,
+ * set the BFH state machine to an appropriate state depending
+ * on whether there was DTX muting before start of speech or not
+ * If there was DTX muting, the first speech frame is muted.
+ * If there was no DTX muting, the first speech frame is not
+ * muted. The BFH state machine starts from state 5, however, to
+ * keep the audible noise resulting from a SID frame which is
+ * erroneously interpreted as a good speech frame as small as
+ * possible (the decoder output in this case is quickly muted)
+ */
+
+ if(st->dtx_decSt->mem_dtx_global_state == DTX)
+ {
+ st->mem_state = 5;
+ st->mem_bfi = 0;
+ }
+ else if(st->dtx_decSt->mem_dtx_global_state == D_DTX_MUTE)
+ {
+ st->mem_state = 5;
+ st->mem_bfi = 1;
+ }
+
+ if(newDTXState == SPEECH)
+ {
+ vad_flag = (UWord8)(*prms++);
+
+ if(bfi == 0)
+ {
+ if(vad_flag == 0)
+ {
+ st->mem_vad_hist = (Word16)(st->mem_vad_hist + 1);
+
+ if(st->mem_vad_hist > 32767)
+ {
+ st->mem_vad_hist = 32767;
+ }
+ }
+ else
+ {
+ st->mem_vad_hist = 0;
+ }
+ }
+ }
+
+ /*
+ * DTX-CNG
+ */
+ if(newDTXState != SPEECH) /* CNG mode */
+ {
+ /*
+ * increase slightly energy of noise below 200 Hz
+ * Convert ISFs to the cosine domain
+ */
+ D_LPC_isf_isp_conversion(isf, ispnew, M);
+ D_LPC_isp_a_conversion(ispnew, Aq, 1, M);
+ memcpy(isf_tmp, st->mem_isf, M * sizeof(Word16));
+
+ for(i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR)
+ {
+ j = (i_subfr >> 6);
+
+ for(i = 0; i < M; i++)
+ {
+ L_tmp = (isf_tmp[i] * (32767 - D_ROM_interpol_frac[j])) << 1;
+ L_tmp = L_tmp + ((isf[i] * D_ROM_interpol_frac[j]) << 1);
+ HfIsf[i] = (Word16)((L_tmp + 0x8000) >> 16);
+ }
+
+ D_UTIL_dec_synthesis(Aq, &exc2[i_subfr], 0, &synth16k[i_subfr * 5 /4],
+ (Word16) 1, HfIsf, mode, newDTXState, bfi, st);
+ }
+
+ /* reset speech coder memories */
+ D_MAIN_reset(st, 0);
+ memcpy(st->mem_isf, isf, M * sizeof(Word16));
+ st->mem_bfi = bfi;
+ st->dtx_decSt->mem_dtx_global_state = (UWord8)newDTXState;
+
+ return(0);
+ }
+
+ /*
+ * ACELP
+ */
+
+ exc = st->mem_exc + PIT_MAX + L_INTERPOL;
+
+ /* Decode the ISFs */
+ if(mode <= MODE_7k)
+ {
+ ind[0] = *prms++;
+ ind[1] = *prms++;
+ ind[2] = *prms++;
+ ind[3] = *prms++;
+ ind[4] = *prms++;
+ D_LPC_isf_2s3s_decode(ind, isf, st->mem_isf_q, st->mem_isf,
+ st->mem_isf_buf, bfi);
+ }
+ else
+ {
+ ind[0] = *prms++;
+ ind[1] = *prms++;
+ ind[2] = *prms++;
+ ind[3] = *prms++;
+ ind[4] = *prms++;
+ ind[5] = *prms++;
+ ind[6] = *prms++;
+ D_LPC_isf_2s5s_decode(ind, isf, st->mem_isf_q, st->mem_isf,
+ st->mem_isf_buf, bfi);
+ }
+
+ /* Convert ISFs to the cosine domain */
+ D_LPC_isf_isp_conversion(isf, ispnew, M);
+
+ if(st->mem_first_frame != 0)
+ {
+ st->mem_first_frame = 0;
+ memcpy(st->mem_isp, ispnew, M * sizeof(Word16));
+ }
+
+ /* Find the interpolated ISPs and convert to a[] for all subframes */
+ D_LPC_int_isp_find(st->mem_isp, ispnew, D_ROM_interpol_frac, Aq);
+
+ /* update isp memory for the next frame */
+ memcpy(st->mem_isp, ispnew, M * sizeof(Word16));
+
+ /* Check stability on isf : distance between old isf and current isf */
+ L_tmp = 0;
+ p_isf = st->mem_isf;
+
+ for(i = 0; i < M - 1; i++)
+ {
+ tmp = (Word16)((isf[i] - p_isf[i]));
+ L_tmp = L_tmp + (tmp * tmp);
+ }
+
+ if(L_tmp < 3276928)
+ {
+ L_tmp = L_tmp >> 7;
+ L_tmp = (L_tmp * 26214) >> 15; /* tmp = L_tmp*0.8/256 */
+ L_tmp = 20480 - L_tmp; /* 1.25 - tmp */
+ L_stab_fac = L_tmp << 1; /* Q14 -> Q15 with saturation */
+
+ if(L_stab_fac > 0x7FFF)
+ {
+ L_stab_fac = 0x7FFF;
+ }
+ }
+ else
+ {
+ L_stab_fac = 0x0;
+ }
+
+ memcpy(isf_tmp, st->mem_isf, M * sizeof(Word16));
+ memcpy(st->mem_isf, isf, M * sizeof(Word16));
+
+ /*
+ * Loop for every subframe in the analysis frame
+ *
+ * The subframe size is L_SUBFR and the loop is repeated L_FRAME/L_SUBFR
+ * times
+ * - decode the pitch delay and filter mode
+ * - decode algebraic code
+ * - decode pitch and codebook gains
+ * - find voicing factor and tilt of code for next subframe
+ * - find the excitation and compute synthesis speech
+ */
+
+ p_Aq = Aq; /* pointer to interpolated LPC parameters */
+
+ for(i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR)
+ {
+ pit_flag = i_subfr;
+
+ if((i_subfr == (2 * L_SUBFR)) & (mode > MODE_7k))
+ {
+ pit_flag = 0;
+ }
+
+ /*
+ * - Decode pitch lag
+ * Lag indeces received also in case of BFI,
+ * so that the parameter pointer stays in sync.
+ */
+
+ if(pit_flag == 0)
+ {
+ if(mode <= MODE_9k)
+ {
+ index = *prms++;
+
+ if(index < ((PIT_FR1_8b - PIT_MIN) * 2))
+ {
+ T0 = (PIT_MIN + (index >> 1));
+ T0_frac = (index - ((T0 - PIT_MIN) << 1));
+ T0_frac = (T0_frac << 1);
+ }
+ else
+ {
+ T0 = index + (PIT_FR1_8b - ((PIT_FR1_8b - PIT_MIN) * 2));
+ T0_frac = 0;
+ }
+ }
+ else
+ {
+ index = *prms++;
+
+ if(index < ((PIT_FR2 - PIT_MIN) * 4))
+ {
+ T0 = PIT_MIN + (index >> 2);
+ T0_frac = index - ((T0 - PIT_MIN) << 2);
+ }
+ else if(index <
+ ((((PIT_FR2 - PIT_MIN) * 4) + ((PIT_FR1_9b - PIT_FR2) * 2))))
+ {
+ index = (Word16)((index - ((PIT_FR2 - PIT_MIN) * 4)));
+ T0 = PIT_FR2 + (index >> 1);
+ T0_frac = index - ((T0 - PIT_FR2) << 1);
+ T0_frac = T0_frac << 1;
+ }
+ else
+ {
+ T0 = index + (PIT_FR1_9b - ((PIT_FR2 - PIT_MIN) * 4) -
+ ((PIT_FR1_9b - PIT_FR2) * 2));
+ T0_frac = 0;
+ }
+ }
+
+ /* find T0_min and T0_max for subframe 2 and 4 */
+ T0_min = T0 - 8;
+
+ if(T0_min < PIT_MIN)
+ {
+ T0_min = PIT_MIN;
+ }
+
+ T0_max = T0_min + 15;
+
+ if(T0_max > PIT_MAX)
+ {
+ T0_max = PIT_MAX;
+ T0_min = T0_max - 15;
+ }
+ }
+ else
+ { /* if subframe 2 or 4 */
+
+ if(mode <= MODE_9k)
+ {
+ index = *prms++;
+ T0 = T0_min + (index >> 1);
+ T0_frac = index - ((T0 - T0_min) << 1);
+ T0_frac = T0_frac << 1;
+ }
+ else
+ {
+ index = *prms++;
+ T0 = T0_min + (index >> 2);
+ T0_frac = index - ((T0 - T0_min) << 2);
+ }
+ }
+
+ /* check BFI after pitch lag decoding */
+ if(bfi != 0) /* if frame erasure */
+ {
+ D_GAIN_lag_concealment(&(st->mem_gain[17]), st->mem_lag, &T0,
+ &(st->mem_T0), &(st->mem_seed3), unusable_frame);
+ T0_frac = 0;
+ }
+
+ /*
+ * Find the pitch gain, the interpolation filter
+ * and the adaptive codebook vector.
+ */
+
+ D_GAIN_adaptive_codebook_excitation(&exc[i_subfr], T0, T0_frac);
+
+ if(unusable_frame)
+ {
+ select = 1;
+ }
+ else
+ {
+ if(mode <= MODE_9k)
+ {
+ select = 0;
+ }
+ else
+ {
+ select = *prms++;
+ }
+ }
+
+ if(select == 0)
+ {
+ /* find pitch excitation with lp filter */
+ for(i = 0; i < L_SUBFR; i++)
+ {
+ L_tmp = 2949 * exc[i - 1 + i_subfr];
+ L_tmp = L_tmp + (10486 * exc[i + i_subfr]);
+ L_tmp = L_tmp + (2949 * exc[i + 1 + i_subfr]);
+ code[i] = (Word16)((L_tmp + 0x2000) >> 14);
+ }
+
+ memcpy(&exc[i_subfr], code, L_SUBFR * sizeof(Word16));
+ }
+
+ /*
+ * Decode innovative codebook.
+ * Add the fixed-gain pitch contribution to code[].
+ */
+
+ if(unusable_frame != 0)
+ {
+ /* the innovative code doesn't need to be scaled (see Q_gain2) */
+ for(i = 0; i < L_SUBFR; i++)
+ {
+ code[i] = (Word16)(D_UTIL_random(&(st->mem_seed)) >> 3);
+ }
+ }
+ else if(mode <= MODE_7k)
+ {
+ ind[0] = *prms++;
+ D_ACELP_decode_2t(ind[0], code);
+ }
+ else if(mode <= MODE_9k)
+ {
+ memcpy(ind, prms, 4 * sizeof(Word16));
+ prms += 4;
+ D_ACELP_decode_4t(ind, 20, code);
+ }
+ else if(mode <= MODE_12k)
+ {
+ memcpy(ind, prms, 4 * sizeof(Word16));
+ prms += 4;
+ D_ACELP_decode_4t(ind, 36, code);
+ }
+ else if(mode <= MODE_14k)
+ {
+ memcpy(ind, prms, 4 * sizeof(Word16));
+ prms += 4;
+ D_ACELP_decode_4t(ind, 44, code);
+ }
+ else if(mode <= MODE_16k)
+ {
+ memcpy(ind, prms, 4 * sizeof(Word16));
+ prms += 4;
+ D_ACELP_decode_4t(ind, 52, code);
+ }
+ else if(mode <= MODE_18k)
+ {
+ memcpy(ind, prms, 8 * sizeof(Word16));
+ prms += 8;
+ D_ACELP_decode_4t(ind, 64, code);
+ }
+ else if(mode <= MODE_20k)
+ {
+ memcpy(ind, prms, 8 * sizeof(Word16));
+ prms += 8;
+ D_ACELP_decode_4t(ind, 72, code);
+ }
+ else
+ {
+ memcpy(ind, prms, 8 * sizeof(Word16));
+ prms += 8;
+ D_ACELP_decode_4t(ind, 88, code);
+ }
+
+ tmp = 0;
+ D_UTIL_preemph(code, st->mem_tilt_code, L_SUBFR, &tmp);
+
+ L_tmp = T0;
+
+ if(T0_frac > 2)
+ {
+ L_tmp = L_tmp + 1;
+ }
+
+ D_GAIN_pitch_sharpening(code, L_tmp, PIT_SHARP);
+
+ /*
+ * Decode codebooks gains.
+ */
+ index = *prms++; /* codebook gain index */
+
+ if(mode <= MODE_9k)
+ {
+ D_GAIN_decode(index, 6, code, &gain_pit, &L_gain_code, bfi,
+ st->mem_bfi, st->mem_state, unusable_frame, st->mem_vad_hist,
+ st->mem_gain);
+ }
+ else
+ {
+ D_GAIN_decode(index, 7, code, &gain_pit, &L_gain_code, bfi,
+ st->mem_bfi, st->mem_state, unusable_frame, st->mem_vad_hist,
+ st->mem_gain);
+ }
+
+ /* find best scaling to perform on excitation (Q_new) */
+ tmp = st->mem_subfr_q[0];
+
+ for(i = 1; i < 4; i++)
+ {
+ if(st->mem_subfr_q[i] < tmp)
+ {
+ tmp = st->mem_subfr_q[i];
+ }
+ }
+
+ /* limit scaling (Q_new) to Q_MAX */
+ if(tmp > Q_MAX)
+ {
+ tmp = Q_MAX;
+ }
+
+ Q_new = 0;
+ L_tmp = L_gain_code; /* L_gain_code in Q16 */
+
+ while((L_tmp < 0x08000000L) && (Q_new < tmp))
+ {
+ L_tmp = (L_tmp << 1);
+ Q_new = (Word16)((Q_new + 1));
+ }
+
+ if(L_tmp < 0x7FFF7FFF)
+ {
+ gain_code = (Word16)((L_tmp + 0x8000) >> 16);
+ /* scaled gain_code with Qnew */
+ }
+ else
+ {
+ gain_code = 32767;
+ }
+
+ if(Q_new > st->mem_q)
+ {
+ D_UTIL_signal_up_scale(exc + i_subfr - (PIT_MAX + L_INTERPOL),
+ PIT_MAX + L_INTERPOL + L_SUBFR, (Word16)(Q_new - st->mem_q));
+ }
+ else
+ {
+ D_UTIL_signal_down_scale(exc + i_subfr - (PIT_MAX + L_INTERPOL),
+ PIT_MAX + L_INTERPOL + L_SUBFR, (Word16)(st->mem_q - Q_new));
+ }
+
+ st->mem_q = Q_new;
+
+ /*
+ * Update parameters for the next subframe.
+ * - tilt of code: 0.0 (unvoiced) to 0.5 (voiced)
+ */
+ if(bfi == 0)
+ {
+ /* LTP-Lag history update */
+ for(i = 4; i > 0; i--)
+ {
+ st->mem_lag[i] = st->mem_lag[i - 1];
+ }
+ st->mem_lag[0] = (Word16)T0;
+ st->mem_T0 = (Word16)T0;
+ st->mem_T0_frac = 0; /* Remove fraction in case of BFI */
+ }
+
+ /* find voice factor in Q15 (1=voiced, -1=unvoiced) */
+ memcpy(exc2, &exc[i_subfr], L_SUBFR * sizeof(Word16));
+ D_UTIL_signal_down_scale(exc2, L_SUBFR, 3);
+
+ /* post processing of excitation elements */
+ if(mode <= MODE_9k)
+ {
+ pit_sharp = (Word16)(gain_pit << 1);
+
+ if(pit_sharp > 16384)
+ {
+ if(pit_sharp > 32767)
+ {
+ pit_sharp = 32767;
+ }
+
+ for(i = 0; i < L_SUBFR; i++)
+ {
+ L_tmp = (exc2[i] * pit_sharp) >> 15;
+ L_tmp = L_tmp * gain_pit;
+ excp[i] = (Word16)((L_tmp + 0x8000) >> 16);
+ }
+ }
+ }
+
+ voice_fac = D_GAIN_find_voice_factor(exc2, -3, gain_pit, code, gain_code,
+ L_SUBFR);
+
+ /* tilt of code for next subframe: 0.5=voiced, 0=unvoiced */
+ st->mem_tilt_code = (Word16)((voice_fac >> 2) + 8192);
+
+ /*
+ * Find the total excitation.
+ * Find synthesis speech corresponding to exc[].
+ * Find maximum value of excitation for next scaling
+ */
+ memcpy(exc2, &exc[i_subfr], L_SUBFR * sizeof(Word16));
+ max = 1;
+
+ for(i = 0; i < L_SUBFR; i++)
+ {
+ L_tmp = (code[i] * gain_code) << 5;
+ L_tmp = L_tmp + (exc[i + i_subfr] * gain_pit);
+ L_tmp = (L_tmp + 0x2000) >> 14;
+
+ if((L_tmp > MIN_16) & (L_tmp < 32768))
+ {
+ exc[i + i_subfr] = (Word16)L_tmp;
+ tmp = (Word16)(abs(L_tmp));
+
+ if(tmp > max)
+ {
+ max = tmp;
+ }
+ }
+ else if(L_tmp > MAX_16)
+ {
+ exc[i + i_subfr] = MAX_16;
+ max = MAX_16;
+ }
+ else
+ {
+ exc[i + i_subfr] = MIN_16;
+ max = MAX_16;
+ }
+ }
+
+ /* tmp = scaling possible according to max value of excitation */
+ tmp = (Word16)((D_UTIL_norm_s(max) + Q_new) - 1);
+ st->mem_subfr_q[3] = st->mem_subfr_q[2];
+ st->mem_subfr_q[2] = st->mem_subfr_q[1];
+ st->mem_subfr_q[1] = st->mem_subfr_q[0];
+ st->mem_subfr_q[0] = tmp;
+
+ /*
+ * phase dispersion to enhance noise in low bit rate
+ */
+
+ /* L_gain_code in Q16 */
+ D_UTIL_l_extract(L_gain_code, &gain_code, &gain_code_lo);
+
+ if(mode <= MODE_7k)
+ {
+ j = 0; /* high dispersion for rate <= 7.5 kbit/s */
+ }
+ else if(mode <= MODE_9k)
+ {
+ j = 1; /* low dispersion for rate <= 9.6 kbit/s */
+ }
+ else
+ {
+ j = 2; /* no dispersion for rate > 9.6 kbit/s */
+ }
+
+ D_ACELP_phase_dispersion(gain_code, gain_pit, code, (Word16)j,
+ st->mem_ph_disp);
+
+ /*
+ * 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.
+ */
+ L_tmp = 16384 - (voice_fac >> 1); /* 1=unvoiced, 0=voiced */
+ fac = (Word16)((L_stab_fac * L_tmp) >> 15);
+ L_tmp = L_gain_code;
+
+ if(L_tmp < st->mem_gc_thres)
+ {
+ L_tmp = (L_tmp + D_UTIL_mpy_32_16(gain_code, gain_code_lo, 6226));
+
+ if(L_tmp > st->mem_gc_thres)
+ {
+ L_tmp = st->mem_gc_thres;
+ }
+ }
+ else
+ {
+ L_tmp = D_UTIL_mpy_32_16(gain_code, gain_code_lo, 27536);
+
+ if(L_tmp < st->mem_gc_thres)
+ {
+ L_tmp = st->mem_gc_thres;
+ }
+ }
+ st->mem_gc_thres = L_tmp;
+ L_gain_code =
+ D_UTIL_mpy_32_16(gain_code, gain_code_lo, (Word16)(32767 - fac));
+ D_UTIL_l_extract(L_tmp, &gain_code, &gain_code_lo);
+ L_gain_code =
+ L_gain_code + D_UTIL_mpy_32_16(gain_code, gain_code_lo, fac);
+
+ /*
+ * pitch enhancer
+ * - Enhance excitation on voice. (HP filtering of code)
+ * On voiced signal, filtering of code by a smooth fir HP
+ * filter to decrease energy of code in low frequency.
+ */
+
+ L_tmp2 = (voice_fac >> 3) + 4096; /* 0.25=voiced, 0=unvoiced */
+ L_tmp = (code[0] << 15) - (code[1] * L_tmp2);
+ code2[0] = (L_tmp + 0x4000) >> 15;
+
+ for(i = 1; i < L_SUBFR - 1; i++)
+ {
+ L_tmp = code[i] << 15;
+ L_tmp = L_tmp - (code[i + 1] * L_tmp2);
+ L_tmp = L_tmp - (code[i - 1] * L_tmp2);
+ code2[i] = (L_tmp + 0x4000) >> 15;
+ }
+
+ L_tmp = code[L_SUBFR - 1] << 15;
+ L_tmp = L_tmp - (code[L_SUBFR - 2] * L_tmp2);
+ code2[L_SUBFR - 1] = (L_tmp + 0x4000) >> 15;
+
+ /* build excitation */
+ gain_code = (Word16)(((L_gain_code << Q_new) + 0x8000) >> 16);
+
+ for(i = 0; i < L_SUBFR; i++)
+ {
+ L_tmp = (code2[i] * gain_code) << 5;
+ L_tmp = L_tmp + (exc2[i] * gain_pit);
+ L_tmp = (L_tmp + 0x2000) >> 14;
+
+ exc2[i] = D_UTIL_saturate(L_tmp);
+ }
+
+ if(mode <= MODE_9k)
+ {
+ if(pit_sharp > 16384)
+ {
+ for(i = 0; i < L_SUBFR; i++)
+ {
+ L_tmp = (excp[i] + exc2[i]);
+ excp[i] = D_UTIL_saturate(L_tmp);
+ }
+
+ D_GAIN_adaptive_control(exc2, excp, L_SUBFR);
+ memcpy(exc2, excp, L_SUBFR * sizeof(Word16));
+ }
+ }
+
+ if(mode <= MODE_7k)
+ {
+ j = (i_subfr >> 6);
+
+ for(i = 0; i < M; i++)
+ {
+ L_tmp = isf_tmp[i] * (32767 - D_ROM_interpol_frac[j]);
+ L_tmp = L_tmp + (isf[i] * D_ROM_interpol_frac[j]);
+ HfIsf[i] = (Word16)((L_tmp + 0x4000) >> 15);
+ }
+ }
+ else
+ {
+ memset(st->mem_syn_hf, 0, (M16k - M) * sizeof(Word16));
+ }
+
+ if(mode >= MODE_24k)
+ {
+ corr_gain = *prms++;
+ D_UTIL_dec_synthesis(p_Aq, exc2, Q_new, &synth16k[i_subfr * 5 / 4],
+ corr_gain, HfIsf, mode, newDTXState, bfi, st);
+ }
+ else
+ {
+ D_UTIL_dec_synthesis(p_Aq, exc2, Q_new, &synth16k[i_subfr * 5 / 4], 0,
+ HfIsf, mode, newDTXState, bfi, st);
+ }
+
+ p_Aq += (M + 1); /* interpolated LPC parameters for next subframe */
+ }
+
+ /*
+ * Update signal for next frame
+ * -> save past of exc[]
+ * -> save pitch parameters.
+ */
+
+ memmove(st->mem_exc, &st->mem_exc[L_FRAME], (PIT_MAX + L_INTERPOL) * sizeof(Word16));
+ D_UTIL_signal_down_scale(exc, L_FRAME, Q_new);
+ D_DTX_activity_update(st->dtx_decSt, isf, exc);
+ st->dtx_decSt->mem_dtx_global_state = (UWord8)newDTXState;
+ st->mem_bfi = bfi;
+
+ return(0);
+}
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_main.h b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_main.h
new file mode 100644
index 000000000..4896622ae
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_main.h
@@ -0,0 +1,58 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef DEC_MAIN_H
+#define DEC_MAIN_H
+
+#include "typedef.h"
+#include "dec_dtx.h"
+
+#define L_FRAME 256 /* Frame size */
+#define PIT_MAX 231 /* Maximum pitch lag */
+#define L_INTERPOL (16 + 1) /* Length of filter for interpolation */
+#define L_MEANBUF 3
+#define L_FILT 12 /* Delay of up-sampling filter */
+#define L_FILT16k 15 /* Delay of down-sampling filter */
+#define M16k 20 /* Order of LP filter */
+
+typedef struct
+{
+ Word32 mem_gc_thres; /* threshold for noise enhancer */
+ Word16 mem_exc[(L_FRAME + 1) + PIT_MAX + L_INTERPOL];/* old excitation vector */
+ Word16 mem_isf_buf[L_MEANBUF * M];/* isf buffer(frequency domain) */
+ Word16 mem_hf[2 * L_FILT16k]; /* HF band-pass filter memory */
+ Word16 mem_hf2[2 * L_FILT16k]; /* HF band-pass filter memory */
+ Word16 mem_hf3[2 * L_FILT16k]; /* HF band-pass filter memory */
+ Word16 mem_oversamp[2 * L_FILT]; /* synthesis oversampled filter memory */
+ Word16 mem_gain[23]; /* gain decoder memory */
+ Word16 mem_syn_hf[M16k]; /* HF synthesis memory */
+ Word16 mem_isp[M]; /* old isp (immittance spectral pairs) */
+ Word16 mem_isf[M]; /* old isf (frequency domain) */
+ Word16 mem_isf_q[M]; /* past isf quantizer */
+ Word16 mem_syn_hi[M]; /* modified synthesis memory (MSB) */
+ Word16 mem_syn_lo[M]; /* modified synthesis memory (LSB) */
+ Word16 mem_ph_disp[8]; /* phase dispersion memory */
+ Word16 mem_sig_out[6]; /* hp50 filter memory for synthesis */
+ Word16 mem_hp400[6]; /* hp400 filter memory for synthesis */
+ Word16 mem_lag[5]; /* LTP lag history */
+ Word16 mem_subfr_q[4]; /* old maximum scaling factor */
+ Word16 mem_tilt_code; /* tilt of code */
+ Word16 mem_q; /* old scaling factor */
+ Word16 mem_deemph; /* speech deemph filter memory */
+ Word16 mem_seed; /* random memory for frame erasure */
+ Word16 mem_seed2; /* random memory for HF generation */
+ Word16 mem_seed3; /* random memory for lag concealment */
+ Word16 mem_T0; /* old pitch lag */
+ Word16 mem_T0_frac; /* old pitch fraction lag */
+ UWord16 mem_vad_hist; /* VAD history */
+ D_DTX_State *dtx_decSt;
+ UWord8 mem_bfi; /* Previous BFI */
+ UWord8 mem_state; /* BGH state machine memory */
+ UWord8 mem_first_frame; /* First frame indicator */
+
+} Decoder_State;
+
+#endif
+
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_rom.c b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_rom.c
new file mode 100644
index 000000000..fb2dc91c8
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_rom.c
@@ -0,0 +1,2112 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#include "typedef.h"
+
+#define L_SUBFR 64 /* Subframe size */
+#define L_FIR 31
+#define ORDER 16 /* Order of linear prediction filter */
+#define M 16 /* Order of LP filter */
+#define NB_SUBFR 4 /* Number of subframe per frame */
+#define UP_SAMP 4
+#define L_INTERPOL2 16
+
+#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 SIZE_BK_NOISE1 64
+#define SIZE_BK_NOISE2 64
+#define SIZE_BK_NOISE3 64
+#define SIZE_BK_NOISE4 32
+#define SIZE_BK_NOISE5 32
+
+/* 16-byte align start */
+
+/*
+ * isf codebooks: two-stage VQ with split-by-5 in 2nd stage
+ *
+ * codebook vector dimension number of vectors
+ * ~~~~~~~~ ~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
+ * 1_1 9 256
+ * 1_2 7 256
+ * 2_1 3 64
+ * 2_2 3 128
+ * 2_3 3 128
+ * 2_4 3 32
+ * 2_5 4 32
+ */
+
+/*
+ * 1st stage codebook; 1st split: isf0 to isf8
+ */
+
+const Word16 D_ROM_dico1_isf[SIZE_BK1 * 9] = {
+
+ 579, 1081, 1035, 390, 3, -263, -198, -82, 38,
+ 18, -68, -12, 313, 761, 405, 249, 111, -76,
+ 740, 1263, 1292, 1006, 997, 1019, 1017, 976, 923,
+ -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,
+ 557, 946, 1049, 867, 846, 990, 1112, 1262, 1241,
+ -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,
+ 633, 898, 996, 756, 662, 683, 783, 909, 996,
+ -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,
+ 830, 736, 278, 820, 1254, 686, 712, 1039, 473,
+ -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,
+ 503, 885, 1508, 1307, 1282, 1172, 1119, 1209, 1061,
+ 416, 719, 989, 1227, 1001, 1052, 954, 741, 1044,
+ -127, -376, -657, 139, 623, 223, 501, 306, 220,
+ -113, -384, -796, 504, 438, 85, 213, -83, -194,
+ 585, 1132, 1233, 1091, 1247, 1433, 1512, 1448, 1314,
+ -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,
+ -31, 469, 803, 659, 619, 658, 843, 987, 1113,
+ -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,
+ 842, 1678, 1841, 1549, 1474, 1256, 1082, 905, 742,
+ 370, 1216, 1768, 1633, 1212, 636, 22, -330, 71,
+ -76, -281, -741, -742, 898, 619, 277, 71, -222,
+ -32, -265, -556, -25, 994, 682, 305, 126, -165,
+ 73, 738, 893, 968, 993, 1768, 2273, 1840, 1391,
+ -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,
+ 1513, 1714, 1238, 534, 276, 315, 461, 459, 508,
+ -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,
+ 421, 1293, 1640, 1623, 1742, 1617, 1499, 1284, 1006,
+ -95, 752, 1680, 1569, 1618, 1436, 1200, 980, 712,
+ -69, -300, -683, -435, 1132, 899, 504, 332, 109,
+ -74, -323, -637, 563, 1074, 608, 371, 105, -49,
+ -78, 831, 1194, 1110, 1378, 1481, 1492, 1365, 1217,
+ -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,
+ 670, 1208, 1168, 860, 742, 601, 528, 403, 309,
+ 397, 621, 966, 752, 579, 398, 400, 329, 252,
+ 191, 180, -137, -467, 272, 106, -95, 17, -192,
+ -80, -290, -626, 194, 598, 196, 21, -281, 77,
+ 510, 864, 1108, 807, 939, 902, 925, 717, 481,
+ 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,
+ 539, 835, 913, 719, 617, 544, 591, 565, 642,
+ 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,
+ 162, 889, 654, 108, -34, 244, 488, 561, 532,
+ 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,
+ -62, 1033, 1308, 1035, 1127, 1098, 1029, 961, 823,
+ 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,
+ -14, 945, 990, 801, 755, 815, 847, 913, 892,
+ 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,
+ 394, 1765, 1666, 1339, 1117, 806, 642, 479, 380,
+ 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,
+ 529, 1851, 2003, 1228, 622, -41, -416, 344, 819,
+ -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,
+ 635, 1058, 883, 492, 372, 312, 317, 274, 241,
+ 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,
+ 279, 966, 1642, 1478, 1463, 1123, 795, 525, 339,
+ -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,
+ 457, 955, 1177, 1214, 1427, 1457, 1345, 917, 539,
+ -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,
+ 148, 751, 1515, 1105, 867, 606, 474, 448, 399,
+ -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
+};
+
+/*
+ * 1st stage codebook; 2nd split: isf9 to isf15
+ */
+
+const Word16 D_ROM_dico2_isf[SIZE_BK2 * 7] = {
+
+ 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
+};
+
+/*
+ * 2nd stage codebook; 1st split: isf2_0 to isf2_2
+ */
+const Word16 D_ROM_dico21_isf[SIZE_BK21 * 3] = {
+
+ 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
+};
+
+
+
+/*
+ * 2nd stage codebook; 2nd split: isf2_3 to isf2_5
+ */
+const Word16 D_ROM_dico22_isf[SIZE_BK22 * 3] = {
+
+ -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
+};
+
+
+/*
+ * 2nd stage codebook; 3rd split: isf2_6 to isf2_8
+ */
+const Word16 D_ROM_dico23_isf[SIZE_BK23 * 3] = {
+
+ -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
+};
+
+
+/*
+ * 2nd stage codebook; 4th split: isf2_9 to isf2_11
+ */
+const Word16 D_ROM_dico24_isf[SIZE_BK24 * 3] = {
+
+ -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
+};
+
+
+/*
+ * 2nd stage codebook; 5th split: isf2_12 to isf2_15
+ */
+const Word16 D_ROM_dico25_isf[SIZE_BK25 * 4] = {
+
+ 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 codebooks: two-stage VQ with split-by-3 in 2nd stage
+ * 1st stage is kept the same as the 46 bit quantizer
+ *
+ * codebook vector dimension number of vectors
+ * ~~~~~~~~ ~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
+ * 1_1 9 256
+ * 1_2 7 256
+ * 2_1 5 128
+ * 2_2 4 128
+ * 2_3 7 64
+ */
+
+const Word16 D_ROM_dico21_isf_36b[SIZE_BK21_36b * 5] = {
+
+ -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
+};
+
+const Word16 D_ROM_dico22_isf_36b[SIZE_BK22_36b * 4] = {
+
+ -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
+};
+
+const Word16 D_ROM_dico23_isf_36b[SIZE_BK23_36b * 7] = {
+
+ 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 codebooks: split-by-5 VQ
+ *
+ * codebook vector dimension number of vectors
+ * ~~~~~~~~ ~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
+ * 1 2 64
+ * 2 3 64
+ * 3 3 64
+ * 4 4 32
+ * 5 4 32
+ */
+
+/*
+ * 1st split: isf0 to isf1
+ */
+const Word16 D_ROM_dico1_isf_noise[SIZE_BK_NOISE1 * 2] = {
+ -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
+};
+
+
+/*
+ * 2nd split: isf2 to isf4
+ */
+const Word16 D_ROM_dico2_isf_noise[SIZE_BK_NOISE2 * 3] = {
+ -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
+};
+
+/*
+ * 3rd split: isf5 to isf7
+ */
+const Word16 D_ROM_dico3_isf_noise[SIZE_BK_NOISE3 * 3] = {
+ -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
+};
+
+/*
+ * 4th split: isf8 to isf11
+ */
+const Word16 D_ROM_dico4_isf_noise[SIZE_BK_NOISE4 * 4] = {
+ -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
+};
+
+/*
+ * 5th split: isf12 to isf15
+ */
+const Word16 D_ROM_dico5_isf_noise[SIZE_BK_NOISE5 * 4] = {
+ -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 pitch and codebook gains
+ *
+ * g_pitch(Q14), g_code(Q11)
+ *
+ * pitch gain are ordered in table to reduce complexity
+ * during quantization of gains.
+ */
+
+/* Number of quantization level is 64 */
+const Word16 D_ROM_qua_gain6b[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
+};
+
+/* Number of quantization level is 128 */
+const Word16 D_ROM_qua_gain7b[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
+};
+
+/*
+ * 1/4 resolution interpolation filter (-3 dB at 0.856*fs/2) in Q14
+ */
+const Word16 D_ROM_inter4_2[UP_SAMP * 2 * L_INTERPOL2] = {
+ 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
+};
+
+/*
+ * 1/5 resolution interpolation filter (in Q14)
+ * -1.5dB @ 6kHz, -6dB @ 6.4kHz, -10dB @ 6.6kHz, -20dB @ 6.9kHz, -25dB @ 7kHz, -55dB @ 8kHz
+ */
+const Word16 D_ROM_fir_up[120] = {
+ -1, -4, -7, -6, 0,
+ 12, 24, 30, 23, 0,
+ -33, -62, -73, -52, 0,
+ 68, 124, 139, 96, 0,
+ -119, -213, -235, -160, 0,
+ 191, 338, 368, 247, 0,
+ -291, -510, -552, -369, 0,
+ 430, 752, 812, 542, 0,
+ -634, -1111, -1204, -809, 0,
+ 963, 1708, 1881, 1288, 0,
+ -1616, -2974, -3432, -2496, 0,
+ 3792, 8219, 12368, 15317, 16384,
+ 15317, 12368, 8219, 3792, 0,
+ -2496, -3432, -2974, -1616, 0,
+ 1288, 1881, 1708, 963, 0,
+ -809, -1204, -1111, -634, 0,
+ 542, 812, 752, 430, 0,
+ -369, -552, -510, -291, 0,
+ 247, 368, 338, 191, 0,
+ -160, -235, -213, -119, 0,
+ 96, 139, 124, 68, 0,
+ -52, -73, -62, -33, 0,
+ 23, 30, 24, 12, 0,
+ -6, -7, -4, -1, 0
+};
+
+/* table x4/5 */
+const Word16 D_ROM_fir_down[120] = {
+ -1, -3, -6, -5,
+ 0, 9, 19, 24,
+ 18, 0, -26, -50,
+ -58, -41, 0, 54,
+ 99, 111, 77, 0,
+ -95, -170, -188, -128,
+ 0, 153, 270, 294,
+ 198, 0, -233, -408,
+ -441, -295, 0, 344,
+ 601, 649, 434, 0,
+ -507, -888, -964, -647,
+ 0, 770, 1366, 1505,
+ 1030, 0, -1293, -2379,
+ -2746, -1997, 0, 3034,
+ 6575, 9894, 12254, 13107,
+ 12254, 9894, 6575, 3034,
+ 0, -1997, -2746, -2379,
+ -1293, 0, 1030, 1505,
+ 1366, 770, 0, -647,
+ -964, -888, -507, 0,
+ 434, 649, 601, 344,
+ 0, -295, -441, -408,
+ -233, 0, 198, 294,
+ 270, 153, 0, -128,
+ -188, -170, -95, 0,
+ 77, 111, 99, 54,
+ 0, -41, -58, -50,
+ -26, 0, 18, 24,
+ 19, 9, 0, -5,
+ -6, -3, -1, 0
+};
+
+/*
+ * Impulse response with phase dispersion
+ */
+
+/* 2.0 - 6.4 kHz phase dispersion */
+const Word16 D_ROM_ph_imp_low[L_SUBFR] = {
+ 20182, 9693, 3270, -3437, 2864, -5240, 1589, -1357,
+ 600, 3893, -1497, -698, 1203, -5249, 1199, 5371,
+ -1488, -705, -2887, 1976, 898, 721, -3876, 4227,
+ -5112, 6400, -1032, -4725, 4093, -4352, 3205, 2130,
+ -1996, -1835, 2648, -1786, -406, 573, 2484, -3608,
+ 3139, -1363, -2566, 3808, -639, -2051, -541, 2376,
+ 3932, -6262, 1432, -3601, 4889, 370, 567, -1163,
+ -2854, 1914, 39, -2418, 3454, 2975, -4021, 3431
+};
+
+/* 3.2 - 6.4 kHz phase dispersion */
+const Word16 D_ROM_ph_imp_mid[L_SUBFR] = {
+ 24098, 10460, -5263, -763, 2048, -927, 1753, -3323,
+ 2212, 652, -2146, 2487, -3539, 4109, -2107, -374,
+ -626, 4270, -5485, 2235, 1858, -2769, 744, 1140,
+ -763, -1615, 4060, -4574, 2982, -1163, 731, -1098,
+ 803, 167, -714, 606, -560, 639, 43, -1766,
+ 3228, -2782, 665, 763, 233, -2002, 1291, 1871,
+ -3470, 1032, 2710, -4040, 3624, -4214, 5292, -4270,
+ 1563, 108, -580, 1642, -2458, 957, 544, 2540
+};
+
+/*
+ * Table for synthesis of signal at 16kHz with HF extension.
+ */
+const Word16 D_ROM_hp_gain[16] = {
+ 3624, 4673, 5597, 6479, 7425, 8378, 9324, 10264,
+ 11210, 12206, 13391, 14844, 16770, 19655, 24289, 32728
+};
+
+/*
+ * isp and isf tables for initialization
+ */
+const Word16 D_ROM_isp[M] = {
+ 32138, 30274, 27246, 23170, 18205, 12540, 6393, 0,
+ -6393, -12540, -18205, -23170, -27246, -30274, -32138, 1475
+};
+
+const Word16 D_ROM_isf[M] = {
+ 1024, 2048, 3072, 4096, 5120, 6144, 7168, 8192,
+ 9216, 10240, 11264, 12288, 13312, 14336, 15360, 3840
+};
+
+/*
+ * means of ISFs
+ */
+const Word16 D_ROM_mean_isf[ORDER] = {
+ 738, 1326, 2336, 3578, 4596, 5662, 6711, 7730,
+ 8750, 9753, 10705, 11728, 12833, 13971, 15043, 4037
+};
+
+const Word16 D_ROM_mean_isf_noise[ORDER] = {
+ 478, 1100, 2213, 3267, 4219, 5222, 6198, 7240,
+ 8229, 9153, 10098, 11108, 12144, 13184, 14165, 3803
+};
+
+/* 16-byte align end */
+
+/*
+ * LTP gain & fixed codebook gain consealement
+ */
+
+/* pitch gain weight */
+const Word16 D_ROM_pdown_unusable[7] = {32767, 31130, 29491, 24576, 7537, 1638, 328};
+const Word16 D_ROM_cdown_unusable[7] = {32767, 16384, 8192, 8192, 8192, 4915, 3277};
+
+/* codebook gain weight */
+const Word16 D_ROM_pdown_usable[7] = {32767, 32113, 31457, 24576, 7537, 1638, 328};
+const Word16 D_ROM_cdown_usable[7] = {32767, 32113, 32113, 32113, 32113, 32113, 22938};
+
+
+/*
+ * filter coefficients (gain=4.0)
+ */
+const Word16 D_ROM_fir_6k_7k[L_FIR] = {
+ -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 D_ROM_fir_7k[L_FIR] = {
+ -21, 47, -89, 146, -203,
+ 229, -177, 0, 335, -839,
+ 1485, -2211, 2931, -3542, 3953,
+ 28682, 3953, -3542, 2931, -2211,
+ 1485, -839, 335, 0, -177,
+ 229, -203, 146, -89, 47,
+ -21
+};
+
+/*
+ * LPC interpolation coef {0.45, 0.8, 0.96, 1.0}; in Q15
+ */
+const Word16 D_ROM_interpol_frac[NB_SUBFR] = {14746, 26214, 31457, 32767};
+
+/*
+ * Math tables
+ */
+const Word16 D_ROM_pow2[33] = {
+ 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, 32767
+};
+
+const Word16 D_ROM_isqrt[49] = {
+ 32767, 31790, 30894, 30070, 29309, 28602, 27945, 27330, 26755, 26214,
+ 25705, 25225, 24770, 24339, 23930, 23541, 23170, 22817, 22479, 22155,
+ 21845, 21548, 21263, 20988, 20724, 20470, 20225, 19988, 19760, 19539,
+ 19326, 19119, 18919, 18725, 18536, 18354, 18176, 18004, 17837, 17674,
+ 17515, 17361, 17211, 17064, 16921, 16782, 16646, 16514, 16384
+};
+
+const Word16 D_ROM_log2[33] = {
+ 0, 1455, 2866, 4236, 5568, 6863, 8124, 9352, 10549, 11716,
+ 12855, 13967, 15054, 16117, 17156, 18172, 19167, 20142, 21097, 22033,
+ 22951, 23852, 24735, 25603, 26455, 27291, 28113, 28922, 29716, 30497,
+ 31266, 32023, 32767
+};
+
+/* table of cos(x) in Q15 */
+const Word16 D_ROM_cos[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
+};
+
+
+
+
+
+
+
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_util.c b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_util.c
new file mode 100644
index 000000000..d3c525ab3
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_util.c
@@ -0,0 +1,1387 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#include <math.h>
+#include <memory.h>
+#include "typedef.h"
+#include "dec_main.h"
+#include "dec_lpc.h"
+
+#define MAX_16 (Word16)0x7FFF
+#define MIN_16 (Word16)0x8000
+#define L_SUBFR 64 /* Subframe size */
+#define L_SUBFR16k 80 /* Subframe size at 16kHz */
+#define M16k 20 /* Order of LP filter */
+#define PREEMPH_FAC 22282 /* preemphasis factor (0.68 in Q15) */
+#define FAC4 4
+#define FAC5 5
+#define UP_FAC 20480 /* 5/4 in Q14 */
+#define INV_FAC5 6554 /* 1/5 in Q15 */
+#define NB_COEF_UP 12
+#define L_FIR 31
+#define MODE_7k 0
+#define MODE_24k 8
+
+
+extern const Word16 D_ROM_pow2[];
+extern const Word16 D_ROM_isqrt[];
+extern const Word16 D_ROM_log2[];
+extern const Word16 D_ROM_fir_up[];
+extern const Word16 D_ROM_fir_6k_7k[];
+extern const Word16 D_ROM_fir_7k[];
+extern const Word16 D_ROM_hp_gain[];
+
+#ifdef WIN32
+#pragma warning( disable : 4310)
+#endif
+/*
+ * D_UTIL_random
+ *
+ * Parameters:
+ * seed I/O: seed for random number
+ *
+ * Function:
+ * Signed 16 bits random generator.
+ *
+ * Returns:
+ * random number
+ */
+Word16 D_UTIL_random(Word16 *seed)
+{
+ /*static Word16 seed = 21845;*/
+ *seed = (Word16)(*seed * 31821L + 13849L);
+ return(*seed);
+}
+
+
+/*
+ * D_UTIL_pow2
+ *
+ * Parameters:
+ * exponant I: (Q0) Integer part. (range: 0 <= val <= 30)
+ * fraction I: (Q15) Fractionnal part. (range: 0.0 <= val < 1.0)
+ *
+ * Function:
+ * 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)
+ *
+ * Returns:
+ * range 0 <= val <= 0x7fffffff
+ */
+Word32 D_UTIL_pow2(Word16 exponant, Word16 fraction)
+{
+ Word32 L_x, tmp, i, exp;
+ Word16 a;
+
+ L_x = fraction * 32; /* L_x = fraction<<6 */
+ i = L_x >> 15; /* Extract b10-b16 of fraction */
+ a = (Word16)(L_x); /* Extract b0-b9 of fraction */
+ a = (Word16)(a & (Word16)0x7fff);
+ L_x = D_ROM_pow2[i] << 16; /* table[i] << 16 */
+ tmp = D_ROM_pow2[i] - D_ROM_pow2[i + 1]; /* table[i] - table[i+1] */
+ tmp = L_x - ((tmp * a) << 1); /* L_x -= tmp*a*2 */
+ exp = 30 - exponant;
+ if (exp <= 31)
+ {
+ L_x = tmp >> exp;
+
+ if ((1 << (exp - 1)) & tmp)
+ {
+ L_x++;
+ }
+ }
+ else
+ {
+ L_x = 0;
+ }
+
+ return(L_x);
+}
+
+
+/*
+ * D_UTIL_norm_l
+ *
+ * Parameters:
+ * L_var1 I: 32 bit Word32 signed integer (Word32) whose value
+ * falls in the range 0x8000 0000 <= var1 <= 0x7fff ffff.
+ *
+ * Function:
+ * Produces the number of left shifts needed to normalize the 32 bit
+ * variable L_var1 for positive values on the interval with minimum of
+ * 1073741824 and maximum of 2147483647, and for negative values on
+ * the interval 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)).
+ *
+ * Returns:
+ * 16 bit Word16 signed integer (Word16) whose value falls in the range
+ * 0x0000 0000 <= var_out <= 0x0000 001f.
+ */
+Word16 D_UTIL_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;
+ }
+ }
+ }
+
+ return(var_out);
+}
+
+
+/*
+ * D_UTIL_norm_s
+ *
+ * Parameters:
+ * L_var1 I: 32 bit Word32 signed integer (Word32) whose value
+ * falls in the range 0xffff 8000 <= var1 <= 0x0000 7fff.
+ *
+ * Function:
+ * Produces the number of left shift needed to normalize the 16 bit
+ * variable 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.
+ *
+ * Returns:
+ * 16 bit Word16 signed integer (Word16) whose value falls in the range
+ * 0x0000 0000 <= var_out <= 0x0000 000f.
+ */
+Word16 D_UTIL_norm_s(Word16 var1)
+{
+ Word16 var_out;
+
+ if(var1 == 0)
+ {
+ var_out = 0;
+ }
+ else
+ {
+ if(var1 == -1)
+ {
+ var_out = 15;
+ }
+ else
+ {
+ if(var1 < 0)
+ {
+ var1 = (Word16)~var1;
+ }
+
+ for(var_out = 0; var1 < 0x4000; var_out++)
+ {
+ var1 <<= 1;
+ }
+ }
+ }
+ return(var_out);
+}
+
+
+/*
+ * D_UTIL_dot_product12
+ *
+ * Parameters:
+ * x I: 12bit x vector
+ * y I: 12bit y vector
+ * lg I: vector length
+ * exp O: exponent of result (0..+30)
+ *
+ * Function:
+ * Compute scalar product of <x[],y[]> using accumulator.
+ * The result is normalized (in Q31) with exponent (0..30).
+ *
+ * Returns:
+ * Q31 normalised result (1 < val <= -1)
+ */
+Word32 D_UTIL_dot_product12(Word16 x[], Word16 y[], Word16 lg, Word16 *exp)
+{
+ Word32 sum, i, sft;
+
+ sum = 0L;
+
+ for(i = 0; i < lg; i++)
+ {
+ sum += x[i] * y[i];
+ }
+ sum = (sum << 1) + 1;
+
+ /* Normalize acc in Q31 */
+ sft = D_UTIL_norm_l(sum);
+ sum = sum << sft;
+ *exp = (Word16)(30 - sft); /* exponent = 0..30 */
+
+ return(sum);
+}
+
+
+/*
+ * D_UTIL_normalised_inverse_sqrt
+ *
+ * Parameters:
+ * frac I/O: (Q31) normalized value (1.0 < frac <= 0.5)
+ * exp I/O: exponent (value = frac x 2^exponent)
+ *
+ * Function:
+ * Compute 1/sqrt(value).
+ * If value is negative or zero, result is 1 (frac=7fffffff, exp=0).
+ *
+ * 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
+ *
+ * Returns:
+ * void
+ */
+void D_UTIL_normalised_inverse_sqrt(Word32 *frac, Word16 *exp)
+{
+ Word32 i, tmp;
+ Word16 a;
+
+ if(*frac <= (Word32)0)
+ {
+ *exp = 0;
+ *frac = 0x7fffffffL;
+ return;
+ }
+
+ if((*exp & 0x1) == 1) /* If exponant odd -> shift right */
+ {
+ *frac = *frac >> 1;
+ }
+ *exp = (Word16)(-((*exp - 1) >> 1));
+ *frac = *frac >> 9;
+ i = *frac >>16; /* Extract b25-b31 */
+ *frac = *frac >> 1;
+ a = (Word16)(*frac); /* Extract b10-b24 */
+ a = (Word16)(a & (Word16)0x7fff);
+ i = i - 16;
+ *frac = D_ROM_isqrt[i] << 16; /* table[i] << 16 */
+ tmp = D_ROM_isqrt[i] - D_ROM_isqrt[i + 1]; /* table[i] - table[i+1]) */
+ *frac = *frac - ((tmp * a) << 1); /* frac -= tmp*a*2 */
+
+ return;
+}
+
+
+/*
+ * D_UTIL_inverse_sqrt
+ *
+ * Parameters:
+ * L_x I/O: (Q0) input value (range: 0<=val<=7fffffff)
+ *
+ * Function:
+ * Compute 1/sqrt(L_x).
+ * If value is negative or zero, result is 1 (7fffffff).
+ *
+ * The function 1/sqrt(value) is approximated by a table and linear
+ * interpolation.
+ * 1. Normalization of L_x
+ * 2. call Normalised_Inverse_sqrt(L_x, exponant)
+ * 3. L_y = L_x << exponant
+ *
+ * Returns:
+ * (Q31) output value (range: 0 <= val < 1)
+ */
+Word32 D_UTIL_inverse_sqrt(Word32 L_x)
+{
+ Word32 L_y;
+ Word16 exp;
+
+ exp = D_UTIL_norm_l(L_x);
+ L_x = (L_x << exp); /* L_x is normalized */
+ exp = (Word16)(31 - exp);
+ D_UTIL_normalised_inverse_sqrt(&L_x, &exp);
+
+ if(exp < 0)
+ {
+ L_y = (L_x >> -exp); /* denormalization */
+ }
+ else
+ {
+ L_y = (L_x << exp); /* denormalization */
+ }
+
+ return(L_y);
+}
+
+
+/*
+ * D_UTIL_normalised_log2
+ *
+ * Parameters:
+ * L_x I: input value (normalized)
+ * exp I: norm_l (L_x)
+ * exponent O: Integer part of Log2. (range: 0<=val<=30)
+ * fraction O: Fractional part of Log2. (range: 0<=val<1)
+ *
+ * Function:
+ * 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.
+ *
+ * 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
+ *
+ *
+ * Returns:
+ * void
+ */
+static void D_UTIL_normalised_log2(Word32 L_x, Word16 exp, Word16 *exponent,
+ Word16 *fraction)
+{
+ Word32 i, a, tmp;
+ Word32 L_y;
+
+ if (L_x <= 0)
+ {
+ *exponent = 0;
+ *fraction = 0;
+ return;
+ }
+
+ *exponent = (Word16)(30 - exp);
+
+ L_x = L_x >> 10;
+ i = L_x >> 15; /* Extract b25-b31 */
+ a = L_x; /* Extract b10-b24 of fraction */
+ a = a & 0x00007fff;
+ i = i - 32;
+ L_y = D_ROM_log2[i] << 16; /* table[i] << 16 */
+ tmp = D_ROM_log2[i] - D_ROM_log2[i + 1]; /* table[i] - table[i+1] */
+ L_y = L_y - ((tmp * a) << 1); /* L_y -= tmp*a*2 */
+ *fraction = (Word16)(L_y >> 16);
+
+ return;
+}
+
+
+/*
+ * D_UTIL_log2
+ *
+ * Parameters:
+ * L_x I: input value
+ * exponent O: Integer part of Log2. (range: 0<=val<=30)
+ * fraction O: Fractional part of Log2. (range: 0<=val<1)
+ *
+ * Function:
+ * Computes log2(L_x), where L_x is positive.
+ * If L_x is negative or zero, the result is 0.
+ *
+ * Returns:
+ * void
+ */
+void D_UTIL_log2(Word32 L_x, Word16 *exponent, Word16 *fraction)
+{
+ Word16 exp;
+
+ exp = D_UTIL_norm_l(L_x);
+ D_UTIL_normalised_log2((L_x <<exp), exp, exponent, fraction);
+}
+
+
+/*
+ * D_UTIL_l_extract
+ *
+ * Parameters:
+ * L_32 I: 32 bit integer.
+ * hi O: b16 to b31 of L_32
+ * lo O: (L_32 - hi<<16)>>1
+ *
+ * Function:
+ * Extract from a 32 bit integer two 16 bit DPF.
+ *
+ * Returns:
+ * void
+ */
+void D_UTIL_l_extract(Word32 L_32, Word16 *hi, Word16 *lo)
+{
+ *hi = (Word16)(L_32 >> 16);
+ *lo = (Word16)((L_32 >> 1) - (*hi * 32768));
+
+ return;
+}
+
+
+/*
+ * D_UTIL_mpy_32_16
+ *
+ * Parameters:
+ * hi I: hi part of 32 bit number
+ * lo I: lo part of 32 bit number
+ * n I: 16 bit number
+ *
+ * Function:
+ * 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
+ *
+ * Returns:
+ * 32 bit result
+ */
+Word32 D_UTIL_mpy_32_16(Word16 hi, Word16 lo, Word16 n)
+{
+ Word32 L_32;
+
+ L_32 = hi * n;
+ L_32 += (lo * n) >> 15;
+
+ return(L_32 << 1);
+}
+
+
+/*
+ * D_UTIL_mpy_32
+ *
+ * Parameters:
+ * hi1 I: hi part of first number
+ * lo1 I: lo part of first number
+ * hi2 I: hi part of second number
+ * lo2 I: lo part of second number
+ *
+ * Function:
+ * Multiply two 32 bit integers (DPF). The result is divided by 2^31
+ *
+ * L_32 = (hi1*lo2)<<1 + ((lo1*lo2)>>15)<<1
+ *
+ * Returns:
+ * 32 bit result
+ */
+Word32 D_UTIL_mpy_32(Word16 hi1, Word16 lo1, Word16 hi2, Word16 lo2)
+{
+ Word32 L_32;
+
+ L_32 = hi1 * hi2;
+ L_32 += (hi1 * lo2) >> 15;
+ L_32 += (lo1 * hi2) >> 15;
+
+ return(L_32 << 1);
+}
+
+/*
+ * D_UTIL_saturate
+ *
+ * Parameters:
+ * inp I: 32-bit number
+ *
+ * Function:
+ * Saturation to 16-bit number
+ *
+ * Returns:
+ * 16-bit number
+ */
+Word16 D_UTIL_saturate(Word32 inp)
+{
+ Word16 out;
+ if ((inp < MAX_16) & (inp > MIN_16))
+ {
+ out = (Word16)inp;
+ }
+ else
+ {
+ if (inp > 0)
+ {
+ out = MAX_16;
+ }
+ else
+ {
+ out = MIN_16;
+ }
+ }
+
+ return(out);
+}
+
+/*
+ * D_UTIL_signal_up_scale
+ *
+ * Parameters:
+ * x I/O: signal to scale
+ * lg I: size of x[]
+ * exp I: exponent: x = round(x << exp)
+ *
+ * Function:
+ * Scale signal up to get maximum of dynamic.
+ *
+ * Returns:
+ * 32 bit result
+ */
+void D_UTIL_signal_up_scale(Word16 x[], Word16 lg, Word16 exp)
+{
+ Word32 i, tmp;
+
+ for (i = 0; i < lg; i++)
+ {
+ tmp = x[i] << exp;
+ x[i] = D_UTIL_saturate(tmp);
+ }
+
+ return;
+}
+
+
+/*
+ * D_UTIL_signal_down_scale
+ *
+ * Parameters:
+ * x I/O: signal to scale
+ * lg I: size of x[]
+ * exp I: exponent: x = round(x << exp)
+ *
+ * Function:
+ * Scale signal up to get maximum of dynamic.
+ *
+ * Returns:
+ * 32 bit result
+ */
+void D_UTIL_signal_down_scale(Word16 x[], Word16 lg, Word16 exp)
+{
+ Word32 i, tmp;
+
+ for(i = 0; i < lg; i++)
+ {
+ tmp = x[i] << 16;
+ tmp = tmp >> exp;
+ x[i] = (Word16)((tmp + 0x8000) >> 16);
+ }
+
+ return;
+}
+
+
+/*
+ * D_UTIL_deemph_32
+ *
+ * Parameters:
+ * x_hi I: input signal (bit31..16)
+ * x_lo I: input signal (bit15..4)
+ * y O: output signal (x16)
+ * mu I: (Q15) deemphasis factor
+ * L I: vector size
+ * mem I/O: memory (y[-1])
+ *
+ * Function:
+ * Filtering through 1/(1-mu z^-1)
+ *
+ * Returns:
+ * void
+ */
+static void D_UTIL_deemph_32(Word16 x_hi[], Word16 x_lo[], Word16 y[],
+ Word16 mu, Word16 L, Word16 *mem)
+{
+ Word32 i, fac;
+ Word32 tmp;
+
+ fac = mu >> 1; /* Q15 --> Q14 */
+
+ /* L_tmp = hi<<16 + lo<<4 */
+ tmp = (x_hi[0] << 12) + x_lo[0];
+ tmp = (tmp << 6) + (*mem * fac);
+ tmp = (tmp + 0x2000) >> 14;
+ y[0] = D_UTIL_saturate(tmp);
+
+ for(i = 1; i < L; i++)
+ {
+ tmp = (x_hi[i] << 12) + x_lo[i];
+ tmp = (tmp << 6) + (y[i - 1] * fac);
+ tmp = (tmp + 0x2000) >> 14;
+ y[i] = D_UTIL_saturate(tmp);
+ }
+
+ *mem = y[L - 1];
+
+ return;
+}
+
+
+/*
+ * D_UTIL_synthesis_32
+ *
+ * Parameters:
+ * a I: LP filter coefficients
+ * m I: order of LP filter
+ * exc I: excitation
+ * Qnew I: exc scaling = 0(min) to 8(max)
+ * sig_hi O: synthesis high
+ * sig_lo O: synthesis low
+ * lg I: size of filtering
+ *
+ * Function:
+ * Perform the synthesis filtering 1/A(z).
+ *
+ * Returns:
+ * void
+ */
+static void D_UTIL_synthesis_32(Word16 a[], Word16 m, Word16 exc[],
+ Word16 Qnew, Word16 sig_hi[], Word16 sig_lo[],
+ Word16 lg)
+{
+ Word32 i, j, a0, s;
+ Word32 tmp, tmp2;
+
+ /* See if a[0] is scaled */
+ s = D_UTIL_norm_s((Word16)a[0]) - 2;
+
+ a0 = a[0] >> (4 + Qnew); /* input / 16 and >>Qnew */
+
+ /* Do the filtering. */
+ for(i = 0; i < lg; i++)
+ {
+ tmp = 0;
+
+ for(j = 1; j <= m; j++)
+ {
+ tmp -= sig_lo[i - j] * a[j];
+ }
+
+ tmp = tmp >> (15 - 4); /* -4 : sig_lo[i] << 4 */
+
+ tmp2 = exc[i] * a0;
+
+ for(j = 1; j <= m; j++)
+ {
+ tmp2 -= sig_hi[i - j] * a[j];
+ }
+
+ tmp += tmp2 << 1;
+ tmp <<= s;
+
+ /* sig_hi = bit16 to bit31 of synthesis */
+ sig_hi[i] = (Word16)(tmp >> 13);
+
+ /* sig_lo = bit4 to bit15 of synthesis */
+ sig_lo[i] = (Word16)((tmp >> 1) - (sig_hi[i] * 4096));
+ }
+
+ return;
+}
+
+
+/*
+ * D_UTIL_hp50_12k8
+ *
+ * Parameters:
+ * signal I/O: signal
+ * lg I: lenght of signal
+ * mem I/O: filter memory [6]
+ *
+ * Function:
+ * 2nd order high pass filter with cut off frequency at 50 Hz.
+ *
+ * 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];
+ *
+ * b[3] = {0.989501953f, -1.979003906f, 0.989501953f};
+ * a[3] = {1.000000000F, 1.978881836f,-0.966308594f};
+ *
+ *
+ * Returns:
+ * void
+ */
+static void D_UTIL_hp50_12k8(Word16 signal[], Word16 lg, Word16 mem[])
+{
+ Word32 i, L_tmp;
+ Word16 y2_hi, y2_lo, y1_hi, y1_lo, x0, x1, x2;
+
+ y2_hi = mem[0];
+ y2_lo = mem[1];
+ y1_hi = mem[2];
+ y1_lo = mem[3];
+ x0 = mem[4];
+ x1 = mem[5];
+
+ for(i = 0; i < lg; i++)
+ {
+ x2 = x1;
+ x1 = x0;
+ x0 = signal[i];
+
+ /* y[i] = b[0]*x[i] + b[1]*x[i-1] + b140[2]*x[i-2] */
+ /* + a[1]*y[i-1] + a[2] * y[i-2]; */
+ L_tmp = 8192L; /* rounding to maximise precision */
+ L_tmp = L_tmp + (y1_lo * 16211);
+ L_tmp = L_tmp + (y2_lo * (-8021));
+ L_tmp = L_tmp >> 14;
+ L_tmp = L_tmp + (y1_hi * 32422);
+ L_tmp = L_tmp + (y2_hi * (-16042));
+ L_tmp = L_tmp + (x0 * 8106);
+ L_tmp = L_tmp + (x1 * (-16212));
+ L_tmp = L_tmp + (x2 * 8106);
+ L_tmp = L_tmp << 2; /* coeff Q11 --> Q14 */
+ y2_hi = y1_hi;
+ y2_lo = y1_lo;
+ D_UTIL_l_extract(L_tmp, &y1_hi, &y1_lo);
+ L_tmp = (L_tmp + 0x4000) >> 15; /* coeff Q14 --> Q15 with saturation */
+ signal[i] = D_UTIL_saturate(L_tmp);
+
+ }
+ mem[0] = y2_hi;
+ mem[1] = y2_lo;
+ mem[2] = y1_hi;
+ mem[3] = y1_lo;
+ mem[4] = x0;
+ mem[5] = x1;
+
+ return;
+}
+
+
+/*
+ * D_UTIL_interpol
+ *
+ * Parameters:
+ * x I: input vector
+ * fir I: filter coefficient
+ * frac I: fraction (0..resol)
+ * up_samp I: resolution
+ * nb_coef I: number of coefficients
+ *
+ * Function:
+ * Fractional interpolation of signal at position (frac/up_samp)
+ *
+ * Returns:
+ * result of interpolation
+ */
+Word16 D_UTIL_interpol(Word16 *x, Word16 const *fir, Word16 frac,
+ Word16 resol, Word16 nb_coef)
+{
+ Word32 i, k;
+ Word32 sum;
+
+ x = x - nb_coef + 1;
+ sum = 0L;
+
+ for(i = 0, k = ((resol - 1) - frac); i < 2 * nb_coef; i++,
+ k = (Word16)(k + resol))
+ {
+ sum = sum + (x[i] * fir[k]);
+ }
+
+ if((sum < 536846336) & (sum > -536879104))
+ {
+ sum = (sum + 0x2000) >> 14;
+ }
+ else if(sum > 536846336)
+ {
+ sum = 32767;
+ }
+ else
+ {
+ sum = -32768;
+ }
+
+ return((Word16)sum); /* saturation can occur here */
+}
+
+
+/*
+ * D_UTIL_up_samp
+ *
+ * Parameters:
+ * res_d I: signal to upsampling
+ * res_u O: upsampled output
+ * L_frame I: length of output
+ *
+ * Function:
+ * Upsampling
+ *
+ * Returns:
+ * void
+ */
+static void D_UTIL_up_samp(Word16 *sig_d, Word16 *sig_u, Word16 L_frame)
+{
+ Word32 pos, i, j;
+ Word16 frac;
+
+ pos = 0; /* position with 1/5 resolution */
+
+ for(j = 0; j < L_frame; j++)
+ {
+ i = (pos * INV_FAC5) >> 15; /* integer part = pos * 1/5 */
+ frac = (Word16)(pos - ((i << 2) + i)); /* frac = pos - (pos/5)*5 */
+ sig_u[j] = D_UTIL_interpol(&sig_d[i], D_ROM_fir_up, frac, FAC5, NB_COEF_UP);
+ pos = pos + FAC4; /* position + 4/5 */
+ }
+
+ return;
+}
+
+
+/*
+ * D_UTIL_oversamp_16k
+ *
+ * Parameters:
+ * sig12k8 I: signal to oversampling
+ * lg I: length of input
+ * sig16k O: oversampled signal
+ * mem I/O: memory (2*12)
+ *
+ * Function:
+ * Oversampling from 12.8kHz to 16kHz
+ *
+ * Returns:
+ * void
+ */
+static void D_UTIL_oversamp_16k(Word16 sig12k8[], Word16 lg, Word16 sig16k[],
+ Word16 mem[])
+{
+ Word16 lg_up;
+ Word16 signal[L_SUBFR + (2 * NB_COEF_UP)];
+
+ memcpy(signal, mem, (2 * NB_COEF_UP) * sizeof(Word16));
+ memcpy(signal + (2 * NB_COEF_UP), sig12k8, lg * sizeof(Word16));
+ lg_up = (Word16)(((lg * UP_FAC) >> 15) << 1);
+ D_UTIL_up_samp(signal + NB_COEF_UP, sig16k, lg_up);
+ memcpy(mem, signal + lg, (2 * NB_COEF_UP) * sizeof(Word16));
+
+ return;
+}
+
+
+/*
+ * D_UTIL_hp400_12k8
+ *
+ * Parameters:
+ * signal I/O: signal
+ * lg I: lenght of signal
+ * mem I/O: filter memory [6]
+ *
+ * Function:
+ * 2nd order high pass filter with cut off frequency at 400 Hz.
+ *
+ * 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];
+ *
+ * b[3] = {0.893554687, -1.787109375, 0.893554687};
+ * a[3] = {1.000000000, 1.787109375, -0.864257812};
+ *
+ *
+ * Returns:
+ * void
+ */
+void D_UTIL_hp400_12k8(Word16 signal[], Word16 lg, Word16 mem[])
+{
+
+ Word32 i, L_tmp;
+ Word16 y2_hi, y2_lo, y1_hi, y1_lo, x0, x1, x2;
+
+ y2_hi = mem[0];
+ y2_lo = mem[1];
+ y1_hi = mem[2];
+ y1_lo = mem[3];
+ x0 = mem[4];
+ x1 = mem[5];
+
+ for(i = 0; i < lg; i++)
+ {
+ x2 = x1;
+ x1 = x0;
+ x0 = signal[i];
+
+ /* y[i] = b[0]*x[i] + b[1]*x[i-1] + b140[2]*x[i-2] */
+ /* + a[1]*y[i-1] + a[2] * y[i-2]; */
+ L_tmp = 8192L + (y1_lo * 29280);
+ L_tmp = L_tmp + (y2_lo * (-14160));
+ L_tmp = (L_tmp >> 14);
+ L_tmp = L_tmp + (y1_hi * 58560);
+ L_tmp = L_tmp + (y2_hi * (-28320));
+ L_tmp = L_tmp + (x0 * 1830);
+ L_tmp = L_tmp + (x1 * (-3660));
+ L_tmp = L_tmp + (x2 * 1830);
+ L_tmp = (L_tmp << 1); /* coeff Q12 --> Q13 */
+ y2_hi = y1_hi;
+ y2_lo = y1_lo;
+ D_UTIL_l_extract(L_tmp, &y1_hi, &y1_lo);
+
+ /* signal is divided by 16 to avoid overflow in energy computation */
+ signal[i] = (Word16)((L_tmp + 0x8000) >> 16);
+ }
+ mem[0] = y2_hi;
+ mem[1] = y2_lo;
+ mem[2] = y1_hi;
+ mem[3] = y1_lo;
+ mem[4] = x0;
+ mem[5] = x1;
+
+ return;
+}
+
+
+/*
+ * D_UTIL_synthesis
+ *
+ * Parameters:
+ * a I: LP filter coefficients
+ * m I: order of LP filter
+ * x I: input signal
+ * y O: output signal
+ * lg I: size of filtering
+ * mem I/O: initial filter states
+ * update_m I: update memory flag
+ *
+ * Function:
+ * Perform the synthesis filtering 1/A(z).
+ *
+ * Returns:
+ * void
+ */
+static void D_UTIL_synthesis(Word16 a[], Word16 m, Word16 x[], Word16 y[],
+ Word16 lg, Word16 mem[], Word16 update)
+{
+ Word32 i, j, tmp, s;
+ Word16 y_buf[L_SUBFR16k + M16k], a0;
+ Word16 *yy;
+
+ yy = &y_buf[m];
+
+ /* See if a[0] is scaled */
+ s = D_UTIL_norm_s(a[0]) - 2;
+ /* copy initial filter states into synthesis buffer */
+ memcpy(y_buf, mem, m * sizeof(Word16));
+
+ a0 = (Word16)(a[0] >> 1); /* input / 2 */
+
+ /* Do the filtering. */
+ for(i = 0; i < lg; i++)
+ {
+ tmp = x[i] * a0;
+
+ for(j = 1; j <= m; j++)
+ {
+ tmp -= a[j] * yy[i - j];
+ }
+ tmp <<= s;
+
+ y[i] = yy[i] = (Word16)((tmp + 0x800) >> 12);
+ }
+
+ /* Update memory if required */
+ if(update)
+ {
+ memcpy(mem, &yy[lg - m], m * sizeof(Word16));
+ }
+
+ return;
+}
+
+
+/*
+ * D_UTIL_bp_6k_7k
+ *
+ * Parameters:
+ * signal I/O: signal
+ * lg I: lenght of signal
+ * mem I/O: filter memory [4]
+ *
+ * Function:
+ * 15th order band pass 6kHz to 7kHz FIR filter.
+ *
+ * Returns:
+ * void
+ */
+void D_UTIL_bp_6k_7k(Word16 signal[], Word16 lg, Word16 mem[])
+{
+ Word32 x[L_SUBFR16k + (L_FIR - 1)];
+ Word32 i, j, tmp;
+
+ for(i = 0; i < (L_FIR - 1); i++)
+ {
+ x[i] = (Word16)mem[i]; /* gain of filter = 4 */
+ }
+
+ for(i = 0; i < lg; i++)
+ {
+ x[i + L_FIR - 1] = signal[i] >> 2; /* gain of filter = 4 */
+ }
+
+ for(i = 0; i < lg; i++)
+ {
+ tmp = 0;
+
+ for(j = 0; j < L_FIR; j++)
+ {
+ tmp += x[i + j] * D_ROM_fir_6k_7k[j];
+ }
+
+ signal[i] = (Word16)((tmp + 0x4000) >> 15);
+ }
+
+ for(i = 0; i < (L_FIR - 1); i++)
+ {
+ mem[i] = (Word16)x[lg + i]; /* gain of filter = 4 */
+ }
+
+ return;
+}
+
+
+/*
+ * D_UTIL_hp_7k
+ *
+ * Parameters:
+ * signal I/O: ISF vector
+ * lg I: length of signal
+ * mem I/O: memory (30)
+ *
+ * Function:
+ * 15th order high pass 7kHz FIR filter
+ *
+ * Returns:
+ * void
+ */
+static void D_UTIL_hp_7k(Word16 signal[], Word16 lg, Word16 mem[])
+{
+
+ Word32 i, j, tmp;
+ Word16 x[L_SUBFR16k + (L_FIR - 1)];
+
+ memcpy(x, mem, (L_FIR - 1) * sizeof(Word16));
+ memcpy(&x[L_FIR - 1], signal, lg * sizeof(Word16));
+
+ for(i = 0; i < lg; i++)
+ {
+ tmp = 0;
+
+ for(j = 0; j < L_FIR; j++)
+ {
+ tmp += x[i + j] * D_ROM_fir_7k[j];
+ }
+
+ signal[i] = (Word16)((tmp + 0x4000) >> 15);
+ }
+
+ memcpy(mem, x + lg, (L_FIR - 1) * sizeof(Word16));
+
+ return;
+}
+
+
+/*
+ * D_UTIL_Dec_synthesis
+ *
+ * Parameters:
+ * Aq I: quantized Az
+ * exc I: excitation at 12kHz
+ * Q_new I: scaling performed on exc
+ * synth16k O: 16kHz synthesis signal
+ * prms I: parameters
+ * HfIsf I/O: High frequency ISF:s
+ * mode I: codec mode
+ * newDTXState I: dtx state
+ * bfi I: bad frame indicator
+ * st I/O: State structure
+ *
+ * Function:
+ * Synthesis of signal at 16kHz with HF extension.
+ *
+ * Returns:
+ * void
+ */
+void D_UTIL_dec_synthesis(Word16 Aq[], Word16 exc[], Word16 Q_new,
+ Word16 synth16k[], Word16 prms, Word16 HfIsf[],
+ Word16 mode, Word16 newDTXState, Word16 bfi,
+ Decoder_State *st)
+{
+ Word32 tmp, i;
+ Word16 exp;
+ Word16 ener, exp_ener;
+ Word32 fac;
+ Word16 synth_hi[M + L_SUBFR], synth_lo[M + L_SUBFR];
+ Word16 synth[L_SUBFR];
+ Word16 HF[L_SUBFR16k]; /* High Frequency vector */
+ Word16 Ap[M16k + 1];
+ Word16 HfA[M16k + 1];
+ Word16 HF_corr_gain;
+ Word16 HF_gain_ind;
+ Word32 gain1, gain2;
+ Word16 weight1, weight2;
+
+ /*
+ * Speech synthesis
+ *
+ * - Find synthesis speech corresponding to exc2[].
+ * - Perform fixed deemphasis and hp 50hz filtering.
+ * - Oversampling from 12.8kHz to 16kHz.
+ */
+ memcpy(synth_hi, st->mem_syn_hi, M * sizeof(Word16));
+ memcpy(synth_lo, st->mem_syn_lo, M * sizeof(Word16));
+ D_UTIL_synthesis_32(Aq, M, exc, Q_new, synth_hi + M, synth_lo + M, L_SUBFR);
+ memcpy(st->mem_syn_hi, synth_hi + L_SUBFR, M * sizeof(Word16));
+ memcpy(st->mem_syn_lo, synth_lo + L_SUBFR, M * sizeof(Word16));
+ D_UTIL_deemph_32(synth_hi + M, synth_lo + M, synth, PREEMPH_FAC, L_SUBFR,
+ &(st->mem_deemph));
+ D_UTIL_hp50_12k8(synth, L_SUBFR, st->mem_sig_out);
+ D_UTIL_oversamp_16k(synth, L_SUBFR, synth16k, st->mem_oversamp);
+
+ /*
+ * HF noise synthesis
+ *
+ * - Generate HF noise between 5.5 and 7.5 kHz.
+ * - Set energy of noise according to synthesis tilt.
+ * tilt > 0.8 ==> - 14 dB (voiced)
+ * tilt 0.5 ==> - 6 dB (voiced or noise)
+ * tilt < 0.0 ==> 0 dB (noise)
+ */
+
+ /* generate white noise vector */
+ for(i = 0; i < L_SUBFR16k; i++)
+ {
+ HF[i] = (Word16)(D_UTIL_random(&(st->mem_seed2)) >> 3);
+ }
+
+ /* energy of excitation */
+ D_UTIL_signal_down_scale(exc, L_SUBFR, 3);
+ Q_new = (Word16)(Q_new - 3);
+ ener = (Word16)(D_UTIL_dot_product12(exc, exc, L_SUBFR, &exp_ener) >> 16);
+ exp_ener = (Word16)(exp_ener - (Q_new << 1));
+
+ /* set energy of white noise to energy of excitation */
+ tmp = (Word16)(D_UTIL_dot_product12(HF, HF, L_SUBFR16k, &exp) >> 16);
+
+ if(tmp > ener)
+ {
+ tmp = tmp >> 1; /* Be sure tmp < ener */
+ exp = (Word16)(exp + 1);
+ }
+
+ tmp = (tmp << 15) / ener;
+
+ if(tmp > 32767)
+ {
+ tmp = 32767;
+ }
+
+ tmp = tmp << 16; /* result is normalized */
+ exp = (Word16)(exp - exp_ener);
+ D_UTIL_normalised_inverse_sqrt(&tmp, &exp);
+
+ /* L_tmp x 2, L_tmp in Q31 */
+ /* tmp = 2 x sqrt(ener_exc/ener_hf) */
+ if(exp >= 0)
+ {
+ tmp = tmp >> (15 - exp);
+ }
+ else
+ {
+ tmp = tmp >> (-exp);
+ tmp = tmp >> 15;
+ }
+
+ /* saturation */
+ if(tmp > 0x7FFF)
+ {
+ tmp = 0x7FFF;
+ }
+
+ for(i = 0; i < L_SUBFR16k; i++)
+ {
+ HF[i] = (Word16)((HF[i] * tmp) >> 15);
+ }
+
+ /* find tilt of synthesis speech (tilt: 1=voiced, -1=unvoiced) */
+ D_UTIL_hp400_12k8(synth, L_SUBFR, st->mem_hp400);
+ tmp = 0L;
+
+ for(i = 0; i < L_SUBFR; i++)
+ {
+ tmp = tmp + (synth[i] * synth[i]);
+ }
+
+ tmp = (tmp << 1) + 1;
+ exp = D_UTIL_norm_l(tmp);
+ ener = (Word16)((tmp << exp) >> 16); /* ener = r[0] */
+ tmp = 0L;
+
+ for(i = 1; i < L_SUBFR; i++)
+ {
+ tmp = tmp + (synth[i] * synth[i - 1]);
+ }
+
+ tmp = (tmp << 1) + 1;
+ tmp = (tmp << exp) >> 16; /* tmp = r[1] */
+
+ if(tmp > 0)
+ {
+ fac = ((tmp << 15) / ener);
+
+ if(fac > 32767)
+ {
+ fac = 32767;
+ }
+ }
+ else
+ {
+ fac = 0;
+ }
+
+ /* modify energy of white noise according to synthesis tilt */
+ gain1 = (32767 - fac);
+ gain2 = ((32767 - fac) * 20480) >> 15;
+ gain2 = (gain2 << 1);
+
+ if(gain2 > 32767)
+ gain2 = 32767;
+
+ if(st->mem_vad_hist > 0)
+ {
+ weight1 = 0;
+ weight2 = 32767;
+ }
+ else
+ {
+ weight1 = 32767;
+ weight2 = 0;
+ }
+
+ tmp = (weight1 * gain1) >> 15;
+ tmp = tmp + ((weight2 * gain2) >> 15);
+
+ if(tmp != 0)
+ {
+ tmp = tmp + 1;
+ }
+
+ if(tmp < 3277)
+ {
+ tmp = 3277; /* 0.1 in Q15 */
+ }
+
+ if((mode == MODE_24k) & (bfi == 0))
+ {
+ /* HF correction gain */
+ HF_gain_ind = prms;
+ HF_corr_gain = D_ROM_hp_gain[HF_gain_ind];
+
+ /* HF gain */
+ for(i = 0; i < L_SUBFR16k; i++)
+ {
+ HF[i] = (Word16)(((HF[i] * HF_corr_gain) >> 15) << 1);
+ }
+ }
+ else
+ {
+ for(i = 0; i < L_SUBFR16k; i++)
+ {
+ HF[i] = (Word16)((HF[i] * tmp) >> 15);
+ }
+ }
+
+ if((mode <= MODE_7k) & (newDTXState == SPEECH))
+ {
+ D_LPC_isf_extrapolation(HfIsf);
+ D_LPC_isp_a_conversion(HfIsf, HfA, 0, M16k);
+ D_LPC_a_weight(HfA, Ap, 29491, M16k); /* fac=0.9 */
+ D_UTIL_synthesis(Ap, M16k, HF, HF, L_SUBFR16k, st->mem_syn_hf, 1);
+ }
+ else
+ {
+ /* synthesis of noise: 4.8kHz..5.6kHz --> 6kHz..7kHz */
+ D_LPC_a_weight(Aq, Ap, 19661, M); /* fac=0.6 */
+ D_UTIL_synthesis(Ap, M, HF, HF, L_SUBFR16k, st->mem_syn_hf + (M16k - M), 1);
+ }
+
+ /* noise High Pass filtering (1ms of delay) */
+ D_UTIL_bp_6k_7k(HF, L_SUBFR16k, st->mem_hf);
+
+ if(mode == MODE_24k)
+ {
+ /* Low Pass filtering (7 kHz) */
+ D_UTIL_hp_7k(HF, L_SUBFR16k, st->mem_hf3);
+ }
+
+ /* add filtered HF noise to speech synthesis */
+ for(i = 0; i < L_SUBFR16k; i++)
+ {
+ tmp = (synth16k[i] + HF[i]);
+ synth16k[i] = D_UTIL_saturate(tmp);
+ }
+
+ return;
+}
+
+
+/*
+ * D_UTIL_preemph
+ *
+ * Parameters:
+ * x I/O: signal
+ * mu I: preemphasis factor
+ * lg I: vector size
+ * mem I/O: memory (x[-1])
+ *
+ * Function:
+ * Filtering through 1 - mu z^-1
+ *
+ *
+ * Returns:
+ * void
+ */
+void D_UTIL_preemph(Word16 x[], Word16 mu, Word16 lg, Word16 *mem)
+{
+ Word32 i, L_tmp;
+ Word16 temp;
+
+ temp = x[lg - 1];
+
+ for(i = lg - 1; i > 0; i--)
+ {
+ L_tmp = x[i] << 15;
+ L_tmp = L_tmp - (x[i - 1] * mu);
+ x[i] = (Word16)((L_tmp + 0x4000) >> 15);
+ }
+
+ L_tmp = x[0] << 15;
+ L_tmp = L_tmp - (*mem * mu);
+ x[0] = (Word16)((L_tmp + 0x4000) >> 15);
+ *mem = temp;
+
+ return;
+}
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_util.h b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_util.h
new file mode 100644
index 000000000..df5fae208
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/dec_util.h
@@ -0,0 +1,33 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef DEC_UTIL_H
+#define DEC_UTIL_H
+
+#include "typedef.h"
+#include "dec_main.h"
+
+Word16 D_UTIL_random(Word16 *seed);
+
+Word32 D_UTIL_pow2(Word16 exponant, Word16 fraction);
+Word16 D_UTIL_norm_l (Word32 L_var1);
+Word16 D_UTIL_norm_s (Word16 var1);
+Word32 D_UTIL_dot_product12(Word16 x[], Word16 y[], Word16 lg, Word16 *exp);
+void D_UTIL_normalised_inverse_sqrt(Word32 *frac, Word16 *exp);
+Word32 D_UTIL_inverse_sqrt(Word32 L_x);
+void D_UTIL_log2(Word32 L_x, Word16 *exponent, Word16 *fraction);
+void D_UTIL_l_extract(Word32 L_32, Word16 *hi, Word16 *lo);
+Word32 D_UTIL_mpy_32_16 (Word16 hi, Word16 lo, Word16 n);
+Word32 D_UTIL_mpy_32 (Word16 hi1, Word16 lo1, Word16 hi2, Word16 lo2);
+Word16 D_UTIL_saturate(Word32 inp);
+void D_UTIL_signal_up_scale(Word16 x[], Word16 lg, Word16 exp);
+void D_UTIL_signal_down_scale(Word16 x[], Word16 lg, Word16 exp);
+void D_UTIL_dec_synthesis(Word16 Aq[], Word16 exc[], Word16 Q_new,
+ Word16 synth16k[], Word16 prms, Word16 HfIsf[],
+ Word16 mode, Word16 newDTXState, Word16 bfi,
+ Decoder_State *st);
+void D_UTIL_preemph(Word16 x[], Word16 mu, Word16 lg, Word16 *mem);
+
+#endif
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/decoder.c b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/decoder.c
new file mode 100644
index 000000000..ab0495a1d
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/decoder.c
@@ -0,0 +1,146 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "typedef.h"
+#include "dec_if.h"
+
+#ifndef IF2
+#include <string.h>
+#define AMRWB_MAGIC_NUMBER "#!AMR-WB\n"
+#endif
+
+/*
+ * DECODER.C
+ *
+ * Main program of the AMR WB ACELP wideband decoder.
+ *
+ * Usage : decoder bitstream_file synth_file
+ *
+ * Format for bitstream_file:
+ * Described in TS26.201
+ *
+ * Format for synth_file:
+ * Synthesis is written to a binary file of 16 bits data.
+ *
+ */
+
+extern const UWord8 block_size[];
+
+int main(int argc, char *argv[])
+{
+ FILE *f_serial; /* File of serial bits for transmission */
+ FILE *f_synth; /* File of speech data */
+
+ Word16 synth[L_FRAME16k]; /* Buffer for speech @ 16kHz */
+ UWord8 serial[NB_SERIAL_MAX];
+ Word16 mode;
+ Word32 frame;
+
+#ifndef IF2
+ char magic[16];
+#endif
+ void *st;
+
+ fprintf(stderr, "\n");
+ fprintf(stderr, "===================================================================\n");
+ fprintf(stderr, " 3GPP AMR-WB Floating-point Speech Decoder, v6.0.0, Dec 14, 2004\n");
+ fprintf(stderr, "===================================================================\n");
+ fprintf(stderr, "\n");
+
+ /*
+ * Read passed arguments and open in/out files
+ */
+ if (argc != 3)
+ {
+ fprintf(stderr, "Usage : decoder bitstream_file synth_file\n");
+ fprintf(stderr, "\n");
+ fprintf(stderr, "Format for bitstream_file:\n");
+#ifdef IF2
+ fprintf(stderr, " Described in TS26.201.\n");
+#else
+ fprintf(stderr, " Described in RFC 3267 (Sections 5.1 and 5.3).\n");
+#endif
+ fprintf(stderr, "\n");
+ fprintf(stderr, "Format for synth_file:\n");
+ fprintf(stderr, " Synthesis is written to a binary file of 16 bits data.\n");
+ fprintf(stderr, "\n");
+ exit(0);
+ }
+
+ /* Open file for synthesis and packed serial stream */
+ if ((f_serial = fopen(argv[1], "rb")) == NULL)
+ {
+ fprintf(stderr, "Input file '%s' does not exist !!\n", argv[1]);
+ exit(0);
+ }
+ else
+ {
+ fprintf(stderr, "Input bitstream file: %s\n", argv[1]);
+ }
+
+ if ((f_synth = fopen(argv[2], "wb")) == NULL)
+ {
+ fprintf(stderr, "Cannot open file '%s' !!\n", argv[2]);
+ exit(0);
+ }
+ else
+ {
+ fprintf(stderr, "Synthesis speech file: %s\n", argv[2]);
+ }
+
+ /*
+ * Initialization of decoder
+ */
+ st = D_IF_init();
+
+#ifndef IF2
+ /* read magic number */
+ fread(magic, sizeof(char), strlen(AMRWB_MAGIC_NUMBER), f_serial);
+
+ /* verify magic number */
+ if (strncmp(magic, AMRWB_MAGIC_NUMBER, strlen(AMRWB_MAGIC_NUMBER)))
+ {
+ fprintf(stderr, "%s%s\n", "Invalid magic number: ", magic);
+ fclose(f_serial);
+ fclose(f_synth);
+ exit(0);
+ }
+#endif
+
+ /*
+ * Loop for each "L_FRAME" speech data
+ */
+ fprintf(stderr, "\n --- Running ---\n");
+
+ frame = 0;
+ while (fread(serial, sizeof (UWord8), 1, f_serial ) > 0)
+ {
+#ifdef IF2
+ mode = (Word16)(serial[0] >> 4);
+#else
+ mode = (Word16)((serial[0] >> 3) & 0x0F);
+#endif
+ fread(&serial[1], sizeof (UWord8), block_size[mode] - 1, f_serial );
+
+ frame++;
+
+ fprintf(stderr, " Decoding frame: %ld\r", frame);
+
+ D_IF_decode( st, serial, synth, _good_frame);
+
+ fwrite(synth, sizeof(Word16), L_FRAME16k, f_synth);
+ fflush(f_synth);
+ }
+
+ D_IF_exit(st);
+
+ fclose(f_serial);
+ fclose(f_synth);
+
+ return 0;
+}
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc.h b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc.h
new file mode 100644
index 000000000..afef61ec6
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc.h
@@ -0,0 +1,18 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef ENC_H
+#define ENC_H
+
+#include "typedef.h"
+
+Word16 E_MAIN_init(void **spe_state);
+void E_MAIN_reset(void *st, Word16 reset_all);
+Word16 E_MAIN_encode(Word16 * mode, Word16 input_sp[], Word16 prms[],
+ void *spe_state, Word16 allow_dtx);
+void E_MAIN_close(void **spe_state);
+
+#endif
+
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_acelp.c b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_acelp.c
new file mode 100644
index 000000000..4aea6ede6
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_acelp.c
@@ -0,0 +1,2074 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#include <math.h>
+#include <memory.h>
+#include <float.h>
+
+#include "typedef.h"
+#include "enc_util.h"
+
+#define L_SUBFR 64
+#define NB_PULSE_MAX 24
+#define NPMAXPT ((NB_PULSE_MAX + 4 - 1) / 4)
+#define NB_QUA_GAIN7B 128 /* Number of quantization level */
+#define MODE_23k 7
+
+extern const UWord8 E_ROM_tipos[];
+extern const Float32 E_ROM_qua_gain6b[];
+extern const Float32 E_ROM_qua_gain7b[];
+
+/*
+ * E_ACELP_Gain2_Q_init
+ *
+ * Parameters:
+ * mem O: static memory
+ *
+ * Function:
+ * Initializes state memory
+ *
+ * Returns:
+ * void
+ */
+void E_ACELP_Gain2_Q_init(Word16 *mem)
+{
+ Word32 i;
+
+ /* 2nd order quantizer energy predictor */
+ for (i = 0; i < 4; i++)
+ {
+ mem[i] = -14336; /* past_qua_en[i] */
+ }
+
+ return;
+}
+
+/*
+ * E_ACELP_xy1_corr
+ *
+ * Parameters:
+ * xn I: target signal
+ * y1 I: filtered adaptive codebook excitation
+ * g_coeff O: correlations <y1,y1> and -2<xn,y1>
+ *
+ * Function:
+ * Find the correlations between the target xn[] and the filtered adaptive
+ * codebook excitation y1[]. ( <y1,y1> and -2<xn,y1> )
+ * Subframe size = L_SUBFR
+ *
+ * Returns:
+ * pitch gain (0 ... 1.2F) (Q14)
+ */
+Float32 E_ACELP_xy1_corr(Float32 xn[], Float32 y1[], Float32 g_corr[])
+{
+ Float32 gain;
+ Float32 t0, t1;
+ Word32 i;
+
+ t0 = xn[0] * y1[0];
+ t1 = y1[0] * y1[0];
+
+ for (i = 1; i < L_SUBFR; i += 7)
+ {
+ t0 += xn[i] * y1[i];
+ t1 += y1[i] * y1[i];
+ t0 += xn[i + 1] * y1[i + 1];
+ t1 += y1[i + 1] * y1[i + 1];
+ t0 += xn[i + 2] * y1[i + 2];
+ t1 += y1[i + 2] * y1[i + 2];
+ t0 += xn[i + 3] * y1[i + 3];
+ t1 += y1[i + 3] * y1[i + 3];
+ t0 += xn[i + 4] * y1[i + 4];
+ t1 += y1[i + 4] * y1[i + 4];
+ t0 += xn[i + 5] * y1[i + 5];
+ t1 += y1[i + 5] * y1[i + 5];
+ t0 += xn[i + 6] * y1[i + 6];
+ t1 += y1[i + 6] * y1[i + 6];
+ }
+
+ g_corr[0] = t1;
+ g_corr[1] = -2.0F * t0 + 0.01F;
+
+ /* find pitch gain and bound it by [0,1.2F] */
+
+ if (t1)
+ {
+ gain = t0 / t1;
+ }
+ else
+ {
+ gain = 1.0F;
+ }
+
+ if (gain < 0.0)
+ {
+ gain = 0.0;
+ }
+ else if (gain > 1.2F)
+ {
+ gain = 1.2F;
+ }
+
+ return gain;
+}
+
+/*
+ * E_ACELP_xy2_corr
+ *
+ * Parameters:
+ * xn I: target signal
+ * y1 I: filtered adaptive codebook excitation
+ * y2 I: filtered fixed codebook excitation
+ * g_corr O: correlations <y2,y2>, -2<xn,y2>, 2<y1,y2>
+ * L_subfr I: subframe size
+ *
+ * Function:
+ * Find the correlations between the target xn[], the filtered adaptive
+ * codebook exc. y1[], and the filtered fixed codebook innovation y2[].
+ * ( <y2,y2> , -2<xn,y2> and 2<y1,y2> )
+ * Subrame size = L_SUBFR
+ *
+ * Returns:
+ * pitch gain (0 ... 1.2F)
+ */
+void E_ACELP_xy2_corr(Float32 xn[], Float32 y1[], Float32 y2[],
+ Float32 g_corr[])
+{
+ Float32 temp1, temp2, temp3;
+ Word32 i;
+
+ temp1 = 0.01F + y2[0] * y2[0];
+ temp2 = 0.01F + xn[0] * y2[0];
+ temp3 = 0.01F + y1[0] * y2[0];
+ temp1 += y2[1] * y2[1];
+ temp2 += xn[1] * y2[1];
+ temp3 += y1[1] * y2[1];
+ temp1 += y2[2] * y2[2];
+ temp2 += xn[2] * y2[2];
+ temp3 += y1[2] * y2[2];
+ temp1 += y2[3] * y2[3];
+ temp2 += xn[3] * y2[3];
+ temp3 += y1[3] * y2[3];
+
+ for (i = 4; i < L_SUBFR; i += 6)
+ {
+ temp1 += y2[i] * y2[i];
+ temp2 += xn[i] * y2[i];
+ temp3 += y1[i] * y2[i];
+ temp1 += y2[i + 1] * y2[i + 1];
+ temp2 += xn[i + 1] * y2[i + 1];
+ temp3 += y1[i + 1] * y2[i + 1];
+ temp1 += y2[i + 2] * y2[i + 2];
+ temp2 += xn[i + 2] * y2[i + 2];
+ temp3 += y1[i + 2] * y2[i + 2];
+ temp1 += y2[i + 3] * y2[i + 3];
+ temp2 += xn[i + 3] * y2[i + 3];
+ temp3 += y1[i + 3] * y2[i + 3];
+ temp1 += y2[i + 4] * y2[i + 4];
+ temp2 += xn[i + 4] * y2[i + 4];
+ temp3 += y1[i + 4] * y2[i + 4];
+ temp1 += y2[i + 5] * y2[i + 5];
+ temp2 += xn[i + 5] * y2[i + 5];
+ temp3 += y1[i + 5] * y2[i + 5];
+ }
+
+ g_corr[2] = temp1;
+ g_corr[3] = -2.0F * temp2;
+ g_corr[4] = 2.0F * temp3;
+
+ return;
+}
+
+/*
+ * E_ACELP_xh_corr
+ *
+ * Parameters:
+ * h I: impulse response (of weighted synthesis filter) (Q12)
+ * x I: target signal (Q0)
+ * y O: correlation between x[] and h[]
+ *
+ * Function:
+ * Compute the correlation between the target signal and the impulse
+ * response of the weighted synthesis filter.
+ *
+ * y[i]=sum(j=i,l-1) x[j]*h[j-i], i=0,l-1
+ *
+ * Vector size is L_SUBFR
+ *
+ * Returns:
+ * void
+ */
+void E_ACELP_xh_corr(Float32 *x, Float32 *y, Float32 *h)
+{
+ Word32 i, j;
+ Float32 s;
+
+ for (i = 0; i < L_SUBFR; i++)
+ {
+ s = 0.0F;
+
+ for (j = i; j < L_SUBFR ; j++)
+ {
+ s += x[j] * h[j - i];
+ }
+
+ y[i] = s;
+ }
+
+ return;
+}
+
+/*
+ * E_ACELP_codebook_target_update
+ *
+ * Parameters:
+ * x I: old target (for pitch search) (Q0)
+ * x2 O: new target (for codebook search) (Q0)
+ * y I: filtered adaptive codebook vector (Q0)
+ * gain I: adaptive codebook gain (Q14)
+ *
+ * Function:
+ * Update the target vector for codebook search.
+ * Subframe size = L_SUBFR
+ * Returns:
+ * void
+ */
+void E_ACELP_codebook_target_update(Float32 *x, Float32 *x2, Float32 *y,
+ Float32 gain)
+{
+ Word32 i;
+
+ for (i = 0; i < L_SUBFR; i ++)
+ {
+ x2[i] = x[i] - gain * y[i];
+ }
+
+}
+
+/*
+ * E_ACELP_h_vec_corr?
+ *
+ * Parameters:
+ * h I: scaled impulse response
+ * vec I: vector to correlate with h[]
+ * track I: track to use
+ * sign I: sign vector
+ * rrixix I: correlation of h[x] with h[x]
+ * cor O: result of correlation (16 elements)
+ *
+ * Function:
+ * Calculate the correlations of h[] with vec[] for the specified track
+ *
+ * Returns:
+ * void
+ */
+static void E_ACELP_h_vec_corr1(Float32 h[], Float32 vec[], UWord8 track,
+ Float32 sign[], Float32 (*rrixix)[16],
+ Float32 cor[], Word32 dn2_pos[],
+ Word32 nb_pulse)
+{
+ Word32 i, j, dn;
+ Word32 *dn2;
+ Float32 *p0;
+ Float32 s;
+
+ dn2 = &dn2_pos[track * 8];
+ p0 = rrixix[track];
+
+ for (i = 0; i < nb_pulse; i++)
+ {
+ dn = dn2[i];
+ s = 0.0F;
+ for (j = 0; j < (L_SUBFR - dn); j++)
+ {
+ s += h[j] * vec[dn + j];
+ }
+
+ cor[dn >> 2] = sign[dn] * s + p0[dn >> 2];
+ }
+
+ return;
+}
+
+static void E_ACELP_h_vec_corr2(Float32 h[], Float32 vec[], UWord8 track,
+ Float32 sign[], Float32 (*rrixix)[16],
+ Float32 cor[])
+{
+ Word32 i, j;
+ Float32 *p0;
+ Float32 s;
+
+ p0 = rrixix[track];
+ for (i = 0; i < 16; i++)
+ {
+ s = 0.0F;
+ for (j = 0; j < L_SUBFR - track; j++)
+ {
+ s += h[j] * vec[track + j];
+ }
+
+ cor[i] = s * sign[track] + p0[i];
+ track += 4;
+ }
+
+ return;
+}
+
+/*
+ * E_ACELP_2pulse_search
+ *
+ * Parameters:
+ * nb_pos_ix I: nb of pos for pulse 1 (1..8)
+ * track_x I: track of pulse 1
+ * track_y I: track of pulse 2
+ * ps I/O: correlation of all fixed pulses
+ * alp I/O: energy of all fixed pulses
+ * ix O: position of pulse 1
+ * iy O: position of pulse 2
+ * dn I: corr. between target and h[]
+ * dn2 I: vector of selected positions
+ * cor_x I: corr. of pulse 1 with fixed pulses
+ * cor_y I: corr. of pulse 2 with fixed pulses
+ * rrixiy I: corr. of pulse 1 with pulse 2
+ *
+ * Function:
+ * Find the best positions of 2 pulses in a subframe
+ *
+ * Returns:
+ * void
+ */
+static void E_ACELP_2pulse_search(Word32 nb_pos_ix, UWord8 track_x,
+ UWord8 track_y, Float32 *ps, Float32 *alp,
+ Word32 *ix, Word32 *iy, Float32 dn[],
+ Word32 *dn2, Float32 cor_x[],
+ Float32 cor_y[], Float32 (*rrixiy)[256])
+{
+ Word32 x, x2, y, x_save = 0, y_save = 0, i, *pos_x;
+ Float32 ps0, alp0;
+ Float32 ps1, ps2, sq, sqk;
+ Float32 alp1, alp2, alpk;
+ Float32 *p1, *p2;
+ Float32 s;
+
+ /* eight dn2 max positions per track */
+ pos_x = &dn2[track_x << 3];
+ /* save these to limit memory searches */
+ ps0 = *ps;
+ alp0 = *alp;
+
+ sqk = -1.0F;
+ alpk = 1.0F;
+
+ /* loop track 1 */
+ for (i = 0; i < nb_pos_ix; i++)
+ {
+ x = pos_x[i];
+ x2 = x >> 2;
+ /* dn[x] has only nb_pos_ix positions saved */
+ ps1 = ps0 + dn[x];
+ alp1 = alp0 + cor_x[x2];
+ p1 = cor_y;
+ p2 = &rrixiy[track_x][x2 << 4];
+
+ for (y = track_y; y < L_SUBFR; y += 4)
+ {
+ ps2 = ps1 + dn[y];
+ alp2 = alp1 + (*p1++) + (*p2++);
+
+ sq = ps2 * ps2;
+
+ s = (alpk * sq) - (sqk * alp2);
+
+ if (s > 0.0F)
+ {
+ sqk = sq;
+ alpk = alp2;
+ y_save = y;
+ x_save = x;
+ }
+ }
+ }
+
+ *ps = ps0 + dn[x_save] + dn[y_save];
+ *alp = alpk;
+ *ix = x_save;
+ *iy = y_save;
+
+ return;
+}
+
+/*
+ * E_ACELP_quant_1p_N1
+ *
+ * Parameters:
+ * pos I: position of the pulse
+ * N I: number of bits for position
+ *
+ * Function:
+ * Quantization of 1 pulse with N+1 bits
+ *
+ * Returns:
+ * return N+1 bits
+ */
+static Word32 E_ACELP_quant_1p_N1(Word32 pos, Word32 N)
+{
+ Word32 mask;
+ Word32 index;
+
+ mask = ((1<<N)-1);
+ /*
+ * Quantization of 1 pulse with N+1 bits:
+ */
+ index = (pos & mask);
+ if ((pos & 16) != 0)
+ {
+ index += 1 << N;
+ }
+
+ return(index);
+}
+
+/*
+ * E_ACELP_quant_2p_2N1
+ *
+ * Parameters:
+ * pos1 I: position of the pulse 1
+ * pos2 I: position of the pulse 2
+ * N I: number of bits for position
+ *
+ * Function:
+ * Quantization of 2 pulses with 2*N+1 bits
+ *
+ * Returns:
+ * (2*N)+1 bits
+ */
+static Word32 E_ACELP_quant_2p_2N1(Word32 pos1, Word32 pos2, Word32 N)
+{
+ Word32 mask;
+ Word32 index;
+
+ mask = ((1 << N) - 1);
+ /*
+ * Quantization of 2 pulses with 2*N+1 bits:
+ */
+ if (((pos2 ^ pos1) & 16) == 0)
+ {
+ /* sign of 1st pulse == sign of 2th pulse */
+ if ((pos1 - pos2) <= 0)
+ {
+ index = ((pos1 & mask) << N) + (pos2 & mask);
+ }
+ else
+ {
+ index = ((pos2 & mask) << N) + (pos1 & mask);
+ }
+ if ((pos1 & 16) != 0)
+ {
+ index += 1 << (2 * N);
+ }
+ }
+ else
+ {
+ /* sign of 1st pulse != sign of 2th pulse */
+ if (((pos1 & mask) - (pos2 & mask)) <= 0)
+ {
+ index = ((pos2 & mask) << N) + (pos1 & mask);
+ if ((pos2 & 16) != 0)
+ {
+ index += 1 << (2 * N);
+ }
+ }
+ else
+ {
+ index = ((pos1 & mask) << N) + (pos2 & mask);
+ if ((pos1 & 16) != 0)
+ {
+ index += 1 << (2 * N);
+ }
+ }
+ }
+
+ return(index);
+}
+
+/*
+ * E_ACELP_quant_3p_3N1
+ *
+ * Parameters:
+ * pos1 I: position of the pulse 1
+ * pos2 I: position of the pulse 2
+ * pos3 I: position of the pulse 3
+ * N I: number of bits for position
+ *
+ * Function:
+ * Quantization of 3 pulses with 3*N+1 bits
+ *
+ * Returns:
+ * (3*N)+1 bits
+ */
+static Word32 E_ACELP_quant_3p_3N1(Word32 pos1, Word32 pos2, Word32 pos3,
+ Word32 N)
+{
+ Word32 nb_pos;
+ Word32 index;
+
+ nb_pos = (1 << (N - 1));
+ /*
+ * Quantization of 3 pulses with 3*N+1 bits:
+ */
+ if (((pos1 ^ pos2) & nb_pos) == 0)
+ {
+ index = E_ACELP_quant_2p_2N1(pos1, pos2, (N - 1));
+ index += (pos1 & nb_pos) << N;
+ index += E_ACELP_quant_1p_N1(pos3, N) << (2 * N);
+ }
+ else if (((pos1 ^ pos3) & nb_pos) == 0)
+ {
+ index = E_ACELP_quant_2p_2N1(pos1, pos3, (N - 1));
+ index += (pos1 & nb_pos) << N;
+ index += E_ACELP_quant_1p_N1(pos2, N) << (2 * N);
+ }
+ else
+ {
+ index = E_ACELP_quant_2p_2N1(pos2, pos3, (N - 1));
+ index += (pos2 & nb_pos) << N;
+ index += E_ACELP_quant_1p_N1(pos1, N) << (2 * N);
+ }
+
+ return(index);
+}
+
+/*
+ * E_ACELP_quant_4p_4N1
+ *
+ * Parameters:
+ * pos1 I: position of the pulse 1
+ * pos2 I: position of the pulse 2
+ * pos3 I: position of the pulse 3
+ * pos4 I: position of the pulse 4
+ * N I: number of bits for position
+ *
+ * Function:
+ * Quantization of 4 pulses with 4*N+1 bits
+ *
+ * Returns:
+ * (4*N)+1 bits
+ */
+static Word32 E_ACELP_quant_4p_4N1(Word32 pos1, Word32 pos2, Word32 pos3,
+ Word32 pos4, Word32 N)
+{
+ Word32 nb_pos;
+ Word32 index;
+
+ nb_pos = (1 << (N - 1));
+ /*
+ * Quantization of 4 pulses with 4*N+1 bits:
+ */
+ if (((pos1 ^ pos2) & nb_pos) == 0)
+ {
+ index = E_ACELP_quant_2p_2N1(pos1, pos2, (N - 1));
+ index += (pos1 & nb_pos) << N;
+ index += E_ACELP_quant_2p_2N1(pos3, pos4, N) << (2 * N);
+ }
+ else if (((pos1 ^ pos3) & nb_pos) == 0)
+ {
+ index = E_ACELP_quant_2p_2N1(pos1, pos3, (N - 1));
+ index += (pos1 & nb_pos) << N;
+ index += E_ACELP_quant_2p_2N1(pos2, pos4, N) << (2 * N);
+ }
+ else
+ {
+ index = E_ACELP_quant_2p_2N1(pos2, pos3, (N - 1));
+ index += (pos2 & nb_pos) << N;
+ index += E_ACELP_quant_2p_2N1(pos1, pos4, N) << (2 * N);
+ }
+
+ return(index);
+}
+
+/*
+ * E_ACELP_quant_4p_4N
+ *
+ * Parameters:
+ * pos I: position of the pulse 1..4
+ * N I: number of bits for position
+ *
+ * Function:
+ * Quantization of 4 pulses with 4*N bits
+ *
+ * Returns:
+ * 4*N bits
+ */
+static Word32 E_ACELP_quant_4p_4N(Word32 pos[], Word32 N)
+{
+ Word32 i, j, k, nb_pos, n_1;
+ Word32 posA[4], posB[4];
+ Word32 index=0;
+
+ n_1 = N - 1;
+ nb_pos = (1 << n_1);
+
+ i = 0;
+ j = 0;
+ for (k = 0; k < 4; k++)
+ {
+ if ((pos[k] & nb_pos) == 0)
+ {
+ posA[i++] = pos[k];
+ }
+ else
+ {
+ posB[j++] = pos[k];
+ }
+ }
+
+ switch (i)
+ {
+ case 0:
+ index = 1 << ((4 * N) - 3);
+ index += E_ACELP_quant_4p_4N1(posB[0], posB[1], posB[2], posB[3], n_1);
+ break;
+ case 1:
+ index = E_ACELP_quant_1p_N1(posA[0], n_1) << (( 3 * n_1) + 1);
+ index += E_ACELP_quant_3p_3N1(posB[0], posB[1], posB[2], n_1);
+ break;
+ case 2:
+ index = E_ACELP_quant_2p_2N1(posA[0], posA[1], n_1) << (( 2 * n_1) + 1);
+ index += E_ACELP_quant_2p_2N1(posB[0], posB[1], n_1);
+ break;
+ case 3:
+ index = E_ACELP_quant_3p_3N1(posA[0], posA[1], posA[2], n_1) << N;
+ index += E_ACELP_quant_1p_N1(posB[0], n_1);
+ break;
+ case 4:
+ index = E_ACELP_quant_4p_4N1(posA[0], posA[1], posA[2], posA[3], n_1);
+ break;
+ }
+ index += (i & 3) << ((4 * N) - 2);
+
+ return(index);
+}
+
+/*
+ * E_ACELP_quant_5p_5N
+ *
+ * Parameters:
+ * pos I: position of the pulse 1..5
+ * N I: number of bits for position
+ *
+ * Function:
+ * Quantization of 5 pulses with 5*N bits
+ *
+ * Returns:
+ * 5*N bits
+ */
+static Word32 E_ACELP_quant_5p_5N(Word32 pos[], Word32 N)
+{
+ Word32 i,j,k,nb_pos,n_1;
+ Word32 posA[5], posB[5];
+ Word32 index=0;
+
+ n_1 = N-1;
+ nb_pos = (1 << n_1);
+
+ i = 0;
+ j = 0;
+ for (k = 0; k < 5; k++)
+ {
+ if ((pos[k] & nb_pos) == 0)
+ {
+ posA[i++] = pos[k];
+ }
+ else
+ {
+ posB[j++] = pos[k];
+ }
+ }
+
+ switch (i)
+ {
+ case 0:
+ index = 1 << ((5 * N) - 1);
+ index +=
+ E_ACELP_quant_3p_3N1(posB[0], posB[1], posB[2], n_1) << ((2 * N) + 1);
+ index += E_ACELP_quant_2p_2N1(posB[3], posB[4], N);
+ break;
+ case 1:
+ index = 1 << ((5 * N) - 1);
+ index +=
+ E_ACELP_quant_3p_3N1(posB[0], posB[1], posB[2], n_1) << ((2 * N) + 1);
+ index += E_ACELP_quant_2p_2N1(posB[3], posA[0], N);
+ break;
+ case 2:
+ index = 1 << ((5 * N) - 1);
+ index +=
+ E_ACELP_quant_3p_3N1(posB[0], posB[1], posB[2], n_1) << ((2 * N) + 1);
+ index += E_ACELP_quant_2p_2N1(posA[0], posA[1], N);
+ break;
+ case 3:
+ index =
+ E_ACELP_quant_3p_3N1(posA[0], posA[1], posA[2], n_1) << ((2 * N) + 1);
+ index += E_ACELP_quant_2p_2N1(posB[0], posB[1], N);
+ break;
+ case 4:
+ index =
+ E_ACELP_quant_3p_3N1(posA[0], posA[1], posA[2], n_1) << ((2 * N) + 1);
+ index += E_ACELP_quant_2p_2N1(posA[3], posB[0], N);
+ break;
+ case 5:
+ index =
+ E_ACELP_quant_3p_3N1(posA[0], posA[1], posA[2], n_1) << ((2 * N) + 1);
+ index += E_ACELP_quant_2p_2N1(posA[3], posA[4], N);
+ break;
+ }
+
+ return(index);
+}
+
+/*
+* E_ACELP_quant_6p_6N_2
+*
+* Parameters:
+* pos I: position of the pulse 1..6
+* N I: number of bits for position
+*
+* Function:
+* Quantization of 6 pulses with 6*N-2 bits
+*
+* Returns:
+* (6*N)-2 bits
+*/
+static Word32 E_ACELP_quant_6p_6N_2(Word32 pos[], Word32 N)
+{
+ Word32 i, j, k, nb_pos, n_1;
+ Word32 posA[6], posB[6];
+ Word32 index=0;
+
+ n_1 = N - 1;
+ nb_pos = 1 << n_1;
+
+ i = 0;
+ j = 0;
+ for (k = 0; k < 6; k++)
+ {
+ if ((pos[k] & nb_pos) == 0)
+ {
+ posA[i++] = pos[k];
+ }
+ else
+ {
+ posB[j++] = pos[k];
+ }
+ }
+
+ switch (i)
+ {
+ case 0:
+ index = 1 << ((6 * N) - 5);
+ index += E_ACELP_quant_5p_5N(posB, n_1) << N;
+ index += E_ACELP_quant_1p_N1(posB[5], n_1);
+ break;
+ case 1:
+ index = 1 << ((6 * N) - 5);
+ index += E_ACELP_quant_5p_5N(posB, n_1) << N;
+ index += E_ACELP_quant_1p_N1(posA[0], n_1);
+ break;
+ case 2:
+ index = 1 << ((6 * N) - 5);
+ index += E_ACELP_quant_4p_4N(posB, n_1) << ((2 * n_1) + 1);
+ index += E_ACELP_quant_2p_2N1(posA[0], posA[1], n_1);
+ break;
+ case 3:
+ index = E_ACELP_quant_3p_3N1(posA[0], posA[1], posA[2], n_1)
+ << ((3 * n_1) + 1);
+ index += E_ACELP_quant_3p_3N1(posB[0], posB[1], posB[2], n_1);
+ break;
+ case 4:
+ i = 2;
+ index = E_ACELP_quant_4p_4N(posA, n_1) << ((2 * n_1) + 1);
+ index += E_ACELP_quant_2p_2N1(posB[0], posB[1], n_1);
+ break;
+ case 5:
+ i = 1;
+ index = E_ACELP_quant_5p_5N(posA, n_1) << N;
+ index += E_ACELP_quant_1p_N1(posB[0], n_1);
+ break;
+ case 6:
+ i = 0;
+ index = E_ACELP_quant_5p_5N(posA, n_1) << N;
+ index += E_ACELP_quant_1p_N1(posA[5], n_1);
+ break;
+ }
+
+ index += (i & 3) << ((6 * N) - 4);
+
+ return(index);
+}
+
+/*
+ * E_ACELP_2t
+ *
+ * Parameters:
+ * dn I: corr. between target and h[].
+ * cn I: residual after Word32 term prediction
+ * H I: impulse response of weighted synthesis filter (Q12)
+ * code O: algebraic (fixed) codebook excitation (Q9)
+ * y O: filtered fixed codebook excitation (Q9)
+ * index O: index (12): 5 + 1 + 5 + 1 = 11 bits.
+ *
+ * Function:
+ * 12 bits algebraic codebook.
+ * 2 tracks x 32 positions per track = 64 samples.
+ *
+ * 12 bits --> 2 pulses in a frame of 64 samples.
+ *
+ * All pulses can have two (2) possible amplitudes: +1 or -1.
+ * Each pulse can have 32 possible positions.
+ *
+ * Returns:
+ * void
+ */
+void E_ACELP_2t(Float32 dn[], Float32 cn[], Float32 H[],
+ Word16 code[], Float32 y[], Word32 *index)
+{
+ Word32 i, j, k, i0, i1, ix, iy, pos = 0, pos2;
+
+ Float32 ps, psk, ps1, ps2, alpk, alp1, alp2, sq;
+ Float32 s, cor, alp, val;
+ Float32 *p0, *p1, *p2, *psign;
+ Float32 *h, *h_inv, *ptr_h1, *ptr_h2, *ptr_hf;
+ static Float32 sign[L_SUBFR], vec[L_SUBFR], dn2[L_SUBFR];
+ static Float32 h_buf[4 * L_SUBFR];
+ static Float32 rrixix[2][32];
+ static Float32 rrixiy[1024];
+
+ /*
+ * Find sign for each pulse position.
+ */
+ alp = 2.0;
+
+ /* calculate energy for normalization of cn[] and dn[] */
+ val = 1.0;
+ cor = 1.0;
+
+ for(i = 0; i < L_SUBFR; i++)
+ {
+ val += cn[i] * cn[i];
+ }
+
+ for(i = 0; i < L_SUBFR; i++)
+ {
+ cor += dn[i] * dn[i];
+ }
+
+ s = (Float32)sqrt(cor / val);
+
+ for(i = 0; i < 2; i++)
+ {
+ for(j = i; j < L_SUBFR; j += 2)
+ {
+ val = dn[j];
+ cor = (s * cn[j]) + (alp * val);
+
+ if(cor >= 0.0)
+ {
+ sign[j] = 1.0;
+ vec[j] = -1.0;
+ }
+ else
+ {
+ sign[j] = -1.0;
+ vec[j] = 1.0;
+ val = -val;
+ cor = -cor;
+ }
+
+ dn[j] = val; /* modify dn[] according to the fixed sign */
+ dn2[j] = cor;
+ }
+ }
+
+ /*
+ * Select 16 position per track according to dn2[].
+ */
+ for(i = 0; i < 2; i++)
+ {
+ for(k = 0; k < 16; k++)
+ {
+ ps = -1;
+
+ for(j = i; j < L_SUBFR; j += 2)
+ {
+ if(dn2[j] > ps)
+ {
+ ps = dn2[j];
+ pos = j;
+ }
+ }
+ dn2[pos] = (Float32)k - 16; /* dn2 < 0 when position is selected */
+ }
+ }
+
+ /*
+ * Compute h_inv[i].
+ */
+ h = h_buf;
+ h_inv = h_buf + (2 * L_SUBFR);
+
+ for(i = 0; i < L_SUBFR; i++)
+ {
+ *h++ = 0.0F;
+ *h_inv++ = 0.0F;
+ }
+
+ for(i = 0; i < L_SUBFR; i++)
+ {
+ h[i] = H[i];
+ h_inv[i] = -h[i];
+ }
+
+ /*
+ * Compute rrixix[][] needed for the codebook search.
+ */
+ /* Init pointers to last position of rrixix[] */
+ p0 = &rrixix[0][32 - 1];
+ p1 = &rrixix[1][32 - 1];
+ ptr_h1 = h;
+ cor = 0.0F;
+
+ for(i = 0; i < 32; i++)
+ {
+ cor += (*ptr_h1) * (*ptr_h1);
+ ptr_h1++;
+ *p1-- = cor * 0.5F;
+ cor += (*ptr_h1) * (*ptr_h1);
+ ptr_h1++;
+ *p0-- = cor * 0.5F;
+ }
+
+ /*
+ * Compute rrixiy[][] needed for the codebook search.
+ */
+ pos = 1024 - 1;
+ pos2 = 1024 - 2;
+ ptr_hf = h + 1;
+
+ for(k = 0; k < 32; k++)
+ {
+ p1 = &rrixiy[pos];
+ p0 = &rrixiy[pos2];
+ cor = 0.0;
+ ptr_h1 = h;
+ ptr_h2 = ptr_hf;
+
+ for(i = k + 1; i < 32; i++)
+ {
+ cor += (*ptr_h1) * (*ptr_h2);
+ ptr_h1++;
+ ptr_h2++;
+ *p1 = cor;
+ cor += (*ptr_h1) * (*ptr_h2);
+ ptr_h1++;
+ ptr_h2++;
+ *p0 = cor;
+ p1 -= (32 + 1);
+ p0 -= (32 + 1);
+ }
+
+ cor += (*ptr_h1) * (*ptr_h2);
+ ptr_h1++;
+ ptr_h2++;
+ *p1 = cor;
+ pos -= 32;
+ pos2--;
+ ptr_hf += 2;
+ }
+
+ /*
+ * Modification of rrixiy[][] to take signs into account.
+ */
+ p0 = rrixiy;
+
+ for(i = 0; i < L_SUBFR; i += 2)
+ {
+ psign = sign;
+
+ if(psign[i] < 0.0)
+ {
+ psign = vec;
+ }
+
+ for(j = 1; j < L_SUBFR; j += 2)
+ {
+ *p0 = *p0 * psign[j];
+ p0++;
+ }
+ }
+
+ /*
+ * search 2 pulses:
+ * ---------------
+ * 32 pos x 32 pos = 1024 tests (all combinations are tested)
+ */
+ p0 = rrixix[0];
+ p1 = rrixix[1];
+ p2 = rrixiy;
+ psk = -1.0;
+ alpk = 1.0;
+ ix = 0;
+ iy = 1;
+
+ for(i0 = 0; i0 < L_SUBFR; i0 += 2)
+ {
+ ps1 = dn[i0];
+ alp1 = (*p0++);
+ pos = -1;
+
+ for(i1 = 1; i1 < L_SUBFR; i1 += 2)
+ {
+ ps2 = ps1 + dn[i1];
+ alp2 = alp1 + (*p1++) + (*p2++);
+ sq = ps2 * ps2;
+ s = (alpk * sq) - (psk * alp2);
+
+ if(s > 0.0)
+ {
+ psk = sq;
+ alpk = alp2;
+ pos = i1;
+ }
+ }
+ p1 -= 32;
+
+ if(pos >= 0)
+ {
+ ix = i0;
+ iy = pos;
+ }
+ }
+
+ /*
+ * Build the codeword, the filtered codeword and index of codevector.
+ */
+ memset(code, 0, L_SUBFR * sizeof(Word16));
+
+ i0 = ix / 2; /* pos of pulse 1 (0..31) */
+ i1 = iy / 2; /* pos of pulse 2 (0..31) */
+
+ if(sign[ix] > 0.0)
+ {
+ code[ix] = 512;
+ p0 = h - ix;
+ }
+ else
+ {
+ code[ix] = -512;
+ i0 += 32;
+ p0 = h_inv - ix;
+ }
+
+ if(sign[iy] > 0.0)
+ {
+ code[iy] = 512;
+ p1 = h - iy;
+ }
+ else
+ {
+ code[iy] = -512;
+ i1 += 32;
+ p1 = h_inv - iy;
+ }
+
+ *index = (i0 << 6) + i1;
+
+ for(i = 0; i < L_SUBFR; i++)
+ {
+ y[i] = (*p0++) + (*p1++);
+ }
+
+ return;
+}
+
+/*
+ * E_ACELP_4t
+ *
+ * Parameters:
+ * dn I: corr. between target and h[].
+ * cn I: residual after Word32 term prediction
+ * H I: impulse response of weighted synthesis filter (Q12)
+ * code O: algebraic (fixed) codebook excitation (Q9)
+ * y O: filtered fixed codebook excitation (Q9)
+ * nbbits I: 20, 36, 44, 52, 64, 72 or 88 bits
+ * mode I: speech mode
+ * _index O: index
+ *
+ * Function:
+ * 20, 36, 44, 52, 64, 72, 88 bits algebraic codebook.
+ * 4 tracks x 16 positions per track = 64 samples.
+ *
+ * 20 bits 5 + 5 + 5 + 5 --> 4 pulses in a frame of 64 samples.
+ * 36 bits 9 + 9 + 9 + 9 --> 8 pulses in a frame of 64 samples.
+ * 44 bits 13 + 9 + 13 + 9 --> 10 pulses in a frame of 64 samples.
+ * 52 bits 13 + 13 + 13 + 13 --> 12 pulses in a frame of 64 samples.
+ * 64 bits 2 + 2 + 2 + 2 + 14 + 14 + 14 + 14 -->
+ * 16 pulses in a frame of 64 samples.
+ * 72 bits 10 + 2 + 10 + 2 + 10 + 14 + 10 + 14 -->
+ * 18 pulses in a frame of 64 samples.
+ * 88 bits 11 + 11 + 11 + 11 + 11 + 11 + 11 + 11 -->
+ * 24 pulses in a frame of 64 samples.
+ *
+ * All pulses can have two (2) possible amplitudes: +1 or -1.
+ * Each pulse can sixteen (16) possible positions.
+ *
+ * Returns:
+ * void
+ */
+void E_ACELP_4t(Float32 dn[], Float32 cn[], Float32 H[], Word16 code[],
+ Float32 y[], Word32 nbbits, Word16 mode, Word32 _index[])
+{
+ Float32 sign[L_SUBFR], vec[L_SUBFR];
+ Float32 cor_x[16], cor_y[16], h_buf[4 * L_SUBFR];
+ Float32 rrixix[4][16];
+ Float32 rrixiy[4][256];
+ Float32 dn2[L_SUBFR];
+ Word32 ind[NPMAXPT*4];
+ Word32 codvec[NB_PULSE_MAX];
+ Word32 nbpos[10];
+ Word32 pos_max[4];
+ Word32 dn2_pos[8 * 4];
+ UWord8 ipos[NB_PULSE_MAX];
+ Word32 i, j, k, st, pos = 0, index, track, nb_pulse = 0, nbiter = 4;
+ Word32 L_index;
+ Float32 psk, ps, alpk, alp = 0.0F;
+ Float32 val;
+ Float32 s, cor;
+ Float32 *p0, *p1, *p2, *p3, *psign;
+ Float32 *h, *h_inv, *ptr_h1, *ptr_h2, *ptr_hf;
+
+ switch (nbbits)
+ {
+ case 20: /* 20 bits, 4 pulses, 4 tracks */
+ nbiter = 4; /* 4x16x16=1024 loop */
+ alp = 2.0;
+ nb_pulse = 4;
+ nbpos[0] = 4;
+ nbpos[1] = 8;
+ break;
+ case 36: /* 36 bits, 8 pulses, 4 tracks */
+ nbiter = 4; /* 4x20x16=1280 loop */
+ alp = 1.0; /* coeff for sign setting */
+ nb_pulse = 8;
+ nbpos[0] = 4;
+ nbpos[1] = 8;
+ nbpos[2] = 8;
+ break;
+ case 44: /* 44 bits, 10 pulses, 4 tracks */
+ nbiter = 4; /* 4x26x16=1664 loop */
+ alp = 1.0;
+ nb_pulse = 10;
+ nbpos[0] = 4;
+ nbpos[1] = 6;
+ nbpos[2] = 8;
+ nbpos[3] = 8;
+ break;
+ case 52: /* 52 bits, 12 pulses, 4 tracks */
+ nbiter = 4; /* 4x26x16=1664 loop */
+ alp = 1.0;
+ nb_pulse = 12;
+ nbpos[0] = 4;
+ nbpos[1] = 6;
+ nbpos[2] = 8;
+ nbpos[3] = 8;
+ break;
+ case 64: /* 64 bits, 16 pulses, 4 tracks */
+ nbiter = 3; /* 3x36x16=1728 loop */
+ alp = 0.8F;
+ nb_pulse = 16;
+ nbpos[0] = 4;
+ nbpos[1] = 4;
+ nbpos[2] = 6;
+ nbpos[3] = 6;
+ nbpos[4] = 8;
+ nbpos[5] = 8;
+ break;
+ case 72: /* 72 bits, 18 pulses, 4 tracks */
+ nbiter = 3; /* 3x35x16=1680 loop */
+ alp = 0.75F;
+ nb_pulse = 18;
+ nbpos[0] = 2;
+ nbpos[1] = 3;
+ nbpos[2] = 4;
+ nbpos[3] = 5;
+ nbpos[4] = 6;
+ nbpos[5] = 7;
+ nbpos[6] = 8;
+ break;
+ case 88: /* 88 bits, 24 pulses, 4 tracks */
+ if (mode > MODE_23k)
+ {
+ nbiter = 1;
+ }
+ else
+ {
+ nbiter = 2; /* 2x53x16=1696 loop */
+ }
+
+ alp = 0.5;
+ nb_pulse = 24;
+ nbpos[0] = 2;
+ nbpos[1] = 2;
+ nbpos[2] = 3;
+ nbpos[3] = 4;
+ nbpos[4] = 5;
+ nbpos[5] = 6;
+ nbpos[6] = 7;
+ nbpos[7] = 8;
+ nbpos[8] = 8;
+ nbpos[9] = 8;
+ break;
+ }
+
+ /*
+ * Find sign for each pulse position.
+ */
+
+ /* calculate energy for normalization of cn[] and dn[] */
+
+ val = (cn[0] * cn[0]) + 1.0F;
+ cor = (dn[0] * dn[0]) + 1.0F;
+
+ for (i = 1; i < L_SUBFR; i += 7)
+ {
+ val += (cn[i] * cn[i]);
+ cor += (dn[i] * dn[i]);
+ val += (cn[i + 1] * cn[i + 1]);
+ cor += (dn[i + 1] * dn[i + 1]);
+ val += (cn[i + 2] * cn[i + 2]);
+ cor += (dn[i + 2] * dn[i + 2]);
+ val += (cn[i + 3] * cn[i + 3]);
+ cor += (dn[i + 3] * dn[i + 3]);
+ val += (cn[i + 4] * cn[i + 4]);
+ cor += (dn[i + 4] * dn[i + 4]);
+ val += (cn[i + 5] * cn[i + 5]);
+ cor += (dn[i + 5] * dn[i + 5]);
+ val += (cn[i + 6] * cn[i + 6]);
+ cor += (dn[i + 6] * dn[i + 6]);
+ }
+
+ s = (Float32)sqrt(cor / val);
+
+ for (j = 0; j < L_SUBFR; j++)
+ {
+ cor = (s * cn[j]) + (alp * dn[j]);
+
+ if (cor >= 0.0F)
+ {
+ sign[j] = 1.0F;
+ vec[j] = -1.0F;
+ dn2[j] = cor; /* dn2[] = mix of dn[] and cn[] */
+ }
+ else
+ {
+ sign[j] = -1.0F;
+ vec[j] = 1.0F;
+ dn[j] = -dn[j]; /* modify dn[] according to the fixed sign */
+ dn2[j] = -cor; /* dn2[] = mix of dn[] and cn[] */
+ }
+ }
+
+ /*
+ * Select 8 position per track according to dn2[].
+ */
+ for (i = 0; i < 4; i++)
+ {
+ for (k = 0; k < 8; k++)
+ {
+ ps = -1;
+
+ for (j = i; j < L_SUBFR; j += 4)
+ {
+ if (dn2[j] > ps)
+ {
+ ps = dn2[j];
+ pos = j;
+ }
+ }
+
+ dn2[pos] = (Float32)k - 8; /* dn2 < 0 when position is selected */
+ dn2_pos[i * 8 + k] = pos;
+ }
+
+ pos_max[i] = dn2_pos[i * 8];
+ }
+
+ /*
+ * Compute h_inv[i].
+ */
+ memset(h_buf, 0, L_SUBFR * sizeof(Float32));
+ memset(h_buf + (2 * L_SUBFR), 0, L_SUBFR * sizeof(Float32));
+
+ h = h_buf + L_SUBFR;
+ h_inv = h_buf + (3 * L_SUBFR);
+
+ memcpy(h, H, L_SUBFR * sizeof(Float32));
+
+ h_inv[0] = -h[0];
+ h_inv[1] = -h[1];
+ h_inv[2] = -h[2];
+ h_inv[3] = -h[3];
+
+ for(i = 4; i < L_SUBFR; i += 6)
+ {
+ h_inv[i] = -h[i];
+ h_inv[i + 1] = -h[i + 1];
+ h_inv[i + 2] = -h[i + 2];
+ h_inv[i + 3] = -h[i + 3];
+ h_inv[i + 4] = -h[i + 4];
+ h_inv[i + 5] = -h[i + 5];
+ }
+
+ /*
+ * Compute rrixix[][] needed for the codebook search.
+ */
+
+ /* storage order --> i3i3, i2i2, i1i1, i0i0 */
+
+ /* Init pointers to last position of rrixix[] */
+ p0 = &rrixix[0][16 - 1];
+ p1 = &rrixix[1][16 - 1];
+ p2 = &rrixix[2][16 - 1];
+ p3 = &rrixix[3][16 - 1];
+
+ ptr_h1 = h;
+ cor = 0.0F;
+
+ for(i = 0; i < 16; i++)
+ {
+ cor += (*ptr_h1) * (*ptr_h1);
+ ptr_h1++;
+ *p3-- = cor * 0.5F;
+ cor += (*ptr_h1) * (*ptr_h1);
+ ptr_h1++;
+ *p2-- = cor * 0.5F;
+ cor += (*ptr_h1) * (*ptr_h1);
+ ptr_h1++;
+ *p1-- = cor * 0.5F;
+ cor += (*ptr_h1) * (*ptr_h1);
+ ptr_h1++;
+ *p0-- = cor * 0.5F;
+ }
+
+
+ /*
+ * Compute rrixiy[][] needed for the codebook search.
+ */
+
+ /* storage order --> i2i3, i1i2, i0i1, i3i0 */
+
+ pos = 256 - 1;
+ ptr_hf = h + 1;
+
+ for(k = 0; k < 16; k++)
+ {
+
+ p3 = &rrixiy[2][pos];
+ p2 = &rrixiy[1][pos];
+ p1 = &rrixiy[0][pos];
+ p0 = &rrixiy[3][pos - 16];
+
+ cor = 0.0F;
+ ptr_h1 = h;
+ ptr_h2 = ptr_hf;
+
+ for(i = k + 1; i < 16; i++)
+ {
+ cor += (*ptr_h1) * (*ptr_h2);
+ ptr_h1++;
+ ptr_h2++;
+ *p3 = cor;
+ cor += (*ptr_h1) * (*ptr_h2);
+ ptr_h1++;
+ ptr_h2++;
+ *p2 = cor;
+ cor += (*ptr_h1) * (*ptr_h2);
+ ptr_h1++;
+ ptr_h2++;
+ *p1 = cor;
+ cor += (*ptr_h1) * (*ptr_h2);
+ ptr_h1++;
+ ptr_h2++;
+ *p0 = cor;
+
+ p3 -= (16 + 1);
+ p2 -= (16 + 1);
+ p1 -= (16 + 1);
+ p0 -= (16 + 1);
+ }
+
+ cor += (*ptr_h1) * (*ptr_h2);
+ ptr_h1++;
+ ptr_h2++;
+ *p3 = cor;
+ cor += (*ptr_h1) * (*ptr_h2);
+ ptr_h1++;
+ ptr_h2++;
+ *p2 = cor;
+ cor += (*ptr_h1) * (*ptr_h2);
+ ptr_h1++;
+ ptr_h2++;
+ *p1 = cor;
+
+ pos -= 16;
+ ptr_hf += 4;
+ }
+
+ /* storage order --> i3i0, i2i3, i1i2, i0i1 */
+
+ pos = 256 - 1;
+ ptr_hf = h + 3;
+
+ for(k = 0; k < 16; k++)
+ {
+
+ p3 = &rrixiy[3][pos];
+ p2 = &rrixiy[2][pos - 1];
+ p1 = &rrixiy[1][pos - 1];
+ p0 = &rrixiy[0][pos - 1];
+
+ cor = 0.0F;
+ ptr_h1 = h;
+ ptr_h2 = ptr_hf;
+
+ for(i= k + 1; i < 16; i++ )
+ {
+ cor += (*ptr_h1) * (*ptr_h2);
+ ptr_h1++;
+ ptr_h2++;
+ *p3 = cor;
+ cor += (*ptr_h1) * (*ptr_h2);
+ ptr_h1++;
+ ptr_h2++;
+ *p2 = cor;
+ cor += (*ptr_h1) * (*ptr_h2);
+ ptr_h1++;
+ ptr_h2++;
+ *p1 = cor;
+ cor += (*ptr_h1) * (*ptr_h2);
+ ptr_h1++;
+ ptr_h2++;
+ *p0 = cor;
+
+ p3 -= (16 + 1);
+ p2 -= (16 + 1);
+ p1 -= (16 + 1);
+ p0 -= (16 + 1);
+ }
+
+ cor += (*ptr_h1) * (*ptr_h2);
+ ptr_h1++;
+ ptr_h2++;
+ *p3 = cor;
+
+ pos--;
+ ptr_hf += 4;
+ }
+
+ /*
+ * Modification of rrixiy[][] to take signs into account.
+ */
+
+ p0 = &rrixiy[0][0];
+
+ for (k = 0; k < 4; k++)
+ {
+ for(i = k; i < L_SUBFR; i += 4)
+ {
+ psign = sign;
+
+ if (psign[i] < 0.0F)
+ {
+ psign = vec;
+ }
+
+ j = (k + 1) % 4;
+
+ p0[0] = p0[0] * psign[j];
+ p0[1] = p0[1] * psign[j + 4];
+ p0[2] = p0[2] * psign[j + 8];
+ p0[3] = p0[3] * psign[j + 12];
+ p0[4] = p0[4] * psign[j + 16];
+ p0[5] = p0[5] * psign[j + 20];
+ p0[6] = p0[6] * psign[j + 24];
+ p0[7] = p0[7] * psign[j + 28];
+ p0[8] = p0[8] * psign[j + 32];
+ p0[9] = p0[9] * psign[j + 36];
+ p0[10] = p0[10] * psign[j + 40];
+ p0[11] = p0[11] * psign[j + 44];
+ p0[12] = p0[12] * psign[j + 48];
+ p0[13] = p0[13] * psign[j + 52];
+ p0[14] = p0[14] * psign[j + 56];
+ p0[15] = p0[15] * psign[j + 60];
+ p0 += 16;
+ }
+ }
+
+ /*
+ * Deep first search:
+ * ------------------
+ * 20 bits (4p): 4 iter x ((4x16)+(8x16)) = 768 tests
+ * 36 bits (8p): 4 iter x ((1x1)+(4x16)+(8x16)+(8x16)) = 1280 tests
+ * 52 bits (12p): 3 iter x ((1x1)+(1x1)+(4x16)+(6x16)
+ * +(8x16)+(8x16)) = 1248 tests
+ * 64 bits (16p): 2 iter x ((1x1)+(1x1)+(4x16)+(6x16)
+ * +(6x16)+(8x16)+(8x16)+(8x16)) = 1280 tests
+ */
+
+ psk = -1.0;
+ alpk = 1.0;
+
+ for (k = 0; k < nbiter; k++)
+ {
+ for (i = 0; i < nb_pulse - (nb_pulse % 3); i += 3)
+ {
+ ipos[i] = E_ROM_tipos[(k * 4) + i];
+ ipos[i + 1] = E_ROM_tipos[(k * 4) + i + 1];
+ ipos[i + 2] = E_ROM_tipos[(k * 4) + i + 2];
+ }
+
+ for (; i < nb_pulse; i ++)
+ {
+ ipos[i] = E_ROM_tipos[(k * 4) + i];
+ }
+
+ if (nbbits == 20)
+ {
+ pos = 0;
+ ps = 0.0F;
+ alp = 0.0F;
+ memset(vec, 0, L_SUBFR * sizeof(Float32));
+ }
+ else if ((nbbits == 36) | (nbbits == 44))
+ {
+ /* first stage: fix 2 pulses */
+ pos = 2;
+
+ ind[0] = pos_max[ipos[0]];
+ ind[1] = pos_max[ipos[1]];
+ ps = dn[ind[0]] + dn[ind[1]];
+ alp = rrixix[ipos[0]][ind[0] >> 2] + rrixix[ipos[1]][ind[1] >> 2] +
+ rrixiy[ipos[0]][((ind[0] >> 2) << 4) + (ind[1] >> 2)];
+
+ if (sign[ind[0]] < 0.0)
+ {
+ p0 = h_inv - ind[0];
+ }
+ else
+ {
+ p0 = h - ind[0];
+ }
+
+ if (sign[ind[1]] < 0.0)
+ {
+ p1 = h_inv - ind[1];
+ }
+ else
+ {
+ p1 = h - ind[1];
+ }
+
+ vec[0] = p0[0] + p1[0];
+ vec[1] = p0[1] + p1[1];
+ vec[2] = p0[2] + p1[2];
+ vec[3] = p0[3] + p1[3];
+
+ for (i = 4; i < L_SUBFR; i += 6)
+ {
+ vec[i] = p0[i] + p1[i];
+ vec[i + 1] = p0[i + 1] + p1[i + 1];
+ vec[i + 2] = p0[i + 2] + p1[i + 2];
+ vec[i + 3] = p0[i + 3] + p1[i + 3];
+ vec[i + 4] = p0[i + 4] + p1[i + 4];
+ vec[i + 5] = p0[i + 5] + p1[i + 5];
+ }
+
+ if (nbbits == 44)
+ {
+ ipos[8] = 0;
+ ipos[9] = 1;
+ }
+ }
+ else
+ {
+ /* first stage: fix 4 pulses */
+ pos = 4;
+
+ ind[0] = pos_max[ipos[0]];
+ ind[1] = pos_max[ipos[1]];
+ ind[2] = pos_max[ipos[2]];
+ ind[3] = pos_max[ipos[3]];
+ ps = dn[ind[0]] + dn[ind[1]] + dn[ind[2]] + dn[ind[3]];
+
+ p0 = h - ind[0];
+ if (sign[ind[0]] < 0.0)
+ {
+ p0 = h_inv - ind[0];
+ }
+
+ p1 = h - ind[1];
+ if (sign[ind[1]] < 0.0)
+ {
+ p1 = h_inv - ind[1];
+ }
+
+ p2 = h - ind[2];
+ if (sign[ind[2]] < 0.0)
+ {
+ p2 = h_inv - ind[2];
+ }
+
+ p3 = h - ind[3];
+ if (sign[ind[3]] < 0.0)
+ {
+ p3 = h_inv - ind[3];
+ }
+
+ vec[0] = p0[0] + p1[0] + p2[0] + p3[0];
+
+ for (i = 1; i < L_SUBFR; i += 3)
+ {
+ vec[i] = p0[i] + p1[i] + p2[i] + p3[i];
+ vec[i + 1] = p0[i + 1] + p1[i + 1] + p2[i + 1] + p3[i + 1];
+ vec[i + 2] = p0[i + 2] + p1[i + 2] + p2[i + 2] + p3[i + 2];
+ }
+
+ alp = 0.0F;
+ alp += vec[0] * vec[0] + vec[1] * vec[1];
+ alp += vec[2] * vec[2] + vec[3] * vec[3];
+
+ for (i = 4; i < L_SUBFR; i += 6)
+ {
+ alp += vec[i] * vec[i];
+ alp += vec[i + 1] * vec[i + 1];
+ alp += vec[i + 2] * vec[i + 2];
+ alp += vec[i + 3] * vec[i + 3];
+ alp += vec[i + 4] * vec[i + 4];
+ alp += vec[i + 5] * vec[i + 5];
+ }
+
+ alp *= 0.5F;
+
+ if (nbbits == 72)
+ {
+ ipos[16] = 0;
+ ipos[17] = 1;
+ }
+ }
+
+ /* other stages of 2 pulses */
+
+ for (j = pos, st = 0; j < nb_pulse; j += 2, st++)
+ {
+ /*
+ * Calculate correlation of all possible positions
+ * of the next 2 pulses with previous fixed pulses.
+ * Each pulse can have 16 possible positions.
+ */
+ E_ACELP_h_vec_corr1(h, vec, ipos[j], sign, rrixix, cor_x, dn2_pos,
+ nbpos[st]);
+
+ E_ACELP_h_vec_corr2(h, vec, ipos[j + 1], sign, rrixix, cor_y);
+
+ /*
+ * Find best positions of 2 pulses.
+ */
+ E_ACELP_2pulse_search(nbpos[st], ipos[j], ipos[j + 1], &ps, &alp,
+ &ind[j], &ind[j+1], dn, dn2_pos, cor_x, cor_y, rrixiy);
+
+ if (j < (nb_pulse - 2))
+ {
+ p0 = h - ind[j];
+ if (sign[ind[j]] < 0.0)
+ {
+ p0 = h_inv - ind[j];
+ }
+
+ p1 = h - ind[j + 1];
+ if (sign[ind[j + 1]] < 0.0)
+ {
+ p1 = h_inv - ind[j + 1];
+ }
+
+ vec[0] += p0[0] + p1[0];
+ vec[1] += p0[1] + p1[1];
+ vec[2] += p0[2] + p1[2];
+ vec[3] += p0[3] + p1[3];
+
+ for (i = 4; i < L_SUBFR; i += 6)
+ {
+ vec[i] += p0[i] + p1[i];
+ vec[i + 1] += p0[i + 1] + p1[i + 1];
+ vec[i + 2] += p0[i + 2] + p1[i + 2];
+ vec[i + 3] += p0[i + 3] + p1[i + 3];
+ vec[i + 4] += p0[i + 4] + p1[i + 4];
+ vec[i + 5] += p0[i + 5] + p1[i + 5];
+
+ }
+ }
+ }
+
+ /* memorise the best codevector */
+
+ ps = ps * ps;
+ s = (alpk * ps) - (psk * alp);
+
+ if (s > 0.0F)
+ {
+ psk = ps;
+ alpk = alp;
+ memcpy(codvec, ind, nb_pulse * sizeof(Word32));
+ }
+ }
+
+ /*
+ * Build the codeword, the filtered codeword and index of codevector.
+ */
+
+ memset(code, 0, L_SUBFR * sizeof(Word16));
+ memset(y, 0, L_SUBFR * sizeof(Float32));
+ memset(ind, 0xffffffff, NPMAXPT * 4 * sizeof(Word32));
+
+ for (k = 0; k < nb_pulse; k++)
+ {
+ i = codvec[k]; /* read pulse position */
+ val = sign[i]; /* read sign */
+
+ index = i / 4; /* pos of pulse (0..15) */
+ track = i % 4;
+
+ if (val > 0)
+ {
+ code[i] += 512;
+ codvec[k] += (2 * L_SUBFR);
+ }
+ else
+ {
+ code[i] -= 512;
+ index += 16;
+ }
+
+ i = track * NPMAXPT;
+
+ while (ind[i] >= 0)
+ {
+ i++;
+ }
+
+ ind[i] = index;
+
+ p0 = h_inv - codvec[k];
+ y[0] += p0[0];
+
+ for(i = 1; i < L_SUBFR; i += 3)
+ {
+ y[i] += p0[i];
+ y[i + 1] += p0[i + 1];
+ y[i + 2] += p0[i + 2];
+ }
+ }
+
+ if (nbbits == 20)
+ {
+ for (track = 0; track < 4; track++)
+ {
+ k = track * NPMAXPT;
+ _index[track] = E_ACELP_quant_1p_N1(ind[k], 4);
+ }
+ }
+ else if (nbbits == 36)
+ {
+ for (track = 0; track < 4; track++)
+ {
+ k = track * NPMAXPT;
+ _index[track] = E_ACELP_quant_2p_2N1(ind[k], ind[k + 1], 4);
+ }
+ }
+ else if (nbbits == 44)
+ {
+ for (track = 0; track < (4 - 2); track++)
+ {
+ k = track * NPMAXPT;
+ _index[track] =
+ E_ACELP_quant_3p_3N1(ind[k], ind[k + 1], ind[k + 2], 4);
+ }
+ for (track = 2; track < 4; track++)
+ {
+ k = track * NPMAXPT;
+ _index[track] = E_ACELP_quant_2p_2N1(ind[k], ind[k + 1], 4);
+ }
+ }
+ else if (nbbits == 52)
+ {
+ for (track = 0; track < 4; track++)
+ {
+ k = track*NPMAXPT;
+ _index[track] =
+ E_ACELP_quant_3p_3N1(ind[k], ind[k + 1], ind[k + 2], 4);
+ }
+ }
+ else if (nbbits == 64)
+ {
+ for (track = 0; track < 4; track++)
+ {
+ k = track * NPMAXPT;
+ L_index = E_ACELP_quant_4p_4N(&ind[k], 4);
+ _index[track] = ((L_index >> 14) & 3);
+ _index[track + 4] = (L_index & 0x3FFF);
+ }
+ }
+ else if (nbbits == 72)
+ {
+ for (track=0; track< (4 - 2); track++)
+ {
+ k = track * NPMAXPT;
+ L_index = E_ACELP_quant_5p_5N(&ind[k], 4);
+ _index[track] = ((L_index >> 10) & 0x03FF);
+ _index[track + 4] = (L_index & 0x03FF);
+ }
+ for (track = 2; track < 4; track++)
+ {
+ k = track * NPMAXPT;
+ L_index = E_ACELP_quant_4p_4N(&ind[k], 4);
+ _index[track] = ((L_index >> 14) & 3);
+ _index[track + 4] = (L_index & 0x3FFF);
+ }
+ }
+ else if (nbbits == 88)
+ {
+ for (track = 0; track < 4; track++)
+ {
+ k = track * NPMAXPT;
+ L_index = E_ACELP_quant_6p_6N_2(&ind[k], 4);
+ _index[track] = ((L_index >> 11) & 0x07FF);
+ _index[track + 4] = (L_index & 0x07FF);
+ }
+ }
+
+ return;
+}
+
+/*
+ * E_ACELP_gains_quantise
+ *
+ * Parameters:
+ * code I: Innovative code vector
+ * nbits I: number of bits (6 or 7)
+ * gain_pit I/O: Pitch gain / Quantized pitch gain
+ * gain_code O: Quantized codebook gain
+ * coeff O: correlations
+ * <y1,y1>, -2<xn,y1>, <y2,y2>, -2<xn,y2>, 2<y1,y2>
+ * gp_clip I: gain pitch clipping flag (1 = clipping)
+ * mem I/O: static memory
+ *
+ * Function:
+ * Quantization of pitch and codebook gains.
+ * MA prediction is performed on the innovation energy
+ * (in dB with mean removed).
+ * An initial predicted gain, g_0, is first determined and the correction
+ * factor alpha = gain / g_0 is quantized.
+ * The pitch gain and the correction factor are vector quantized and the
+ * mean-squared weighted error criterion is used in the quantizer search.
+ * Subrame size is L_SUBFR
+ *
+ * Returns:
+ * index of quantizer
+ */
+Word32 E_ACELP_gains_quantise(Word16 code[], Word32 nbits, Float32 f_gain_pit,
+ Word16 *gain_pit, Word32 *gain_code,
+ Float32 *coeff, Word32 gp_clip,
+ Word16 *past_qua_en)
+{
+
+ Word32 i, j, indice = 0, min_ind, size, L_tmp, gcode_inov, L_gcode0;
+ Word32 exp;
+ Float32 gcode0;
+ Float32 dist, dist_min, g_pitch, g_code, ener_code, pred_code;
+ Float32 coef0, coef1, coef2, coef3, coef4;
+ const Float32 *t_qua_gain, *p;
+ Word16 s_exp, s_gcode0, exp_gcode0, frac;
+
+ /*
+ * Find the initial quantization pitch index
+ * Set gains search range
+ */
+ if (nbits == 6)
+ {
+ t_qua_gain = E_ROM_qua_gain6b;
+ min_ind = 0;
+ size = 64;
+ if (gp_clip == 1)
+ {
+ size -= 16; /* limit gain pitch to 1.0 */
+ }
+ }
+ else
+ {
+ t_qua_gain = E_ROM_qua_gain7b;
+
+ p = E_ROM_qua_gain7b + 64; /* pt at 1/4th of table */
+
+ j = NB_QUA_GAIN7B - 64;
+ if (gp_clip == 1)
+ {
+ j -= 27; /* limit gain pitch to 1.0 */
+ }
+
+ min_ind = 0;
+ g_pitch = f_gain_pit;
+
+ for (i = 0; i < j; i++, p += 2)
+ {
+ if (g_pitch > *p)
+ {
+ min_ind++;
+ }
+ }
+
+ size = 64;
+ }
+
+ /* innovation energy */
+ L_tmp = E_UTIL_dot_product12(code, code, L_SUBFR, &exp);
+
+ ener_code = (Float32)(L_tmp * pow(2, (exp - 31) - 18));
+ ener_code = (Float32)(10.0F * log10(ener_code * 0.015625F));
+ /* exp: -18 (code in Q9), -6 (/L_subfr) */
+ s_exp = (Word16)(exp - (18 + 6));
+
+ E_UTIL_normalised_inverse_sqrt(&L_tmp, &s_exp);
+
+ if (s_exp > 3)
+ {
+ L_tmp <<= (s_exp - 3);
+ }
+ else
+ {
+ L_tmp >>= (3 - s_exp);
+ }
+
+ gcode_inov = (Word16)(L_tmp >> 16); /* g_code_inov in Q12 */
+
+ /*
+ * Compute gcode0.
+ * = Sum(i=0,1) pred[i] * past_qua_en[i] + mean_ener - ener_code
+ */
+
+ /* MEAN_ENER in Q24 = 0x1e000000 */
+ /* MA prediction coeff = {0.5, 0.4, 0.3, 0.2} in Q13 */
+ L_tmp = 0xF000000 + 4096 * past_qua_en[0]; /* Q13 * Q10 -> Q24 */
+ L_tmp = L_tmp + 3277 * past_qua_en[1]; /* Q13 * Q10 -> Q24 */
+ L_tmp = L_tmp + 2458 * past_qua_en[2]; /* Q13 * Q10 -> Q24 */
+ L_tmp = L_tmp + 1638 * past_qua_en[3]; /* Q13 * Q10 -> Q24 */
+
+ L_gcode0 = L_tmp >> 15; /* From Q24 to Q8 */
+ pred_code = (Float32)(L_gcode0 * pow(2, -8));
+
+ /*
+ * gcode0 = pow(10.0, gcode0/20)
+ * = pow(2, 3.321928*gcode0/20)
+ * = pow(2, 0.166096*gcode0)
+ */
+
+ L_tmp = (L_gcode0 * 5443) >> 7; /* *0.166096 in Q15 -> Q24, From Q24 to Q16 */
+ E_UTIL_l_extract(L_tmp, &exp_gcode0, &frac); /* Extract exponant of gcode0 */
+
+ s_gcode0 = (Word16)(E_UTIL_pow2(14, frac)); /* Put 14 as exponant so that */
+ /*
+ * output of Pow2() will be:
+ * 16384 < Pow2() <= 32767
+ */
+ exp_gcode0 = (Word16)(exp_gcode0 - 14);
+ /* Search for best quantizer */
+ gcode0 = pred_code - ener_code;
+ gcode0 = (Float32)pow(10.0, gcode0 * 0.05F); /* predicted gain */
+
+ dist_min = FLT_MAX;
+ p = t_qua_gain + min_ind * 2;
+
+ coef0 = coeff[0];
+ coef1 = coeff[1];
+ coef2 = coeff[2];
+ coef3 = coeff[3];
+ coef4 = coeff[4];
+
+ for (i = 0; i < size; i++)
+ {
+ g_pitch = *p++; /* pitch gain */
+
+ g_code = gcode0 * *p++; /* codebook gain */
+
+ dist = g_pitch * g_pitch * coef0
+ + g_pitch * coef1
+ + g_code * g_code * coef2
+ + g_code * coef3
+ + g_pitch * g_code * coef4;
+
+ if (dist < dist_min)
+ {
+ dist_min = dist;
+ indice = i;
+ }
+ }
+
+ indice += min_ind;
+ *gain_pit = (Word16)floor(t_qua_gain[indice * 2] * (1 << 14) + 0.5F);
+ L_tmp = (Word32)floor(t_qua_gain[indice * 2 + 1] * (1 << 11) + 0.5F);
+ L_tmp = E_UTIL_saturate(L_tmp);
+ L_tmp *= s_gcode0;
+ exp_gcode0 += 5;
+
+ if (exp_gcode0 >= 0)
+ {
+ *gain_code = L_tmp << exp_gcode0; /* gain of code in Q16 */
+ }
+ else
+ {
+ *gain_code = L_tmp >> -exp_gcode0; /* gain of code in Q16 */
+ }
+
+ /* adjust gain according to energy of code */
+ E_UTIL_l_extract((Word32)*gain_code, &s_exp, &frac);
+ L_tmp = E_UTIL_mpy_32_16(s_exp, frac, (Word16)gcode_inov);
+
+ if (L_tmp < 0xFFFFFFF)
+ {
+ *gain_code = L_tmp << 3; /* gcode_inov in Q12 */
+ }
+ else
+ {
+ *gain_code = 0x7FFFFFFF;
+ }
+
+ /*
+ * qua_ener = 20*log10(g_code)
+ * = 6.0206*log2(g_code)
+ * = 6.0206*(log2(g_codeQ11) - 11)
+ */
+
+ L_tmp = (Word32)floor(t_qua_gain[indice * 2 + 1] * (1 << 11) + 0.5F);
+ L_tmp = E_UTIL_saturate(L_tmp);
+ E_UTIL_log2_32(L_tmp, &s_exp, &frac);
+ s_exp = (Word16)(s_exp - 11);
+ L_tmp = E_UTIL_mpy_32_16(s_exp, frac, 24660); /* x 6.0206 in Q12 */
+
+ /* update table of past quantized energies */
+
+ past_qua_en[3] = past_qua_en[2];
+ past_qua_en[2] = past_qua_en[1];
+ past_qua_en[1] = past_qua_en[0];
+ past_qua_en[0] = (Word16)(L_tmp >> 3); /* result in Q10 */
+
+ return indice;
+}
+
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_acelp.h b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_acelp.h
new file mode 100644
index 000000000..5200e8fc5
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_acelp.h
@@ -0,0 +1,27 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef ENC_E_ACELP_H
+#define ENC_E_ACELP_H
+
+#include "typedef.h"
+
+void E_ACELP_Gain2_Q_init(Word16 *mem);
+void E_ACELP_xy2_corr(Float32 xn[], Float32 y1[], Float32 y2[],
+ Float32 g_corr[]);
+Float32 E_ACELP_xy1_corr(Float32 xn[], Float32 y1[], Float32 g_corr[]);
+void E_ACELP_xh_corr(Float32 *x, Float32 *y, Float32 *h);
+void E_ACELP_codebook_target_update(Float32 *x, Float32 *x2, Float32 *y,
+ Float32 gain);
+void E_ACELP_2t(Float32 dn[], Float32 cn[], Float32 H[], Word16 code[],
+ Float32 y[], Word32 *index);
+void E_ACELP_4t(Float32 dn[], Float32 cn[], Float32 H[], Word16 code[],
+ Float32 y[], Word32 nbbits, Word16 mode, Word32 _index[]);
+Word32 E_ACELP_gains_quantise(Word16 code[], Word32 nbits, Float32 f_gain_pit,
+ Word16 *gain_pit, Word32 *gain_code,
+ Float32 *coeff, Word32 gp_clip,
+ Word16 *past_qua_en);
+
+#endif
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_dtx.c b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_dtx.c
new file mode 100644
index 000000000..c47de2af4
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_dtx.c
@@ -0,0 +1,1585 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#include <stdlib.h>
+#include <memory.h>
+#include <math.h>
+#include "typedef.h"
+#include "enc_lpc.h"
+#include "enc_util.h"
+
+
+#define DTX_HIST_SIZE_MIN_ONE 7
+#define DTX_HANG_CONST 7 /* yields eight frames of SP HANGOVER */
+#define DTX_ELAPSED_FRAMES_THRESH (24 + 7 -1)
+#define MED_THRESH 2.25
+#define GAIN_THR 1.406
+#define ORDER 16 /* order of linear prediction filter */
+#define RANDOM_INITSEED 21845 /* own random init value */
+#define MRDTX 9
+
+#define SIZE_BK_NOISE1 64
+#define SIZE_BK_NOISE2 64
+#define SIZE_BK_NOISE3 64
+#define SIZE_BK_NOISE4 32
+#define SIZE_BK_NOISE5 32
+
+#define FRAME_LEN 256 /* Length (samples) of the input frame */
+#define SCALE 128 /* (UNITY * UNITY) / 512 */
+#define TONE_THR 0.65f /* Threshold for tone detection */
+
+/* constants for speech level estimation */
+#define SP_EST_COUNT 80
+#define SP_ACTIVITY_COUNT 25
+#define ALPHA_SP_UP (1.0f - 0.85f)
+#define ALPHA_SP_DOWN (1.0f - 0.85f)
+
+#define NOM_LEVEL 2050.0F /* about -26 dBov */
+#define SPEECH_LEVEL_INIT NOM_LEVEL
+#define MIN_SPEECH_LEVEL1 (NOM_LEVEL * 0.063F) /* NOM_LEVEL -24 dB */
+#define MIN_SPEECH_LEVEL2 (NOM_LEVEL * 0.2F) /* NOM_LEVEL -14 dB */
+#define MIN_SPEECH_SNR 0.125F /* 0 dB, lowest SNR estimation */
+
+/* Constants for background spectrum update */
+#define ALPHA_UP1 (1.0f - 0.95f) /* Normal update, upwards: */
+#define ALPHA_DOWN1 (1.0f - 0.936f) /* Normal update, downwards */
+#define ALPHA_UP2 (1.0f - 0.985f) /* Forced update, upwards */
+#define ALPHA_DOWN2 (1.0f - 0.943f) /* Forced update, downwards */
+#define ALPHA3 (1.0f - 0.95f) /* Update downwards */
+#define ALPHA4 (1.0f - 0.9f) /* For stationary estimation */
+#define ALPHA5 (1.0f - 0.5f) /* For stationary estimation */
+
+/* Constants for VAD threshold */
+#define THR_MIN (1.6F * SCALE) /* Minimum threshold */
+#define THR_HIGH (6.0F * SCALE) /* Highest threshold */
+#define THR_LOW (1.7F * SCALE) /* Lowest threshold */
+#define NO_P1 31744.0F /* ilog2(1), Noise level for highest threshold */
+#define NO_P2 19786.0F /* ilog2(0.1, Noise level for lowest threshold */
+#define NO_SLOPE ((Float32)(THR_LOW - THR_HIGH) / (Float32)(NO_P2 - NO_P1))
+#define SP_CH_MIN (-0.75F * SCALE)
+#define SP_CH_MAX (0.75F * SCALE)
+#define SP_P1 22527.0F /* ilog2(NOM_LEVEL / 4) */
+#define SP_P2 17832.0F /* ilog2(NOM_LEVEL * 4) */
+#define SP_SLOPE ((Float32)(SP_CH_MAX - SP_CH_MIN) / (Float32)(SP_P2 - SP_P1))
+
+/* Constants for hangover length */
+#define HANG_HIGH 12 /* longest hangover */
+#define HANG_LOW 2 /* shortest hangover */
+#define HANG_P1 THR_LOW /* threshold for longest hangover */
+#define HANG_P2 (4 * SCALE) /* threshold for Word16est hangover */
+#define HANG_SLOPE ((Float32)(HANG_LOW - HANG_HIGH) / (Float32)(HANG_P2 - HANG_P1))
+
+/* Constants for burst length */
+#define BURST_HIGH 8 /* longest burst length */
+#define BURST_LOW 3 /* shortest burst length */
+#define BURST_P1 THR_HIGH /* threshold for Word32est burst */
+#define BURST_P2 THR_LOW /* threshold for Word16est burst */
+#define BURST_SLOPE ((Float32)(BURST_LOW - BURST_HIGH) / (Float32)(BURST_P2 - BURST_P1))
+
+/* Parameters for background spectrum recovery function */
+#define STAT_COUNT 20 /* threshold of stationary detection counter */
+#define STAT_THR_LEVEL 184 /* Threshold level for stationarity detection */
+#define STAT_THR 1000 /* Threshold for stationarity detection */
+
+/* Limits for background noise estimate */
+#define NOISE_MIN 40 /* minimum */
+#define NOISE_MAX 20000 /* maximum */
+#define NOISE_INIT 150 /* initial */
+
+/* Thresholds for signal power (now calculated on 2 frames) */
+#define VAD_POW_LOW 30000.0f /* If input power is lower than this, VAD is set to 0 */
+#define POW_PITCH_TONE_THR 686080.0f /* If input power is lower, pitch detection is ignored */
+
+/* Constants for the filter bank */
+#define COEFF3 0.407806f /* coefficient for the 3rd order filter */
+#define COEFF5_1 0.670013f /* 1st coefficient the for 5th order filter */
+#define COEFF5_2 0.195007f /* 2nd coefficient the for 5th order filter */
+
+extern const Float32 E_ROM_en_adjust[];
+extern const Float32 E_ROM_mean_isf_noise[];
+extern const Float32 E_ROM_dico1_isf_noise[];
+extern const Float32 E_ROM_dico2_isf_noise[];
+extern const Float32 E_ROM_dico3_isf_noise[];
+extern const Float32 E_ROM_dico4_isf_noise[];
+extern const Float32 E_ROM_dico5_isf_noise[];
+extern const Float32 E_ROM_isf[];
+
+
+/*
+ * E_DTX_isf_history_aver
+ *
+ * Parameters:
+ * isf_old I/O: ISF vectors
+ * indices I: ISF indices
+ * isf_aver O: averaged ISFs
+ *
+ * Function:
+ * Perform the ISF averaging
+ *
+ * Returns:
+ * void
+ */
+static void E_DTX_isf_history_aver(Float32 isf_old[], Word16 indices[],
+ Float32 isf_aver[])
+{
+ Float32 isf_tmp[2 * M];
+ Float32 tmp;
+ Word32 i, j, k;
+
+ /*
+ * Memorize in isf_tmp[][] the ISF vectors to be replaced by
+ * the median ISF vector prior to the averaging
+ */
+ for (k = 0; k < 2; k++)
+ {
+ if (indices[k] != -1)
+ {
+ for (i = 0; i < M; i++)
+ {
+ isf_tmp[k * M + i] = isf_old[indices[k] * M + i];
+ isf_old[indices[k] * M + i] = isf_old[indices[2] * M + i];
+ }
+ }
+ }
+
+ /* Perform the ISF averaging */
+ for (j = 0; j < M; j++)
+ {
+ tmp = 0;
+
+ for (i = 0; i < DTX_HIST_SIZE; i++)
+ {
+ tmp += isf_old[i * M + j];
+ }
+
+ isf_aver[j] = tmp;
+ }
+
+ /* Retrieve from isf_tmp[][] the ISF vectors saved prior to averaging */
+ for (k = 0; k < 2; k++)
+ {
+ if (indices[k] != -1)
+ {
+ for (i = 0; i < M; i++)
+ {
+ isf_old[indices[k] * M + i] = isf_tmp[k * M + i];
+ }
+ }
+ }
+
+ return;
+}
+
+/*
+ * E_DTX_dithering_control
+ *
+ * Parameters:
+ * st I: state struct
+ *
+ * Function:
+ * Analysis of the variation and stationarity
+ * of the background noise.
+ *
+ * Returns:
+ * Dithering decision
+ */
+static Word16 E_DTX_dithering_control(E_DTX_State * st)
+{
+ Float32 ISF_diff, gain_diff, mean, tmp;
+ Word32 i;
+ Word16 CN_dith;
+
+ /* determine how stationary the spectrum of background noise is */
+ ISF_diff = 0.0F;
+
+ for (i = 0; i < 8; i++)
+ {
+ ISF_diff += st->mem_distance_sum[i];
+ }
+
+ if (ISF_diff > 5147609.0f)
+ {
+ CN_dith = 1;
+ }
+ else
+ {
+ CN_dith = 0;
+ }
+
+ /* determine how stationary the energy of background noise is */
+ mean = 0.0f;
+
+ for (i = 0; i < DTX_HIST_SIZE; i++)
+ {
+ mean += st->mem_log_en[i] / (Float32)DTX_HIST_SIZE;
+ }
+
+ gain_diff = 0.0f;
+
+ for (i = 0; i < DTX_HIST_SIZE; i++)
+ {
+ tmp = (Float32)fabs(st->mem_log_en[i] - mean);
+ gain_diff += tmp;
+ }
+
+ if (gain_diff > GAIN_THR)
+ {
+ CN_dith = 1;
+ }
+
+ return CN_dith;
+}
+
+/*
+ * E_DTX_buffer
+ *
+ * Parameters:
+ * st I/O: state struct
+ * isf_new I: isf vector
+ * enr I: residual energy (for L_FRAME)
+ * codec_mode I: speech coder mode
+ *
+ * Function:
+ * Handles the DTX buffer
+ *
+ * Returns:
+ * void
+ */
+void E_DTX_buffer(E_DTX_State *st, Float32 isf_new[], Float32 enr,
+ Word16 codec_mode)
+{
+ Float32 log_en;
+
+ /* update pointer to circular buffer */
+ st->mem_hist_ptr++;
+
+ if (st->mem_hist_ptr == DTX_HIST_SIZE)
+ {
+ st->mem_hist_ptr = 0;
+ }
+
+ /* copy isf vector into buffer */
+ memcpy(&st->mem_isf[st->mem_hist_ptr * M], isf_new, M * sizeof(Float32));
+
+ enr += 1e-10F;
+
+ log_en = (Float32)(log10(enr / ((Float64)L_FRAME)) / log10(2.0F));
+
+ /* Subtract ~ 3 dB */
+ st->mem_log_en[st->mem_hist_ptr] = log_en + E_ROM_en_adjust[codec_mode];
+
+ return;
+}
+
+/*
+ * E_DTX_frame_indices_find
+ *
+ * Parameters:
+ * st I/O: state struct
+ * isf_old_tx I: isf vector
+ * indices I: distance indices
+ *
+ * Function:
+ * Find indices for min/max distances
+ *
+ * Returns:
+ * void
+ */
+static void E_DTX_frame_indices_find(E_DTX_State * st, Word16 indices[])
+{
+ Float32 L_tmp, tmp, summin, summax, summax2nd;
+ Word32 i, j, k;
+ Word16 ptr;
+
+ /*
+ * Remove the effect of the oldest frame from the column
+ * sum sumD[0..E_DTX_HIST_SIZE-1]. sumD[E_DTX_HIST_SIZE] is
+ * not updated since it will be removed later.
+ */
+
+ k = DTX_HIST_SIZE_MIN_ONE;
+ j = -1;
+
+ for (i = 0; i < DTX_HIST_SIZE_MIN_ONE; i++)
+ {
+ j = j + k;
+ st->mem_distance_sum[i] = st->mem_distance_sum[i] - st->mem_distance[j];
+ k--;
+ }
+
+ /*
+ * Shift the column sum sumD. The element sumD[E_DTX_HIST_SIZE-1]
+ * corresponding to the oldest frame is removed. The sum of
+ * the distances between the latest isf and other isfs,
+ * i.e. the element sumD[0], will be computed during this call.
+ * Hence this element is initialized to zero.
+ */
+
+ for (i = DTX_HIST_SIZE_MIN_ONE; i > 0; i--)
+ {
+ st->mem_distance_sum[i] = st->mem_distance_sum[i - 1];
+ }
+ st->mem_distance_sum[0] = 0.0F;
+
+ /*
+ * Remove the oldest frame from the distance matrix.
+ * Note that the distance matrix is replaced by a one-
+ * dimensional array to save static memory.
+ */
+
+ k = 0;
+
+ for (i = 27; i >= 12; i = i - k)
+ {
+ k++;
+ for (j = k; j > 0; j--)
+ {
+ st->mem_distance[i - j + 1] = st->mem_distance[i - j - k];
+ }
+ }
+
+ /*
+ * Compute the first column of the distance matrix D
+ * (squared Euclidean distances from isf1[] to isf_old_tx[][]).
+ */
+
+ ptr = st->mem_hist_ptr;
+
+ for (i = 1; i < DTX_HIST_SIZE; i++)
+ {
+ /* Compute the distance between the latest isf and the other isfs. */
+ ptr--;
+
+ if (ptr < 0)
+ {
+ ptr = DTX_HIST_SIZE_MIN_ONE;
+ }
+ L_tmp = 0;
+
+ for (j = 0; j < M; j++)
+ {
+ tmp = st->mem_isf[st->mem_hist_ptr * M + j] - st->mem_isf[ptr * M + j];
+ L_tmp += tmp * tmp;
+ }
+
+ st->mem_distance[i - 1] = L_tmp;
+
+ /* Update also the column sums. */
+ st->mem_distance_sum[0] += st->mem_distance[i - 1];
+ st->mem_distance_sum[i] += st->mem_distance[i - 1];
+ }
+
+ /* Find the minimum and maximum distances */
+ summax = st->mem_distance_sum[0];
+ summin = st->mem_distance_sum[0];
+ indices[0] = 0;
+ indices[2] = 0;
+
+ for (i = 1; i < DTX_HIST_SIZE; i++)
+ {
+ if (st->mem_distance_sum[i] > summax)
+ {
+ indices[0] = (Word16)i;
+ summax = st->mem_distance_sum[i];
+ }
+
+ if (st->mem_distance_sum[i] < summin)
+ {
+ indices[2] = (Word16)i;
+ summin = st->mem_distance_sum[i];
+ }
+ }
+
+ /* Find the second largest distance */
+ summax2nd = -100000000.0;
+ indices[1] = -1;
+ for (i = 0; i < DTX_HIST_SIZE; i++)
+ {
+ if ((st->mem_distance_sum[i] > summax2nd) && (i != indices[0]))
+ {
+ indices[1] = (Word16)i;
+ summax2nd = st->mem_distance_sum[i];
+ }
+ }
+
+ for (i = 0; i < 3; i++)
+ {
+ indices[i] = (Word16)(st->mem_hist_ptr - indices[i]);
+ if (indices[i] < 0)
+ {
+ indices[i] += DTX_HIST_SIZE;
+ }
+ }
+
+ /*
+ * If maximum distance / MED_THRESH is smaller than minimum distance
+ * then the median ISF vector replacement is not performed
+ */
+ L_tmp = (Float32)(summax / MED_THRESH);
+
+ if (L_tmp <= summin)
+ {
+ indices[0] = -1;
+ }
+
+ /*
+ * If second largest distance/MED_THRESH is smaller than
+ * minimum distance then the median ISF vector replacement is
+ * not performed
+ */
+ L_tmp = (Float32)(summax2nd / MED_THRESH);
+
+ if (L_tmp <= summin)
+ {
+ indices[1] = -1;
+ }
+
+ return;
+}
+
+/*
+ * E_DTX_isf_q
+ *
+ * Parameters:
+ * isf I: ISF in the frequency domain (0..6400)
+ * isf_q O: quantised ISF
+ * indice O: quantisation indices
+ *
+ * Function:
+ * The ISF vector is quantized using VQ with split-by-5
+ *
+ * Returns:
+ * void
+ */
+static void E_DTX_isf_q(Float32 *isf, Word16 **indice)
+{
+ Word32 i;
+ Float32 tmp;
+
+ for (i = 0; i < ORDER; i++)
+ {
+ isf[i] = isf[i] - E_ROM_mean_isf_noise[i];
+ }
+
+ (*indice)[0] = E_LPC_isf_sub_vq(&isf[0], E_ROM_dico1_isf_noise, 2,
+ SIZE_BK_NOISE1, &tmp);
+ (*indice)[1] = E_LPC_isf_sub_vq(&isf[2], E_ROM_dico2_isf_noise, 3,
+ SIZE_BK_NOISE2, &tmp);
+ (*indice)[2] = E_LPC_isf_sub_vq(&isf[5], E_ROM_dico3_isf_noise, 3,
+ SIZE_BK_NOISE3, &tmp);
+ (*indice)[3] = E_LPC_isf_sub_vq(&isf[8], E_ROM_dico4_isf_noise, 4,
+ SIZE_BK_NOISE4, &tmp);
+ (*indice)[4] = E_LPC_isf_sub_vq(&isf[12], E_ROM_dico5_isf_noise, 4,
+ SIZE_BK_NOISE5, &tmp);
+
+ return;
+}
+
+/*
+ * E_DTX_exe
+ *
+ * Parameters:
+ * st I/O: state struct
+ * exc2 O: CN excitation
+ * pt_prms O: analysis parameters
+ *
+ * Function:
+ * Confort noise parameters are encoded for the SID frame
+ *
+ * Returns:
+ * void
+ */
+void E_DTX_exe(E_DTX_State *st, Float32 *exc2, Word16 **pt_prms)
+{
+ Float32 isf[M];
+ Float32 log_en, level, gain, ener;
+ Word32 i,j;
+ Word16 isf_order[3];
+ Word16 CN_dith;
+
+ /* VOX mode computation of SID parameters */
+
+ log_en = 0.0F;
+ memset(isf, 0, M * sizeof(Float32));
+
+ /* average energy and isf */
+ for (i = 0; i < DTX_HIST_SIZE; i++)
+ {
+ log_en += st->mem_log_en[i] / (Float32)DTX_HIST_SIZE;
+ }
+
+ E_DTX_frame_indices_find(st, isf_order);
+ E_DTX_isf_history_aver(st->mem_isf, isf_order, isf);
+
+ for (j = 0; j < M; j++)
+ {
+ isf[j] = isf[j] / (Float32)DTX_HIST_SIZE; /* divide by 8 */
+ }
+
+ /* quantize logarithmic energy to 6 bits (-6 : 66 dB) */
+
+ st->mem_log_en_index = (Word16)((log_en + 2.0F) * 2.625F);
+
+ if(st->mem_log_en_index > 63)
+ {
+ st->mem_log_en_index = 63;
+ }
+
+ if(st->mem_log_en_index < 0)
+ {
+ st->mem_log_en_index = 0;
+ }
+
+ E_DTX_isf_q(isf, pt_prms);
+ (*pt_prms) += 5;
+
+ **pt_prms = st->mem_log_en_index;
+ (*pt_prms) += 1;
+
+ CN_dith = E_DTX_dithering_control(st);
+
+ **pt_prms = CN_dith;
+ (*pt_prms) += 1;
+
+ /* adjust level to speech coder mode */
+
+ log_en = (Float32)((Float32)st->mem_log_en_index / 2.625 - 2.0);
+ level = (Float32)(pow( 2.0, log_en ));
+
+ /* generate white noise vector */
+
+ for (i = 0; i < L_FRAME; i++)
+ {
+ exc2[i] = (Float32)E_UTIL_random(&(st->mem_cng_seed));
+ }
+
+ ener = 0.01F;
+
+ for (i = 0; i < L_FRAME; i++)
+ {
+ ener += exc2[i] * exc2[i];
+ }
+
+ gain = (Float32)sqrt(level * L_FRAME / ener);
+
+ for (i = 0; i < L_FRAME; i++)
+ {
+ exc2[i] *= gain;
+ }
+
+ return;
+}
+
+/*
+ * E_DTX_reset
+ *
+ * Parameters:
+ * st O: state struct
+ *
+ * Function:
+ * Initializes state memory
+ *
+ * Returns:
+ * non-zero with error, zero for ok
+ */
+Word32 E_DTX_reset(E_DTX_State *st)
+{
+ Word32 i;
+
+ if (st == (E_DTX_State *) NULL)
+ {
+ return -1;
+ }
+
+ st->mem_hist_ptr = 0;
+ st->mem_log_en_index = 0;
+
+ /* Init isf_hist[] */
+ for(i = 0; i < DTX_HIST_SIZE; i++)
+ {
+ memcpy(&st->mem_isf[i * M], E_ROM_isf, M * sizeof(Float32));
+ }
+
+ st->mem_cng_seed = RANDOM_INITSEED;
+
+ /* Reset energy history */
+ memset(st->mem_log_en, 0, DTX_HIST_SIZE * sizeof(Float32));
+
+ st->mem_dtx_hangover_count = DTX_HANG_CONST;
+ st->mem_dec_ana_elapsed_count = DTX_ELAPSED_FRAMES_THRESH;
+
+ memset(st->mem_distance, 0, 28 * sizeof(Float32));
+ memset(st->mem_distance_sum, 0, (DTX_HIST_SIZE - 1) * sizeof(Float32));
+
+ return 0;
+}
+
+/*
+ * E_DTX_init
+ *
+ * Parameters:
+ * st I/O: state struct
+ *
+ * Function:
+ * Allocates state memory and initializes state memory
+ *
+ * Returns:
+ * non-zero with error, zero for ok
+ */
+Word32 E_DTX_init (E_DTX_State **st)
+{
+ E_DTX_State* s;
+
+ if (st == (E_DTX_State **) NULL)
+ {
+ return -1;
+ }
+
+ *st = NULL;
+
+ /* allocate memory */
+ if ((s= (E_DTX_State *) malloc(sizeof(E_DTX_State))) == NULL)
+ {
+ return -1;
+ }
+
+ E_DTX_reset(s);
+ *st = s;
+
+ return 0;
+}
+
+/*
+ * E_DTX_exit
+ *
+ * Parameters:
+ * state I/0: State struct
+ *
+ * Function:
+ * The memory used for state memory is freed
+ *
+ * Returns:
+ * void
+ */
+void E_DTX_exit (E_DTX_State **st)
+{
+ if (st == NULL || *st == NULL)
+ {
+ return;
+ }
+
+ /* deallocate memory */
+ free(*st);
+ *st = NULL;
+
+ return;
+}
+
+
+/*
+ * E_DTX_tx_handler
+ *
+ * Parameters:
+ * st I/O: State struct
+ * vad_flag I: vad decision
+ * usedMode I/O: mode changed or not
+ *
+ * Function:
+ * Adds extra speech hangover to analyze speech on the decoding side.
+ *
+ * Returns:
+ * void
+ */
+void E_DTX_tx_handler(E_DTX_State *st, Word32 vad_flag, Word16 *usedMode)
+{
+
+ /* this state machine is in synch with the GSMEFR txDtx machine */
+ st->mem_dec_ana_elapsed_count++;
+
+ if (vad_flag != 0)
+ {
+ st->mem_dtx_hangover_count = DTX_HANG_CONST;
+ }
+ else
+ { /* non-speech */
+ if (st->mem_dtx_hangover_count == 0)
+ { /* out of decoder analysis hangover */
+ st->mem_dec_ana_elapsed_count = 0;
+ *usedMode = MRDTX;
+ }
+ else
+ { /* in possible analysis hangover */
+ st->mem_dtx_hangover_count--;
+
+ /* decAnaElapsedCount + dtxHangoverCount < E_DTX_ELAPSED_FRAMES_THRESH */
+ if ((st->mem_dec_ana_elapsed_count + st->mem_dtx_hangover_count)
+ < DTX_ELAPSED_FRAMES_THRESH)
+ {
+ *usedMode = MRDTX;
+ /* if Word16 time since decoder update, do not add extra HO */
+ }
+ /*
+ else
+ override VAD and stay in
+ speech mode *usedMode
+ and add extra hangover
+ */
+ }
+ }
+
+ return;
+}
+
+/*
+ * E_DTX_filter5
+ *
+ * Parameters:
+ * in0 I/O: input values / output low-pass part
+ * in1 I/O: input values / output high-pass part
+ * data I/O: updated filter memory
+ *
+ * Function:
+ * Fifth-order half-band lowpass/highpass filter pair with decimation.
+ *
+ * Returns:
+ * void
+ */
+static void E_DTX_filter5(Float32 *in0, Float32 *in1, Float32 data[])
+{
+ Float32 temp0, temp1, temp2;
+
+ temp0 = *in0 - COEFF5_1 * data[0];
+ temp1 = data[0] + COEFF5_1 * temp0;
+ data[0] = ((temp0 > 1e-10) | (temp0 < -1e-10)) ? temp0 : 0;
+
+ temp0 = *in1 - COEFF5_2 * data[1];
+ temp2 = data[1] + COEFF5_2 * temp0;
+ data[1] = ((temp0 > 1e-10) | (temp0 < -1e-10)) ? temp0 : 0;
+
+ *in0 = (temp1 + temp2) * 0.5F;
+ *in1 = (temp1 - temp2) * 0.5F;
+}
+
+/*
+ * E_DTX_filter3
+ *
+ * Parameters:
+ * in0 I/O: input values / output low-pass part
+ * in1 I/O: input values / output high-pass part
+ * data I/O: updated filter memory
+ *
+ * Function:
+ * Third-order half-band lowpass/highpass filter pair with decimation.
+ *
+ * Returns:
+ * void
+ */
+static void E_DTX_filter3(Float32 *in0, Float32 *in1, Float32 *data)
+{
+ Float32 temp1, temp2;
+
+ temp1 = *in1 - COEFF3 * *data;
+ temp2 = *data + COEFF3 * temp1;
+ *data = ((temp1 > 1e-10) | (temp1 < -1e-10)) ? temp1 : 0;
+
+ *in1 = (*in0 - temp2) * 0.5F;
+ *in0 = (*in0 + temp2) * 0.5F;
+}
+
+/*
+ * E_DTX_level_calculation
+ *
+ * Parameters:
+ * data I: signal buffer
+ * sub_level I/0: level calculated at the end of the previous frame /
+ * level of signal calculated from the last
+ * (count2 - count1) samples
+ * count1 I: number of samples to be counted
+ * count2 I: number of samples to be counted
+ * ind_m I: step size for the index of the data buffer
+ * ind_a I: starting index of the data buffer
+ * scale I: scaling for the level calculation
+ *
+ * Function:
+ * Calculate signal level in a sub-band. Level is calculated
+ * by summing absolute values of the input data.
+ *
+ * Because speech coder has a lookahead, signal level calculated
+ * over the lookahead (data[count1 - count2]) is stored (*sub_level)
+ * and added to the level of the next frame. Additionally, group
+ * delay and decimation of the filter bank is taken into the count
+ * for the values of the counters (count1, count2).
+ *
+ * Returns:
+ * signal level
+ */
+static Float32 E_DTX_level_calculation(Float32 data[], Float32 *sub_level,
+ Word16 count1, Word16 count2,
+ Word16 ind_m, Word16 ind_a,
+ Float32 scale)
+{
+ Float64 l_temp1, l_temp2;
+ Float32 level;
+ Word32 i;
+
+ l_temp1 = 0.0;
+
+ for (i = count1; i < count2; i++)
+ {
+ l_temp1 += fabs(data[ind_m * i + ind_a]);
+ }
+
+ l_temp1 *= 2.0;
+ l_temp2 = l_temp1 + *sub_level / scale;
+ *sub_level = (Float32)(l_temp1 * scale);
+
+ for (i = 0; i < count1; i++)
+ {
+ l_temp2 += 2.0f * fabs(data[ind_m * i + ind_a]);
+ }
+
+ level = (Float32)(l_temp2 * scale);
+
+ return level;
+}
+
+/*
+ * E_DTX_filter_bank
+ *
+ * Parameters:
+ * st I/0: State struct
+ * in I: input frame
+ * level I: signal levels at each band
+ *
+ * Function:
+ * Divide input signal into bands and calculate level of
+ * the signal in each band
+ *
+ * Returns:
+ * void
+ */
+static void E_DTX_filter_bank(E_DTX_Vad_State *st, Float32 in[],
+ Float32 level[])
+{
+ Float32 tmp_buf[FRAME_LEN];
+ Word32 i, j;
+
+ /* shift input 1 bit down for safe scaling */
+ for (i = 0; i < FRAME_LEN; i++)
+ {
+ tmp_buf[i] = in[i] * 0.5F;
+ }
+
+ /* run the filter bank */
+ for (i = 0; i < (FRAME_LEN >> 1); i++)
+ {
+ j = i << 1;
+ E_DTX_filter5(&tmp_buf[j], &tmp_buf[j + 1], st->mem_a_data5[0]);
+ }
+ for (i = 0; i < (FRAME_LEN >> 2); i++)
+ {
+ j = i << 2;
+ E_DTX_filter5(&tmp_buf[j], &tmp_buf[j + 2], st->mem_a_data5[1]);
+ E_DTX_filter5(&tmp_buf[j + 1], &tmp_buf[j + 3], st->mem_a_data5[2]);
+ }
+ for (i = 0; i < (FRAME_LEN >> 3); i++)
+ {
+ j = i << 3;
+ E_DTX_filter5(&tmp_buf[j], &tmp_buf[j + 4], st->mem_a_data5[3]);
+ E_DTX_filter5(&tmp_buf[j + 2], &tmp_buf[j + 6], st->mem_a_data5[4]);
+ E_DTX_filter3(&tmp_buf[j + 3], &tmp_buf[j + 7], &st->mem_a_data3[0]);
+ }
+ for (i = 0; i < (FRAME_LEN >> 4); i++)
+ {
+ j = i << 4;
+ E_DTX_filter3(&tmp_buf[j], &tmp_buf[j + 8], &st->mem_a_data3[1]);
+ E_DTX_filter3(&tmp_buf[j + 4], &tmp_buf[j + 12], &st->mem_a_data3[2]);
+ E_DTX_filter3(&tmp_buf[j + 6], &tmp_buf[j + 14], &st->mem_a_data3[3]);
+ }
+
+ for (i = 0; i < (FRAME_LEN >> 5); i++)
+ {
+ j = i << 5;
+ E_DTX_filter3(&tmp_buf[j + 0], &tmp_buf[j + 16], &st->mem_a_data3[4]);
+ E_DTX_filter3(&tmp_buf[j + 8], &tmp_buf[j + 24], &st->mem_a_data3[5]);
+ }
+
+ /* calculate levels in each frequency band */
+
+ /* 4800 - 6400 Hz*/
+ level[11] = E_DTX_level_calculation(tmp_buf, &st->mem_sub_level[11],
+ (FRAME_LEN >> 2) - 48, FRAME_LEN >> 2, 4, 1, 0.25F);
+ /* 4000 - 4800 Hz*/
+ level[10] = E_DTX_level_calculation(tmp_buf, &st->mem_sub_level[10],
+ (FRAME_LEN >> 3) - 24, FRAME_LEN >> 3, 8, 7, 0.5F);
+ /* 3200 - 4000 Hz*/
+ level[9] = E_DTX_level_calculation(tmp_buf, &st->mem_sub_level[9],
+ (FRAME_LEN >> 3) - 24, FRAME_LEN >> 3, 8, 3, 0.5F);
+ /* 2400 - 3200 Hz*/
+ level[8] = E_DTX_level_calculation(tmp_buf, &st->mem_sub_level[8],
+ (FRAME_LEN >> 3) - 24, FRAME_LEN >> 3, 8, 2, 0.5F);
+ /* 2000 - 2400 Hz*/
+ level[7] = E_DTX_level_calculation(tmp_buf, &st->mem_sub_level[7],
+ (FRAME_LEN >> 4) - 12, FRAME_LEN >> 4, 16, 14, 1.0F);
+ /* 1600 - 2000 Hz*/
+ level[6] = E_DTX_level_calculation(tmp_buf, &st->mem_sub_level[6],
+ (FRAME_LEN >> 4) - 12, FRAME_LEN >> 4, 16, 6, 1.0F);
+ /* 1200 - 1600 Hz*/
+ level[5] = E_DTX_level_calculation(tmp_buf, &st->mem_sub_level[5],
+ (FRAME_LEN >> 4) - 12, FRAME_LEN >> 4, 16, 4, 1.0F);
+ /* 800 - 1200 Hz*/
+ level[4] = E_DTX_level_calculation(tmp_buf, &st->mem_sub_level[4],
+ (FRAME_LEN >> 4) - 12, FRAME_LEN >> 4, 16, 12, 1.0F);
+ /* 600 - 800 Hz*/
+ level[3] = E_DTX_level_calculation(tmp_buf, &st->mem_sub_level[3],
+ (FRAME_LEN >> 5) - 6, FRAME_LEN >> 5, 32, 8, 2.0F);
+ /* 400 - 600 Hz*/
+ level[2] = E_DTX_level_calculation(tmp_buf, &st->mem_sub_level[2],
+ (FRAME_LEN >> 5) - 6, FRAME_LEN >> 5, 32, 24, 2.0F);
+ /* 200 - 400 Hz*/
+ level[1] = E_DTX_level_calculation(tmp_buf, &st->mem_sub_level[1],
+ (FRAME_LEN >> 5) - 6, FRAME_LEN >> 5, 32, 16, 2.0F);
+ /* 0 - 200 Hz*/
+ level[0] = E_DTX_level_calculation(tmp_buf, &st->mem_sub_level[0],
+ (FRAME_LEN >> 5) - 6, FRAME_LEN >> 5, 32, 0, 2.0F);
+}
+
+/*
+ * E_DTX_update_cntrl
+ *
+ * Parameters:
+ * st I/0: State struct
+ * level I: sub-band levels of the input frame
+ *
+ * Function:
+ * Control update of the background noise estimate.
+ *
+ * Returns:
+ * void
+ */
+static void E_DTX_update_cntrl(E_DTX_Vad_State *st, Float32 level[])
+{
+
+ Float32 stat_rat;
+ Float32 num, denom;
+ Float32 alpha;
+ Word32 i;
+
+ /* if fullband pitch or tone have been detected for a while, initialize stat_count */
+
+ if ((st->mem_pitch_tone & 0x7c00) == 0x7c00)
+ {
+ st->mem_stat_count = STAT_COUNT;
+
+ }
+ else
+ {
+ /* if 8 last vad-decisions have been "0", reinitialize stat_count */
+
+ if ((st->mem_vadreg & 0x7f80) == 0)
+ {
+ st->mem_stat_count = STAT_COUNT;
+ }
+ else
+ {
+ stat_rat = 0;
+ for (i = 0; i < COMPLEN; i++)
+ {
+
+ if (level[i] > st->mem_ave_level[i])
+ {
+ num = level[i];
+ denom = st->mem_ave_level[i];
+ }
+ else
+ {
+ num = st->mem_ave_level[i];
+ denom = level[i];
+ }
+ /* Limit nimimum value of num and denom to STAT_THR_LEVEL */
+
+ if (num < STAT_THR_LEVEL)
+ {
+ num = STAT_THR_LEVEL;
+ }
+
+ if (denom < STAT_THR_LEVEL)
+ {
+ denom = STAT_THR_LEVEL;
+ }
+
+ stat_rat += num/denom * 64;
+
+ }
+
+ /* compare stat_rat with a threshold and update stat_count */
+
+ if (stat_rat > STAT_THR)
+ {
+ st->mem_stat_count = STAT_COUNT;
+ }
+ else
+ {
+
+ if ((st->mem_vadreg & 0x4000) != 0)
+ {
+
+ if (st->mem_stat_count != 0)
+ {
+ st->mem_stat_count--;
+ }
+ }
+ }
+ }
+ }
+
+ /* Update average amplitude estimate for stationarity estimation */
+ alpha = ALPHA4;
+
+ if (st->mem_stat_count == STAT_COUNT)
+ {
+ alpha = 1.0;
+ }
+ else if ((st->mem_vadreg & 0x4000) == 0)
+ {
+
+ alpha = ALPHA5;
+ }
+
+ for (i = 0; i < COMPLEN; i++)
+ {
+ st->mem_ave_level[i] += alpha * (level[i] - st->mem_ave_level[i]);
+ }
+
+}
+
+/*
+ * E_DTX_hangover_addition
+ *
+ * Parameters:
+ * st I/0: State struct
+ * low_power I: flag power of the input frame
+ * hang_len I: hangover length
+ * burst_len I: minimum burst length for hangover addition
+ *
+ * Function:
+ * Add hangover after speech bursts.
+ *
+ * Returns:
+ * VAD_flag indicating final VAD decision
+ */
+static Word16 E_DTX_hangover_addition(E_DTX_Vad_State *st, Word16 low_power,
+ Word16 hang_len, Word16 burst_len)
+{
+ /*
+ * if the input power (pow_sum) is lower than a threshold, clear
+ * counters and set VAD_flag to "0" "fast exit"
+ */
+
+ if (low_power != 0)
+ {
+ st->mem_burst_count = 0;
+ st->mem_hang_count = 0;
+ return 0;
+ }
+
+ /* update the counters (hang_count, burst_count) */
+
+ if ((st->mem_vadreg & 0x4000) != 0)
+ {
+ st->mem_burst_count++;
+
+ if (st->mem_burst_count >= burst_len)
+ {
+ st->mem_hang_count = hang_len;
+ }
+ return 1;
+ }
+ else
+ {
+ st->mem_burst_count = 0;
+
+ if (st->mem_hang_count > 0)
+ {
+ st->mem_hang_count--;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+/*
+ * E_DTX_noise_estimate_update
+ *
+ * Parameters:
+ * st I/0: State struct
+ * level I: sub-band levels of the input frame
+ *
+ * Function:
+ * Update of background noise estimate
+ *
+ * Returns:
+ * void
+ */
+static void E_DTX_noise_estimate_update(E_DTX_Vad_State *st, Float32 level[])
+{
+
+ Float32 alpha_up, alpha_down, bckr_add, temp;
+ Word32 i;
+
+ /* Control update of bckr_est[] */
+ E_DTX_update_cntrl(st, level);
+
+ /* Choose update speed */
+ bckr_add = 2.0;
+
+
+ if ((0x7800 & st->mem_vadreg) == 0)
+ {
+ alpha_up = ALPHA_UP1;
+ alpha_down = ALPHA_DOWN1;
+ }
+ else
+ {
+
+ if (st->mem_stat_count == 0)
+ {
+ alpha_up = ALPHA_UP2;
+ alpha_down = ALPHA_DOWN2;
+ }
+ else
+ {
+ alpha_up = 0.0;
+ alpha_down = ALPHA3;
+ bckr_add = 0.0;
+ }
+ }
+
+ /* Update noise estimate (bckr_est) */
+ for (i = 0; i < COMPLEN; i++)
+ {
+ temp = st->mem_level[i] - st->mem_bckr_est[i];
+
+ if (temp < 0.0)
+ { /* update downwards*/
+ st->mem_bckr_est[i] += -2 + (alpha_down * temp);
+
+ /* limit minimum value of the noise estimate to NOISE_MIN */
+
+ if (st->mem_bckr_est[i] < NOISE_MIN)
+ {
+ st->mem_bckr_est[i] = NOISE_MIN;
+ }
+ }
+ else
+ { /* update upwards */
+ st->mem_bckr_est[i] += bckr_add + (alpha_up * temp);
+
+ /* limit maximum value of the noise estimate to NOISE_MAX */
+
+ if (st->mem_bckr_est[i] > NOISE_MAX)
+ {
+ st->mem_bckr_est[i] = NOISE_MAX;
+ }
+ }
+ }
+
+ /* Update signal levels of the previous frame (old_level) */
+ memcpy(st->mem_level, level, COMPLEN * sizeof(Float32));
+}
+
+/*
+ * E_DTX_decision
+ *
+ * Parameters:
+ * st I/0: State struct
+ * level I: sub-band levels of the input frame
+ * pow_sum I: power of the input frame
+ *
+ * Function:
+ * Calculates VAD_flag
+ *
+ * Returns:
+ * VAD_flag
+ */
+static Word16 E_DTX_decision(E_DTX_Vad_State *st, Float32 level[COMPLEN], Float64 pow_sum)
+{
+ Float64 snr_sum;
+ Float32 vad_thr, temp, noise_level;
+ Float32 ilog2_speech_level, ilog2_noise_level;
+ Float32 temp2;
+ Word32 i;
+ Word16 low_power_flag;
+ Word16 hang_len,burst_len;
+
+ /*
+ * Calculate squared sum of the input levels (level)
+ * divided by the background noise components (bckr_est).
+ */
+ snr_sum = 0.0;
+
+ for (i = 0; i < COMPLEN; i++)
+ {
+ temp = level[i] / st->mem_bckr_est[i];
+ snr_sum += temp * temp;
+ }
+
+ /* Calculate average level of estimated background noise */
+ temp = 0.0;
+
+ for (i = 1; i < COMPLEN; i++) /* ignore lowest band */
+ {
+ temp += st->mem_bckr_est[i];
+ }
+
+ noise_level = (Float32)(temp * 0.0625);
+ /*
+ * if SNR is lower than a threshold (MIN_SPEECH_SNR),
+ * and increase speech_level
+ */
+ temp = noise_level * MIN_SPEECH_SNR * 8;
+
+ if (st->mem_speech_level <= temp)
+ {
+ st->mem_speech_level = temp;
+
+ /* avoid log10 error */
+ temp -= 1E-8F;
+ }
+
+ ilog2_noise_level = (Float32)(-1024.0F * log10(noise_level / 2147483648.0F) / log10(2.0F));
+
+ /*
+ * If SNR is very poor, speech_level is probably corrupted by noise level. This
+ * is correctred by subtracting -MIN_SPEECH_SNR*noise_level from speech level
+ */
+ ilog2_speech_level = (Float32)(-1024.0F * log10((st->mem_speech_level - temp) / 2147483648.0F) / log10(2.0F));
+
+ temp = NO_SLOPE * (ilog2_noise_level- NO_P1) + THR_HIGH;
+
+ temp2 = SP_CH_MIN + SP_SLOPE * (ilog2_speech_level - SP_P1);
+
+ if (temp2 < SP_CH_MIN)
+ {
+ temp2 = SP_CH_MIN;
+ }
+
+ if (temp2 > SP_CH_MAX)
+ {
+ temp2 = SP_CH_MAX;
+ }
+
+ vad_thr = temp + temp2;
+
+ if (vad_thr < THR_MIN)
+ {
+ vad_thr = THR_MIN;
+ }
+
+ /* Shift VAD decision register */
+ st->mem_vadreg = (Word16)(st->mem_vadreg >> 1);
+
+ /* Make intermediate VAD decision */
+
+ if (snr_sum > (vad_thr * (Float32)COMPLEN / 128.0F))
+ {
+ st->mem_vadreg = (Word16)(st->mem_vadreg | 0x4000);
+ }
+ /* primary vad decision made */
+
+ /* check if the input power (pow_sum) is lower than a threshold" */
+
+ if (pow_sum < VAD_POW_LOW)
+ {
+ low_power_flag = 1;
+ }
+ else
+ {
+ low_power_flag = 0;
+ }
+
+ /* Update speech subband background noise estimates */
+ E_DTX_noise_estimate_update(st, level);
+
+ hang_len = (Word16)((HANG_SLOPE * (vad_thr - HANG_P1) - 0.5) + HANG_HIGH);
+
+ if (hang_len < HANG_LOW)
+ {
+ hang_len = HANG_LOW;
+ }
+
+ burst_len = (Word16)((BURST_SLOPE * (vad_thr - BURST_P1) - 0.5) + BURST_HIGH);
+
+ return(E_DTX_hangover_addition(st, low_power_flag, hang_len,burst_len));
+}
+
+/*
+ * E_DTX_dpeech_estimate
+ *
+ * Parameters:
+ * st I/0: State struct
+ * in_level I: level of the input frame
+ *
+ * Function:
+ * Estimate speech level
+ *
+ * Maximum signal level is searched and stored to the variable sp_max.
+ * The speech frames must locate within SP_EST_COUNT number of frames to be counted.
+ * Thus, noisy frames having occasional VAD = "1" decisions will not
+ * affect to the estimated speech_level.
+ *
+ * Returns:
+ * void
+ */
+static void E_DTX_speech_estimate(E_DTX_Vad_State *st, Float32 in_level)
+{
+ Float32 alpha, tmp;
+
+ /* if the required activity count cannot be achieved, reset counters */
+ if (SP_ACTIVITY_COUNT > (SP_EST_COUNT - st->mem_sp_est_cnt + st->mem_sp_max_cnt))
+ {
+ st->mem_sp_est_cnt = 0;
+ st->mem_sp_max = 0.0;
+ st->mem_sp_max_cnt = 0;
+ }
+
+ st->mem_sp_est_cnt++;
+
+ if (((st->mem_vadreg & 0x4000) || (in_level > st->mem_speech_level))
+ && (in_level > MIN_SPEECH_LEVEL1))
+ {
+ if (in_level > st->mem_sp_max)
+ {
+ st->mem_sp_max = in_level;
+ }
+
+ st->mem_sp_max_cnt++;
+
+ if (st->mem_sp_max_cnt >= SP_ACTIVITY_COUNT)
+ {
+
+ tmp = st->mem_sp_max / 2.0F; /* scale to get "average" speech level*/
+
+ if (tmp > st->mem_speech_level)
+ {
+ alpha = ALPHA_SP_UP;
+ }
+ else
+ {
+ alpha = ALPHA_SP_DOWN;
+ }
+
+ if (tmp > MIN_SPEECH_LEVEL2)
+ {
+ st->mem_speech_level += alpha * (tmp - st->mem_speech_level);
+ }
+
+ st->mem_sp_max = 0.0;
+ st->mem_sp_max_cnt = 0;
+ st->mem_sp_est_cnt = 0;
+ }
+ }
+}
+
+/*
+ * E_DTX_vad_reset
+ *
+ * Parameters:
+ * state I/0: State struct
+ *
+ * Function:
+ * Initialises state memory
+ *
+ * Returns:
+ * non-zero with error, zero for ok
+ */
+Word32 E_DTX_vad_reset (E_DTX_Vad_State *state)
+{
+ Word32 i;
+
+ if (state == (E_DTX_Vad_State *) NULL)
+ {
+ return -1;
+ }
+
+ /* Initialize pitch detection variables */
+ state->mem_pitch_tone = 0;
+ state->mem_vadreg = 0;
+ state->mem_hang_count = 0;
+ state->mem_burst_count = 0;
+ state->mem_hang_count = 0;
+
+ /* initialize memory used by the filter bank */
+ memset(state->mem_a_data5, 0, F_5TH_CNT * 2 * sizeof(Float32));
+ memset(state->mem_a_data3, 0, F_3TH_CNT * sizeof(Float32));
+
+ /* initialize the rest of the memory */
+ for (i = 0; i < COMPLEN; i++)
+ {
+ state->mem_bckr_est[i] = NOISE_INIT;
+ state->mem_level[i] = NOISE_INIT;
+ state->mem_ave_level[i] = NOISE_INIT;
+ state->mem_sub_level[i] = 0;
+ }
+
+ state->mem_sp_est_cnt = 0;
+ state->mem_sp_max = 0;
+ state->mem_sp_max_cnt = 0;
+ state->mem_speech_level = SPEECH_LEVEL_INIT;
+ state->mem_pow_sum = 0;
+ state->mem_stat_count = 0;
+
+ return 0;
+}
+
+/*
+ * E_DTX_vad_init
+ *
+ * Parameters:
+ * state I/0: State struct
+ *
+ * Function:
+ * Allocates state memory and initializes state memory
+ *
+ * Returns:
+ * non-zero with error, zero for ok
+ */
+Word32 E_DTX_vad_init (E_DTX_Vad_State **state)
+{
+ E_DTX_Vad_State* s;
+
+ if (state == (E_DTX_Vad_State **) NULL)
+ {
+ return -1;
+ }
+ *state = NULL;
+
+ /* allocate memory */
+ if ((s = (E_DTX_Vad_State *) malloc(sizeof(E_DTX_Vad_State))) == NULL)
+ {
+ return -1;
+ }
+
+ E_DTX_vad_reset(s);
+
+ *state = s;
+
+ return 0;
+}
+
+/*
+ * E_DTX_vad_exit
+ *
+ * Parameters:
+ * state I/0: State struct
+ *
+ * Function:
+ * The memory used for state memory is freed
+ *
+ * Returns:
+ * void
+ */
+void E_DTX_vad_exit (E_DTX_Vad_State **state)
+{
+ if (state == NULL || *state == NULL)
+ {
+ return;
+ }
+
+ /* deallocate memory */
+ free(*state);
+ *state = NULL;
+
+ return;
+}
+
+/*
+ * E_DTX_pitch_tone_detection
+ *
+ * Parameters:
+ * state I/0: State struct
+ * p_gain I: pitch gain
+ *
+ * Function:
+ * Set tone flag if pitch gain is high. This is used to detect
+ * signaling tones and other signals with high pitch gain.
+ *
+ * Returns:
+ * void
+ */
+void E_DTX_pitch_tone_detection (E_DTX_Vad_State *st, Float32 p_gain)
+{
+ /* update tone flag and pitch flag */
+ st->mem_pitch_tone = (Word16)(st->mem_pitch_tone >> 1);
+
+ /* if (pitch_gain > TONE_THR) set tone flag */
+ if (p_gain > TONE_THR)
+ {
+ st->mem_pitch_tone = (Word16)(st->mem_pitch_tone | 0x4000);
+ }
+}
+
+/*
+ * E_DTX_vad
+ *
+ * Parameters:
+ * st I/0: State struct
+ * in_buf I: samples of the input frame
+ *
+ * Function:
+ * Main program for Voice Activity Detection (VAD)
+ *
+ * Returns:
+ * VAD Decision, 1 = speech, 0 = noise
+ */
+Word16 E_DTX_vad(E_DTX_Vad_State *st, Float32 in_buf[])
+{
+ Float64 L_temp, pow_sum;
+ Float32 level[COMPLEN];
+ Float32 temp;
+ Word32 i;
+ Word16 VAD_flag;
+
+ /* Calculate power of the input frame. */
+ L_temp = 0.0;
+
+ for (i = 0; i < FRAME_LEN; i++)
+ {
+ L_temp += in_buf[i] * in_buf[i];
+ }
+
+ L_temp *= 2.0;
+
+ /* pow_sum = power of current frame and previous frame */
+ pow_sum = L_temp + st->mem_pow_sum;
+
+ /* save power of current frame for next call */
+ st->mem_pow_sum = L_temp;
+
+ /* If input power is very low, clear tone flag */
+ if (pow_sum < POW_PITCH_TONE_THR)
+ {
+ st->mem_pitch_tone = (Word16)(st->mem_pitch_tone & 0x1fff);
+ }
+
+ /* Run the filter bank and calculate signal levels at each band */
+ E_DTX_filter_bank(st, in_buf, level);
+
+ /* compute VAD decision */
+ VAD_flag = E_DTX_decision(st, level, pow_sum);
+
+ /* Calculate input level */
+ L_temp = 0.0;
+ for (i = 1; i < COMPLEN; i++) /* ignore lowest band */
+ {
+ L_temp += level[i];
+ }
+
+ temp = (Float32)(L_temp / 16.0F);
+
+ E_DTX_speech_estimate(st, temp); /* Estimate speech level */
+
+ return(VAD_flag);
+}
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_dtx.h b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_dtx.h
new file mode 100644
index 000000000..5b182321f
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_dtx.h
@@ -0,0 +1,72 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef ENC_F_DTX_H
+#define ENC_F_DTX_H
+
+#include "typedef.h"
+
+#define M 16 /* Order of LP filter */
+#define DTX_HIST_SIZE 8 /* 8 frames */
+#define COMPLEN 12 /* Number of sub-bands used by VAD */
+#define F_5TH_CNT 5 /* Number of 5th order filters in VAD */
+#define F_3TH_CNT 6 /* Number of 3th order filters in VAD */
+
+typedef struct {
+ Float32 mem_isf[M * DTX_HIST_SIZE]; /* LSP history */
+ Float32 mem_distance[28]; /* ISF history distance matrix */
+ Float32 mem_distance_sum[DTX_HIST_SIZE];/* Sum of ISF history distances */
+ Float32 mem_log_en[DTX_HIST_SIZE]; /* logarithmic frame energy history */
+
+ Word16 mem_hist_ptr; /* pointer to the cyclic history vectors */
+ Word16 mem_log_en_index; /* Index for logarithmic energy */
+ Word16 mem_cng_seed; /* Comfort noise excitation seed */
+ Word16 mem_dtx_hangover_count; /* DTX hangover period */
+ Word16 mem_dec_ana_elapsed_count;/* counter for elapsed speech frames */
+ /* in DTX */
+} E_DTX_State;
+
+
+typedef struct {
+
+ Float64 mem_pow_sum; /* power of previous frame */
+
+ Float32 mem_bckr_est[COMPLEN]; /* background noise estimate */
+ Float32 mem_ave_level[COMPLEN]; /* averaged input components */
+ /* for stationary estimation */
+ Float32 mem_level[COMPLEN]; /* input levels of the previous frame */
+ Float32 mem_sub_level[COMPLEN]; /* input levels calculated at the end of */
+ /* a frame (lookahead) */
+ Float32 mem_a_data5[F_5TH_CNT][2];/* memory for the filter bank */
+ Float32 mem_a_data3[F_3TH_CNT]; /* memory for the filter bank */
+
+ Float32 mem_sp_max; /* maximum level */
+ Float32 mem_speech_level; /* estimated speech level */
+
+ Word16 mem_burst_count; /* counts length of a speech burst */
+ Word16 mem_hang_count; /* hangover counter */
+ Word16 mem_stat_count; /* stationary counter */
+ Word16 mem_vadreg; /* flags for intermediate VAD decisions */
+ Word16 mem_pitch_tone; /* flags for pitch and tone detection */
+ Word16 mem_sp_est_cnt; /* counter for speech level estimation */
+ Word16 mem_sp_max_cnt; /* counts frames that contains speech */
+
+} E_DTX_Vad_State;
+
+Word32 E_DTX_init(E_DTX_State **st);
+Word32 E_DTX_reset(E_DTX_State *st);
+void E_DTX_exit(E_DTX_State **st);
+void E_DTX_tx_handler(E_DTX_State *st, Word32 vad_flag, Word16 *usedMode);
+void E_DTX_buffer(E_DTX_State *st, Float32 isf_new[], Float32 enr,
+ Word16 codec_mode);
+void E_DTX_exe(E_DTX_State *st, Float32 *exc2, Word16 **pt_prms);
+Word32 E_DTX_vad_init(E_DTX_Vad_State **st);
+Word32 E_DTX_vad_reset(E_DTX_Vad_State *st);
+void E_DTX_vad_exit(E_DTX_Vad_State **st);
+void E_DTX_pitch_tone_detection(E_DTX_Vad_State *st, Float32 p_gain);
+Word16 E_DTX_vad(E_DTX_Vad_State *st, Float32 in_buf[]);
+
+#endif
+
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_gain.c b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_gain.c
new file mode 100644
index 000000000..64548e18b
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_gain.c
@@ -0,0 +1,781 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#include <math.h>
+#include <memory.h>
+#include "typedef.h"
+#include "enc_util.h"
+
+#define L_FRAME 256 /* Frame size */
+#define L_SUBFR 64 /* Subframe size */
+#define HP_ORDER 3
+#define L_INTERPOL1 4
+#define L_INTERPOL2 16
+#define PIT_SHARP 27853 /* pitch sharpening factor = 0.85 Q15 */
+#define F_PIT_SHARP 0.85F /* pitch sharpening factor */
+#define PIT_MIN 34 /* Minimum pitch lag with resolution 1/4 */
+#define UP_SAMP 4
+#define DIST_ISF_MAX 120
+#define DIST_ISF_THRES 60
+#define GAIN_PIT_THRES 0.9F
+#define GAIN_PIT_MIN 0.6F
+
+extern const Float32 E_ROM_corrweight[];
+extern const Float32 E_ROM_inter4_1[];
+extern const Word16 E_ROM_inter4_2[];
+
+/*
+ * E_GAIN_clip_init
+ *
+ * Parameters:
+ * mem O: memory of gain of pitch clipping algorithm
+ *
+ * Function:
+ * Initialises state memory
+ *
+ * Returns:
+ * void
+ */
+void E_GAIN_clip_init(Float32 mem[])
+{
+ mem[0] = DIST_ISF_MAX;
+ mem[1] = GAIN_PIT_MIN;
+}
+
+/*
+ * E_GAIN_clip_test
+ *
+ * Parameters:
+ * mem I: memory of gain of pitch clipping algorithm
+ *
+ * Function:
+ * Gain clipping test to avoid unstable synthesis on frame erasure
+ *
+ * Returns:
+ * Test result
+ */
+Word32 E_GAIN_clip_test(Float32 mem[])
+{
+ Word32 clip;
+
+ clip = 0;
+ if ((mem[0] < DIST_ISF_THRES) && (mem[1] > GAIN_PIT_THRES))
+ {
+ clip = 1;
+ }
+
+ return (clip);
+}
+
+/*
+ * E_GAIN_clip_isf_test
+ *
+ * Parameters:
+ * isf I: isf values (in frequency domain)
+ * mem I/O: memory of gain of pitch clipping algorithm
+ *
+ * Function:
+ * Check resonance for pitch clipping algorithm
+ *
+ * Returns:
+ * void
+ */
+void E_GAIN_clip_isf_test(Float32 isf[], Float32 mem[])
+{
+ Word32 i;
+ Float32 dist, dist_min;
+
+ dist_min = isf[1] - isf[0];
+
+ for (i = 2; i < M - 1; i++)
+ {
+ dist = isf[i] - isf[i-1];
+
+ if (dist < dist_min)
+ {
+ dist_min = dist;
+ }
+ }
+
+ dist = 0.8F * mem[0] + 0.2F * dist_min;
+
+ if (dist > DIST_ISF_MAX)
+ {
+ dist = DIST_ISF_MAX;
+ }
+
+ mem[0] = dist;
+
+ return;
+}
+
+/*
+ * E_GAIN_clip_pit_test
+ *
+ * Parameters:
+ * gain_pit I: gain of quantized pitch
+ * mem I/O: memory of gain of pitch clipping algorithm
+ *
+ * Function:
+ * Test quantised gain of pitch for pitch clipping algorithm
+ *
+ * Returns:
+ * void
+ */
+void E_GAIN_clip_pit_test(Float32 gain_pit, Float32 mem[])
+{
+ Float32 gain;
+
+ gain = 0.9F * mem[1] + 0.1F * gain_pit;
+
+ if (gain < GAIN_PIT_MIN)
+ {
+ gain = GAIN_PIT_MIN;
+ }
+
+ mem[1] = gain;
+
+ return;
+}
+
+/*
+ * E_GAIN_lp_decim2
+ *
+ * Parameters:
+ * x I/O: signal to process
+ * l I: size of filtering
+ * mem I/O: memory (size = 3)
+ *
+ * Function:
+ * Decimate a vector by 2 with 2nd order fir filter.
+ *
+ * Returns:
+ * void
+ */
+void E_GAIN_lp_decim2(Float32 x[], Word32 l, Float32 *mem)
+{
+ Float32 x_buf[L_FRAME + 3];
+ Float32 temp;
+ Word32 i, j;
+
+ /* copy initial filter states into buffer */
+
+ memcpy(x_buf, mem, 3 * sizeof(Float32));
+ memcpy(&x_buf[3], x, l * sizeof(Float32));
+
+ for (i = 0; i < 3; i++)
+ {
+ mem[i] =
+ ((x[l - 3 + i] > 1e-10) | (x[l - 3 + i] < -1e-10)) ? x[l - 3 + i] : 0;
+ }
+
+ for (i = 0, j = 0; i < l; i += 2, j++)
+ {
+ temp = x_buf[i] * 0.13F;
+ temp += x_buf[i + 1] * 0.23F;
+ temp += x_buf[i + 2] * 0.28F;
+ temp += x_buf[i + 3] * 0.23F;
+ temp += x_buf[i + 4] * 0.13F;
+ x[j] = temp;
+ }
+
+ return;
+}
+
+/*
+ * E_GAIN_open_loop_search
+ *
+ * Parameters:
+ * wsp I: signal (end pntr) used to compute the open loop pitch
+ * L_min I: minimum pitch lag
+ * L_max I: maximum pitch lag
+ * nFrame I: length of frame to compute pitch
+ * L_0 I: old open-loop lag
+ * gain O: open-loop pitch-gain
+ * hp_wsp_mem I/O: memory of the highpass filter for hp_wsp[] (lg = 9)
+ * hp_old_wsp O: highpass wsp[]
+ * weight_flg I: is weighting function used
+ *
+ * Function:
+ * Find open loop pitch lag
+ *
+ * Returns:
+ * open loop pitch lag
+ */
+Word32 E_GAIN_open_loop_search(Float32 *wsp, Word32 L_min, Word32 L_max,
+ Word32 nFrame, Word32 L_0, Float32 *gain,
+ Float32 *hp_wsp_mem, Float32 hp_old_wsp[],
+ UWord8 weight_flg)
+{
+ Word32 i, j, k, L = 0;
+ Float32 o, R0, R1, R2, R0_max = -1.0e23f;
+ const Float32 *ww, *we;
+ Float32 *data_a, *data_b, *hp_wsp, *p, *p1;
+
+ ww = &E_ROM_corrweight[198];
+ we = &E_ROM_corrweight[98 + L_max - L_0];
+
+ for (i = L_max; i > L_min; i--)
+ {
+ p = &wsp[0];
+ p1 = &wsp[-i];
+
+ /* Compute the correlation R0 and the energy R1. */
+ R0 = 0.0;
+
+ for (j = 0; j < nFrame; j += 2)
+ {
+ R0 += p[j] * p1[j];
+ R0 += p[j + 1] * p1[j + 1];
+ }
+
+ /* Weighting of the correlation function. */
+
+ R0 *= *ww--;
+
+ /* Weight the neighborhood of the old lag. */
+ if ((L_0 > 0) & (weight_flg == 1))
+ {
+ R0 *= *we--;
+ }
+
+ /* Store the values if a currest maximum has been found. */
+
+ if (R0 >= R0_max)
+ {
+ R0_max = R0;
+ L = i;
+ }
+ }
+
+ data_a = hp_wsp_mem;
+ data_b = hp_wsp_mem + HP_ORDER;
+ hp_wsp = hp_old_wsp + L_max;
+
+ for (k = 0; k < nFrame; k++)
+ {
+
+ data_b[0] = data_b[1];
+ data_b[1] = data_b[2];
+ data_b[2] = data_b[3];
+
+ data_b[HP_ORDER] = wsp[k];
+
+ o = data_b[0] * 0.83787057505665F;
+ o += data_b[1] * -2.50975570071058F;
+ o += data_b[2] * 2.50975570071058F;
+ o += data_b[3] * -0.83787057505665F;
+
+ o -= data_a[0] * -2.64436711600664F;
+ o -= data_a[1] * 2.35087386625360F;
+ o -= data_a[2] * -0.70001156927424F;
+
+ data_a[2] = data_a[1];
+ data_a[1] = data_a[0];
+
+ data_a[0] = o;
+ hp_wsp[k] = o;
+ }
+
+ p = &hp_wsp[0];
+ p1 = &hp_wsp[-L];
+
+ R0 = 0.0F;
+ R1 = 0.0F;
+ R2 = 0.0F;
+
+ for (j = 0; j < nFrame; j++)
+ {
+ R1 += p1[j] * p1[j];
+ R2 += p[j] * p[j];
+ R0 += p[j] * p1[j];
+ }
+
+ *gain = (Float32)(R0 / (sqrt(R1 * R2) + 1e-5));
+
+ memcpy(hp_old_wsp, &hp_old_wsp[nFrame], L_max * sizeof(Float32));
+
+ return(L);
+}
+
+/*
+ * E_GAIN_sort
+ *
+ * Parameters:
+ * n I: number of lags
+ * ra I/O: lags / sorted lags
+ *
+ * Function:
+ * Sort open-loop lags
+ *
+ * Returns:
+ * void
+ */
+static void E_GAIN_sort(Word32 n, Word32 *ra)
+{
+ Word32 l, j, ir, i, rra;
+
+ l = (n >> 1) + 1;
+ ir = n;
+ for (;;)
+ {
+ if (l > 1)
+ {
+ rra = ra[--l];
+ }
+ else
+ {
+ rra = ra[ir];
+ ra[ir] = ra[1];
+
+ if (--ir == 1)
+ {
+ ra[1] = rra;
+ return;
+ }
+ }
+
+ i = l;
+ j = l << 1;
+ while (j <= ir)
+ {
+ if (j < ir && ra[j] < ra[j + 1])
+ {
+ ++j;
+ }
+
+ if (rra < ra[j])
+ {
+ ra[i] = ra[j];
+ j += (i = j);
+ }
+ else
+ {
+ j = ir + 1;
+ }
+ }
+
+ ra[i] = rra;
+ }
+}
+
+/*
+ * E_GAIN_olag_median
+ *
+ * Parameters:
+ * prev_ol_lag I: previous open-loop lag
+ * old_ol_lag I: old open-loop lags
+ *
+ * Function:
+ * Median of 5 previous open-loop lags
+ *
+ * Returns:
+ * median of 5 previous open-loop lags
+ */
+Word32 E_GAIN_olag_median(Word32 prev_ol_lag, Word32 old_ol_lag[5])
+{
+ Word32 tmp[6] = {0};
+ Word32 i;
+
+ /* Use median of 5 previous open-loop lags as old lag */
+
+ for (i = 4; i > 0; i--)
+ {
+ old_ol_lag[i] = old_ol_lag[i-1];
+ }
+
+ old_ol_lag[0] = prev_ol_lag;
+
+ for (i = 0; i < 5; i++)
+ {
+ tmp[i+1] = old_ol_lag[i];
+ }
+
+ E_GAIN_sort(5, tmp);
+
+ return tmp[3];
+
+}
+
+/*
+ * E_GAIN_norm_corr
+ *
+ * Parameters:
+ * exc I: excitation buffer
+ * xn I: target signal
+ * h I: weighted synthesis filter impulse response (Q15)
+ * t0_min I: minimum value in the searched range
+ * t0_max I: maximum value in the searched range
+ * corr_norm O: normalized correlation (Q15)
+ *
+ * Function:
+ * Find the normalized correlation between the target vector and the
+ * filtered past excitation (correlation between target and filtered
+ * excitation divided by the square root of energy of filtered excitation)
+ * Size of subframe = L_SUBFR.
+ *
+ * Returns:
+ * void
+ */
+static void E_GAIN_norm_corr(Float32 exc[], Float32 xn[], Float32 h[],
+ Word32 t_min, Word32 t_max, Float32 corr_norm[])
+{
+ Float32 excf[L_SUBFR]; /* filtered past excitation */
+ Float32 alp, ps, norm;
+ Word32 t, j, k;
+
+
+ k = - t_min;
+
+ /* compute the filtered excitation for the first delay t_min */
+
+ E_UTIL_f_convolve(&exc[k], h, excf);
+
+ /* loop for every possible period */
+
+ for (t = t_min; t <= t_max; t++)
+ {
+ /* Compute correlation between xn[] and excf[] */
+
+ ps = 0.0F;
+ alp = 0.01F;
+
+ for (j = 0; j < L_SUBFR; j++)
+ {
+ ps += xn[j] * excf[j];
+ alp += excf[j] * excf[j];
+ }
+
+ /* Compute 1/sqrt(energie of excf[]) */
+
+ norm = (Float32)(1.0F / sqrt(alp));
+
+ /* Normalize correlation = correlation * (1/sqrt(energy)) */
+
+ corr_norm[t] = ps * norm;
+
+ /* update the filtered excitation excf[] for the next iteration */
+
+ if (t != t_max)
+ {
+ k--;
+
+ for (j = L_SUBFR - 1; j > 0; j--)
+ {
+ excf[j] = excf[j - 1] + exc[k] * h[j];
+ }
+
+ excf[0] = exc[k];
+ }
+ }
+
+ return;
+}
+
+
+/*
+ * E_GAIN_norm_corr_interpolate
+ *
+ * Parameters:
+ * x I: input vector
+ * frac I: fraction (-4..+3)
+ *
+ * Function:
+ * Interpolating the normalized correlation
+ *
+ * Returns:
+ * interpolated value
+ */
+static Float32 E_GAIN_norm_corr_interpolate(Float32 *x, Word32 frac)
+{
+ Float32 s, *x1, *x2;
+ const Float32 *c1, *c2;
+
+ if (frac < 0)
+ {
+ frac += 4;
+ x--;
+ }
+
+ x1 = &x[0];
+ x2 = &x[1];
+ c1 = &E_ROM_inter4_1[frac];
+ c2 = &E_ROM_inter4_1[4 - frac];
+
+ s = x1[0] * c1[0] + x2[0] * c2[0];
+ s += x1[-1] * c1[4] + x2[1] * c2[4];
+ s += x1[-2] * c1[8] + x2[2] * c2[8];
+ s += x1[-3] * c1[12] + x2[3] * c2[12];
+
+ return s;
+}
+
+/*
+ * E_GAIN_closed_loop_search
+ *
+ * Parameters:
+ * exc I: excitation buffer
+ * xn I: target signal
+ * h I: weighted synthesis filter impulse response
+ * t0_min I: minimum value in the searched range
+ * t0_max I: maximum value in the searched range
+ * pit_frac O: chosen fraction
+ * i_subfr I: flag to first subframe
+ * t0_fr2 I: minimum value for resolution 1/2
+ * t0_fr1 I: minimum value for resolution 1
+ *
+ * Function:
+ * Find the closed loop pitch period with 1/4 subsample resolution.
+ *
+ * Returns:
+ * chosen integer pitch lag
+ */
+Word32 E_GAIN_closed_loop_search(Float32 exc[], Float32 xn[], Float32 h[],
+ Word32 t0_min, Word32 t0_max, Word32 *pit_frac,
+ Word32 i_subfr, Word32 t0_fr2, Word32 t0_fr1)
+{
+ Float32 corr_v[15 + 2 * L_INTERPOL1 + 1];
+ Float32 cor_max, max, temp;
+ Float32 *corr;
+ Word32 i, fraction, step;
+ Word32 t0, t_min, t_max;
+
+ /* Find interval to compute normalized correlation */
+
+ t_min = t0_min - L_INTERPOL1;
+ t_max = t0_max + L_INTERPOL1;
+
+ /* allocate memory to normalized correlation vector */
+ corr = &corr_v[-t_min]; /* corr[t_min..t_max] */
+
+ /* Compute normalized correlation between target and filtered excitation */
+ E_GAIN_norm_corr(exc, xn, h, t_min, t_max, corr);
+
+ /* find integer pitch */
+ max = corr[t0_min];
+ t0 = t0_min;
+
+ for(i = t0_min + 1; i <= t0_max; i++)
+ {
+ if( corr[i] > max)
+ {
+ max = corr[i];
+ t0 = i;
+ }
+ }
+
+ /* If first subframe and t0 >= t0_fr1, do not search fractionnal pitch */
+
+ if((i_subfr == 0) & (t0 >= t0_fr1))
+ {
+ *pit_frac = 0;
+ return(t0);
+ }
+
+ /*
+ * Search fractionnal pitch with 1/4 subsample resolution.
+ * Test the fractions around t0 and choose the one which maximizes
+ * the interpolated normalized correlation.
+ */
+
+ step = 1; /* 1/4 subsample resolution */
+ fraction = -3;
+ if (((i_subfr == 0) & (t0 >= t0_fr2)) | (t0_fr2 == PIT_MIN))
+ {
+ step = 2; /* 1/2 subsample resolution */
+ fraction = -2;
+ }
+
+ if (t0 == t0_min)
+ {
+ fraction = 0;
+ }
+
+ cor_max = E_GAIN_norm_corr_interpolate(&corr[t0], fraction);
+
+ for (i = (fraction + step); i <= 3; i += step)
+ {
+ temp = E_GAIN_norm_corr_interpolate(&corr[t0], i);
+
+ if (temp > cor_max)
+ {
+ cor_max = temp;
+ fraction = i;
+ }
+ }
+
+ /* limit the fraction value in the interval [0,1,2,3] */
+
+ if (fraction < 0)
+ {
+ fraction += 4;
+ t0 -= 1;
+ }
+
+ *pit_frac = fraction;
+
+ return (t0);
+}
+
+
+/*
+ * E_GAIN_adaptive_codebook_excitation
+ *
+ * Parameters:
+ * exc I/O: excitation buffer
+ * T0 I: integer pitch lag
+ * frac I: fraction of lag
+ * L_subfr I: subframe size
+ *
+ * Function:
+ * Compute the result of Word32 term prediction with fractional
+ * interpolation of resolution 1/4.
+ *
+ * Returns:
+ * interpolated signal (adaptive codebook excitation)
+ */
+void E_GAIN_adaptive_codebook_excitation(Word16 exc[], Word16 T0, Word32 frac, Word16 L_subfr)
+{
+ Word32 i, j, k, L_sum;
+ Word16 *x;
+
+ x = &exc[-T0];
+
+ frac = -(frac);
+
+ if (frac < 0)
+ {
+ frac = (frac + UP_SAMP);
+ x--;
+
+ }
+
+ x = x - L_INTERPOL2 + 1;
+
+ for (j = 0; j < L_subfr; j++)
+ {
+ L_sum = 0L;
+
+ for (i = 0, k = ((UP_SAMP - 1) - frac); i < 2 * L_INTERPOL2; i++, k += UP_SAMP)
+ {
+ L_sum = L_sum + (x[i] * E_ROM_inter4_2[k]);
+ }
+
+ L_sum = (L_sum + 0x2000) >> 14;
+ exc[j] = E_UTIL_saturate(L_sum);
+ x++;
+ }
+
+ return;
+}
+
+/*
+ * E_GAIN_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
+ */
+void E_GAIN_pitch_sharpening(Word16 *x, Word16 pit_lag)
+{
+ Word32 L_tmp, i;
+
+ for (i = pit_lag; i < L_SUBFR; i++)
+ {
+ L_tmp = x[i] << 15;
+ L_tmp += x[i - pit_lag] * PIT_SHARP;
+ x[i] = (Word16)((L_tmp + 0x4000) >> 15);
+ }
+
+ return;
+}
+
+void E_GAIN_f_pitch_sharpening(Float32 *x, Word32 pit_lag)
+{
+ Word32 i;
+
+ for (i = pit_lag; i < L_SUBFR; i++)
+ {
+ x[i] += x[i - pit_lag] * F_PIT_SHARP;
+ }
+
+ return;
+}
+
+/*
+ * E_GAIN_voice_factor
+ *
+ * Parameters:
+ * exc I: pitch excitation (Q_exc)
+ * Q_exc I: exc format
+ * gain_pit I: gain of pitch (Q14)
+ * code I: Fixed codebook excitation (Q9)
+ * gain_code I: gain of code (Q0)
+ *
+ *
+ * Function:
+ * Find the voicing factor (1=voice to -1=unvoiced)
+ * Subframe length is L_SUBFR
+ *
+ * Returns:
+ * factor (-1=unvoiced to 1=voiced) (Q15)
+ */
+Word32 E_GAIN_voice_factor(Word16 exc[], Word16 Q_exc, Word16 gain_pit,
+ Word16 code[], Word16 gain_code)
+{
+
+ Word32 i, L_tmp, tmp, exp, ener1, exp1, ener2, exp2;
+
+ ener1 = E_UTIL_dot_product12(exc, exc, L_SUBFR, &exp1) >> 16;
+ exp1 = exp1 - (Q_exc + Q_exc);
+ L_tmp = (gain_pit * gain_pit) << 1;
+ exp = E_UTIL_norm_l(L_tmp);
+ tmp = (L_tmp << exp) >> 16;
+ ener1 = (ener1 * tmp) >> 15;
+ exp1 = (exp1 - exp) - 10; /* 10 -> gain_pit Q14 to Q9 */
+
+ ener2 = E_UTIL_dot_product12(code, code, L_SUBFR, &exp2) >> 16;
+
+ exp = E_UTIL_norm_s(gain_code);
+ tmp = gain_code << exp;
+ tmp = (tmp * tmp) >> 15;
+ ener2 = (ener2 * tmp) >> 15;
+ exp2 = exp2 - (exp + exp);
+
+ i = exp1 - exp2;
+
+ if (i >= 0)
+ {
+ ener1 = ener1 >> 1;
+ ener2 = ener2 >> (i + 1);
+ }
+ else
+ {
+ i = 1 - i;
+ if (i < 32)
+ {
+ ener1 = ener1 >> i;
+ }
+ else
+ {
+ ener1 = 0;
+ }
+ ener2 = ener2 >> 1;
+ }
+
+ tmp = ener1 - ener2;
+ ener1 = (ener1 + ener2) + 1;
+
+ tmp = (tmp << 15) / ener1;
+
+ return (tmp);
+}
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_gain.h b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_gain.h
new file mode 100644
index 000000000..cd8b59dda
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_gain.h
@@ -0,0 +1,33 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef ENC_GAIN_H
+#define ENC_GAIN_H
+
+#include "typedef.h"
+
+void E_GAIN_clip_init(Float32 mem[]);
+Word32 E_GAIN_clip_test(Float32 mem[]);
+void E_GAIN_clip_isf_test(Float32 isf[], Float32 mem[]);
+void E_GAIN_clip_pit_test(Float32 gain_pit, Float32 mem[]);
+void E_GAIN_lp_decim2(Float32 x[], Word32 l, Float32 *mem);
+Word32 E_GAIN_olag_median(Word32 prev_ol_lag, Word32 old_ol_lag[5]);
+Word32 E_GAIN_open_loop_search(Float32 *wsp, Word32 L_min, Word32 L_max,
+ Word32 nFrame, Word32 L_0, Float32 *gain,
+ Float32 *mem, Float32 hp_old_wsp[],
+ UWord8 weight_flg);
+Word32 E_GAIN_closed_loop_search(Float32 exc[], Float32 xn[], Float32 h[],
+ Word32 t0_min, Word32 t0_max,
+ Word32 *pit_frac, Word32 i_subfr,
+ Word32 t0_fr2, Word32 t0_fr1);
+void E_GAIN_adaptive_codebook_excitation(Word16 exc[], Word16 T0, Word32 frac,
+ Word16 L_subfr);
+void E_GAIN_pitch_sharpening(Word16 *x, Word16 pit_lag);
+void E_GAIN_f_pitch_sharpening(Float32 *x, Word32 pit_lag);
+Word32 E_GAIN_voice_factor(Word16 exc[], Word16 Q_exc, Word16 gain_pit,
+ Word16 code[], Word16 gain_code);
+
+#endif
+
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_if.c b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_if.c
new file mode 100644
index 000000000..2ec76508f
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_if.c
@@ -0,0 +1,1031 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#include <stdlib.h>
+#include <memory.h>
+#include "typedef.h"
+#include "enc_if.h"
+#include "if_rom.h"
+#include "enc.h"
+
+#define L_FRAME16k 320 /* Frame size at 16kHz */
+#define EHF_MASK (Word32)0x0008 /* homing frame pattern */
+#define MODE_7k 0
+#define MODE_9k 1
+#define MODE_12k 2
+#define MODE_14k 3
+#define MODE_16k 4
+#define MODE_18k 5
+#define MODE_20k 6
+#define MODE_23k 7
+#define MODE_24k 8
+#define MRDTX 9
+#define MRNO_DATA 15
+
+/* number of bits */
+#define HEADER_SIZE 6 /* real size + 1 */
+#define T_NBBITS_7k (NBBITS_7k + HEADER_SIZE)
+#define T_NBBITS_9k (NBBITS_9k + HEADER_SIZE)
+#define T_NBBITS_12k (NBBITS_12k + HEADER_SIZE)
+#define T_NBBITS_14k (NBBITS_14k + HEADER_SIZE)
+#define T_NBBITS_16k (NBBITS_16k + HEADER_SIZE)
+#define T_NBBITS_18k (NBBITS_18k + HEADER_SIZE)
+#define T_NBBITS_20k (NBBITS_20k + HEADER_SIZE)
+#define T_NBBITS_23k (NBBITS_23k + HEADER_SIZE)
+#define T_NBBITS_24k (NBBITS_24k + HEADER_SIZE)
+#define T_NBBITS_SID (NBBITS_SID + HEADER_SIZE)
+
+
+typedef struct
+{
+ Word16 sid_update_counter; /* Number of frames since last SID */
+ Word16 sid_handover_debt; /* Number of extra SID_UPD frames to schedule */
+ Word16 prev_ft; /* Type of the previous frame */
+ void *encoder_state; /* Points encoder state structure */
+} WB_enc_if_state;
+
+
+extern const Word16 mode_7k[];
+extern const Word16 mode_9k[];
+extern const Word16 mode_12k[];
+extern const Word16 mode_14k[];
+extern const Word16 mode_16k[];
+extern const Word16 mode_18k[];
+extern const Word16 mode_20k[];
+extern const Word16 mode_23k[];
+extern const Word16 mode_24k[];
+extern const Word16 mode_DTX[];
+
+extern const UWord8 block_size[];
+extern const Word16 nb_of_param[];
+
+extern const Word16 dfh_M7k[];
+extern const Word16 dfh_M9k[];
+extern const Word16 dfh_M12k[];
+extern const Word16 dfh_M14k[];
+extern const Word16 dfh_M16k[];
+extern const Word16 dfh_M18k[];
+extern const Word16 dfh_M20k[];
+extern const Word16 dfh_M23k[];
+extern const Word16 dfh_M24k[];
+
+/* overall table with the parameters of the
+ decoder homing frames for all modes */
+
+const Word16 *dhf[10];
+
+
+/*
+ * E_IF_homing_frame_test
+ *
+ *
+ * Parameters:
+ * input_frame I: input speech frame
+ *
+ * Function:
+ * Check 320 input samples for matching EHF_MASK
+ *
+ * Returns:
+ * If homing frame
+ */
+Word16 E_IF_homing_frame_test(Word16 input_frame[])
+{
+ Word32 i, j = 0;
+
+ for (i = 0; i < L_FRAME16k; i++)
+ {
+ j = input_frame[i] ^ EHF_MASK;
+
+ if (j)
+ {
+ break;
+ }
+ }
+
+ return (Word16) (!j);
+}
+
+/*
+ * E_IF_homing_coding
+ *
+ *
+ * Parameters:
+ * parms I/O: pointer to parameter vector
+ * mode I: speech mode
+ *
+ * Function:
+ * Copy decoder homing frame from memory to parameter vector
+ *
+ * Returns:
+ * void
+ */
+void E_IF_homing_coding(Word16 *parms, Word16 mode)
+{
+ memcpy(parms, dhf[mode], nb_of_param[mode] * sizeof(Word16));
+}
+
+
+#ifdef IF2
+/*
+ * E_IF_if2_conversion
+ *
+ *
+ * Parameters:
+ * mode I: Mode
+ * param I: encoder output
+ * stream O: packed octets (TS26.201)
+ * frame_type I: TX frame type
+ * dtx I: speech mode for mode MRDTX
+ *
+ * Function:
+ * Packing one frame of encoded parameters to AMR-WB IF2
+ *
+ * Returns:
+ * number of octets
+ */
+static int E_IF_if2_conversion(Word16 mode, Word16 *param, UWord8 *stream,
+ Word16 frame_type, Word16 speech_mode)
+{
+ Word32 j = 0;
+ Word16 const *mask;
+
+ memset(stream, 0, block_size[mode]);
+
+ switch(mode)
+ {
+ case MRNO_DATA:
+ *stream = 0xF8;
+ j = 8;
+ break;
+
+ case MODE_7k:
+ mask = mode_7k;
+ *stream = 0x2; /* frame_type = 0, fqi = 1 */
+
+ for (j = HEADER_SIZE; j < T_NBBITS_7k; j++)
+ {
+ if (param[*mask] & *(mask + 1))
+ {
+ *stream += 0x1;
+ }
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ while (j % 8)
+ {
+ *stream <<= 1;
+ j++;
+ }
+
+ break;
+
+ case MODE_9k:
+ mask = mode_9k;
+ *stream = 0x6; /* frame_type = 1, fqi = 1 */
+
+ for (j = HEADER_SIZE; j < T_NBBITS_9k; j++)
+ {
+ if (param[*mask] & *(mask + 1))
+ {
+ *stream += 0x1;
+ }
+
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ while (j % 8)
+ {
+ *stream <<= 1;
+ j++;
+ }
+
+ break;
+
+ case MODE_12k:
+ mask = mode_12k;
+ *stream = 0xA; /* frame_type = 2, fqi = 1 */
+
+ for (j = HEADER_SIZE; j < T_NBBITS_12k; j++)
+ {
+ if (param[*mask] & *(mask + 1))
+ {
+ *stream += 0x1;
+ }
+
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ while (j % 8)
+ {
+ *stream <<= 1;
+ j++;
+ }
+ break;
+
+ case MODE_14k:
+ mask = mode_14k;
+ *stream = 0xE; /* frame_type = 3, fqi = 1 */
+
+ for ( j = HEADER_SIZE; j < T_NBBITS_14k; j++ )
+ {
+ if (param[*mask] & *(mask + 1))
+ {
+ *stream += 0x1;
+ }
+
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ while (j % 8)
+ {
+ *stream <<= 1;
+ j++;
+ }
+
+ break;
+
+ case MODE_16k:
+ mask = mode_16k;
+ *stream = 0x12; /* frame_type = 4, fqi = 1 */
+
+ for (j = HEADER_SIZE; j < T_NBBITS_16k; j++)
+ {
+ if (param[*mask] & *(mask + 1))
+ {
+ *stream += 0x1;
+ }
+
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ while (j % 8)
+ {
+ *stream <<= 1;
+ j++;
+ }
+
+ break;
+
+ case MODE_18k:
+ mask = mode_18k;
+ *stream = 0x16; /* frame_type = 5, fqi = 1 */
+
+ for (j = HEADER_SIZE; j < T_NBBITS_18k; j++)
+ {
+ if (param[*mask] & *(mask + 1))
+ {
+ *stream += 0x1;
+ }
+
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ while (j % 8)
+ {
+ *stream <<= 1;
+ j++;
+ }
+
+ break;
+
+ case MODE_20k:
+ mask = mode_20k;
+ *stream = 0x1A; /* frame_type = 6, fqi = 1 */
+
+ for (j = HEADER_SIZE; j < T_NBBITS_20k; j++)
+ {
+ if (param[*mask] & *( mask + 1))
+ {
+ *stream += 0x1;
+ }
+
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ while (j % 8)
+ {
+ *stream <<= 1;
+ j++;
+ }
+
+ break;
+
+ case MODE_23k:
+ mask = mode_23k;
+ *stream = 0x1E; /* frame_type = 7, fqi = 1 */
+
+ for (j = HEADER_SIZE; j < T_NBBITS_23k; j++)
+ {
+ if (param[*mask] & *( mask + 1))
+ {
+ *stream += 0x1;
+ }
+
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ while (j % 8)
+ {
+ *stream <<= 1;
+ j++;
+ }
+
+ break;
+
+ case MODE_24k:
+ mask = mode_24k;
+ *stream = 0x22; /* frame_type = 8, fqi = 1 */
+
+ for (j = HEADER_SIZE; j < T_NBBITS_24k; j++)
+ {
+ if (param[*mask] & *( mask + 1))
+ {
+ *stream += 0x1;
+ }
+
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ while (j % 8)
+ {
+ *stream <<= 1;
+ j++;
+ }
+
+ break;
+
+ case MRDTX:
+ mask = mode_DTX;
+ *stream = 0x26; /* frame_type = 9, fqi = 1 */
+
+ for ( j = HEADER_SIZE; j < T_NBBITS_SID; j++ )
+ {
+ if (param[*mask] & *(mask + 1))
+ {
+ *stream += 0x1;
+ }
+
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+
+ }
+
+ /* sid type */
+ if (frame_type == TX_SID_UPDATE)
+ {
+ /* sid update */
+ *stream += 0x1;
+ }
+
+ /* speech mode indicator */
+ *stream <<= 4;
+ *stream = (UWord8)(*stream + speech_mode);
+ /* bit stuffing */
+ *stream <<= 3;
+ j = 48;
+
+ break;
+
+ default:
+ break;
+
+ }
+
+ return j/8;
+}
+
+#else
+
+/*
+ * E_IF_mms_conversion
+ *
+ *
+ * Parameters:
+ * mode I: Mode
+ * param I: encoder output
+ * stream O: packed octets (RFC 3267, section 5.3)
+ * frame_type I: TX frame type
+ * dtx I: speech mode for mode MRDTX
+ *
+ * Function:
+ * Packing one frame of encoded parameters to AMR-WB MMS format
+ *
+ * Returns:
+ * number of octets
+ */
+static int E_IF_mms_conversion(Word16 mode, Word16 *param, UWord8 *stream,
+ Word16 frame_type, Word16 speech_mode)
+{
+ Word32 j = 0;
+ Word16 const *mask;
+
+ memset(stream, 0, block_size[mode]);
+
+ switch(mode)
+ {
+ case MRNO_DATA:
+ *stream = 0x7C;
+ j = 0;
+ break;
+
+ case MODE_7k:
+ mask = mode_7k;
+ *stream = 0x04; /* frame_type = 0, fqi = 1 */
+ stream++;
+
+ for (j = 1; j <= NBBITS_7k; j++)
+ {
+ if (param[*mask] & *(mask + 1))
+ {
+ *stream += 0x1;
+ }
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ while (j % 8)
+ {
+ *stream <<= 1;
+ j++;
+ }
+
+ break;
+
+ case MODE_9k:
+ mask = mode_9k;
+ *stream = 0x0C; /* frame_type = 1, fqi = 1 */
+ stream++;
+
+ for (j = 1; j <= NBBITS_9k; j++)
+ {
+ if (param[*mask] & *(mask + 1))
+ {
+ *stream += 0x1;
+ }
+
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ while (j % 8)
+ {
+ *stream <<= 1;
+ j++;
+ }
+
+ break;
+
+ case MODE_12k:
+ mask = mode_12k;
+ *stream = 0x14; /* frame_type = 2, fqi = 1 */
+ stream++;
+
+ for (j = 1; j <= NBBITS_12k; j++)
+ {
+ if (param[*mask] & *(mask + 1))
+ {
+ *stream += 0x1;
+ }
+
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ while (j % 8)
+ {
+ *stream <<= 1;
+ j++;
+ }
+ break;
+
+ case MODE_14k:
+ mask = mode_14k;
+ *stream = 0x1C; /* frame_type = 3, fqi = 1 */
+ stream++;
+
+ for ( j = 1; j <= NBBITS_14k; j++ )
+ {
+ if (param[*mask] & *(mask + 1))
+ {
+ *stream += 0x1;
+ }
+
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ while (j % 8)
+ {
+ *stream <<= 1;
+ j++;
+ }
+
+ break;
+
+ case MODE_16k:
+ mask = mode_16k;
+ *stream = 0x24; /* frame_type = 4, fqi = 1 */
+ stream++;
+
+ for (j = 1; j <= NBBITS_16k; j++)
+ {
+ if (param[*mask] & *(mask + 1))
+ {
+ *stream += 0x1;
+ }
+
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ while (j % 8)
+ {
+ *stream <<= 1;
+ j++;
+ }
+
+ break;
+
+ case MODE_18k:
+ mask = mode_18k;
+ *stream = 0x2C; /* frame_type = 5, fqi = 1 */
+ stream++;
+
+ for (j = 1; j <= NBBITS_18k; j++)
+ {
+ if (param[*mask] & *(mask + 1))
+ {
+ *stream += 0x1;
+ }
+
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ while (j % 8)
+ {
+ *stream <<= 1;
+ j++;
+ }
+
+ break;
+
+ case MODE_20k:
+ mask = mode_20k;
+ *stream = 0x34; /* frame_type = 6, fqi = 1 */
+ stream++;
+
+ for (j = 1; j <= NBBITS_20k; j++)
+ {
+ if (param[*mask] & *( mask + 1))
+ {
+ *stream += 0x1;
+ }
+
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ while (j % 8)
+ {
+ *stream <<= 1;
+ j++;
+ }
+
+ break;
+
+ case MODE_23k:
+ mask = mode_23k;
+ *stream = 0x3C; /* frame_type = 7, fqi = 1 */
+ stream++;
+
+ for (j = 1; j <= NBBITS_23k; j++)
+ {
+ if (param[*mask] & *( mask + 1))
+ {
+ *stream += 0x1;
+ }
+
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ while (j % 8)
+ {
+ *stream <<= 1;
+ j++;
+ }
+
+ break;
+
+ case MODE_24k:
+ mask = mode_24k;
+ *stream = 0x44; /* frame_type = 8, fqi = 1 */
+ stream++;
+
+ for (j = 1; j <= NBBITS_24k; j++)
+ {
+ if (param[*mask] & *( mask + 1))
+ {
+ *stream += 0x1;
+ }
+
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+ }
+
+ while (j % 8)
+ {
+ *stream <<= 1;
+ j++;
+ }
+
+ break;
+
+ case MRDTX:
+ mask = mode_DTX;
+ *stream = 0x4C; /* frame_type = 9, fqi = 1 */
+ stream++;
+
+ for ( j = 1; j <= NBBITS_SID; j++ )
+ {
+ if (param[*mask] & *(mask + 1))
+ {
+ *stream += 0x1;
+ }
+
+ mask += 2;
+
+ if (j % 8)
+ {
+ *stream <<= 1;
+ }
+ else
+ {
+ stream++;
+ }
+
+ }
+
+ /* sid type */
+ if (frame_type == TX_SID_UPDATE)
+ {
+ /* sid update */
+ *stream += 0x1;
+ }
+
+ /* speech mode indicator */
+ *stream <<= 4;
+ *stream = (UWord8)(*stream + speech_mode);
+ j = 40;
+
+ break;
+
+ default:
+ break;
+
+ }
+
+ return j/8 + 1;
+}
+
+#endif
+
+/*
+ * E_IF_sid_sync_reset
+ *
+ * Parameters:
+ * st O: state structure
+ *
+ * Function:
+ * Initializes state memory
+ *
+ * Returns:
+ * void
+ */
+static void E_IF_sid_sync_reset(WB_enc_if_state *st)
+{
+ st->sid_update_counter = 3;
+ st->sid_handover_debt = 0;
+ st->prev_ft = TX_SPEECH;
+}
+
+/*
+ * E_IF_encode
+ *
+ *
+ * Parameters:
+ * st I: pointer to state structure
+ * mode I: Speech Mode
+ * speech I: Input speech
+ * serial O: Output octet structure IF2 or 16-bit serial stream
+ * dtx I: use DTX
+ *
+ * Function:
+ * Encoding and packing one frame of speech
+ *
+ * Returns:
+ * number of octets
+ */
+int E_IF_encode(void *st, Word16 req_mode, Word16 *speech, UWord8 *serial,
+ Word16 dtx)
+{
+ Word16 prms[NB_PARM_MAX];
+ Word32 i;
+ Word16 frame_type, mode, reset_flag;
+ WB_enc_if_state *s;
+
+ s = (WB_enc_if_state *)st;
+ mode = req_mode;
+
+ /* check for homing frame */
+ reset_flag = E_IF_homing_frame_test(speech);
+
+ if (!reset_flag)
+ {
+ for (i = 0; i < L_FRAME16k; i++) /* Delete the 2 LSBs (14-bit input) */
+ {
+ speech[i] = (Word16) (speech[i] & 0xfffC);
+ }
+
+ E_MAIN_encode(&mode, speech, prms, s->encoder_state, dtx);
+
+ if (mode == MRDTX)
+ {
+ s->sid_update_counter--;
+
+ if (s->prev_ft == TX_SPEECH)
+ {
+ frame_type = TX_SID_FIRST;
+ s->sid_update_counter = 3;
+ }
+ else
+ {
+ if ((s->sid_handover_debt > 0) && (s->sid_update_counter > 2))
+ {
+ /*
+ * ensure extra updates are
+ * properly delayed after a possible SID_FIRST
+ */
+ frame_type = TX_SID_UPDATE;
+ s->sid_handover_debt--;
+ }
+ else
+ {
+ if (s->sid_update_counter == 0)
+ {
+ frame_type = TX_SID_UPDATE;
+ s->sid_update_counter = 8;
+ }
+ else
+ {
+ frame_type = TX_NO_DATA;
+ mode = MRNO_DATA;
+ }
+ }
+ }
+ }
+ else
+ {
+ s->sid_update_counter = 8;
+ frame_type = TX_SPEECH;
+ }
+
+ s->prev_ft = frame_type;
+
+ }
+ /* perform homing if homing frame was detected at encoder input */
+ else
+ {
+ E_MAIN_reset(s->encoder_state, 1);
+ E_IF_sid_sync_reset(s);
+ E_IF_homing_coding(prms, mode);
+ frame_type = TX_SPEECH;
+ }
+
+#ifdef IF2
+ return E_IF_if2_conversion(mode, prms, serial, frame_type, req_mode);
+#else
+ return E_IF_mms_conversion(mode, prms, serial, frame_type, req_mode);
+#endif
+}
+
+/*
+ * E_IF_init
+ *
+ * Parameters:
+ * none
+ *
+ * Function:
+ * Allocates state memory and initializes state memory
+ *
+ * Returns:
+ * pointer to encoder interface structure
+ */
+void *E_IF_init(void)
+{
+ WB_enc_if_state * s;
+
+ /* allocate memory */
+ if ((s = (WB_enc_if_state *)malloc(sizeof(WB_enc_if_state))) == NULL)
+ {
+ return NULL;
+ }
+
+ E_MAIN_init(&(s->encoder_state));
+ if (s->encoder_state == NULL)
+ {
+ free(s);
+ return NULL;
+ }
+
+ E_IF_sid_sync_reset(s);
+
+ return s;
+}
+
+/*
+ * E_IF_exit
+ *
+ * Parameters:
+ * state I: state structure
+ *
+ * Function:
+ * The memory used for state memory is freed
+ *
+ * Returns:
+ * Void
+ */
+void E_IF_exit(void *state)
+{
+ WB_enc_if_state *s;
+ s = (WB_enc_if_state *)state;
+
+ /* free memory */
+ E_MAIN_close(&s->encoder_state);
+ free(s);
+ state = NULL;
+}
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_if.h b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_if.h
new file mode 100644
index 000000000..9c88ff92c
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_if.h
@@ -0,0 +1,19 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef WB_E_IF_H
+#define WB_E_IF_H
+
+#include "typedef.h"
+
+#define L_FRAME16k 320 /* Frame size at 16kHz */
+#define NB_SERIAL_MAX 61 /* max serial size */
+
+int E_IF_encode(void *st, Word16 mode, Word16 *speech,
+ UWord8 *serial, Word16 dtx);
+void *E_IF_init(void);
+void E_IF_exit(void *state);
+
+#endif
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_lpc.c b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_lpc.c
new file mode 100644
index 000000000..e17f5ad9e
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_lpc.c
@@ -0,0 +1,1255 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#include <math.h>
+#include <memory.h>
+
+#include "typedef.h"
+#include "enc_util.h"
+
+#define ORDER 16 /* order of linear prediction filter */
+#define ISF_GAP 128 /* 50 */
+#define M 16
+#define M16k 20 /* Order of LP filter */
+#define MP1 (M+1)
+#define NC16k (M16k / 2)
+#define MU 10923 /* Prediction factor (1.0/3.0) in Q15 */
+#define F_MU (1.0 / 3.0) /* prediction factor */
+#define N_SURV_MAX 4 /* 4 survivors max */
+
+#ifndef PI
+#define PI 3.141592654
+#endif
+
+/* isp_isf_conversion */
+#define SCALE1 (6400.0/PI)
+
+/* chebyshev */
+#define NO_ITER 4 /* no of iterations for tracking the root */
+#define NO_POINTS 100
+
+#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 SIZE_BK_NOISE1 64
+#define SIZE_BK_NOISE2 64
+#define SIZE_BK_NOISE3 64
+#define SIZE_BK_NOISE4 32
+#define SIZE_BK_NOISE5 32
+
+extern const Word16 E_ROM_mean_isf[];
+extern const Word16 E_ROM_cos[];
+
+extern const Float32 E_ROM_dico1_isf[];
+extern const Float32 E_ROM_dico2_isf[];
+extern const Float32 E_ROM_dico21_isf[];
+extern const Float32 E_ROM_dico22_isf[];
+extern const Float32 E_ROM_dico23_isf[];
+extern const Float32 E_ROM_dico24_isf[];
+extern const Float32 E_ROM_dico25_isf[];
+extern const Float32 E_ROM_dico21_isf_36b[];
+extern const Float32 E_ROM_dico22_isf_36b[];
+extern const Float32 E_ROM_dico23_isf_36b[];
+extern const Float32 E_ROM_f_mean_isf[];
+extern const Float32 E_ROM_lag_window[];
+extern const Float32 E_ROM_grid[];
+extern const Float32 E_ROM_f_interpol_frac[];
+
+/*
+ * E_LPC_isf_reorder
+ *
+ * Parameters:
+ * isf I/O: vector of isfs
+ * min_dist I: quantized ISFs (in frequency domain)
+ * n I: LPC order
+ *
+ * Function:
+ * To make sure that the isfs are properly order and to keep a certain
+ * minimum distance between consecutive isfs.
+ *
+ * Returns:
+ * void
+ */
+static void E_LPC_isf_reorder(Word16 *isf, Word16 min_dist, Word16 n)
+{
+
+ Word32 i, isf_min;
+
+ isf_min = min_dist;
+
+ for (i = 0; i < n - 1; i++)
+ {
+ if (isf[i] < isf_min)
+ {
+ isf[i] = (Word16)isf_min;
+ }
+
+ isf_min = isf[i] + min_dist;
+ }
+
+ return;
+}
+
+/*
+ * E_LPC_isp_pol_get
+ *
+ * Parameters:
+ * isp I: Immitance spectral pairs (cosine domaine)
+ * f O: the coefficients of F1 or F2
+ * n I: no of coefficients (m/2)
+ * k16 I: 16k flag
+ *
+ * Function:
+ * Find the polynomial F1(z) or F2(z) from the ISPs.
+ * This is performed by expanding the product polynomials:
+ *
+ * F1(z) = product ( 1 - 2 isp_i z^-1 + z^-2 )
+ * i=0,2,4,6,8
+ * F2(z) = product ( 1 - 2 isp_i z^-1 + z^-2 )
+ * i=1,3,5,7
+ *
+ * where isp_i are the ISPs in the cosine domain.
+ *
+ * Returns:
+ * void
+ */
+static void E_LPC_isp_pol_get(Word16 *isp, Word32 *f, Word32 n, Word16 k16)
+{
+ Word32 i, j, t0, s1, s2;
+ Word16 hi, lo;
+
+ s1 = 8388608;
+ s2 = 512;
+
+ if(k16)
+ {
+ s1 >>= 2;
+ s2 >>= 2;
+ }
+
+ /* All computation in Q23 */
+ f[0] = s1; /* f[0] = 1.0; in Q23 */
+ f[1] = isp[0] * (-s2); /* f[1] = -2.0*isp[0] in Q23 */
+ f += 2; /* Advance f pointer */
+ isp += 2; /* Advance isp pointer */
+
+ for(i = 2; i <= n; i++)
+ {
+ *f = f[ - 2];
+
+ for(j = 1; j < i; j++, f--)
+ {
+ E_UTIL_l_extract(f[- 1], &hi, &lo);
+ t0 = E_UTIL_mpy_32_16(hi, lo, *isp); /* t0 = f[-1] * isp */
+ t0 = (t0 << 1);
+ *f = (*f - t0); /* *f -= t0 */
+ *f = (*f + f[ - 2]); /* *f += f[-2] */
+ }
+
+ *f = *f - (*isp * s2); /* *f -= isp << 8 */
+ f += i; /* Advance f pointer */
+ isp += 2; /* Advance isp pointer */
+ }
+
+ return;
+}
+
+static void E_LPC_f_isp_pol_get(Float32 isp[], Float32 f[], Word32 n)
+{
+ Float32 b;
+ Word32 i, j;
+
+ f[0] = 1;
+ b = (Float32)(-2.0 * *isp);
+ f[1] = b;
+
+ for (i = 2; i <= n; i++)
+ {
+ isp += 2;
+ b = (Float32)(-2.0 * *isp);
+ f[i] = (Float32)(b * f[i - 1] + 2.0 * f[i - 2]);
+
+ for (j = i - 1; j > 1; j--)
+ {
+ f[j] += b * f[j - 1] + f[j - 2];
+ }
+
+ f[1] += b;
+ }
+
+ return;
+}
+
+/*
+ * E_LPC_isp_a_conversion
+ *
+ * Parameters:
+ * isp I: (Q15) Immittance spectral pairs
+ * a O: (Q12) Predictor coefficients (order = M)
+ * m I: order of LP filter
+ *
+ * Function:
+ * Convert ISPs to predictor coefficients a[]
+ *
+ * Returns:
+ * void
+ */
+void E_LPC_isp_a_conversion(Word16 isp[], Word16 a[], Word16 m)
+{
+ Word32 f1[NC16k + 1], f2[NC16k];
+ Word32 i, j, nc, t0;
+ Word16 hi, lo;
+
+ nc = m >> 1;
+
+ if (nc > 8)
+ {
+ E_LPC_isp_pol_get(&isp[0], f1, nc, 1);
+
+ for (i = 0; i <= nc; i++)
+ {
+ f1[i] = (f1[i] << 2);
+ }
+ }
+ else
+ {
+ E_LPC_isp_pol_get(&isp[0], f1, nc, 0);
+ }
+
+ if (nc > 8)
+ {
+ E_LPC_isp_pol_get(&isp[1], f2, nc - 1, 1);
+
+ for (i = 0; i <= nc - 1; i++)
+ {
+ f2[i] = (f2[i] << 2);
+ }
+ }
+ else
+ {
+ E_LPC_isp_pol_get(&isp[1], f2, nc - 1, 0);
+ }
+
+ /* Multiply F2(z) by (1 - z^-2) */
+ for (i = (nc - 1); i > 1; i--)
+ {
+ f2[i] = f2[i] - f2[i - 2]; /* f2[i] -= f2[i-2]; */
+ }
+
+ /* 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]); */
+
+ E_UTIL_l_extract(f1[i], &hi, &lo);
+ t0 = E_UTIL_mpy_32_16(hi, lo, isp[m - 1]);
+ f1[i] = f1[i] + t0;
+
+ /* f2[i] *= (1.0 - isp[M-1]); */
+
+ E_UTIL_l_extract(f2[i], &hi, &lo);
+ t0 = E_UTIL_mpy_32_16(hi, lo, isp[m - 1]);
+ f2[i] = f2[i] - t0;
+ }
+
+ /*
+ * A(z) = (F1(z)+F2(z))/2
+ * F1(z) is symmetric and F2(z) is antisymmetric
+ */
+
+ /* a[0] = 1.0; */
+ a[0] = 4096;
+
+ for (i = 1, j = (m - 1); i < nc; i++, j--)
+ {
+ /* a[i] = 0.5*(f1[i] + f2[i]); */
+ t0 = f1[i] + f2[i]; /* f1[i] + f2[i] */
+ a[i] = (Word16)((t0 + 0x800) >> 12); /* from Q23 to Q12 and * 0.5 */
+
+ /* a[j] = 0.5*(f1[i] - f2[i]); */
+ t0 = (f1[i] - f2[i]); /* f1[i] - f2[i] */
+ a[j] = (Word16)((t0 + 0x800) >> 12); /* from Q23 to Q12 and * 0.5 */
+
+ }
+
+ /* a[NC] = 0.5*f1[NC]*(1.0 + isp[M-1]); */
+ E_UTIL_l_extract(f1[nc], &hi, &lo);
+ t0 = E_UTIL_mpy_32_16(hi, lo, isp[m - 1]);
+ t0 = (f1[nc] + t0);
+ a[nc] = (Word16)((t0 + 0x800) >> 12); /* from Q23 to Q12 and * 0.5 */
+
+ /* a[m] = isp[m-1]; */
+ a[m] = (Word16)((isp[m - 1] + 0x4) >> 3); /* from Q15 to Q12 */
+
+ return;
+}
+
+void E_LPC_f_isp_a_conversion(Float32 *isp, Float32 *a, Word32 m)
+{
+ Float32 f1[(M16k / 2) + 1], f2[M16k / 2];
+ Word32 i, j, nc;
+
+ nc = m / 2;
+
+ /*
+ * Find the polynomials F1(z) and F2(z)
+ */
+
+ E_LPC_f_isp_pol_get(&isp[0], f1, nc);
+ E_LPC_f_isp_pol_get(&isp[1], f2, nc-1);
+
+ /*
+ * Multiply F2(z) by (1 - z^-2)
+ */
+ for (i = (nc - 1); i > 1; i--)
+ {
+ f2[i] -= f2[i - 2];
+ }
+
+ /*
+ * Scale F1(z) by (1+isp[m-1]) and F2(z) by (1-isp[m-1])
+ */
+
+ for (i = 0; i < nc; i++)
+ {
+ f1[i] *= (Float32)(1.0 + isp[m - 1]);
+ f2[i] *= (Float32)(1.0 - isp[m - 1]);
+ }
+
+ /*
+ * A(z) = (F1(z)+F2(z))/2
+ * F1(z) is symmetric and F2(z) is antisymmetric
+ */
+
+ a[0] = 1.0;
+
+ for (i = 1, j = m - 1; i < nc; i++, j--)
+ {
+ a[i] = (Float32)(0.5 * (f1[i] + f2[i]));
+ a[j] = (Float32)(0.5 * (f1[i] - f2[i]));
+ }
+
+ a[nc] = (Float32)(0.5 * f1[nc] * (1.0 + isp[m - 1]));
+ a[m] = isp[m - 1];
+
+ return;
+}
+
+/*
+ * E_LPC_int_isp_find
+ *
+ * Parameters:
+ * isp_old I: isps from past frame
+ * isp_new I: isps from present frame
+ * frac I: (Q15) fraction for 3 first subfr
+ * Az O: LP coefficients in 4 subframes
+ *
+ * Function:
+ * Find the Word32erpolated ISP parameters for all subframes.
+ *
+ * Returns:
+ * void
+ */
+void E_LPC_int_isp_find(Word16 isp_old[], Word16 isp_new[],
+ const Word16 frac[], Word16 Az[])
+{
+ Word32 i, k, fac_old, fac_new, tmp;
+ Word16 isp[M];
+
+ for (k = 0; k < 3; k++)
+ {
+ fac_new = frac[k];
+ fac_old = ((32767 - fac_new) + 1); /* 1.0 - fac_new */
+
+ for (i = 0; i < M; i++)
+ {
+ tmp = isp_old[i] * fac_old;
+ tmp += (isp_new[i] * fac_new);
+ isp[i] = (Word16)((tmp + 0x4000) >> 15);
+ }
+
+ E_LPC_isp_a_conversion(isp, Az, M);
+ Az += MP1;
+ }
+
+ /* 4th subframe: isp_new (frac=1.0) */
+ E_LPC_isp_a_conversion(isp_new, Az, M);
+
+ return;
+}
+
+void E_LPC_f_int_isp_find(Float32 isp_old[], Float32 isp_new[], Float32 a[],
+ Word32 nb_subfr, Word32 m)
+{
+ Float32 isp[M], fnew, fold;
+ Float32 *p_a;
+ Word32 i, k;
+
+ p_a = a;
+
+ for (k = 0; k < nb_subfr; k++)
+ {
+ fnew = E_ROM_f_interpol_frac[k];
+ fold = (Float32)(1.0 - fnew);
+
+ for (i = 0; i < m; i++)
+ {
+ isp[i] = isp_old[i] * fold + isp_new[i] * fnew;
+ }
+
+ E_LPC_f_isp_a_conversion(isp, p_a, m);
+ p_a += (m + 1);
+ }
+
+ return;
+}
+
+/*
+ * E_LPC_a_weight
+ *
+ * Parameters:
+ * a I: LP filter coefficients
+ * ap O: weighted LP filter coefficients
+ * gamma I: weighting factor
+ * m I: order of LP filter
+ *
+ * Function:
+ * Weighting of LP filter coefficients, ap[i] = a[i] * (gamma^i).
+ *
+ * Returns:
+ * void
+ */
+void E_LPC_a_weight(Float32 *a, Float32 *ap, Float32 gamma, Word32 m)
+{
+ Float32 f;
+ Word32 i;
+
+ ap[0] = a[0];
+ f = gamma;
+
+ for (i = 1; i <= m; i++)
+ {
+ ap[i] = f*a[i];
+ f *= gamma;
+ }
+
+ return;
+}
+
+/*
+ * E_LPC_isf_2s3s_decode
+ *
+ * Parameters:
+ * indice I: quantisation indices
+ * isf_q O: quantised ISFs in the cosine domain
+ * past_isfq I/O: past ISF quantizer
+ *
+ * Function:
+ * Decoding of ISF parameters.
+ *
+ * Returns:
+ * void
+ */
+static void E_LPC_isf_2s3s_decode(Word32 *indice, Word16 *isf_q,
+ Word16 *past_isfq)
+{
+ Word32 i;
+ Word16 tmp;
+
+ for(i = 0; i < 9; i++)
+ {
+ isf_q[i] = (Word16)((E_ROM_dico1_isf[indice[0] * 9 + i] * 2.56F) + 0.5F);
+ }
+
+ for(i = 0; i < 7; i++)
+ {
+ isf_q[i + 9] =
+ (Word16)((E_ROM_dico2_isf[indice[1] * 7 + i] * 2.56F) + 0.5F);
+ }
+
+ for(i = 0; i < 5; i++)
+ {
+ isf_q[i] = (Word16)(isf_q[i] +
+ (Word16)((E_ROM_dico21_isf_36b[indice[2] * 5 + i] * 2.56F) + 0.5F));
+ }
+
+ for(i = 0; i < 4; i++)
+ {
+ isf_q[i + 5] = (Word16)(isf_q[i + 5] +
+ (Word32)((E_ROM_dico22_isf_36b[indice[3] * 4 + i] * 2.56F) + 0.5F));
+ }
+
+ for(i = 0; i < 7; i++)
+ {
+ isf_q[i + 9] = (Word16)(isf_q[i + 9] +
+ (Word32)((E_ROM_dico23_isf_36b[indice[4] * 7 + i] * 2.56F) + 0.5F));
+ }
+
+ for(i = 0; i < ORDER; i++)
+ {
+ tmp = isf_q[i];
+ isf_q[i] = (Word16)(tmp + E_ROM_mean_isf[i]);
+ isf_q[i] = (Word16)(isf_q[i] + ((MU * past_isfq[i]) >> 15));
+ past_isfq[i] = tmp;
+ }
+
+ E_LPC_isf_reorder(isf_q, ISF_GAP, ORDER);
+
+ return;
+}
+
+
+/*
+ * E_LPC_isf_2s5s_decode
+ *
+ * Parameters:
+ * indice I: quantization indices
+ * isf_q O: quantized ISFs in the cosine domain
+ * past_isfq I/O: past ISF quantizer
+ * isfold I: past quantized ISF
+ * isf_buf I: isf buffer
+ * bfi I: Bad frame indicator
+ * enc_dec I:
+ *
+ * Function:
+ * Decoding of ISF parameters.
+ *
+ * Returns:
+ * void
+ */
+void E_LPC_isf_2s5s_decode(Word32 *indice, Word16 *isf_q, Word16 *past_isfq)
+{
+ Word32 i;
+ Word16 tmp;
+
+ for (i = 0; i < 9; i++)
+ {
+ isf_q[i] = (Word16)((E_ROM_dico1_isf[indice[0] * 9 + i] * 2.56F) + 0.5F);
+ }
+
+ for (i = 0; i < 7; i++)
+ {
+ isf_q[i + 9] =
+ (Word16)((E_ROM_dico2_isf[indice[1] * 7 + i] * 2.56F) + 0.5F);
+ }
+
+ for (i = 0; i < 3; i++)
+ {
+ isf_q[i] = (Word16)(isf_q[i] +
+ (Word32)((E_ROM_dico21_isf[indice[2] * 3 + i] * 2.56F) + 0.5F));
+ }
+
+ for (i = 0; i < 3; i++)
+ {
+ isf_q[i + 3] = (Word16)(isf_q[i + 3] +
+ (Word32)((E_ROM_dico22_isf[indice[3] * 3 + i] * 2.56F) + 0.5F));
+ }
+
+ for (i = 0; i < 3; i++)
+ {
+ isf_q[i + 6] = (Word16)(isf_q[i + 6] +
+ (Word32)((E_ROM_dico23_isf[indice[4] * 3 + i] * 2.56F) + 0.5F));
+ }
+
+ for (i = 0; i < 3; i++)
+ {
+ isf_q[i + 9] = (Word16)(isf_q[i + 9] +
+ (Word32)((E_ROM_dico24_isf[indice[5] * 3 + i] * 2.56F) + 0.5F));
+ }
+
+ for (i = 0; i < 4; i++)
+ {
+ isf_q[i + 12] = (Word16)(isf_q[i + 12] +
+ (Word32)((E_ROM_dico25_isf[indice[6] * 4 + i] * 2.56F) + 0.5F));
+ }
+
+ for (i = 0; i < ORDER; i++)
+ {
+ tmp = isf_q[i];
+ isf_q[i] = (Word16)(tmp + E_ROM_mean_isf[i]);
+ isf_q[i] = (Word16)(isf_q[i] + ((MU * past_isfq[i]) >> 15));
+ past_isfq[i] = tmp;
+ }
+
+ E_LPC_isf_reorder(isf_q, ISF_GAP, ORDER);
+
+ return;
+}
+
+/*
+ * E_LPC_isf_isp_conversion
+ *
+ * Parameters:
+ * isp O: (Q15) isp[m] (range: -1<=val<1)
+ * isf I: (Q15) isf[m] normalized (range: 0.0 <= val <= 0.5)
+ * m I: LPC order
+ *
+ * Function:
+ * Transformation isf to isp
+ *
+ * ISP are immitance spectral pair in cosine domain (-1 to 1).
+ * ISF are immitance spectral pair in frequency domain (0 to 6400).
+ * Returns:
+ * void
+ */
+void E_LPC_isf_isp_conversion(Word16 isf[], Word16 isp[], Word16 m)
+{
+ Word32 i, ind, offset, tmp;
+
+ for (i = 0; i < m - 1; i++)
+ {
+ isp[i] = isf[i];
+ }
+
+ isp[m - 1] = (Word16)(isf[m - 1] << 1);
+
+ for (i = 0; i < m; i++)
+ {
+ ind = isp[i] >> 7; /* ind = b7-b15 of isf[i] */
+ offset = isp[i] & 0x007f; /* offset = b0-b6 of isf[i] */
+
+ /* isp[i] = table[ind]+ ((table[ind+1]-table[ind])*offset) / 128 */
+ tmp = ((E_ROM_cos[ind + 1] - E_ROM_cos[ind]) * offset) << 1;
+ isp[i] = (Word16)(E_ROM_cos[ind] + (tmp >> 8));
+ }
+
+ return;
+}
+
+/*
+ * E_LPC_chebyshev
+ *
+ * Parameters:
+ * x I: value of evaluation; x=cos(freq)
+ * f I: coefficients of sum or diff polynomial
+ * n I: order of polynomial
+ *
+ * Function:
+ * Evaluates the Chebyshev polynomial series
+ *
+ * The polynomial order is n = m/2 (m is the prediction order)
+ * The polynomial is given by
+ * C(x) = f(0)T_n(x) + f(1)T_n-1(x) + ... +f(n-1)T_1(x) + f(n)/2
+ *
+ * Returns:
+ * the value of the polynomial C(x)
+ */
+static Float32 E_LPC_chebyshev(Float32 x, Float32 *f, Word32 n)
+{
+ Float32 b1, b2, b0, x2;
+ Word32 i; /* for the special case of 10th order */
+ /* filter (n=5) */
+ x2 = 2.0F * x; /* x2 = 2.0*x; */
+ b2 = f[0]; /* b2 = f[0]; */
+ b1 = x2 * b2 + f[1]; /* b1 = x2*b2 + f[1]; */
+
+ for (i = 2; i < n; i++)
+ {
+ b0 = x2 * b1 - b2 + f[i]; /* b0 = x2 * b1 - 1. + f[2]; */
+ b2 = b1; /* b2 = x2 * b0 - b1 + f[3]; */
+ b1 = b0; /* b1 = x2 * b2 - b0 + f[4]; */
+ }
+
+ return (x * b1 - b2 + 0.5F * f[n]); /* return (x*b1 - b2 + 0.5*f[5]); */
+}
+/*
+ * E_LPC_isf_sub_vq
+ *
+ * Parameters:
+ * x I/O: unquantised / quantised ISF
+ * dico I: codebook
+ * dim I: dimension of vector
+ * dico_size I: codebook size
+ * distance O: minimum distance
+ *
+ * Function:
+ * Quantization of a subvector of size 2 in Split-VQ of ISFs
+ *
+ * Returns:
+ * quantisation index
+ */
+Word16 E_LPC_isf_sub_vq(Float32 *x, const Float32 *E_ROM_dico, Word32 dim,
+ Word32 E_ROM_dico_size, Float32 *distance)
+{
+ Float32 dist_min, dist, temp;
+ const Float32 *p_E_ROM_dico;
+ Word32 i, j, index = 0;
+
+ dist_min = 1.0e30f;
+ p_E_ROM_dico = E_ROM_dico;
+
+ for (i = 0; i < E_ROM_dico_size; i++)
+ {
+ dist = x[0] - *p_E_ROM_dico++;
+ dist *= dist;
+
+ for (j = 1; j < dim; j++)
+ {
+ temp = x[j] - *p_E_ROM_dico++;
+ dist += temp * temp;
+ }
+
+ if (dist < dist_min)
+ {
+ dist_min = dist;
+ index = i;
+ }
+ }
+
+ *distance = dist_min;
+
+ /* Reading the selected vector */
+ memcpy(x, &E_ROM_dico[index * dim], dim * sizeof(Float32));
+
+ return (Word16)index;
+}
+
+/*
+ * E_LPC_lag_wind
+ *
+ * Parameters:
+ * r I/O: autocorrelations vector
+ * m I: window lenght
+ *
+ * Function:
+ * Lag windowing of the autocorrelations.
+ *
+ * Returns:
+ * void
+ */
+void E_LPC_lag_wind(Float32 r[], Word32 m)
+{
+ Word32 i;
+
+ for (i = 0; i < m; i++)
+ {
+ r[i] *= E_ROM_lag_window[i];
+ }
+
+ return;
+}
+
+/*
+ * E_LPC_lev_dur
+ *
+ * Parameters:
+ * r_h I: vector of autocorrelations (msb)
+ * r_l I: vector of autocorrelations (lsb)
+ * A O: LP coefficients (a[0] = 1.0) (m = 16)
+* rc O: reflection coefficients
+ * mem I/O: static memory
+ *
+ * Function:
+ * Wiener-Levinson-Durbin algorithm to compute
+ * the LPC parameters from the autocorrelations of speech.
+ *
+ * Returns:
+ * void
+ */
+void E_LPC_lev_dur(Float32 *a, Float32 *r, Word32 m)
+{
+ Float32 buf[M];
+ Float32 *rc; /* reflection coefficients 0,...,m-1 */
+ Float32 s, at, err;
+ Word32 i, j, l;
+
+ rc = &buf[0];
+
+ rc[0] = (-r[1]) / r[0];
+ a[0] = 1.0F;
+ a[1] = rc[0];
+ err = r[0] + r[1] * rc[0];
+
+ for (i = 2; i <= m; i++)
+ {
+ s = 0.0F;
+
+ for (j = 0; j < i; j++)
+ {
+ s += r[i - j] * a[j];
+ }
+
+ rc[i - 1]= (-s) / (err);
+
+ for (j = 1; j <= (i >> 1); j++)
+ {
+ l = i - j;
+ at = a[j] + rc[i - 1] * a[l];
+ a[l] += rc[i - 1] * a[j];
+ a[j] = at;
+ }
+
+ a[i] = rc[i - 1];
+ err += rc[i - 1] * s;
+
+ if (err <= 0.0F)
+ {
+ err = 0.01F;
+ }
+ }
+
+ return;
+}
+
+/*
+ * E_LPC_a_isp_conversion
+ *
+ * Parameters:
+ * a I: LP filter coefficients
+ * isp O: Immittance spectral pairs
+ * old_isp I: ISP vector from past frame
+ *
+ * Function:
+ * Compute the ISPs from the LPC coefficients a[] using Chebyshev
+ * polynomials. The found ISPs are in the cosine domain with values
+ * in the range from 1 down to -1.
+ * The table E_ROM_grid[] contains the polongs (in the cosine domain) at
+ * which the polynomials are evaluated.
+ *
+ * The ISPs are the roots of the two polynomials F1(z) and F2(z)
+ * defined as
+ * F1(z) = A(z) + z^-m A(z^-1)
+ * and F2(z) = A(z) - z^-m A(z^-1)
+ *
+ * for a even order m=2n, F1(z) has 5 conjugate roots on the unit circle
+ * and F2(z) has 4 conjugate roots on the unit circle in addition to two
+ * roots at 0 and pi.
+ *
+ * For a 10th order LP analysis, F1(z) and F2(z) can be written as
+ *
+ * F1(z) = (1 + a[10]) PRODUCT (1 - 2 cos(w_i) z^-1 + z^-2 )
+ * i=0,2,4,6,8
+ *
+ * F2(z) = (1 - a[10]) (1 - z^-2) PRODUCT (1 - 2 cos(w_i) z^-1 + z^-2 )
+ * i=1,3,5,7
+ *
+ * The ISPs are the M-1 frequencies w_i, i=0...M-2 plus the last
+ * predictor coefficient a[M].
+ *
+ * Returns:
+ * void
+ */
+void E_LPC_a_isp_conversion(Float32 *a, Float32 *isp, Float32 *old_isp,
+ Word32 m)
+{
+ Float32 f1[(M >> 1) + 1], f2[M >> 1];
+ Float32 *pf;
+ Float32 xlow, ylow, xhigh, yhigh, xmid, ymid, xint;
+ Word32 j, i, nf, ip, order, nc;
+
+ nc = m >> 1;
+
+ /*
+ * 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 < nc; i++)
+ {
+ f1[i] = a[i] + a[m - i];
+ f2[i] = a[i] - a[m - i];
+ }
+
+ f1[nc] = 2.0F * a[nc];
+
+ /* divide by (1 - z^-2) */
+ for (i = 2; i < nc; i++)
+ {
+ f2[i] += f2[i - 2];
+ }
+
+ /*
+ * Find the ISPs (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 E_ROM_grid polongs and check for sign change.
+ * - If sign change track the root by subdividing the Word32erval
+ * 4 times and ckecking sign change.
+ */
+
+ nf=0; /* number of found frequencies */
+ ip=0; /* flag to first polynomial */
+
+ pf = f1; /* start with F1(z) */
+ order = nc;
+
+ xlow = E_ROM_grid[0];
+ ylow = E_LPC_chebyshev(xlow, pf, nc);
+
+ j = 0;
+
+ while ( (nf < m - 1) && (j < NO_POINTS) )
+ {
+ j++;
+ xhigh = xlow;
+ yhigh = ylow;
+ xlow = E_ROM_grid[j];
+ ylow = E_LPC_chebyshev(xlow, pf, order);
+
+ if (ylow * yhigh <= 0.0F) /* if sign change new root exists */
+ {
+ j--;
+
+ /* divide the Word32erval of sign change by NO_ITER */
+
+ for (i = 0; i < NO_ITER; i++)
+ {
+ xmid = 0.5F * (xlow + xhigh);
+ ymid = E_LPC_chebyshev(xmid, pf, order);
+
+ if (ylow * ymid <= 0.0F)
+ {
+ yhigh = ymid;
+ xhigh = xmid;
+ }
+ else
+ {
+ ylow = ymid;
+ xlow = xmid;
+ }
+ }
+
+ /* linear interpolation for evaluating the root */
+
+ xint = xlow - ylow * (xhigh - xlow) / (yhigh - ylow);
+
+ isp[nf] = xint; /* new root */
+ nf++;
+
+ ip = 1 - ip; /* flag to other polynomial */
+ pf = ip ? f2 : f1; /* pointer to other polynomial */
+ order = ip ? (nc - 1) : nc; /* order of other polynomial */
+
+ xlow = xint;
+ ylow = E_LPC_chebyshev(xlow, pf, order);
+ }
+ }
+
+ isp[m - 1] = a[m];
+
+ /*
+ * Check if m-1 roots found
+ * if not use the ISPs from previous frame
+ */
+
+ if (nf < m - 1)
+ {
+ for(i = 0; i < m; i++)
+ {
+ isp[i] = old_isp[i];
+ }
+ }
+
+ 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)
+ * 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(Float32 isp[], Float32 isf[], Word32 m)
+{
+ Word32 i;
+
+ /* convert ISPs to frequency domain 0..6400 */
+ for(i = 0; i < (m - 1); i++)
+ {
+ isf[i] = (Float32)(acos(isp[i]) * SCALE1);
+ }
+
+ isf[m - 1] = (Float32)(acos(isp[m - 1]) * SCALE1 * 0.5F);
+
+ return;
+}
+
+/*
+ * E_LPC_stage1_isf_vq
+ *
+ * Parameters:
+ * x I: ISF residual vector
+ * dico I: quantisation codebook
+ * dim I: dimension of vector
+ * dico_size I: size of quantization codebook
+ * index O: indices of survivors
+ * surv I: number of survivor
+ *
+ * Function:
+ * 1st stage VQ with split-by-2.
+ *
+ * Returns:
+ * void
+ */
+static void E_LPC_stage1_isf_vq(Float32 *x, const Float32 *E_ROM_dico,
+ Word32 dim, Word32 E_ROM_dico_size,
+ Word32 *index, Word32 surv)
+{
+ Float32 dist_min[N_SURV_MAX];
+ Float32 dist, temp1, temp2;
+ const Float32 *p_E_ROM_dico;
+ Word32 i, j, k, l;
+
+ for (i = 0; i < surv; i++)
+ {
+ dist_min[i] = 1.0e30F;
+ }
+
+ for (i = 0; i < surv; i++)
+ {
+ index[i] = i;
+ }
+
+ p_E_ROM_dico = E_ROM_dico;
+
+ for (i = 0; i < E_ROM_dico_size; i++)
+ {
+ dist = x[0] - *p_E_ROM_dico++;
+ dist *= dist;
+
+ for (j = 1; j < dim; j += 2)
+ {
+ temp1 = x[j] - *p_E_ROM_dico++;
+ temp2 = x[j + 1] - *p_E_ROM_dico++;
+ dist += temp1 * temp1 + temp2 * temp2;
+ }
+
+ for (k = 0; k < surv; k++)
+ {
+ if (dist < dist_min[k])
+ {
+ for (l = surv - 1; l > k; l--)
+ {
+ dist_min[l] = dist_min[l - 1];
+ index[l] = index[l - 1];
+ }
+
+ dist_min[k] = dist;
+ index[k] = i;
+
+ break;
+ }
+ }
+ }
+
+ return;
+}
+
+/*
+ * E_LPC_isf_2s3s_quantise
+ *
+ * Parameters:
+ * isf1 I: ISF in the frequency domain (0..6400)
+ * isf_q O: quantized ISF
+ * past_isfq I/O: past ISF quantizer
+ * indice O: quantisation indices (5 words)
+ * nb_surv I: number of survivor (1, 2, 3 or 4)
+ *
+ * Function:
+ * Quantization of isf parameters with prediction. (36 bits)
+ *
+ * The isf vector is quantized using two-stage VQ with split-by-2 in
+ * 1st stage and split-by-3 in the second stage.
+ * Returns:
+ * void
+ */
+void E_LPC_isf_2s3s_quantise(Float32 *isf1, Word16 *isf_q, Word16 *past_isfq,
+ Word32 *indice, Word32 nb_surv)
+{
+ Float32 isf[ORDER], isf_stage2[ORDER];
+ Float32 temp, min_err, distance;
+ Word32 surv1[N_SURV_MAX]; /* indices of survivors from 1st stage */
+ Word32 tmp_ind[5];
+ Word32 i, k;
+
+ for (i = 0; i < ORDER; i++)
+ {
+ isf[i] = (Float32)((isf1[i] - E_ROM_f_mean_isf[i]) -
+ F_MU * past_isfq[i] * 0.390625F);
+ }
+
+ E_LPC_stage1_isf_vq(&isf[0], E_ROM_dico1_isf, 9, SIZE_BK1, surv1, nb_surv);
+
+ distance = 1.0e30F;
+
+ for (k = 0; k < nb_surv; k++)
+ {
+ for (i = 0; i < 9; i++)
+ {
+ isf_stage2[i] = isf[i] - E_ROM_dico1_isf[i + surv1[k] * 9];
+ }
+
+ tmp_ind[0] = E_LPC_isf_sub_vq(&isf_stage2[0], E_ROM_dico21_isf_36b, 5,
+ SIZE_BK21_36b, &min_err);
+ temp = min_err;
+ tmp_ind[1] = E_LPC_isf_sub_vq(&isf_stage2[5], E_ROM_dico22_isf_36b, 4,
+ SIZE_BK22_36b, &min_err);
+ temp += min_err;
+
+ if (temp < distance)
+ {
+ distance = temp;
+ indice[0] = surv1[k];
+
+ for (i = 0; i < 2; i++)
+ {
+ indice[i + 2] = tmp_ind[i];
+ }
+ }
+ }
+
+ E_LPC_stage1_isf_vq(&isf[9], E_ROM_dico2_isf, 7, SIZE_BK2, surv1, nb_surv);
+
+ distance = 1.0e30F;
+
+ for (k = 0; k < nb_surv; k++)
+ {
+ for (i = 0; i < 7; i++)
+ {
+ isf_stage2[i] = isf[9 + i] - E_ROM_dico2_isf[i + surv1[k] * 7];
+ }
+
+ tmp_ind[0] = E_LPC_isf_sub_vq(&isf_stage2[0], E_ROM_dico23_isf_36b, 7,
+ SIZE_BK23_36b, &min_err);
+ temp = min_err;
+
+ if (temp < distance)
+ {
+ distance = temp;
+ indice[1] = surv1[k];
+ indice[4]= tmp_ind[0];
+ }
+ }
+
+ /* decoding the ISF */
+
+ E_LPC_isf_2s3s_decode(indice, isf_q, past_isfq);
+
+ return;
+}
+
+/*
+ * E_LPC_isf_2s5s_quantise
+ *
+ * Parameters:
+ * isf1 I: ISF in the frequency domain (0..6400)
+ * isf_q O: quantized ISF
+ * past_isfq I/O: past ISF quantizer
+ * indice O: quantisation indices (5 words)
+ * nb_surv I: number of survivor (1, 2, 3 or 4)
+ *
+ * Function:
+ * Quantization of isf parameters with prediction. (46 bits)
+ *
+ * The isf vector is quantized using two-stage VQ with split-by-2 in
+ * 1st stage and split-by-5 in the second stage.
+ * Returns:
+ * void
+ */
+void E_LPC_isf_2s5s_quantise(Float32 *isf1, Word16 *isf_q, Word16 *past_isfq,
+ Word32 *indice, Word32 nb_surv)
+{
+ Float32 isf[ORDER], isf_stage2[ORDER];
+ Float32 temp, min_err, distance;
+ Word32 surv1[N_SURV_MAX]; /* indices of survivors from 1st stage */
+ Word32 tmp_ind[5];
+ Word32 i, k;
+
+ for (i=0; i<ORDER; i++)
+ {
+ isf[i] = (Float32)((isf1[i] - E_ROM_f_mean_isf[i]) -
+ F_MU * past_isfq[i] * 0.390625F);
+ }
+
+ E_LPC_stage1_isf_vq(&isf[0], E_ROM_dico1_isf, 9, SIZE_BK1, surv1, nb_surv);
+
+ distance = 1.0e30F;
+
+ for (k = 0; k < nb_surv; k++)
+ {
+ for (i = 0; i < 9; i++)
+ {
+ isf_stage2[i] = isf[i] - E_ROM_dico1_isf[i + surv1[k] * 9];
+ }
+
+ tmp_ind[0] = E_LPC_isf_sub_vq(&isf_stage2[0], E_ROM_dico21_isf, 3,
+ SIZE_BK21, &min_err);
+ temp = min_err;
+ tmp_ind[1] = E_LPC_isf_sub_vq(&isf_stage2[3], E_ROM_dico22_isf, 3,
+ SIZE_BK22, &min_err);
+ temp += min_err;
+ tmp_ind[2] = E_LPC_isf_sub_vq(&isf_stage2[6], E_ROM_dico23_isf, 3,
+ SIZE_BK23, &min_err);
+ temp += min_err;
+
+ if (temp < distance)
+ {
+ distance = temp;
+ indice[0] = surv1[k];
+
+ for (i = 0; i < 3; i++)
+ {
+ indice[i + 2] = tmp_ind[i];
+ }
+ }
+ }
+
+ E_LPC_stage1_isf_vq(&isf[9], E_ROM_dico2_isf, 7, SIZE_BK2, surv1, nb_surv);
+
+ distance = 1.0e30F;
+
+ for (k=0; k<nb_surv; k++)
+ {
+ for (i = 0; i < 7; i++)
+ {
+ isf_stage2[i] = isf[9+i] - E_ROM_dico2_isf[i+surv1[k]*7];
+ }
+
+ tmp_ind[0] = E_LPC_isf_sub_vq(&isf_stage2[0], E_ROM_dico24_isf, 3,
+ SIZE_BK24, &min_err);
+ temp = min_err;
+ tmp_ind[1] = E_LPC_isf_sub_vq(&isf_stage2[3], E_ROM_dico25_isf, 4,
+ SIZE_BK25, &min_err);
+ temp += min_err;
+
+ if (temp < distance)
+ {
+ distance = temp;
+ indice[1] = surv1[k];
+
+ for (i = 0; i < 2; i++)
+ {
+ indice[i + 5]= tmp_ind[i];
+ }
+ }
+ }
+
+ /* decoding the ISFs */
+ E_LPC_isf_2s5s_decode(indice, isf_q, past_isfq);
+
+ return;
+}
+
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_lpc.h b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_lpc.h
new file mode 100644
index 000000000..492c1391c
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_lpc.h
@@ -0,0 +1,32 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef ENC_LPC_H
+#define ENC_LPC_H
+
+#include "typedef.h"
+
+void E_LPC_int_isp_find(Word16 isp_old[], Word16 isp_new[],
+ const Word16 frac[], Word16 Az[]);
+void E_LPC_f_int_isp_find(Float32 isp_old[], Float32 isp_new[], Float32 a[],
+ Word32 nb_subfr, Word32 m);
+void E_LPC_a_weight(Float32 *a, Float32 *ap, Float32 gamma, Word32 m);
+void E_LPC_isf_isp_conversion(Word16 isf[], Word16 isp[], Word16 m);
+Word16 E_LPC_isf_sub_vq(Float32 *x, const Float32 *E_ROM_dico, Word32 dim,
+ Word32 E_ROM_dico_size, Float32 *distance);
+void E_LPC_isp_a_conversion(Word16 isp[], Word16 a[], Word16 m);
+void E_LPC_isp_isf_conversion(Float32 isp[], Float32 isf[], Word32 m);
+void E_LPC_lag_wind(Float32 r[], Word32 m);
+void E_LPC_lev_dur(Float32 *a, Float32 *r, Word32 m);
+void E_LPC_a_isp_conversion(Float32 *a, Float32 *isp, Float32 *old_isp,
+ Word32 m);
+void E_LPC_isf_2s3s_quantise(Float32 *isf1, Word16 *isf_q, Word16 *past_isfq,
+ Word32 *indice, Word32 nb_surv);
+void E_LPC_isf_2s5s_quantise(Float32 *isf1, Word16 *isf_q, Word16 *past_isfq,
+ Word32 *indice, Word32 nb_surv);
+
+
+#endif
+
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_main.c b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_main.c
new file mode 100644
index 000000000..0795cbbbf
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_main.c
@@ -0,0 +1,1416 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#include <stdlib.h>
+#include <memory.h>
+#include <math.h>
+#include <float.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "enc_dtx.h"
+#include "enc_acelp.h"
+#include "enc_lpc.h"
+#include "enc_main.h"
+#include "enc_gain.h"
+#include "enc_util.h"
+
+#ifdef WIN32
+#pragma warning( disable : 4310)
+#endif
+
+#include "typedef.h"
+
+#define MAX_16 (Word16)0x7fff
+#define MIN_16 (Word16)0x8000
+#define Q_MAX 8 /* scaling max for signal */
+#define PREEMPH_FAC 0.68F /* preemphasis factor */
+#define GAMMA1 0.92F /* Weighting factor (numerator) */
+#define TILT_FAC 0.68F /* tilt factor (denominator) */
+#define PIT_MIN 34 /* Minimum pitch lag with resolution 1/4 */
+#define PIT_FR2 128 /* Minimum pitch lag with resolution 1/2 */
+#define PIT_FR1_9b 160 /* Minimum pitch lag with resolution 1 */
+#define PIT_FR1_8b 92 /* Minimum pitch lag with resolution 1 */
+#define PIT_MAX 231 /* Maximum pitch lag */
+#define L_INTERPOL (16+1) /* Length of filter for interpolation */
+#define L_FRAME16k 320 /* Frame size at 16kHz */
+#define L_SUBFR 64 /* Subframe size */
+#define NB_SUBFR 4 /* Number of subframe per frame */
+#define L_FILT 12 /* Delay of up-sampling filter */
+#define L_NEXT 64 /* Overhead in LP analysis */
+#define MODE_7k 0 /* modes */
+#define MODE_9k 1
+#define MODE_12k 2
+#define MODE_14k 3
+#define MODE_16k 4
+#define MODE_18k 5
+#define MODE_20k 6
+#define MODE_23k 7
+#define MODE_24k 8
+#define MRDTX 9
+
+extern const Word16 E_ROM_isp[];
+extern const Word16 E_ROM_isf[];
+extern const Word16 E_ROM_interpol_frac[];
+
+/*
+ * E_MAIN_reset
+ *
+ * Parameters:
+ * st I/O: pointer to state structure
+ * reset_all I: perform full reset
+ *
+ * Function:
+ * Initialisation of variables for the coder section.
+ *
+ *
+ * Returns:
+ * void
+ */
+void E_MAIN_reset(void *st, Word16 reset_all)
+{
+ Word32 i;
+
+ Coder_State *cod_state;
+
+ cod_state = (Coder_State *) st;
+
+ memset(cod_state->mem_exc, 0, (PIT_MAX + L_INTERPOL) * sizeof(Word16));
+ memset(cod_state->mem_isf_q, 0, M * sizeof(Word16));
+ memset(cod_state->mem_syn, 0, M * sizeof(Float32));
+
+ cod_state->mem_w0 = 0.0F;
+ cod_state->mem_tilt_code = 0;
+ cod_state->mem_first_frame = 1;
+
+ E_GAIN_clip_init(cod_state->mem_gp_clip);
+
+ cod_state->mem_gc_threshold = 0.0F;
+
+ if (reset_all != 0)
+ {
+ /* Set static vectors to zero */
+ memset(cod_state->mem_speech, 0, (L_TOTAL - L_FRAME) * sizeof(Float32));
+ memset(cod_state->mem_wsp, 0, (PIT_MAX / OPL_DECIM) * sizeof(Float32));
+ memset(cod_state->mem_decim2, 0, 3 * sizeof(Float32));
+
+ /* routines initialization */
+
+ memset(cod_state->mem_decim, 0, 2 * L_FILT16k * sizeof(Float32));
+ memset(cod_state->mem_sig_in, 0, 4 * sizeof(Float32));
+ E_ACELP_Gain2_Q_init(cod_state->mem_gain_q);
+ memset(cod_state->mem_hf_wsp, 0, 8 * sizeof(Float32));
+
+ /* isp initialization */
+ for (i = 0; i < M - 1; i++)
+ {
+ cod_state->mem_isp[i] =
+ (Float32)cos(3.141592654 * (Float32)(i + 1) / (Float32)M);
+ }
+
+ cod_state->mem_isp[M - 1] = 0.045F;
+ memcpy(cod_state->mem_isp_q, E_ROM_isp, M * sizeof(Word16));
+
+ /* variable initialization */
+ cod_state->mem_preemph = 0.0F;
+ cod_state->mem_wsp_df = 0.0F;
+ cod_state->mem_q = Q_MAX;
+ cod_state->mem_subfr_q[3] = Q_MAX;
+ cod_state->mem_subfr_q[2] = Q_MAX;
+ cod_state->mem_subfr_q[1] = Q_MAX;
+ cod_state->mem_subfr_q[0] = Q_MAX;
+ cod_state->mem_ada_w = 0.0F;
+ cod_state->mem_ol_gain = 0.0F;
+ cod_state->mem_ol_wght_flg = 0;
+
+ for (i = 0; i < 5; i++)
+ {
+ cod_state->mem_ol_lag[i] = 40;
+ }
+
+ cod_state->mem_T0_med = 40;
+ memset(cod_state->mem_hp_wsp, 0,
+ ( ( L_FRAME / 2 ) / OPL_DECIM + ( PIT_MAX / OPL_DECIM ) )
+ * sizeof(Float32) );
+
+ memset(cod_state->mem_syn_hf, 0, M * sizeof(Float32));
+ memset(cod_state->mem_syn2, 0, M * sizeof(Float32));
+
+ memset(cod_state->mem_hp400, 0, 4 * sizeof(Float32));
+ memset(cod_state->mem_sig_out, 0, 4 * sizeof(Float32));
+
+ memset(cod_state->mem_hf, 0, 2 * L_FILT16k * sizeof(Float32));
+ memset(cod_state->mem_hf2, 0, 2 * L_FILT16k * sizeof(Float32));
+ memset(cod_state->mem_hf3, 0, 2 * L_FILT16k * sizeof(Float32));
+
+ memcpy(cod_state->mem_isf, E_ROM_isf, M * sizeof(Float32));
+
+ cod_state->mem_deemph = 0.0F;
+
+ cod_state->mem_seed = 21845;
+ cod_state->mem_gain_alpha = 1.0F;
+ cod_state->mem_vad_hist = 0;
+
+ E_DTX_reset(cod_state->dtx_encSt);
+ E_DTX_vad_reset(cod_state->vadSt);
+ }
+}
+
+/*
+ * E_MAIN_init
+ *
+ * Parameters:
+ * spe_state I/O: pointer to state structure
+ *
+ * Function:
+ * Initialisation of variables for the coder section.
+ * Memory allocation.
+ *
+ * Returns:
+ * void
+ */
+Word16 E_MAIN_init(void **spe_state)
+{
+ Coder_State *st;
+
+ *spe_state = NULL;
+
+ /* allocate memory */
+ if ((st = (Coder_State *) malloc(sizeof(Coder_State))) == NULL)
+ {
+ return(-1);
+ }
+
+ st->vadSt = NULL;
+ st->dtx_encSt = NULL;
+
+ E_DTX_init(&(st->dtx_encSt));
+ E_DTX_vad_init(&(st->vadSt));
+
+ E_MAIN_reset((void *) st, 1);
+
+ *spe_state = (void*)st;
+
+ return(0);
+}
+
+/*
+ * E_MAIN_close
+ *
+ *
+ * Parameters:
+ * spe_state I: pointer to state structure
+ *
+ * Function:
+ * Free coder memory.
+ *
+ *
+ * Returns:
+ * void
+ */
+void E_MAIN_close(void **spe_state)
+{
+ E_DTX_exit(&( ( (Coder_State *)(*spe_state) )->dtx_encSt));
+ E_DTX_vad_exit(&( ( (Coder_State *) (*spe_state) )->vadSt));
+ free(*spe_state);
+
+ return;
+}
+
+/*
+ * E_MAIN_parm_store
+ *
+ * Parameters:
+ * value I: parameter value
+ * prms O: output parameters
+ *
+ * Function:
+ * Store parameter values
+ *
+ * Returns:
+ * void
+ */
+static void E_MAIN_parm_store(Word32 value, Word16 **prms)
+{
+ **prms = (Word16)value;
+ (*prms)++;
+ return;
+}
+
+
+/*
+ * E_MAIN_encode
+ *
+ * Parameters:
+ * mode I: used mode
+ * input_sp I: 320 new speech samples (at 16 kHz)
+ * prms O: output parameters
+ * spe_state B: state structure
+ * allow_dtx I: DTX ON/OFF
+ *
+ * Function:
+ * Main coder routine.
+ *
+ * Returns:
+ * void
+ */
+Word16 E_MAIN_encode(Word16 * mode, Word16 speech16k[], Word16 prms[],
+ void *spe_state, Word16 allow_dtx)
+{
+
+ /* Float32 */
+ Float32 f_speech16k[L_FRAME16k]; /* Speech vector */
+ Float32 f_old_exc[(L_FRAME + 1) + PIT_MAX + L_INTERPOL]; /* Excitation vector */
+ Float32 f_exc2[L_FRAME]; /* excitation vector */
+ Float32 error[M + L_SUBFR]; /* error of quantization */
+ Float32 A[NB_SUBFR * (M + 1)]; /* A(z) unquantized for the 4 subframes */
+ Float32 Aq[NB_SUBFR * (M + 1)]; /* A(z) quantized for the 4 subframes */
+ Float32 xn[L_SUBFR]; /* Target vector for pitch search */
+ Float32 xn2[L_SUBFR]; /* Target vector for codebook search */
+ Float32 dn[L_SUBFR]; /* Correlation between xn2 and h1 */
+ Float32 cn[L_SUBFR]; /* Target vector in residual domain */
+ Float32 h1[L_SUBFR]; /* Impulse response vector */
+ Float32 f_code[L_SUBFR]; /* Fixed codebook excitation */
+ Float32 y1[L_SUBFR]; /* Filtered adaptive excitation */
+ Float32 y2[L_SUBFR]; /* Filtered adaptive excitation */
+ Float32 synth[L_SUBFR]; /* 12.8kHz synthesis vector */
+ Float32 r[M + 1]; /* Autocorrelations of windowed speech */
+ Float32 Ap[M + 1]; /* A(z) with spectral expansion */
+ Float32 ispnew[M]; /* immittance spectral pairs at 4nd sfr */
+ Float32 isf[M]; /* ISF (frequency domain) at 4nd sfr */
+ Float32 g_coeff[5], g_coeff2[2]; /* Correlations */
+ Float32 gain_pit;
+ Float32 f_tmp, gain1, gain2;
+ Float32 stab_fac = 0.0F, fac;
+ Float32 *new_speech, *speech; /* Speech vector */
+ Float32 *wsp; /* Weighted speech vector */
+ Float32 *f_exc; /* Excitation vector */
+ Float32 *p_A, *p_Aq; /* ptr to A(z) for the 4 subframes */
+ Float32 *f_pt_tmp;
+
+ /* Word32 */
+ Word32 indice[8]; /* quantization indices */
+ Word32 vad_flag, clip_gain;
+ Word32 T_op, T_op2, T0, T0_frac;
+ Word32 T0_min, T0_max;
+ Word32 voice_fac, Q_new = 0;
+ Word32 L_gain_code, l_tmp;
+ Word32 i, i_subfr, pit_flag;
+
+ /* Word16 */
+ Word16 exc2[L_FRAME]; /* excitation vector */
+ Word16 s_Aq[NB_SUBFR * (M + 1)]; /* A(z) quantized for the 4 subframes */
+ Word16 s_code[L_SUBFR]; /* Fixed codebook excitation */
+ Word16 ispnew_q[M]; /* quantized ISPs at 4nd subframe */
+ Word16 isfq[M]; /* quantized ISPs */
+ Word16 select, codec_mode;
+ Word16 index;
+ Word16 s_gain_pit, gain_code;
+ Word16 s_tmp, s_max;
+ Word16 corr_gain;
+ Word16 *exc; /* Excitation vector */
+
+ /* Other */
+ Coder_State *st; /* Coder states */
+
+ st = (Coder_State *)spe_state;
+ codec_mode = *mode;
+
+ /*
+ * Initialize pointers to speech vector.
+ *
+ *
+ * |-------|-------|-------|-------|-------|-------|
+ * past sp sf1 sf2 sf3 sf4 L_NEXT
+ * <------- Total speech buffer (L_TOTAL) ------>
+ * old_speech
+ * <------- LPC analysis window (L_WINDOW) ------>
+ * <-- present frame (L_FRAME) ---->
+ * | <----- new speech (L_FRAME) ---->
+ * | |
+ * speech |
+ * new_speech
+ */
+
+ new_speech = st->mem_speech + L_TOTAL - L_FRAME - L_FILT; /* New speech */
+ speech = st->mem_speech + L_TOTAL - L_FRAME - L_NEXT; /* Present frame */
+
+ exc = st->mem_exc + PIT_MAX + L_INTERPOL;
+ f_exc = f_old_exc + PIT_MAX + L_INTERPOL;
+ wsp = st->mem_wsp + (PIT_MAX / OPL_DECIM);
+
+ for(i = 0; i < L_FRAME16k; i++)
+ {
+ f_speech16k[i] = (Float32)speech16k[i];
+ }
+
+ Q_new = -st->mem_q;
+
+ for(i = 0; i < (PIT_MAX + L_INTERPOL); i++)
+ {
+ f_old_exc[i] = (Float32)(st->mem_exc[i] * pow(2, Q_new));
+ }
+
+ /*
+ * Down sampling signal from 16kHz to 12.8kHz
+ */
+ E_UTIL_decim_12k8(f_speech16k, L_FRAME16k, new_speech, st->mem_decim);
+
+ /* decimate with zero-padding to avoid delay of filter */
+ memcpy(f_code, st->mem_decim, 2 * L_FILT16k * sizeof(Float32));
+ memset(error, 0, L_FILT16k * sizeof(Float32));
+
+ E_UTIL_decim_12k8(error, L_FILT16k, new_speech + L_FRAME, f_code);
+
+ /*
+ * Perform 50Hz HP filtering of input signal.
+ * Perform fixed preemphasis through 1 - g z^-1
+ */
+ E_UTIL_hp50_12k8(new_speech, L_FRAME, st->mem_sig_in);
+
+ memcpy(f_code, st->mem_sig_in, 4 * sizeof(Float32) );
+
+ E_UTIL_hp50_12k8(new_speech + L_FRAME, L_FILT, f_code);
+
+ E_UTIL_f_preemph(new_speech, PREEMPH_FAC, L_FRAME, &(st->mem_preemph));
+
+ /* last L_FILT samples for autocorrelation window */
+ f_tmp = st->mem_preemph;
+ E_UTIL_f_preemph(new_speech + L_FRAME, PREEMPH_FAC, L_FILT, &f_tmp);
+
+ /*
+ * Call VAD
+ * Preemphesis scale down signal in low frequency and keep dynamic in HF.
+ * Vad work slightly in futur (new_speech = speech + L_NEXT - L_FILT).
+ */
+
+ vad_flag = E_DTX_vad(st->vadSt, new_speech);
+
+ if (vad_flag == 0)
+ {
+ st->mem_vad_hist = 1;
+ }
+ else
+ {
+ st->mem_vad_hist = 0;
+ }
+
+ /* DTX processing */
+ if (allow_dtx)
+ {
+ /* Note that mode may change here */
+ E_DTX_tx_handler(st->dtx_encSt, vad_flag, mode);
+ }
+ else
+ {
+ E_DTX_reset(st->dtx_encSt);
+ }
+
+ if(*mode != MRDTX)
+ {
+ E_MAIN_parm_store(vad_flag, &prms);
+ }
+
+ /*
+ * Perform LPC analysis
+ * --------------------
+ * - autocorrelation + lag windowing
+ * - Levinson-durbin algorithm to find a[]
+ * - convert a[] to isp[]
+ * - convert isp[] to isf[] for quantization
+ * - quantize and code the isf[]
+ * - convert isf[] to isp[] for interpolation
+ * - find the interpolated isps and convert to a[] for the 4 subframes
+ */
+
+ /* LP analysis centered at 3nd subframe */
+ E_UTIL_autocorr(st->mem_speech, r);
+ E_LPC_lag_wind(r + 1, M); /* Lag windowing */
+
+ E_LPC_lev_dur(A, r, M);
+
+ E_LPC_a_isp_conversion(A, ispnew, st->mem_isp, M); /* From A(z) to isp */
+
+ /* Find the interpolated isps and convert to a[] for all subframes */
+ E_LPC_f_int_isp_find(st->mem_isp, ispnew, A, NB_SUBFR, M);
+
+ /* update isp memory for the next frame */
+ memcpy(st->mem_isp, ispnew, M * sizeof(Float32));
+
+ /* Convert isps to frequency domain 0..6400 */
+ E_LPC_isp_isf_conversion(ispnew, isf, M);
+
+ /* check resonance for pitch clipping algorithm */
+ E_GAIN_clip_isf_test(isf, st->mem_gp_clip);
+
+
+ /*
+ * Perform PITCH_OL analysis
+ * -------------------------
+ * - Find the residual res[] for the whole speech frame
+ * - Find the weighted input speech wsp[] for the whole speech frame
+ * - Find the 2 open-loop pitch estimate
+ * - Set the range for searching closed-loop pitch in 1st subframe
+ */
+
+ p_A = A;
+
+ for (i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR)
+ {
+ E_LPC_a_weight(p_A, Ap, GAMMA1, M);
+
+ E_UTIL_residu(Ap, &speech[i_subfr], &wsp[i_subfr], L_SUBFR);
+
+ p_A += (M + 1);
+ }
+
+ E_UTIL_deemph(wsp, TILT_FAC, L_FRAME, &(st->mem_wsp_df));
+
+ /* decimation of wsp[] to search pitch in LF and to reduce complexity */
+
+ E_GAIN_lp_decim2(wsp, L_FRAME, st->mem_decim2);
+
+ /* Find open loop pitch lag for whole speech frame */
+
+ if (*mode == MODE_7k)
+ {
+ /* Find open loop pitch lag for whole speech frame */
+
+ T_op = E_GAIN_open_loop_search(wsp, PIT_MIN / OPL_DECIM,
+ PIT_MAX / OPL_DECIM, L_FRAME / OPL_DECIM, st->mem_T0_med,
+ &(st->mem_ol_gain), st->mem_hf_wsp, st->mem_hp_wsp,
+ st->mem_ol_wght_flg);
+ }
+ else
+ {
+ /* Find open loop pitch lag for first 1/2 frame */
+
+ T_op = E_GAIN_open_loop_search(wsp, PIT_MIN / OPL_DECIM,
+ PIT_MAX / OPL_DECIM, (L_FRAME / 2) / OPL_DECIM, st->mem_T0_med,
+ &(st->mem_ol_gain), st->mem_hf_wsp, st->mem_hp_wsp,
+ st->mem_ol_wght_flg);
+ }
+
+ if (st->mem_ol_gain > 0.6)
+ {
+ st->mem_T0_med = E_GAIN_olag_median(T_op, st->mem_ol_lag);
+ st->mem_ada_w = 1.0F;
+ }
+ else
+ {
+ st->mem_ada_w = st->mem_ada_w * 0.9F;
+ }
+
+ if (st->mem_ada_w < 0.8)
+ {
+ st->mem_ol_wght_flg = 0;
+ }
+ else
+ {
+ st->mem_ol_wght_flg = 1;
+ }
+
+ E_DTX_pitch_tone_detection(st->vadSt, st->mem_ol_gain);
+
+ T_op *= OPL_DECIM;
+
+ if (*mode != MODE_7k)
+ {
+ /* Find open loop pitch lag for second 1/2 frame */
+ T_op2 = E_GAIN_open_loop_search(wsp + ((L_FRAME / 2) / OPL_DECIM),
+ PIT_MIN / OPL_DECIM, PIT_MAX / OPL_DECIM, (L_FRAME / 2) / OPL_DECIM,
+ st->mem_T0_med, &st->mem_ol_gain, st->mem_hf_wsp, st->mem_hp_wsp,
+ st->mem_ol_wght_flg);
+
+ if (st->mem_ol_gain > 0.6)
+ {
+ st->mem_T0_med = E_GAIN_olag_median(T_op2, st->mem_ol_lag);
+ st->mem_ada_w = 1.0F;
+ }
+ else
+ {
+ st->mem_ada_w = st->mem_ada_w * 0.9F;
+ }
+
+ if (st->mem_ada_w < 0.8)
+ {
+ st->mem_ol_wght_flg = 0;
+ }
+ else
+ {
+ st->mem_ol_wght_flg = 1;
+ }
+
+ E_DTX_pitch_tone_detection(st->vadSt, st->mem_ol_gain);
+
+ T_op2 *= OPL_DECIM;
+ }
+ else
+ {
+ T_op2 = T_op;
+ }
+
+ /*
+ * DTX-CNG
+ */
+ if(*mode == MRDTX)
+ {
+ /* Buffer isf's and energy */
+ E_UTIL_residu(&A[3 * (M + 1)], speech, f_exc, L_FRAME);
+ f_tmp = 0.0;
+
+ for(i = 0; i < L_FRAME; i++)
+ {
+ f_tmp += f_exc[i] * f_exc[i];
+ }
+
+ E_DTX_buffer(st->dtx_encSt, isf, f_tmp, codec_mode);
+
+ /* Quantize and code the isfs */
+ E_DTX_exe(st->dtx_encSt, f_exc2, &prms);
+
+ /* reset speech coder memories */
+ E_MAIN_reset(st, 0);
+
+ /*
+ * Update signal for next frame.
+ * -> save past of speech[] and wsp[].
+ */
+ memcpy(st->mem_speech, &st->mem_speech[L_FRAME],
+ (L_TOTAL - L_FRAME) * sizeof(Float32));
+ memcpy(st->mem_wsp, &st->mem_wsp[L_FRAME / OPL_DECIM],
+ (PIT_MAX / OPL_DECIM) * sizeof(Float32));
+
+ return(0);
+ }
+
+ /*
+ * ACELP
+ */
+
+ /* Quantize and code the isfs */
+
+ if (*mode <= MODE_7k)
+ {
+ E_LPC_isf_2s3s_quantise(isf, isfq, st->mem_isf_q, indice, 4);
+ E_MAIN_parm_store((Word16)indice[0], &prms);
+ E_MAIN_parm_store((Word16)indice[1], &prms);
+ E_MAIN_parm_store((Word16)indice[2], &prms);
+ E_MAIN_parm_store((Word16)indice[3], &prms);
+ E_MAIN_parm_store((Word16)indice[4], &prms);
+ }
+ else
+ {
+ E_LPC_isf_2s5s_quantise(isf, isfq, st->mem_isf_q, indice, 4);
+ E_MAIN_parm_store((Word16)indice[0], &prms);
+ E_MAIN_parm_store((Word16)indice[1], &prms);
+ E_MAIN_parm_store((Word16)indice[2], &prms);
+ E_MAIN_parm_store((Word16)indice[3], &prms);
+ E_MAIN_parm_store((Word16)indice[4], &prms);
+ E_MAIN_parm_store((Word16)indice[5], &prms);
+ E_MAIN_parm_store((Word16)indice[6], &prms);
+ }
+
+ /* Convert isfs to the cosine domain */
+ E_LPC_isf_isp_conversion(isfq, ispnew_q, M);
+
+ if (*mode == MODE_24k)
+ {
+ /* Check stability on isf : distance between old isf and current isf */
+
+ f_tmp = 0.0F;
+ f_pt_tmp = st->mem_isf;
+
+ for (i=0; i < M - 1; i++)
+ {
+ f_tmp += (isf[i] - f_pt_tmp[i]) * (isf[i] - f_pt_tmp[i]);
+ }
+
+ stab_fac = (Float32)(1.25F - (f_tmp / 400000.0F));
+
+ if (stab_fac > 1.0F)
+ {
+ stab_fac = 1.0F;
+ }
+
+ if (stab_fac < 0.0F)
+ {
+ stab_fac = 0.0F;
+ }
+
+ memcpy(f_pt_tmp, isf, M * sizeof(Float32));
+ }
+
+
+ if (st->mem_first_frame == 1)
+ {
+ st->mem_first_frame = 0;
+ memcpy(st->mem_isp_q, ispnew_q, M * sizeof(Word16));
+ }
+
+ /* Find the interpolated isps and convert to a[] for all subframes */
+ E_LPC_int_isp_find(st->mem_isp_q, ispnew_q, E_ROM_interpol_frac, s_Aq);
+
+
+ for (i = 0; i < (NB_SUBFR * (M + 1)); i++)
+ {
+ Aq[i] = s_Aq[i] * 0.000244140625F; /* 1/4096 */
+ }
+
+ /* update isp memory for the next frame */
+ memcpy(st->mem_isp_q, ispnew_q, M * sizeof(Word16));
+
+ /*
+ * Find the best interpolation for quantized ISPs
+ */
+
+ p_Aq = Aq;
+
+ for (i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR)
+ {
+ E_UTIL_residu(p_Aq, &speech[i_subfr], &f_exc[i_subfr], L_SUBFR);
+ p_Aq += (M + 1);
+ }
+
+
+ /* Buffer isf's and energy for dtx on non-speech frame */
+
+ if(vad_flag == 0)
+ {
+ f_tmp = 0.0F;
+
+ for(i = 0; i < L_FRAME; i++)
+ {
+ f_tmp += f_exc[i] * f_exc[i];
+ }
+
+ E_DTX_buffer(st->dtx_encSt, isf, f_tmp, codec_mode);
+ }
+
+ /* range for closed loop pitch search in 1st subframe */
+
+ T0_min = T_op - 8;
+
+ if (T0_min < PIT_MIN)
+ {
+ T0_min = PIT_MIN;
+ }
+
+ T0_max = T0_min + 15;
+
+ if (T0_max > PIT_MAX)
+ {
+ T0_max = PIT_MAX;
+ T0_min = T0_max - 15;
+ }
+
+ /*
+ * Loop for every subframe in the analysis frame
+ * ---------------------------------------------
+ * To find the pitch and innovation parameters. The subframe size is
+ * L_SUBFR and the loop is repeated L_FRAME/L_SUBFR times.
+ * - compute the target signal for pitch search
+ * - compute impulse response of weighted synthesis filter (h1[])
+ * - find the closed-loop pitch parameters
+ * - encode the pitch dealy
+ * - find 2 lt prediction (with / without LP filter for lt pred)
+ * - find 2 pitch gains and choose the best lt prediction.
+ * - find target vector for codebook search
+ * - update the impulse response h1[] for codebook search
+ * - correlation between target vector and impulse response
+ * - codebook search and encoding
+ * - VQ of pitch and codebook gains
+ * - find voicing factor and tilt of code for next subframe.
+ * - update states of weighting filter
+ * - find excitation and synthesis speech
+ */
+
+ p_A = A;
+ p_Aq = Aq;
+
+ for (i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR)
+ {
+ pit_flag = i_subfr;
+
+ if ((i_subfr == (2 * L_SUBFR)) & (*mode > MODE_7k))
+ {
+ pit_flag = 0;
+
+ /* range for closed loop pitch search in 3rd subframe */
+
+ T0_min = T_op2 - 8;
+
+ if (T0_min < PIT_MIN)
+ {
+ T0_min = PIT_MIN;
+ }
+
+ T0_max = T0_min + 15;
+
+ if (T0_max > PIT_MAX)
+ {
+ T0_max = PIT_MAX;
+ T0_min = T0_max - 15;
+ }
+
+ }
+
+ /*
+ *
+ * Find the target vector for pitch search:
+ * ---------------------------------------
+ *
+ * |------| res[n]
+ * speech[n]---| A(z) |--------
+ * |------| | |--------| error[n] |------|
+ * zero -- (-)--| 1/A(z) |-----------| W(z) |-- target
+ * exc |--------| |------|
+ *
+ * Instead of subtracting the zero-input response of filters from
+ * the weighted input speech, the above configuration is used to
+ * compute the target vector.
+ *
+ */
+
+ for (i = 0; i < M; i++)
+ {
+ error[i] = (Float32)(speech[i + i_subfr - 16] - st->mem_syn[i]);
+ }
+
+ E_UTIL_residu(p_Aq, &speech[i_subfr], &f_exc[i_subfr], L_SUBFR);
+
+ E_UTIL_synthesis(p_Aq, &f_exc[i_subfr], error + M, L_SUBFR, error, 0);
+
+ E_LPC_a_weight(p_A, Ap, GAMMA1, M);
+
+ E_UTIL_residu(Ap, error + M, xn, L_SUBFR);
+
+ E_UTIL_deemph(xn, TILT_FAC, L_SUBFR, &(st->mem_w0));
+
+ /*
+ * Find target in residual domain (cn[]) for innovation search.
+ */
+
+ /* first half: xn[] --> cn[] */
+ memset(f_code, 0, M * sizeof(Float32));
+
+ memcpy(f_code + M, xn, (L_SUBFR / 2) * sizeof(Float32));
+
+ f_tmp = 0.0F;
+
+ E_UTIL_f_preemph(f_code + M, TILT_FAC, L_SUBFR / 2, &f_tmp);
+
+ E_LPC_a_weight(p_A, Ap, GAMMA1, M);
+
+ E_UTIL_synthesis(Ap, f_code + M, f_code + M, L_SUBFR / 2, f_code, 0);
+
+ E_UTIL_residu(p_Aq, f_code + M, cn, L_SUBFR / 2);
+
+ /* second half: res[] --> cn[] (approximated and faster) */
+ for(i = (L_SUBFR / 2); i < L_SUBFR; i++)
+ {
+ cn[i] = f_exc[i_subfr + i];
+ }
+
+ /*
+ * Compute impulse response, h1[], of weighted synthesis filter
+ */
+
+ E_LPC_a_weight(p_A, Ap, GAMMA1, M);
+
+ memset(h1, 0, L_SUBFR * sizeof(Float32));
+ memcpy(h1, Ap, (M + 1) * sizeof(Float32));
+ E_UTIL_synthesis(p_Aq, h1, h1, L_SUBFR, h1 + (M + 1), 0);
+
+ f_tmp = 0.0;
+ E_UTIL_deemph(h1, TILT_FAC, L_SUBFR, &f_tmp);
+
+ /*
+ * Closed-loop fractional pitch search
+ */
+
+ /* find closed loop fractional pitch lag */
+
+ if (*mode <= MODE_9k)
+ {
+ T0 = E_GAIN_closed_loop_search(&f_exc[i_subfr], xn, h1,
+ T0_min, T0_max, &T0_frac,
+ pit_flag, PIT_MIN, PIT_FR1_8b);
+
+ /* encode pitch lag */
+
+ if (pit_flag == 0) /* if 1st/3rd subframe */
+ {
+
+ /*
+ * The pitch range for the 1st/3rd subframe is encoded with
+ * 8 bits and is divided as follows:
+ * PIT_MIN to PIT_FR1-1 resolution 1/2 (frac = 0 or 2)
+ * PIT_FR1 to PIT_MAX resolution 1 (frac = 0)
+ */
+ if (T0 < PIT_FR1_8b)
+ {
+ index = (Word16)(T0 * 2 + (T0_frac >> 1) - (PIT_MIN * 2));
+ }
+ else
+ {
+ index = (Word16)(T0 - PIT_FR1_8b + ((PIT_FR1_8b - PIT_MIN) * 2));
+ }
+
+ E_MAIN_parm_store(index, &prms);
+
+ /* find T0_min and T0_max for subframe 2 and 4 */
+
+ T0_min = T0 - 8;
+
+ if (T0_min < PIT_MIN)
+ {
+ T0_min = PIT_MIN;
+ }
+
+ T0_max = T0_min + 15;
+
+ if (T0_max > PIT_MAX)
+ {
+ T0_max = PIT_MAX;
+ T0_min = T0_max - 15;
+ }
+ }
+ else /* if subframe 2 or 4 */
+ {
+ /*
+ * The pitch range for subframe 2 or 4 is encoded with 6 bits:
+ * T0_min to T0_max resolution 1/2 (frac = 0 or 2)
+ */
+ i = T0 - T0_min;
+ index = (Word16)(i * 2 + (T0_frac >> 1));
+
+ E_MAIN_parm_store(index, &prms);
+ }
+ }
+ else
+ {
+ T0 = E_GAIN_closed_loop_search(&f_exc[i_subfr], xn, h1,
+ T0_min, T0_max, &T0_frac,
+ pit_flag, PIT_FR2, PIT_FR1_9b);
+
+ /* encode pitch lag */
+
+ if (pit_flag == 0) /* if 1st/3rd subframe */
+ {
+ /*
+ * The pitch range for the 1st/3rd subframe is encoded with
+ * 9 bits and is divided as follows:
+ * PIT_MIN to PIT_FR2-1 resolution 1/4 (frac = 0,1,2 or 3)
+ * PIT_FR2 to PIT_FR1-1 resolution 1/2 (frac = 0 or 2)
+ * PIT_FR1 to PIT_MAX resolution 1 (frac = 0)
+ */
+ if (T0 < PIT_FR2)
+ {
+ index = (Word16)(T0 * 4 + T0_frac - (PIT_MIN * 4));
+ }
+ else if (T0 < PIT_FR1_9b)
+ {
+ index = (Word16)(T0 * 2 + (T0_frac >> 1) - (PIT_FR2 * 2) + ((PIT_FR2 - PIT_MIN) * 4));
+ }
+ else
+ {
+ index = (Word16)(T0 - PIT_FR1_9b + ((PIT_FR2 - PIT_MIN) * 4) + ((PIT_FR1_9b - PIT_FR2) * 2));
+ }
+
+ E_MAIN_parm_store(index, &prms);
+
+ /* find T0_min and T0_max for subframe 2 and 4 */
+
+ T0_min = T0 - 8;
+
+ if (T0_min < PIT_MIN)
+ {
+ T0_min = PIT_MIN;
+ }
+
+ T0_max = T0_min + 15;
+
+ if (T0_max > PIT_MAX)
+ {
+ T0_max = PIT_MAX;
+ T0_min = T0_max - 15;
+ }
+ }
+ else /* if subframe 2 or 4 */
+ {
+ /*
+ * The pitch range for subframe 2 or 4 is encoded with 6 bits:
+ * T0_min to T0_max resolution 1/4 (frac = 0,1,2 or 3)
+ */
+ i = T0 - T0_min;
+ index = (Word16)(i * 4 + T0_frac);
+
+ E_MAIN_parm_store(index, &prms);
+ }
+ }
+
+ /*
+ * Gain clipping test to avoid unstable synthesis on frame erasure
+ */
+
+ clip_gain = E_GAIN_clip_test(st->mem_gp_clip);
+
+ /*
+ * - find unity gain pitch excitation (adaptive codebook entry)
+ * with fractional interpolation.
+ * - find filtered pitch exc. y1[]=exc[] convolved with h1[])
+ * - compute pitch gain1
+ */
+
+ /* find pitch exitation */
+ E_GAIN_adaptive_codebook_excitation(&exc[i_subfr], (Word16)T0, T0_frac, L_SUBFR + 1);
+
+ if(*mode > MODE_9k)
+ {
+
+ E_UTIL_convolve(&exc[i_subfr], st->mem_q, h1, y1);
+
+ gain1 = E_ACELP_xy1_corr(xn, y1, g_coeff);
+
+ /* clip gain if necessary to avoid problem at decoder */
+ if (clip_gain && (gain1 > 0.95))
+ {
+ gain1 = 0.95f;
+ }
+
+ /* find energy of new target xn2[] */
+ E_ACELP_codebook_target_update(xn, dn, y1, gain1);
+ }
+ else
+ {
+ gain1 = 0.0F;
+ }
+
+ /*
+ * - find pitch excitation filtered by 1st order LP filter.
+ * - find filtered pitch exc. y2[]=exc[] convolved with h1[])
+ * - compute pitch gain2
+ */
+
+ /* find pitch excitation with lp filter */
+ for (i = 0; i < L_SUBFR; i++)
+ {
+ l_tmp = 5898 * exc[i - 1 + i_subfr];
+ l_tmp += 20972 * exc[i + i_subfr];
+ l_tmp += 5898 * exc[i + 1 + i_subfr];
+ s_code[i] = (Word16)((l_tmp + 0x4000) >> 15);
+ }
+
+ E_UTIL_convolve(s_code, st->mem_q, h1, y2);
+
+ gain2 = E_ACELP_xy1_corr(xn, y2, g_coeff2);
+
+ /* clip gain if necessary to avoid problem at decoder */
+ if (clip_gain && (gain2 > 0.95))
+ {
+ gain2 = 0.95F;
+ }
+
+ /* find energy of new target xn2[] */
+ E_ACELP_codebook_target_update(xn, xn2, y2, gain2);
+
+ /*
+ * use the best prediction (minimise quadratic error).
+ */
+
+ select = 0;
+
+ if (*mode > MODE_9k)
+ {
+ f_tmp = 0.0;
+ for (i = 0; i < L_SUBFR; i++)
+ {
+ f_tmp += dn[i] * dn[i];
+ f_tmp -= xn2[i] * xn2[i];
+ }
+
+ if (f_tmp < 0.1)
+ {
+ select = 1;
+ }
+
+ E_MAIN_parm_store(select, &prms);
+ }
+
+ if (select == 0)
+ {
+ /* use the lp filter for pitch excitation prediction */
+ memcpy(&exc[i_subfr], s_code, L_SUBFR * sizeof(Word16));
+ memcpy(y1, y2, L_SUBFR * sizeof(Float32));
+ gain_pit = gain2;
+ g_coeff[0] = g_coeff2[0];
+ g_coeff[1] = g_coeff2[1];
+ }
+ else
+ {
+ /* no filter used for pitch excitation prediction */
+ gain_pit = gain1;
+ memcpy(xn2, dn, L_SUBFR * sizeof(Float32)); /* target vector for codebook search */
+ }
+
+
+ /*
+ * - update target vector for codebook search
+ * - scaling of cn[] to limit dynamic at 12 bits
+ */
+ for (i = 0; i < L_SUBFR; i ++)
+ {
+ cn[i] = (Float32)(cn[i] - gain_pit * exc[i_subfr + i] * pow(2, Q_new));
+ }
+
+ /*
+ * - include fixed-gain pitch contribution into impulse resp. h1[]
+ */
+ f_tmp = 0.0F;
+ E_UTIL_f_preemph(h1, (Float32)(st->mem_tilt_code / 32768.0), L_SUBFR, &f_tmp);
+
+ if (T0_frac > 2)
+ {
+ T0++;
+ }
+
+ E_GAIN_f_pitch_sharpening(h1, T0);
+
+ /*
+ * - Correlation between target xn2[] and impulse response h1[]
+ * - Innovative codebook search
+ */
+ E_ACELP_xh_corr(xn2, dn, h1);
+
+ switch(*mode)
+ {
+ case MODE_7k:
+ E_ACELP_2t(dn, cn, h1, s_code, y2, indice);
+ E_MAIN_parm_store((Word16)indice[0], &prms);
+ break;
+ case MODE_9k:
+ E_ACELP_4t(dn, cn, h1, s_code, y2, 20, *mode, indice);
+ E_MAIN_parm_store((Word16)indice[0], &prms);
+ E_MAIN_parm_store((Word16)indice[1], &prms);
+ E_MAIN_parm_store((Word16)indice[2], &prms);
+ E_MAIN_parm_store((Word16)indice[3], &prms);
+
+ break;
+ case MODE_12k:
+ E_ACELP_4t(dn, cn, h1, s_code, y2, 36, *mode, indice);
+ E_MAIN_parm_store((Word16)indice[0], &prms);
+ E_MAIN_parm_store((Word16)indice[1], &prms);
+ E_MAIN_parm_store((Word16)indice[2], &prms);
+ E_MAIN_parm_store((Word16)indice[3], &prms);
+
+ break;
+ case MODE_14k:
+ E_ACELP_4t(dn, cn, h1, s_code, y2, 44, *mode, indice);
+ E_MAIN_parm_store((Word16)indice[0], &prms);
+ E_MAIN_parm_store((Word16)indice[1], &prms);
+ E_MAIN_parm_store((Word16)indice[2], &prms);
+ E_MAIN_parm_store((Word16)indice[3], &prms);
+
+ break;
+ case MODE_16k:
+ E_ACELP_4t(dn, cn, h1, s_code, y2, 52, *mode, indice);
+ E_MAIN_parm_store((Word16)indice[0], &prms);
+ E_MAIN_parm_store((Word16)indice[1], &prms);
+ E_MAIN_parm_store((Word16)indice[2], &prms);
+ E_MAIN_parm_store((Word16)indice[3], &prms);
+
+ break;
+ case MODE_18k:
+ E_ACELP_4t(dn, cn, h1, s_code, y2, 64, *mode, indice);
+ E_MAIN_parm_store((Word16)indice[0], &prms);
+ E_MAIN_parm_store((Word16)indice[1], &prms);
+ E_MAIN_parm_store((Word16)indice[2], &prms);
+ E_MAIN_parm_store((Word16)indice[3], &prms);
+ E_MAIN_parm_store((Word16)indice[4], &prms);
+ E_MAIN_parm_store((Word16)indice[5], &prms);
+ E_MAIN_parm_store((Word16)indice[6], &prms);
+ E_MAIN_parm_store((Word16)indice[7], &prms);
+
+ break;
+ case MODE_20k:
+ E_ACELP_4t(dn, cn, h1, s_code, y2, 72, *mode, indice);
+ E_MAIN_parm_store((Word16)indice[0], &prms);
+ E_MAIN_parm_store((Word16)indice[1], &prms);
+ E_MAIN_parm_store((Word16)indice[2], &prms);
+ E_MAIN_parm_store((Word16)indice[3], &prms);
+ E_MAIN_parm_store((Word16)indice[4], &prms);
+ E_MAIN_parm_store((Word16)indice[5], &prms);
+ E_MAIN_parm_store((Word16)indice[6], &prms);
+ E_MAIN_parm_store((Word16)indice[7], &prms);
+
+ break;
+ case MODE_23k:
+ case MODE_24k:
+ E_ACELP_4t(dn, cn, h1, s_code, y2, 88, *mode, indice);
+ E_MAIN_parm_store((Word16)indice[0], &prms);
+ E_MAIN_parm_store((Word16)indice[1], &prms);
+ E_MAIN_parm_store((Word16)indice[2], &prms);
+ E_MAIN_parm_store((Word16)indice[3], &prms);
+ E_MAIN_parm_store((Word16)indice[4], &prms);
+ E_MAIN_parm_store((Word16)indice[5], &prms);
+ E_MAIN_parm_store((Word16)indice[6], &prms);
+ E_MAIN_parm_store((Word16)indice[7], &prms);
+ break;
+ default:
+ return -1;
+ }
+
+ /*
+ * - Add the fixed-gain pitch contribution to code[].
+ */
+ s_tmp = 0;
+ E_UTIL_preemph(s_code, st->mem_tilt_code, L_SUBFR, &s_tmp);
+
+ E_GAIN_pitch_sharpening(s_code, (Word16)T0);
+
+ E_ACELP_xy2_corr(xn, y1, y2, g_coeff);
+
+ /*
+ * - Compute the fixed codebook gain
+ * - quantize fixed codebook gain
+ */
+ if (*mode <= MODE_9k)
+ {
+ index = (Word16)E_ACELP_gains_quantise(s_code, 6, gain_pit,
+ &s_gain_pit, &L_gain_code, g_coeff, clip_gain, st->mem_gain_q);
+
+ E_MAIN_parm_store(index, &prms);
+ }
+ else
+ {
+ index = (Word16)E_ACELP_gains_quantise(s_code, 7, gain_pit,
+ &s_gain_pit, &L_gain_code, g_coeff, clip_gain, st->mem_gain_q);
+ E_MAIN_parm_store(index, &prms);
+ }
+
+ /* find best scaling to perform on excitation (Q_new) */
+ s_tmp = st->mem_subfr_q[0];
+ for (i = 1; i < 4; i++)
+ {
+ if (st->mem_subfr_q[i] < s_tmp)
+ {
+ s_tmp = st->mem_subfr_q[i];
+ }
+ }
+
+ /* limit scaling (Q_new) to Q_MAX */
+ if (s_tmp > Q_MAX)
+ {
+ s_tmp = Q_MAX;
+ }
+
+ Q_new = 0;
+ l_tmp = L_gain_code; /* L_gain_code in Q16 */
+
+ while ((l_tmp < 0x08000000L) && (Q_new < s_tmp))
+ {
+ l_tmp = (l_tmp << 1);
+ Q_new = Q_new + 1;
+ }
+
+ if (l_tmp < 0x7FFF7FFF)
+ {
+ /* scaled gain_code with Qnew */
+ gain_code = (Word16)((l_tmp + 0x8000) >> 16);
+ }
+ else
+ {
+ gain_code = 32767;
+ }
+
+ if (Q_new > st->mem_q)
+ {
+ E_UTIL_signal_up_scale(exc + i_subfr - (PIT_MAX + L_INTERPOL),
+ (Word16)(Q_new - st->mem_q));
+ }
+ else
+ {
+ E_UTIL_signal_down_scale(exc + i_subfr - (PIT_MAX + L_INTERPOL),
+ PIT_MAX + L_INTERPOL + L_SUBFR, (Word16)(st->mem_q - Q_new));
+ }
+ st->mem_q = (Word16)Q_new;
+
+ /* test quantized gain of pitch for pitch clipping algorithm */
+ E_GAIN_clip_pit_test((Float32)(s_gain_pit * pow(2, -14)),
+ st->mem_gp_clip);
+
+ /*
+ * Update parameters for the next subframe.
+ * - tilt of code: 0.0 (unvoiced) to 0.5 (voiced)
+ */
+
+ /* find voice factor in Q15 (1=voiced, -1=unvoiced) */
+ memcpy(exc2, &exc[i_subfr], L_SUBFR * sizeof(Word16));
+
+ E_UTIL_signal_down_scale(exc2, L_SUBFR, 3);
+
+ voice_fac = E_GAIN_voice_factor(exc2, -3, s_gain_pit, s_code, gain_code);
+
+ /* tilt of code for next subframe: 0.5=voiced, 0=unvoiced */
+ st->mem_tilt_code = (Word16)((voice_fac >> 2) + 8192);
+
+ /*
+ * - Update filter's memory "mem_w0" for finding the
+ * target vector in the next subframe.
+ * - Find the total excitation
+ * - Find synthesis speech to update mem_syn[].
+ */
+ memcpy(exc2, &exc[i_subfr], L_SUBFR * sizeof(Word16));
+
+ st->mem_w0 = (Float32)((xn[L_SUBFR - 1] -
+ ((s_gain_pit / 16384.0F) * y1[L_SUBFR - 1])) -
+ (gain_code * pow(2, -st->mem_q) * y2[L_SUBFR - 1]));
+
+ if (*mode == MODE_24k)
+ {
+ Q_new = -st->mem_q;
+
+ for (i = 0; i < L_SUBFR; i++)
+ {
+ f_exc2[i_subfr + i] = (Float32)(exc[i_subfr + i] * pow(2, Q_new) * (s_gain_pit / 16384.0F));
+ }
+ }
+
+ s_max = 1;
+ for (i = 0; i < L_SUBFR; i++)
+ {
+ /* code in Q9, gain_pit in Q14 */
+ l_tmp = gain_code * s_code[i];
+ l_tmp = l_tmp << 5;
+ l_tmp += exc[i + i_subfr] * s_gain_pit; /* gain_pit Q14 */
+ l_tmp = (l_tmp + 0x2000) >> 14;
+
+ if ((l_tmp > MIN_16) & (l_tmp < 32768))
+ {
+ exc[i + i_subfr] = (Word16)l_tmp;
+ s_tmp = (Word16)abs(l_tmp);
+
+ if (s_tmp > s_max)
+ {
+ s_max = s_tmp;
+ }
+ }
+ else if (l_tmp > MAX_16)
+ {
+ exc[i + i_subfr] = MAX_16;
+ s_max = MAX_16;
+ }
+ else
+ {
+ exc[i + i_subfr] = MIN_16;
+ s_max = MAX_16;
+ }
+ }
+
+ /* tmp = scaling possible according to max value of excitation */
+ s_tmp = (Word16)((E_UTIL_norm_s(s_max) + st->mem_q) - 1);
+
+ st->mem_subfr_q[3] = st->mem_subfr_q[2];
+ st->mem_subfr_q[2] = st->mem_subfr_q[1];
+ st->mem_subfr_q[1] = st->mem_subfr_q[0];
+ st->mem_subfr_q[0] = s_tmp;
+
+ Q_new = -st->mem_q;
+
+ for (i = 0; i < L_SUBFR; i++)
+ {
+ f_exc[i + i_subfr] = (Float32)(exc[i + i_subfr] * pow(2, Q_new));
+ }
+
+ E_UTIL_synthesis(p_Aq, &f_exc[i_subfr], synth, L_SUBFR, st->mem_syn, 1);
+
+ if(*mode >= MODE_24k)
+ {
+ /*
+ * 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.
+ */
+
+ /* 1=unvoiced, 0=voiced */
+ f_tmp = (Float32)(0.5 * (1.0 - (voice_fac / 32768.0)));
+ fac = stab_fac * f_tmp;
+ f_tmp = (Float32)(gain_code * pow(2, -st->mem_q));
+
+ if(f_tmp < st->mem_gc_threshold)
+ {
+ f_tmp = (Float32)(f_tmp * 1.19);
+
+ if(f_tmp > st->mem_gc_threshold)
+ {
+ f_tmp = st->mem_gc_threshold;
+ }
+ }
+ else
+ {
+ f_tmp = (Float32)(f_tmp / 1.19);
+
+ if(f_tmp < st->mem_gc_threshold)
+ {
+ f_tmp = st->mem_gc_threshold;
+ }
+ }
+
+ st->mem_gc_threshold = f_tmp;
+ f_tmp = (Float32)(((fac * f_tmp) + ((1.0 - fac) *
+ (gain_code * pow(2, -st->mem_q)))) * 0.001953125F);
+
+ for(i = 0; i < L_SUBFR; i++)
+ {
+ f_code[i] = (Float32)(s_code[i] * f_tmp);
+ }
+
+ /*
+ * pitch enhancer
+ * --------------
+ * - Enhance excitation on voice. (HP filtering of code)
+ * On voiced signal, filtering of code by a smooth fir HP
+ * filter to decrease energy of code in low frequency.
+ */
+
+ /* 0.25=voiced, 0=unvoiced */
+ f_tmp = (Float32)(0.125F * (1.0F + (voice_fac / 32768.0)));
+
+ f_exc2[i_subfr] += f_code[0] - (f_tmp * f_code[1]);
+
+ for(i = 1; i < L_SUBFR - 1; i++)
+ {
+ f_exc2[i + i_subfr] +=
+ f_code[i] - (f_tmp * f_code[i - 1]) - (f_tmp * f_code[i + 1]);
+ }
+
+ f_exc2[i_subfr + L_SUBFR - 1] +=
+ f_code[L_SUBFR - 1] - (f_tmp * f_code[L_SUBFR - 2]);
+
+ corr_gain = (Word16)E_UTIL_enc_synthesis(p_Aq, &f_exc2[i_subfr],
+ &f_speech16k[i_subfr * 5 /4], st);
+
+ E_MAIN_parm_store(corr_gain, &prms);
+ }
+
+ p_A += (M + 1);
+ p_Aq += (M + 1);
+ } /* end of subframe loop */
+
+ /*
+ * Update signal for next frame.
+ * -> save past of speech[], wsp[] and exc[].
+ */
+
+ memmove(st->mem_speech, &st->mem_speech[L_FRAME], (L_TOTAL - L_FRAME) * sizeof(Float32));
+ memmove(st->mem_wsp, &st->mem_wsp[L_FRAME / OPL_DECIM], (PIT_MAX / OPL_DECIM) * sizeof(Float32));
+ memmove(st->mem_exc, &st->mem_exc[L_FRAME], (PIT_MAX + L_INTERPOL) * sizeof(Word16));
+
+ return 0;
+}
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_main.h b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_main.h
new file mode 100644
index 000000000..26b14fb58
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_main.h
@@ -0,0 +1,75 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef ENC_MAIN_H
+#define ENC_MAIN_H
+
+#include "typedef.h"
+#include "enc_dtx.h"
+
+#define L_FRAME 256 /* Frame size */
+#define L_TOTAL 384 /* Total size of speech buffer. */
+#define L_FILT16k 15 /* Delay of down-sampling filter */
+#define PIT_MAX 231 /* Maximum pitch lag */
+#define OPL_DECIM 2 /* Decimation in open-loop pitch analysis */
+#define L_INTERPOL (16+1) /* Length of filter for interpolation */
+
+typedef struct
+{
+ /* Float32 */
+ Float32 mem_speech[L_TOTAL]; /* old speech vector at 12.8kHz */
+ Float32 mem_wsp[L_FRAME + PIT_MAX / OPL_DECIM]; /* old decimated weighted */
+ /* speech vector */
+ Float32 mem_hp_wsp[L_FRAME / OPL_DECIM + (PIT_MAX / OPL_DECIM)];
+ Float32 mem_decim[2 * L_FILT16k]; /* speech decimated filter memory */
+ Float32 mem_hf[2 * L_FILT16k]; /* HF band-pass filter memory */
+ Float32 mem_hf2[2 * L_FILT16k]; /* HF band-pass filter memory */
+ Float32 mem_hf3[2 * L_FILT16k]; /* HF band-pass filter memory */
+ Float32 mem_isp[M]; /* old isp (immittance spectral pairs)*/
+ Float32 mem_syn[M]; /* synthesis memory */
+ Float32 mem_syn2[M]; /* modified synthesis memory */
+ Float32 mem_syn_hf[M]; /* HF synthesis memory */
+ Float32 mem_isf[M]; /* old isf (frequency domain) */
+ Float32 mem_hf_wsp[9]; /* Open-loop lag gain filter memory */
+ Float32 mem_sig_in[4]; /* hp50 filter memory */
+ Float32 mem_sig_out[4]; /* hp50 filter memory for synthesis */
+ Float32 mem_hp400[4]; /* hp400 filter memory for synthesis */
+ Float32 mem_decim2[3]; /* wsp decimation filter memory */
+ Float32 mem_gp_clip[2]; /* gain of pitch clipping memory */
+ Float32 mem_preemph; /* speech preemph filter memory */
+ Float32 mem_deemph; /* speech deemph filter memory */
+ Float32 mem_wsp_df; /* Open-loop LTP deemph filter memory */
+ Float32 mem_w0; /* target vector memory */
+ Float32 mem_ol_gain; /* Open-loop gain */
+ Float32 mem_ada_w; /* weighting level */
+ Float32 mem_gc_threshold; /* threshold for noise enhancer */
+ Float32 mem_gain_alpha; /* Higher band gain weighting factor */
+
+ /* Word32 */
+ Word32 mem_ol_lag[5]; /* Open loop lag history */
+ Word32 mem_T0_med; /* weighted open loop pitch lag */
+
+ /* Word16 */
+ Word16 mem_exc[(L_FRAME + 1) + PIT_MAX + L_INTERPOL];
+ /* old excitation vector */
+ Word16 mem_isp_q[M]; /* quantized old isp */
+ Word16 mem_isf_q[M]; /* past isf quantizer */
+ Word16 mem_gain_q[4]; /* gain quantizer memory */
+ Word16 mem_subfr_q[4]; /* old maximum scaling factor */
+ Word16 mem_tilt_code; /* tilt of code */
+ Word16 mem_q; /* old scaling factor */
+ Word16 mem_seed; /* random memory for HF generation */
+
+ /* other */
+ E_DTX_Vad_State *vadSt;
+ E_DTX_State *dtx_encSt;
+ UWord8 mem_first_frame; /* First frame indicator */
+ UWord8 mem_ol_wght_flg; /* switches lag weighting on and off */
+ UWord8 mem_vad_hist; /* VAD history */
+
+} Coder_State;
+
+#endif
+
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_rom.c b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_rom.c
new file mode 100644
index 000000000..b83ff53a5
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_rom.c
@@ -0,0 +1,2357 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#include "typedef.h"
+
+#define L_SUBFR 64 /* Subframe size */
+#define ORDER 16 /* Order of linear prediction filter */
+#define M 16 /* Order of LP filter */
+#define NB_SUBFR 4 /* Number of subframe per frame */
+#define UP_SAMP 4
+#define L_INTERPOL1 4
+#define L_INTERPOL2 16
+#define L_WINDOW 384 /* hamming cos window size */
+#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 SIZE_BK_NOISE1 64
+#define SIZE_BK_NOISE2 64
+#define SIZE_BK_NOISE3 64
+#define SIZE_BK_NOISE4 32
+#define SIZE_BK_NOISE5 32
+#define NB_QUA_GAIN6B 64 /* Number of quantization level */
+#define NB_QUA_GAIN7B 128 /* Number of quantization level */
+
+/* 16-byte align start */
+
+/*
+ * isf codebooks: two-stage VQ with split-by-5 in 2nd stage
+ *
+ * codebook vector dimension number of vectors
+ * ~~~~~~~~ ~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
+ * 1_1 9 256
+ * 1_2 7 256
+ * 2_1 3 64
+ * 2_2 3 128
+ * 2_3 3 128
+ * 2_4 3 32
+ * 2_5 4 32
+ */
+
+/*
+ * 1st stage codebook; 1st split: isf0 to isf8
+ */
+const Float32 E_ROM_dico1_isf[SIZE_BK1 * 9] = {
+ 226.1477F, 422.2338F, 404.4563F, 152.3442F, 1.2553F, -102.5648F, -77.5073F, -32.1403F, 14.9134F,
+ 6.9890F, -26.5711F, -4.8001F, 122.2654F, 297.4533F, 158.0168F, 97.1963F, 43.4786F, -29.4927F,
+ 289.1461F, 493.4574F, 504.5048F, 393.1421F, 389.3840F, 397.8990F, 397.4072F, 381.0959F, 360.5083F,
+ -35.6482F, 323.0566F, 370.2882F, 252.9499F, 239.6172F, 209.0563F, 203.9713F, 191.4865F, 164.6219F,
+ 16.1026F, -17.1264F, -109.6817F, -184.2085F, 254.5133F, 208.7087F, 75.3774F, 52.8718F, -35.2364F,
+ 15.8336F, -47.0775F, -139.1713F, -23.5561F, 259.0049F, 120.0214F, 23.8825F, -18.5948F, -134.3813F,
+ 217.4017F, 369.5988F, 409.6801F, 338.5433F, 330.4056F, 386.7012F, 434.5276F, 492.7760F, 484.6164F,
+ -46.1429F, -79.6218F, 128.1106F, 199.9543F, 339.7710F, 309.8338F, 238.4430F, 156.8895F, 72.7742F,
+ 61.1308F, 114.6106F, 28.7939F, -131.9070F, -185.5015F, -350.3943F, -232.0556F, -62.9803F, -194.0513F,
+ 88.2757F, 51.2294F, -53.9555F, 120.0698F, 65.9863F, -105.8813F, -64.0929F, -151.0651F, -243.7652F,
+ 24.1201F, -12.6302F, -23.7808F, -98.2577F, -211.1396F, -323.5447F, -401.0499F, -204.4768F, -258.4671F,
+ 39.7202F, -23.9607F, 55.2442F, 43.6804F, -105.4100F, -97.8749F, -211.3002F, 9.7097F, -58.7138F,
+ 2.1766F, -51.7480F, -138.9340F, -268.1601F, -37.5098F, -125.8675F, -203.7929F, -12.2603F, -127.2472F,
+ -14.0622F, -81.7822F, -203.4806F, -89.5766F, 119.8931F, -51.7010F, -2.1055F, -38.5536F, -149.8808F,
+ 23.6196F, -19.7370F, -92.7527F, -260.9933F, -380.1402F, -158.8319F, -276.5396F, -29.3644F, -67.0346F,
+ 10.0869F, -54.0238F, -104.0772F, 43.4993F, -118.0066F, 16.7674F, -108.4172F, -138.9907F, -140.3299F,
+ 222.5364F, 321.1411F, 193.8368F, -60.0340F, -121.7460F, -35.9078F, 53.6514F, 109.0639F, 145.0366F,
+ -57.1173F, 143.6362F, 159.6491F, 26.6189F, 2.3305F, 30.0608F, 65.3329F, 78.8683F, 63.4622F,
+ 247.1436F, 350.7171F, 389.0685F, 295.2953F, 258.6614F, 266.7955F, 305.9202F, 355.1905F, 389.1698F,
+ -40.0882F, 114.6876F, 237.0104F, 161.9769F, 188.5636F, 180.3751F, 187.4189F, 168.3521F, 159.5175F,
+ -46.7654F, -132.1011F, -238.9261F, -204.8685F, 228.1911F, 129.1599F, 36.0960F, 169.1651F, 107.7902F,
+ -69.5087F, -114.5055F, -60.0494F, -15.9078F, 105.1520F, 39.1060F, -3.6140F, 83.1345F, 62.4498F,
+ 324.4036F, 287.6214F, 108.7328F, 320.4871F, 489.7306F, 267.9902F, 278.2168F, 405.7287F, 184.7344F,
+ -85.2571F, -118.8197F, 180.9905F, 177.4239F, 154.8864F, 106.5995F, 78.7528F, 111.5907F, 106.4840F,
+ -90.5891F, 2.5823F, 2.5231F, -151.4854F, -184.4761F, -166.9757F, -147.6148F, -65.2055F, -39.1239F,
+ -114.9974F, -71.3698F, 52.3087F, -18.1814F, 39.4264F, -34.2483F, -32.8691F, -45.8165F, -1.2029F,
+ 22.1063F, 6.7469F, -79.0146F, -247.7831F, -386.2835F, -437.2287F, -208.2931F, 68.6375F, -14.1447F,
+ 46.7840F, -11.0692F, 9.1612F, 43.4278F, -124.5574F, 124.1172F, -8.5368F, -30.1898F, 103.7909F,
+ -105.9007F, -181.3862F, -169.7189F, -257.0920F, -250.0032F, -150.2815F, -150.4918F, -38.5650F, -26.7658F,
+ -77.3138F, -101.1008F, -103.9903F, -17.1337F, -15.2577F, -54.2134F, -53.5373F, 66.9219F, 25.6872F,
+ 3.6265F, -56.7222F, -147.2143F, -330.5455F, -390.5518F, -43.3139F, -126.9112F, 133.5488F, 52.7399F,
+ -31.5816F, -111.6706F, -148.4743F, 75.1588F, -22.0969F, 119.9764F, 29.6891F, -9.5309F, -54.7378F,
+ 264.5383F, 274.1302F, 96.5690F, 21.7008F, 97.2691F, 55.1255F, -40.9705F, -92.2272F, -38.6482F,
+ 13.8969F, -15.1538F, -27.1357F, 135.8413F, 77.4989F, -36.1739F, 125.8114F, 35.5744F, -28.2436F,
+ 196.2991F, 345.8166F, 588.9347F, 510.5197F, 500.8432F, 457.6244F, 436.9384F, 472.1788F, 414.4815F,
+ 162.4519F, 280.7038F, 386.4482F, 479.3623F, 390.8287F, 411.1292F, 372.5701F, 289.3485F, 407.8594F,
+ -49.5343F, -147.0080F, -256.8338F, 54.1618F, 243.5530F, 87.1110F, 195.7264F, 119.5070F, 85.9479F,
+ -43.9641F, -150.1866F, -310.9041F, 196.7455F, 171.2780F, 33.0834F, 83.3645F, -32.4579F, -75.7126F,
+ 228.4330F, 442.3277F, 481.6548F, 426.3000F, 487.1132F, 559.8019F, 590.4699F, 565.5949F, 513.3911F,
+ -68.0544F, -164.7799F, 2.8141F, 451.2739F, 425.3554F, 461.7245F, 391.6532F, 369.1004F, 314.9413F,
+ 3.2743F, -49.3561F, -123.9568F, -40.1754F, -137.2377F, -271.6588F, -38.4305F, -104.5226F, -209.8071F,
+ 12.8092F, -40.2922F, -113.2953F, 65.4057F, -15.2443F, -159.0118F, 17.0998F, -81.3044F, -146.3446F,
+ 40.4305F, -8.9102F, -24.9719F, -113.7701F, -248.7160F, -332.5068F, -423.4328F, -23.8073F, -43.9266F,
+ -29.4866F, -119.6504F, -169.5775F, 85.2585F, -57.7724F, -138.3062F, -265.4940F, -52.0935F, -84.4635F,
+ -47.3285F, -147.4516F, -280.5169F, -38.0164F, -50.7237F, -141.1316F, -60.9737F, -147.8608F, -233.9212F,
+ -22.0146F, -99.1479F, -228.8716F, 91.6618F, 61.1343F, -83.5247F, 4.2834F, -101.7035F, -58.0283F,
+ -48.6094F, -104.2664F, -155.2664F, -226.4858F, -231.7223F, -205.7180F, -314.6280F, -150.3995F, 135.1819F,
+ -75.2552F, -171.9896F, -276.5969F, -137.0060F, -55.2086F, -99.5797F, -195.1097F, -57.2647F, -72.3255F,
+ 174.9245F, 258.0028F, 192.8297F, 81.3562F, 198.8450F, 180.2081F, 132.0824F, 113.5126F, 58.1412F,
+ -87.2559F, 34.2946F, 130.7081F, 62.1078F, 82.7816F, 74.4854F, 111.6818F, 120.3099F, 80.1334F,
+ -11.9671F, 183.3834F, 313.7754F, 257.2813F, 241.7612F, 256.9710F, 329.4492F, 385.5374F, 434.7875F,
+ -66.8195F, -94.6890F, 200.6887F, 141.3063F, 115.2635F, 204.7280F, 215.7973F, 270.9673F, 228.4647F,
+ -24.9070F, -120.1441F, -175.1481F, -8.0896F, 110.9215F, 307.0280F, 174.2457F, 112.7169F, 35.9639F,
+ -85.1717F, -152.2496F, -2.5803F, 66.0904F, 80.5138F, 128.8919F, 137.5303F, 159.4245F, 139.7766F,
+ -14.1396F, 274.4125F, 374.6268F, 335.3957F, 336.4666F, 435.5791F, 495.5083F, 529.9642F, 509.9389F,
+ -51.7794F, -133.3125F, -25.4473F, 264.8054F, 162.9175F, 171.9332F, 189.6735F, 202.1561F, 304.5228F,
+ 12.7820F, -17.2653F, -74.5083F, -134.5510F, -180.1133F, -294.9349F, -78.6120F, 84.8225F, -12.0772F,
+ -137.7282F, -213.7303F, -17.3509F, 48.2225F, -23.9524F, -26.4293F, -30.7054F, 11.1575F, 23.4229F,
+ 28.3886F, -22.3550F, -158.4269F, -299.3692F, -485.7126F, -469.8884F, 93.8213F, 156.3351F, 64.4156F,
+ -28.7029F, -110.1881F, -234.8032F, -83.3735F, -66.7772F, -146.3531F, 129.8178F, 13.7979F, -40.1959F,
+ -11.2220F, -81.0542F, -215.8795F, -186.0052F, -249.1487F, -354.7951F, 67.0249F, -8.7287F, -52.7080F,
+ -75.1895F, -93.5102F, -63.8842F, -40.2971F, -43.3423F, -18.3122F, 59.9384F, 48.9469F, 42.9198F,
+ -0.3036F, -79.3921F, -222.4614F, -402.4193F, -556.4007F, -208.9512F, 60.4822F, 0.2592F, 57.2596F,
+ -130.2469F, -254.9911F, -337.7263F, -76.9102F, -61.5888F, -8.3782F, -17.2822F, 37.1637F, 42.0772F,
+ 151.9460F, 229.6417F, 191.5279F, 12.9809F, -92.7110F, -204.7091F, -245.2630F, -53.2589F, -101.3680F,
+ 15.8084F, -69.0148F, -180.2926F, 176.9411F, 336.6405F, 148.3504F, 51.2260F, -50.6708F, -158.2893F,
+ 328.7315F, 655.2856F, 719.0299F, 605.1412F, 575.6907F, 490.5742F, 422.8277F, 353.4364F, 289.8675F,
+ 144.5240F, 474.8398F, 690.7612F, 638.0545F, 473.3627F, 248.6244F, 8.4810F, -128.9032F, 27.8837F,
+ -29.8052F, -109.6768F, -289.4402F, -289.9344F, 350.9098F, 241.8981F, 108.0220F, 27.7568F, -86.8368F,
+ -12.5998F, -103.5273F, -217.2510F, -9.8401F, 388.4400F, 266.5437F, 118.9818F, 49.1643F, -64.3603F,
+ 28.5445F, 288.4229F, 348.8730F, 378.0052F, 387.8595F, 690.6161F, 887.8799F, 718.7092F, 543.2699F,
+ -27.0127F, -136.3472F, -228.6534F, 91.4073F, 452.4637F, 352.8853F, 244.5759F, 199.3164F, 97.9452F,
+ -0.2574F, -38.8124F, -106.0784F, -81.9691F, -235.3859F, -136.9961F, -210.8024F, -316.9619F, -149.7671F,
+ -6.3268F, -89.9384F, -197.0412F, 160.1820F, 58.3899F, -80.1867F, -134.0614F, -254.4108F, -249.4793F,
+ 40.1439F, -3.4822F, -88.7857F, -80.2522F, -219.3521F, -305.1500F, -421.5967F, -471.9935F, -60.7522F,
+ 55.8529F, 24.5260F, -52.9174F, -26.1113F, -123.8744F, -235.0002F, -306.0707F, -450.7246F, -249.8812F,
+ -56.2297F, -152.7118F, -263.1169F, -243.0294F, -78.2260F, -99.3225F, -257.7953F, -369.9445F, -154.2971F,
+ -15.4570F, -97.8124F, -244.1879F, 10.4628F, 212.1971F, 36.6411F, -51.0200F, -150.9477F, -262.8206F,
+ -47.9169F, -145.0780F, -295.8412F, -176.3119F, -220.4176F, -239.8767F, -162.2583F, -277.5646F, -13.5098F,
+ -45.4312F, -120.7871F, -231.7391F, -104.6837F, 93.3399F, -13.0435F, -131.8873F, -253.9684F, -52.8010F,
+ 36.7261F, 97.8902F, 216.2452F, 22.2667F, -121.9688F, -165.2371F, -60.1795F, -22.1111F, 91.7368F,
+ -104.8126F, -27.6777F, 148.6412F, 44.3956F, -17.0786F, -34.0943F, 48.6552F, 67.5896F, 52.1341F,
+ 590.8627F, 669.3461F, 483.5975F, 208.4471F, 107.7190F, 123.1392F, 179.9797F, 179.2124F, 198.5541F,
+ -51.3512F, -7.3050F, 448.6575F, 261.8456F, 189.7417F, 139.0593F, 120.8041F, 144.0752F, 115.5179F,
+ -87.2434F, -195.6786F, -351.1762F, -282.1990F, -27.3961F, 2.1866F, 51.0065F, 120.9792F, 154.0704F,
+ -38.7878F, -118.5436F, -201.9035F, 97.1421F, 24.9785F, -20.8748F, 52.5830F, -4.3230F, 177.0334F,
+ -57.4864F, -155.8205F, -285.0674F, -156.5139F, 319.0307F, 288.4199F, 313.3522F, 292.7644F, 224.7193F,
+ -60.1766F, -170.1086F, -288.5482F, 312.6666F, 231.6275F, 142.7810F, 206.6260F, 124.0985F, 127.5073F,
+ -87.3474F, 17.7221F, -15.2086F, -151.2513F, -201.3116F, -202.2629F, -237.4979F, -150.1082F, -125.3288F,
+ -123.1549F, -147.2588F, 55.9560F, -39.6018F, -44.1818F, -147.1130F, -69.1241F, -56.1722F, -4.4924F,
+ 45.5201F, 15.5222F, -93.3382F, -254.1893F, -410.5618F, -226.8515F, -287.7839F, -386.6172F, -128.1340F,
+ 10.1233F, -19.6005F, -61.5127F, -8.8349F, -177.1218F, -110.5849F, -207.5041F, -213.2586F, 74.8075F,
+ -98.2741F, -195.7624F, -290.1091F, -230.1600F, -244.7515F, -194.7701F, -128.1076F, -46.1729F, -28.2903F,
+ -126.3800F, -193.1177F, -95.3231F, -119.6219F, -56.1586F, -69.0881F, -102.1922F, -52.5595F, -30.4027F,
+ -13.9604F, -91.5188F, -202.7529F, -375.3352F, -503.8488F, -122.5019F, -187.2047F, -144.9473F, -17.6464F,
+ -37.1158F, -113.9219F, -208.9531F, -3.1283F, -117.0010F, 43.6858F, -64.0984F, -108.2942F, 77.5131F,
+ -38.6401F, -49.9736F, 343.9084F, 326.3879F, 226.1680F, 136.9212F, 9.0736F, -37.1756F, -84.7974F,
+ -10.5004F, -100.6890F, 48.4106F, 394.7867F, 233.0419F, 165.9509F, 56.3291F, 2.7924F, -28.5845F,
+ 164.3221F, 505.0226F, 640.4844F, 633.9930F, 680.5828F, 631.7908F, 585.4574F, 501.5025F, 393.1295F,
+ -37.0300F, 293.6539F, 656.3401F, 612.9729F, 632.0821F, 560.9024F, 468.8401F, 382.9867F, 278.2211F,
+ -26.9959F, -117.0381F, -266.9459F, -169.9414F, 442.3678F, 351.1593F, 196.7216F, 129.6217F, 42.5401F,
+ -28.9160F, -126.1295F, -248.8180F, 219.9974F, 419.6462F, 237.5276F, 144.8018F, 41.0794F, -19.0438F,
+ -30.6524F, 324.5342F, 466.4269F, 433.6403F, 538.3355F, 578.5025F, 582.9940F, 533.2873F, 475.3817F,
+ -101.0867F, -47.3945F, 562.3863F, 521.2437F, 635.9947F, 581.9960F, 561.7294F, 477.7560F, 364.4759F,
+ -32.1078F, -119.5424F, -239.6324F, -86.9073F, -147.6602F, -263.4799F, -212.9377F, -261.9229F, -330.2635F,
+ 20.8260F, -48.5704F, -135.4246F, 164.8506F, 20.4817F, -48.8885F, -105.4348F, -206.6621F, 3.6375F,
+ 30.9311F, -34.7599F, -124.8998F, -258.7565F, -390.0532F, -468.4556F, -485.3543F, -264.1984F, -115.9895F,
+ -26.5921F, -106.6166F, -238.7686F, 53.4977F, -56.8913F, -155.1848F, -245.0791F, -329.9394F, -85.9503F,
+ -43.8040F, -135.2615F, -311.2635F, -322.8195F, 91.5184F, -51.5741F, -73.3097F, -108.7735F, -204.0501F,
+ -61.9589F, -158.0212F, -286.8211F, -163.7011F, 114.5577F, 29.0545F, -65.0919F, -65.1646F, 71.9506F,
+ -59.8760F, -170.6047F, -325.2270F, -421.8182F, -131.3054F, -184.2594F, -219.1312F, -132.9352F, -98.8301F,
+ -65.8626F, -165.1987F, -320.2537F, -353.1492F, -51.0331F, -7.3456F, -135.3074F, -235.8573F, 12.1485F,
+ 12.8460F, -11.9241F, 121.7405F, 24.2470F, -57.8971F, 19.1365F, -23.0243F, 220.3897F, 189.9156F,
+ -119.6102F, -129.9914F, 75.9549F, -17.3359F, 26.2798F, 28.0181F, 57.3185F, 79.8925F, 95.0199F,
+ -81.0524F, -19.0879F, 531.3251F, 384.0082F, 378.6000F, 387.1200F, 396.1896F, 433.4382F, 379.9696F,
+ -82.3204F, -67.1148F, 345.0646F, 244.9884F, 277.8043F, 263.1406F, 275.4622F, 311.7924F, 291.4141F,
+ -34.2889F, -127.1388F, -298.1820F, -380.4511F, 268.4245F, 354.6007F, 200.7670F, 149.3555F, 67.1469F,
+ -114.0830F, -239.0252F, -314.3921F, 24.6004F, 51.2722F, 105.4223F, 101.1157F, 137.3569F, 135.9245F,
+ -91.7432F, -32.7591F, 373.1560F, 319.3955F, 437.4347F, 503.4907F, 608.7997F, 578.2119F, 502.0230F,
+ -70.3367F, -179.9099F, -239.7652F, 256.5794F, 269.9891F, 291.1810F, 333.6932F, 305.8695F, 278.4421F,
+ -38.0671F, -120.8247F, -186.4547F, -239.7784F, -303.6527F, -286.7954F, -300.0361F, -205.3057F, -184.5087F,
+ -134.2125F, -185.9339F, -13.8119F, -65.8529F, 19.0133F, -30.1823F, -58.4970F, -93.5678F, -55.1841F,
+ -20.3990F, -104.7817F, -249.4716F, -358.9899F, -499.3363F, -434.6861F, -133.7299F, -130.1813F, -59.0671F,
+ -26.7201F, -94.4739F, -228.6340F, -28.5857F, -81.7289F, -186.7961F, -62.0135F, -167.5409F, 51.9732F,
+ -76.8652F, -194.8085F, -392.5224F, -495.1741F, -106.3757F, -87.6781F, -40.9442F, -25.9922F, 6.6919F,
+ -141.6526F, -241.2805F, -161.8672F, -45.4915F, -24.1067F, 7.6906F, 3.7741F, 45.2149F, 42.3436F,
+ -76.2028F, -185.3649F, -353.8127F, -492.3104F, -348.1328F, -172.4144F, -108.0814F, -55.5374F, -10.8210F,
+ -88.1331F, -202.9139F, -371.2243F, -273.3005F, -107.5773F, -103.9134F, -45.1607F, -40.9613F, 31.8985F,
+ 157.9412F, 199.7964F, 203.2689F, 127.6304F, 6.7547F, -75.7475F, -130.0489F, -209.2208F, -228.8015F,
+ -44.6527F, -50.6749F, 107.6295F, 92.4422F, 79.8121F, 133.5672F, 52.5620F, -6.2270F, -43.2877F,
+ 261.9115F, 472.0228F, 456.3473F, 335.7553F, 289.8814F, 234.7976F, 206.1187F, 157.4174F, 120.7698F,
+ 155.2229F, 242.6315F, 377.1642F, 293.6065F, 226.0318F, 155.2748F, 156.4116F, 128.6701F, 98.5061F,
+ 74.5256F, 70.1303F, -53.6869F, -182.3488F, 106.1648F, 41.5585F, -37.0232F, 6.5336F, -75.1722F,
+ -31.2252F, -113.3890F, -244.5892F, 75.8334F, 233.5228F, 76.5742F, 8.2886F, -109.6154F, 29.9907F,
+ 199.0678F, 337.3158F, 432.8418F, 315.2969F, 366.8018F, 352.4917F, 361.4405F, 280.1715F, 187.7336F,
+ 53.4911F, 143.3279F, 208.4704F, 298.2910F, 261.7387F, 149.2119F, 115.7060F, 59.9002F, 32.6898F,
+ 118.3519F, 194.3090F, 56.3174F, -33.3258F, -48.8783F, -210.5418F, -188.4141F, -181.0565F, -298.4099F,
+ 91.1937F, 135.5274F, 26.3852F, -57.5649F, 66.0117F, -82.2194F, -94.6889F, -88.3680F, -188.1230F,
+ 119.8292F, 164.8051F, 60.2985F, -68.4990F, -150.8028F, -282.2156F, -282.8785F, -353.0452F, -396.4856F,
+ 120.5806F, 120.4464F, 62.5068F, -23.5466F, -183.4260F, -164.0083F, -233.7240F, -309.0768F, -85.4341F,
+ 26.4925F, 47.3529F, -53.5415F, -218.9011F, -56.8672F, -174.1118F, -201.0902F, -193.1382F, -284.6390F,
+ 50.9597F, 20.8274F, -88.6445F, 17.8450F, 185.2710F, 12.4814F, -62.7698F, -74.9989F, -191.3486F,
+ 83.3881F, 63.9878F, -27.8680F, -181.7226F, -342.0545F, -62.8876F, -178.1327F, -229.1320F, -18.6240F,
+ 85.1419F, 45.8095F, 15.3667F, 69.0366F, -75.9137F, -34.4539F, -88.4330F, -163.4411F, 19.3370F,
+ 81.8880F, 213.5459F, 222.3313F, 109.1533F, 47.1884F, -17.2578F, -19.4486F, 3.7457F, -32.8905F,
+ 22.8266F, 54.6145F, 70.9314F, -2.0301F, 104.3592F, 45.7102F, 41.3375F, 82.5320F, 77.2795F,
+ 210.7176F, 326.3462F, 356.6618F, 280.9097F, 240.9705F, 212.4392F, 230.9905F, 220.8317F, 250.9306F,
+ 59.6089F, 218.2601F, 340.5622F, 179.8372F, 86.7106F, 42.1021F, 73.5578F, 70.2340F, 71.3620F,
+ 61.9071F, 46.6476F, 111.0709F, -59.8230F, -105.9862F, 89.4424F, 34.0065F, 42.7793F, -22.3657F,
+ -71.5290F, 31.9224F, 46.2106F, 8.2769F, 5.2717F, 15.6736F, 45.9446F, 74.5921F, 72.2933F,
+ 63.1228F, 347.0971F, 255.3817F, 42.2624F, -13.4026F, 95.4917F, 190.7911F, 219.1920F, 207.8866F,
+ 63.7817F, 21.7322F, 237.9311F, 133.1283F, 19.5484F, 128.6760F, 26.4302F, 103.7761F, 85.3130F,
+ 39.2312F, 80.2880F, 7.1932F, -118.9054F, -41.8213F, -170.3956F, -190.1681F, -25.3174F, -119.5246F,
+ -33.4058F, 60.1838F, 52.1765F, -11.5418F, -17.6690F, -28.5228F, -40.5342F, -31.3702F, -37.5340F,
+ 95.6257F, 128.8044F, 3.7503F, -171.8902F, -331.7014F, -422.7089F, 30.8156F, 15.6229F, -103.6316F,
+ 76.5623F, 145.2620F, 106.4321F, -70.8798F, -192.7731F, -152.0614F, 107.2952F, 31.2426F, -23.0299F,
+ 0.9016F, -4.6471F, -96.0447F, -197.1141F, -39.1036F, -170.4243F, 8.3031F, -73.0702F, -168.4342F,
+ -86.2673F, -18.7660F, 13.9540F, -105.8362F, -72.7468F, -57.3178F, -42.7630F, 10.3291F, 27.6536F,
+ 83.1109F, 54.8163F, 28.1776F, -137.0164F, -242.1605F, -32.9744F, -141.6118F, 26.8712F, 17.8517F,
+ 35.5325F, 65.1065F, -1.1122F, -37.2264F, -38.7638F, -41.0658F, -18.6295F, 44.3877F, 57.2718F,
+ 101.1713F, 97.2361F, 67.3819F, 236.9884F, 158.4350F, 20.2720F, 23.0851F, -73.7010F, -124.8067F,
+ 44.9800F, -33.1049F, -21.2276F, 224.2546F, 49.9567F, 88.2466F, -23.1899F, -98.6740F, 50.9732F,
+ -24.3959F, 403.6523F, 511.0127F, 404.3978F, 440.2577F, 428.9172F, 401.8223F, 375.5111F, 321.4924F,
+ 15.1345F, 142.1195F, 295.8327F, 367.1741F, 284.5674F, 257.7681F, 257.3533F, 227.7437F, 300.6506F,
+ -44.9562F, -131.9449F, -296.8129F, -184.1626F, 153.8183F, 14.5297F, 172.3343F, 69.5618F, 2.2208F,
+ -22.2475F, -119.2772F, -205.2499F, 310.9423F, 177.0844F, 73.5587F, -1.5010F, -44.3403F, 96.9000F,
+ 27.7742F, 173.5793F, 311.4776F, 285.5815F, 427.9854F, 452.0145F, 477.2097F, 401.7775F, 316.6574F,
+ 52.6696F, 140.2801F, 215.3995F, 166.1714F, 292.6204F, 318.2898F, 341.5682F, 274.8850F, 196.1860F,
+ 51.5561F, 96.4057F, -0.0610F, -80.6567F, -175.2689F, -292.8310F, -100.7723F, -200.9591F, -247.1591F,
+ 96.6859F, 97.0977F, 35.4401F, 47.1563F, -76.2811F, -194.8284F, -34.9894F, -110.1535F, -169.8929F,
+ 30.4654F, 7.6447F, -108.2569F, -243.2014F, -383.8708F, -478.0505F, -162.0353F, -178.7682F, -249.4727F,
+ 135.4580F, 198.9998F, 81.4247F, -69.9475F, -181.4226F, -284.4768F, -29.8270F, -92.7044F, -189.7940F,
+ -40.1188F, -133.9427F, -295.2091F, -278.5829F, -103.4496F, -237.8449F, -74.7856F, -155.3338F, -248.5054F,
+ -47.4470F, -149.6037F, -292.4242F, 221.6694F, 98.4280F, -14.0849F, -138.2963F, -163.0445F, -19.4243F,
+ 79.5896F, 39.1792F, -58.2936F, -253.9809F, -422.3516F, -18.3412F, -2.7302F, -102.9275F, 43.5500F,
+ -17.9005F, -70.1182F, -104.1536F, -126.4881F, -219.3935F, -153.8877F, -270.2488F, 155.3837F, 114.2388F,
+ 188.3484F, 261.8459F, 266.6991F, 243.5570F, 172.7795F, 64.3333F, 45.3547F, 14.1479F, -58.3812F,
+ 42.3610F, 96.6123F, 113.8369F, 96.5219F, 138.7232F, 47.5273F, 42.4855F, 87.4416F, 115.5724F,
+ -5.4013F, 368.9961F, 386.7844F, 312.8328F, 294.8554F, 318.4847F, 330.7657F, 356.5357F, 348.3268F,
+ 113.9440F, 136.1339F, 283.1776F, 188.4109F, 151.5282F, 128.5029F, 167.5631F, 242.2409F, 260.3565F,
+ -13.3113F, 76.9204F, 83.0527F, -49.6054F, 32.9182F, 193.1624F, 242.1413F, 224.6298F, 146.4784F,
+ 49.3300F, 80.8438F, 67.2940F, 65.3665F, 141.4567F, 78.9471F, 115.6802F, 154.3108F, 177.7814F,
+ -2.1684F, 97.5184F, 210.7061F, 182.4635F, 248.3353F, 312.9833F, 448.6478F, 502.5403F, 436.6044F,
+ 10.4934F, 93.6577F, 144.0456F, 109.2677F, 171.7553F, 160.5641F, 247.6292F, 348.4738F, 372.3836F,
+ 62.0393F, 66.4595F, -22.8432F, -154.2429F, -311.1715F, -269.7167F, 30.1724F, -82.4276F, -130.4250F,
+ -1.8658F, -10.8456F, -5.2486F, -28.7596F, -130.9176F, -235.6978F, 116.9998F, 34.2436F, -79.9885F,
+ 32.1393F, -12.8439F, -142.0784F, -272.6861F, -469.8031F, -450.3773F, 42.8701F, -56.9028F, -113.0164F,
+ 44.2438F, 0.5177F, -95.0709F, -229.7896F, -388.2228F, -193.8794F, 161.5550F, 62.3152F, 16.3412F,
+ -21.7573F, -96.5696F, -171.8374F, -270.5201F, -389.2275F, -187.1907F, 4.2880F, -69.4009F, -139.6222F,
+ -59.1336F, -137.9044F, -127.8821F, -82.4177F, -132.8951F, 55.2591F, 25.2046F, 165.8443F, 176.7896F,
+ 13.1713F, -65.9463F, -177.8707F, -363.8923F, -474.4700F, 53.7845F, 194.7626F, 99.8684F, 126.7437F,
+ 26.4565F, 54.2781F, -5.8084F, -213.5320F, -186.7453F, 6.5259F, 119.4530F, 196.2039F, 188.0246F,
+ -12.3442F, -52.3945F, 174.0135F, 50.5399F, -55.6784F, -95.2558F, -196.2955F, -198.2056F, -234.0973F,
+ 23.6446F, -54.5462F, -134.7219F, 193.6175F, 178.7128F, -0.9450F, 7.7510F, -88.8611F, -200.7396F,
+ 154.0881F, 689.2718F, 650.6971F, 522.8596F, 436.5025F, 314.9000F, 250.7824F, 187.1628F, 148.5410F,
+ 83.9959F, 202.8234F, 359.2843F, 411.3538F, 425.6817F, 308.8017F, 206.3666F, 113.2320F, 60.3929F,
+ -21.1689F, -91.1694F, -252.6742F, -235.0333F, 249.5398F, 114.6655F, -0.7796F, -65.2547F, -172.8182F,
+ -30.5567F, -123.2070F, -309.0227F, -44.0884F, 320.4634F, 157.6161F, 61.6828F, -45.3025F, -139.1032F,
+ 206.4974F, 723.0883F, 782.3015F, 479.5419F, 242.9557F, -15.8222F, -162.4184F, 134.4517F, 319.9661F,
+ -41.0232F, -148.1419F, -92.0839F, 478.0700F, 348.8458F, 292.6417F, 221.8808F, 139.1332F, 83.7320F,
+ -6.8324F, -77.6477F, -56.3444F, 19.3478F, -110.6184F, -96.5414F, -225.9007F, -330.6617F, -424.5623F,
+ 26.9337F, -4.4548F, -148.8763F, -80.3516F, 81.8311F, -110.8947F, -150.9911F, -162.4880F, -279.5481F,
+ 15.4135F, -1.8583F, -56.8319F, -146.1688F, -266.5346F, -355.1809F, -419.6793F, -456.7536F, -416.2208F,
+ 112.1756F, 88.2059F, 26.0259F, -86.2333F, -258.4741F, -66.9660F, -164.5662F, -250.9281F, -276.0475F,
+ -51.5026F, -135.9180F, -210.3467F, -175.0943F, -7.7200F, -1.5529F, -138.1960F, -292.0197F, -364.5311F,
+ 1.6098F, -29.3697F, -112.8375F, -233.4716F, 123.6812F, 20.4676F, -81.0632F, -116.0258F, -218.5294F,
+ -34.1878F, -103.0825F, -139.6876F, -229.9859F, -246.3806F, -96.8411F, -204.4168F, -321.0166F, -418.4522F,
+ 27.1891F, -2.9717F, 21.2254F, -122.5167F, -201.1399F, 36.0115F, -56.9192F, -106.8464F, -192.5580F,
+ 77.7097F, 24.2840F, 152.6398F, 61.5673F, -54.9359F, 27.7810F, -85.7347F, -79.4392F, -81.0366F,
+ 59.2315F, 15.7636F, 128.6461F, 63.2966F, -11.4618F, 18.7670F, -58.2229F, 42.0642F, 49.7434F,
+ 247.9855F, 413.3163F, 345.0402F, 192.3750F, 145.4847F, 121.6956F, 123.6805F, 107.2007F, 94.2462F,
+ 104.2558F, 282.0381F, 490.4723F, 344.7097F, 244.1310F, 96.7224F, 2.9896F, -31.7180F, -23.3323F,
+ -22.5118F, -53.8832F, -113.5013F, -234.2837F, -4.7630F, -0.8369F, -15.3972F, 57.4113F, 45.6486F,
+ -41.6155F, -134.7804F, -200.2841F, 179.2444F, 29.8214F, 36.0840F, -106.4028F, 151.5328F, 102.1621F,
+ 141.5078F, 201.5805F, 79.4698F, -159.8402F, -279.6548F, -324.4731F, -129.3751F, 72.2403F, 81.4769F,
+ -45.8403F, -152.7728F, -116.5580F, 262.2678F, 114.2470F, 210.0651F, 100.2266F, 64.9777F, -14.6634F,
+ -39.9272F, -124.8000F, -75.7294F, -110.6360F, -223.7299F, -102.2257F, -226.1053F, -85.4944F, -173.4764F,
+ -91.6640F, 30.6543F, 4.1065F, -65.4408F, -39.3890F, -89.5364F, -102.5911F, -125.5036F, -48.1974F,
+ 27.2660F, 19.3735F, -66.4810F, -233.9350F, -388.9383F, -229.7098F, -102.6715F, -201.6806F, -177.6036F,
+ 153.9685F, 141.8902F, 89.4281F, -53.1892F, -209.9941F, 8.0810F, -71.3509F, -135.8233F, -78.6157F,
+ -48.4004F, -143.6756F, -250.1705F, -343.5184F, -330.9693F, -81.7413F, -159.8642F, -192.9882F, -201.0525F,
+ -49.7401F, -133.3727F, -211.5154F, -166.0789F, -199.3352F, -4.0380F, -98.3591F, -184.6634F, -113.6087F,
+ 32.7128F, -26.7812F, -78.3951F, -264.0457F, -339.2219F, 40.1904F, -121.6728F, -51.6241F, -125.0696F,
+ 1.8568F, -67.7562F, -73.4413F, -115.9242F, -245.2522F, 77.1352F, -22.1839F, 2.7514F, -4.3203F,
+ 19.0296F, -62.4543F, 21.8088F, 217.8850F, 43.1886F, 12.7766F, -121.5772F, -171.9543F, -180.7850F,
+ -0.3986F, -96.1580F, -120.0616F, 336.5914F, 176.9306F, 54.3062F, -66.4501F, -138.8101F, -90.7495F,
+ 109.0295F, 377.1798F, 641.5853F, 577.4881F, 571.3625F, 438.8002F, 310.6432F, 204.9863F, 132.6160F,
+ -76.9013F, -15.0371F, 664.7503F, 520.0686F, 489.1051F, 371.2256F, 270.3431F, 196.9454F, 166.5973F,
+ -42.2498F, -134.3667F, -336.4376F, -457.6409F, 173.4562F, 138.1508F, 34.3921F, -18.1609F, -85.9677F,
+ -20.8727F, -125.4622F, -192.7956F, 434.5861F, 290.6413F, 142.0824F, 77.1623F, -13.2305F, -29.4274F,
+ 178.7104F, 373.0402F, 459.7581F, 474.3989F, 557.5211F, 569.2194F, 525.4768F, 358.3187F, 210.4229F,
+ -26.8194F, 77.7574F, 350.3222F, 445.4183F, 524.4524F, 462.1511F, 381.7293F, 289.9692F, 204.0649F,
+ 47.7632F, 17.1803F, -105.1057F, 10.4223F, -60.5128F, -219.3625F, -119.8198F, -230.6158F, -301.9153F,
+ 60.2078F, 16.2198F, -62.5382F, 98.4891F, -50.3729F, -119.2299F, -183.9794F, -286.1903F, -145.0719F,
+ 52.5866F, 72.1675F, -32.1273F, -162.5446F, -282.0867F, -356.6873F, -196.9938F, -290.2792F, -343.8752F,
+ 58.1756F, 83.5942F, -32.7989F, -128.5429F, -265.7008F, -326.2490F, -166.5130F, -258.2744F, -31.7978F,
+ -49.8436F, -148.3240F, -287.2763F, -389.7832F, -131.7967F, 6.5863F, -71.1640F, -182.3324F, -272.4139F,
+ -32.6407F, -113.2022F, -199.3120F, -231.3794F, 5.2103F, 172.0263F, 60.2526F, -14.7182F, -108.9096F,
+ 27.2077F, -23.7367F, -95.9858F, -283.8613F, -409.0134F, -31.3871F, -148.6489F, -208.9727F, -274.8275F,
+ 69.4333F, -0.7143F, -57.0494F, -261.8966F, -366.3107F, 188.4734F, 53.9671F, 24.5447F, 25.3948F,
+ -4.4283F, 5.6792F, 301.6043F, 172.8969F, 55.6507F, -7.7604F, -81.7609F, -49.2316F, -63.0654F,
+ -12.4033F, -97.3530F, 37.2340F, 215.5548F, 48.4286F, 11.6666F, -133.9813F, 32.1272F, -33.6059F,
+ 57.9103F, 293.2768F, 591.9909F, 431.5314F, 338.6320F, 236.6151F, 185.2476F, 175.1540F, 156.0322F,
+ -63.6185F, -100.3640F, 351.1546F, 428.5004F, 353.7403F, 293.3142F, 196.1020F, 152.1965F, 114.6518F,
+ -20.0721F, -100.8514F, -174.7278F, -314.6773F, -143.5646F, 298.1905F, 181.1825F, 142.0341F, 71.3729F,
+ -64.7951F, -146.2021F, -143.2170F, 33.9854F, 13.8056F, 156.0337F, 163.4005F, 334.1913F, 325.3497F,
+ -79.9064F, -121.2133F, 229.6626F, 303.8755F, 306.8218F, 415.8466F, 436.8824F, 486.2830F, 451.8081F,
+ -67.6130F, -122.0631F, 41.7635F, 134.7727F, 156.2778F, 308.4236F, 340.0357F, 434.5742F, 391.1108F,
+ -2.6037F, -46.9405F, -151.3320F, -160.0405F, -239.8193F, -368.3138F, -88.0921F, -150.1500F, -191.7920F,
+ -79.3309F, -112.6262F, -20.0215F, -129.1640F, -35.3227F, -69.4806F, -159.3188F, -223.7142F, -132.1779F,
+ 21.9835F, -11.3374F, -106.7910F, -244.8813F, -406.4640F, -311.7320F, -96.4711F, -182.5312F, 57.8956F,
+ 25.8713F, -0.7151F, -79.9440F, -80.0111F, -224.4878F, -136.2209F, -22.1062F, -137.4635F, -22.6838F,
+ -17.4638F, -88.0421F, -183.7897F, -361.0791F, -194.1127F, 29.9571F, -12.3110F, 17.3506F, -52.9132F,
+ -108.1431F, -191.9295F, -193.9598F, -196.0948F, -165.6809F, -79.0258F, -53.5949F, 30.1916F, 37.3619F,
+ 10.0420F, -70.0023F, -183.1197F, -393.7681F, -492.0758F, 102.2096F, -13.6587F, -51.6821F, -101.1752F,
+ -25.8195F, -90.5090F, -174.4579F, -208.3670F, -308.3139F, -74.5783F, -38.9631F, -104.3672F, 142.1591F
+};
+
+/*
+ * 1st stage codebook; 2nd split: isf9 to isf15
+ */
+const Float32 E_ROM_dico2_isf[SIZE_BK2 * 7] = {
+ 530.1115F, 512.7983F, 443.8771F, 306.1447F, 171.2327F, 70.8250F, 56.8183F,
+ 248.5479F, 252.9719F, 260.5429F, 221.7305F, 172.6754F, 84.8419F, 141.5120F,
+ 166.9014F, 171.9745F, 263.4265F, 204.8570F, 129.5061F, 45.8705F, -162.9417F,
+ 47.0761F, 115.3926F, 182.9788F, 181.5048F, 89.7111F, 17.3276F, -86.2999F,
+ -57.3148F, -93.7950F, 58.2071F, 31.0844F, 152.3217F, 108.6931F, 41.3677F,
+ -163.1767F, -217.0378F, 215.5667F, 199.7393F, 91.8320F, 56.3535F, -37.1534F,
+ 16.9371F, 75.2105F, 106.8429F, 58.4518F, 26.0167F, 13.3113F, -106.5544F,
+ -16.6336F, -49.0904F, 66.7054F, 162.6404F, 110.2851F, 24.4686F, -138.4124F,
+ -145.3240F, -33.7683F, -134.5548F, -42.3167F, -36.8413F, -70.9451F, -34.7360F,
+ -234.5519F, -328.1575F, -78.2304F, 181.4482F, 100.8272F, -4.3886F, -98.7986F,
+ -18.7314F, 128.6640F, 38.0685F, -113.4033F, -211.9919F, -310.5748F, -138.0866F,
+ -222.6271F, -45.5429F, 72.9616F, 3.9276F, -52.1214F, -162.3586F, -29.6134F,
+ -241.3416F, -50.3196F, -96.3331F, -145.0456F, 17.4087F, -29.8105F, 108.3555F,
+ -399.1142F, -421.4348F, 49.0965F, 185.0085F, 99.2830F, 49.7543F, 20.2726F,
+ -109.7596F, 29.7695F, -65.3607F, -141.1745F, -110.3974F, -215.1475F, -110.3518F,
+ -46.4209F, -20.4624F, -0.5266F, 52.1919F, -12.3074F, -79.8395F, -162.1720F,
+ 415.6808F, 323.0418F, 248.6461F, 267.3440F, 181.1869F, 81.5855F, 4.8347F,
+ 188.1995F, 162.5893F, 175.4467F, 144.9775F, 131.0177F, 114.8023F, 75.6850F,
+ 280.8494F, 225.0358F, 142.4128F, 52.8503F, 44.0619F, 35.6548F, -77.7252F,
+ 116.2722F, 68.6422F, 192.5792F, 142.9262F, 75.7274F, 63.5846F, 13.9314F,
+ -13.4854F, -92.0420F, -101.3018F, -13.9503F, -1.5377F, 38.4848F, 59.2146F,
+ -38.0921F, -119.6284F, -10.4956F, 88.8682F, 35.1836F, 43.2013F, -33.7051F,
+ 35.4547F, 5.0305F, -82.4376F, -100.9264F, -41.5222F, 33.5725F, -24.8381F,
+ 28.3963F, -13.4840F, -22.4480F, -11.9734F, 63.1961F, 13.8177F, -75.0030F,
+ -42.4115F, -130.9516F, -245.5204F, -25.9129F, -23.6896F, -49.8110F, 125.7094F,
+ -193.2334F, -261.3991F, -284.3770F, 75.4337F, 11.9830F, -86.1044F, 47.5069F,
+ 126.4967F, 37.0484F, -34.7501F, -35.5687F, -159.6523F, -277.2735F, -60.1203F,
+ -0.1156F, -91.4527F, 35.7808F, 12.8593F, -134.0804F, -237.8749F, -85.9030F,
+ -134.0644F, -159.5199F, -185.8239F, -255.9559F, -59.8235F, 31.9001F, 86.5795F,
+ -191.3466F, -290.9137F, -99.7657F, 18.9475F, -18.6283F, 52.5484F, -49.6458F,
+ 46.4725F, -26.2220F, -128.3100F, -152.1911F, -106.3316F, -212.7650F, -21.8051F,
+ -22.1899F, -50.6587F, -4.0987F, -2.7160F, -63.9780F, -18.1671F, -8.5809F,
+ 384.5044F, 415.7100F, 375.3419F, 221.7875F, 82.0605F, -10.5889F, 6.1831F,
+ 316.8826F, 269.9225F, 294.6225F, 200.5877F, 87.3740F, -13.6950F, 64.9923F,
+ 258.7122F, 274.8100F, 241.2115F, 150.6316F, 22.2879F, -82.2525F, -100.3677F,
+ 199.2028F, 140.2225F, 163.4630F, 153.3341F, 35.3954F, -56.3718F, -6.8714F,
+ -75.2059F, -12.0741F, -10.5019F, 87.1330F, 34.8811F, -55.7089F, 9.3485F,
+ -43.9131F, -38.3306F, 184.0508F, 124.7862F, 72.2168F, 1.2740F, 68.2432F,
+ 98.5331F, 56.9808F, -18.2386F, 106.3234F, 18.7400F, -82.2337F, -91.2981F,
+ 56.8543F, 26.8486F, 79.2505F, 142.2529F, 26.5547F, -20.1961F, 20.0251F,
+ -101.2805F, -186.8430F, -272.0712F, -136.2303F, -296.2366F, -195.7741F, 24.4320F,
+ -195.6167F, -300.4726F, -112.7403F, 30.7313F, -121.6459F, -194.0080F, -41.2612F,
+ 98.2285F, 20.7275F, -91.7240F, -183.2970F, -349.5879F, -345.3007F, 56.7721F,
+ -162.4512F, -215.0840F, 54.6896F, -51.9437F, -204.1752F, -302.6133F, 17.1211F,
+ -127.3559F, -165.3954F, -278.6780F, -194.2370F, -33.4488F, -168.4021F, 38.6555F,
+ -295.7049F, -301.6402F, -62.3113F, -29.8345F, -17.8150F, -12.4093F, 147.9211F,
+ 33.3799F, -13.6109F, -78.2303F, -156.7363F, -259.0581F, -406.3858F, -96.3685F,
+ -70.3287F, -128.8603F, -35.8870F, -146.8926F, 10.7114F, -71.6699F, -42.8127F,
+ 499.4422F, 424.3595F, 305.0398F, 196.0019F, 126.5760F, 63.9795F, 61.1516F,
+ 266.3734F, 181.9720F, 175.4860F, 108.0995F, 56.9864F, 10.7695F, 159.6035F,
+ 247.9333F, 184.5145F, 152.3734F, 41.9318F, -90.6959F, -210.2689F, -54.1531F,
+ 76.7519F, 154.5846F, 129.7565F, 83.0209F, 81.7690F, -11.2691F, -31.6182F,
+ 58.5084F, -37.0541F, -121.7467F, 29.7202F, -30.0062F, -124.9186F, -19.6730F,
+ 18.1514F, 3.4725F, 18.4977F, 68.3406F, 54.2768F, 11.6546F, 150.1885F,
+ 85.0507F, 80.6332F, -9.5051F, -97.5608F, -37.4477F, -107.8952F, -71.4574F,
+ 10.1458F, 46.5077F, 14.7448F, 5.4868F, -1.5563F, -51.9743F, -20.1740F,
+ -186.2883F, -239.8358F, -385.3964F, -279.2732F, -246.3584F, -317.5150F, 77.9409F,
+ -290.8109F, -394.1977F, -416.1625F, -291.0747F, -246.4900F, -66.6275F, 7.0910F,
+ -53.3572F, -98.2187F, -188.6130F, -239.5862F, -382.9682F, -469.8791F, 4.8130F,
+ -236.2064F, -299.8000F, -219.3447F, -267.9179F, -424.8446F, -200.9900F, 22.5746F,
+ -78.8698F, -167.2648F, -305.5687F, -418.8565F, -37.5231F, -91.3323F, -69.9264F,
+ -187.4632F, -276.9708F, -417.8298F, -350.3085F, -51.2638F, -35.7869F, 125.5794F,
+ -56.7695F, -75.4877F, -200.1077F, -284.6027F, -223.5758F, -298.6907F, -81.9158F,
+ -129.2158F, -228.6000F, -204.9319F, -246.4877F, -109.8989F, -81.0975F, -118.3144F,
+ 455.1133F, 431.3343F, 366.9250F, 323.3162F, 279.7654F, 166.3696F, 60.4075F,
+ 2.2427F, -42.4551F, 320.2264F, 303.9626F, 161.9218F, 44.0682F, -10.4932F,
+ 148.9215F, 132.3074F, 122.6564F, 103.3307F, 47.4590F, -3.4202F, -185.0445F,
+ -145.6115F, 18.4827F, 228.0817F, 172.5267F, 38.5907F, -90.1562F, -43.9888F,
+ -193.6085F, -14.9922F, -111.3547F, 102.4688F, 119.0297F, 66.3613F, 1.6199F,
+ -229.1052F, -217.2523F, 26.9406F, 25.7113F, 183.7947F, 138.0997F, 4.9246F,
+ -54.0735F, 27.3595F, -6.9751F, 41.3897F, 26.0272F, 65.3047F, -117.9287F,
+ -173.6861F, -55.0424F, 72.3582F, 74.4772F, 59.1275F, 32.2629F, -52.0966F,
+ -100.2805F, -203.3997F, -281.1161F, -77.1917F, 52.4149F, -18.1558F, -70.9170F,
+ -319.7560F, -456.2388F, -303.5891F, 199.8376F, 140.0785F, 37.0556F, -44.1020F,
+ 53.3338F, -0.8373F, -29.0162F, -53.8806F, -156.4895F, -44.6551F, -144.9031F,
+ -94.4005F, -181.9505F, 79.8505F, 87.0198F, -12.1349F, -82.6727F, -75.0313F,
+ -207.6459F, -248.8868F, -181.9412F, -267.7931F, 100.0395F, 108.0778F, -54.3928F,
+ -445.8355F, -486.1193F, -148.8008F, -29.2654F, -20.9138F, 5.3055F, 34.4656F,
+ -121.3450F, 45.0588F, -55.9190F, -194.9437F, -134.0013F, 48.6244F, -162.3284F,
+ -240.5215F, -57.3889F, -52.6141F, 16.9554F, -1.6593F, 47.0915F, -144.2315F,
+ 326.1222F, 306.0203F, 250.4581F, 152.3629F, 138.5136F, 136.6061F, 24.8198F,
+ 27.9826F, 75.7094F, 172.8544F, 182.3980F, 170.1943F, 85.7041F, 145.3514F,
+ 181.4035F, 144.2242F, 74.8556F, 1.4272F, -61.0836F, -28.1913F, -88.2541F,
+ 22.2453F, 80.4679F, 118.3400F, 80.0672F, 73.2458F, 39.5447F, 103.6288F,
+ -15.5237F, -80.2624F, -190.5397F, -72.0487F, 107.7333F, 24.8407F, -9.9839F,
+ -84.5773F, -169.2563F, -115.8907F, 53.5535F, 128.0731F, 120.4292F, -112.8952F,
+ 147.5641F, 31.5040F, -120.2366F, -181.4932F, 22.0867F, -14.3306F, 88.8276F,
+ -38.8943F, 9.5208F, -14.2124F, -59.1263F, 77.8884F, 3.1099F, 55.9227F,
+ -166.2941F, -272.4271F, -413.5079F, -51.9034F, 151.3775F, 62.8211F, 125.4737F,
+ -251.4761F, -399.5025F, -496.4470F, 15.1387F, 25.6129F, -47.9447F, 27.2588F,
+ 145.3730F, 69.2023F, -67.5157F, -217.2383F, -216.1160F, -118.5795F, -73.6690F,
+ -45.7917F, -144.0127F, -166.1374F, -47.5218F, -180.4311F, -59.2610F, -28.7005F,
+ -253.6976F, -332.1650F, -464.5507F, -299.7163F, 194.1511F, 140.7432F, 86.8261F,
+ -311.8663F, -444.9106F, -568.2597F, -74.2214F, 168.0938F, 91.5796F, 69.8801F,
+ 16.2576F, -36.8680F, -158.1385F, -270.2551F, 14.7501F, -79.0270F, -96.1519F,
+ -66.0490F, -143.0125F, -113.3699F, -34.3890F, -25.0086F, 12.5482F, -114.0537F,
+ 394.4650F, 360.5732F, 366.5918F, 277.4828F, 181.5850F, 89.9984F, 133.6822F,
+ 84.7064F, 117.2216F, 411.7273F, 263.7720F, 26.7575F, -178.8131F, -69.9364F,
+ 30.5200F, 177.1075F, 123.5531F, 7.2231F, -92.4543F, -193.6012F, -94.9796F,
+ 65.2717F, 8.1559F, 165.7135F, 84.0440F, -35.7379F, -118.5377F, -66.5232F,
+ -113.0977F, -31.5885F, -27.3286F, -26.0692F, 15.5114F, 21.2791F, -23.2414F,
+ -138.0497F, -166.9724F, -35.1916F, 20.7464F, 36.6236F, 3.5627F, 20.9882F,
+ -11.0900F, 124.4114F, 110.4337F, 5.6888F, -93.7853F, -22.5026F, 30.8623F,
+ -29.4226F, -47.2009F, 89.3512F, 13.6996F, 22.5131F, 2.3075F, -51.7825F,
+ -137.2009F, -200.8273F, -290.6017F, -325.7113F, -275.5810F, -53.4554F, 64.1025F,
+ -438.9569F, -542.2731F, -412.1423F, -89.9884F, -28.4069F, 15.6647F, 13.8672F,
+ -63.4932F, -90.8672F, -207.9037F, -306.7191F, -456.9608F, -272.1003F, 37.6908F,
+ -307.9492F, -374.7438F, -96.2506F, -168.0490F, -243.8695F, -64.5296F, -3.1349F,
+ -334.4494F, -210.9558F, -246.0072F, -354.2072F, -131.6393F, -27.1645F, 29.5091F,
+ -366.0860F, -407.0811F, -257.3381F, -286.1801F, -81.4441F, 77.6511F, -10.1480F,
+ -204.4162F, 30.5330F, -38.3922F, -195.6373F, -339.5407F, -347.7475F, -31.6897F,
+ -243.6551F, -274.7409F, -17.3959F, -136.0264F, -9.8248F, 34.1080F, -72.7180F,
+ 392.4115F, 321.3055F, 213.3703F, 97.3249F, 35.2497F, -8.7278F, 80.8223F,
+ 116.4944F, 155.2541F, 148.9464F, 124.6089F, 78.0606F, 24.1574F, 118.5191F,
+ 184.6981F, 148.0850F, 51.9562F, -96.3499F, -247.0329F, -172.3801F, 29.4305F,
+ 110.9024F, 81.4259F, 152.8654F, 45.1114F, -9.8257F, 17.3401F, 36.9414F,
+ -27.9329F, 30.8783F, -37.1648F, -24.5270F, -50.2764F, -114.4973F, 79.3175F,
+ -64.1897F, -136.2614F, 44.8825F, 47.6375F, 26.8591F, -0.2729F, 147.6527F,
+ 135.7539F, 66.4931F, 38.8074F, 22.5599F, -70.1020F, -117.9085F, 73.4314F,
+ -74.1601F, -0.9165F, 58.6634F, 8.8413F, -20.0486F, -4.3857F, 84.5215F,
+ -240.3710F, -336.9822F, -425.7879F, -557.5921F, -313.4519F, -18.6503F, -2.2911F,
+ -375.5428F, -498.5622F, -604.7405F, -284.0899F, -22.5439F, 21.7506F, 87.1215F,
+ -48.5853F, -99.7448F, -219.1610F, -385.9877F, -498.9206F, -58.0072F, -32.0391F,
+ -187.4733F, -257.8106F, -348.0662F, -465.0402F, -523.0202F, -126.9367F, 7.9922F,
+ -242.4066F, -358.0976F, -506.2984F, -527.3067F, 103.2345F, 112.8789F, 19.5721F,
+ -329.7812F, -399.2909F, -525.3788F, -519.3241F, -114.6023F, 18.0531F, 108.4014F,
+ -101.3959F, -182.8774F, -323.7689F, -459.4139F, -208.2967F, -218.5872F, -30.6618F,
+ -83.9128F, -188.9391F, -321.0572F, -481.5454F, -309.1473F, 5.7541F, -53.7133F,
+ 508.3954F, 514.6412F, 492.8828F, 409.4624F, 279.6907F, 139.5316F, -25.0946F,
+ 225.7716F, 321.9763F, 361.4909F, 313.2012F, 246.2739F, 141.2217F, 40.0333F,
+ 183.5499F, 361.1524F, 299.5782F, 200.8792F, 127.5401F, 74.2915F, -43.7510F,
+ 87.8314F, 192.1731F, 193.5542F, 170.6556F, 233.6155F, 150.0142F, -17.3959F,
+ 16.6972F, 31.8549F, -16.4255F, 68.2118F, 202.5792F, 133.4167F, -24.8757F,
+ -118.5934F, -60.2884F, 62.2425F, 224.9154F, 157.3277F, 86.2001F, 127.8335F,
+ 83.3985F, 95.4353F, 47.7289F, -24.4079F, 122.0239F, 35.9347F, -62.3200F,
+ 85.0292F, 81.2156F, 121.2625F, 104.6399F, 119.6594F, 126.2998F, -77.7217F,
+ -111.4887F, -105.1822F, -30.9685F, -48.2729F, -55.9544F, -59.5831F, 92.3539F,
+ -80.0937F, -149.8609F, -166.3557F, 134.5224F, 22.8807F, -72.2311F, -71.7019F,
+ -106.2400F, 96.5443F, 49.1033F, -82.1511F, -202.4001F, -182.6395F, 30.4307F,
+ -38.6498F, -47.0332F, 196.2347F, 62.6390F, -109.4412F, -217.5327F, 118.6330F,
+ -165.3289F, -6.5073F, -110.5468F, -172.9718F, 83.9014F, 82.6244F, -54.8262F,
+ -220.1304F, -267.2490F, -88.9432F, 199.2986F, 140.8517F, 50.8656F, 126.1685F,
+ -167.2625F, 130.8662F, 38.2409F, -25.2887F, 14.1618F, -84.0247F, -96.2550F,
+ -141.5362F, 19.9235F, 142.0336F, -6.1892F, -91.4426F, 58.7228F, -64.2743F,
+ 356.9441F, 345.0619F, 293.3749F, 255.2251F, 264.2440F, 181.1552F, -59.9296F,
+ 246.4391F, 212.9810F, 208.9891F, 281.1677F, 232.7401F, 140.5526F, -31.7890F,
+ 305.7318F, 278.3117F, 199.8758F, 171.6015F, 133.0515F, 98.0317F, -152.6052F,
+ 194.0116F, 162.7764F, 97.4355F, 145.3808F, 115.4215F, 67.7161F, -75.3193F,
+ 50.0116F, -43.0169F, -150.4608F, 36.4008F, 15.3428F, 67.7103F, -90.2827F,
+ 84.1801F, -22.9641F, -98.8488F, 180.4238F, 151.9562F, 59.9903F, 26.9906F,
+ 177.5510F, 105.3890F, -1.4605F, -131.7380F, -19.1906F, 90.9329F, -125.9315F,
+ 119.9137F, 55.8859F, 20.5790F, 85.2794F, 50.1218F, 92.1433F, -60.8729F,
+ -14.4439F, -72.6866F, -93.8542F, -160.4042F, -42.8567F, 3.3977F, 156.0409F,
+ -54.5578F, -142.4629F, -245.2400F, 100.6745F, 148.4848F, 83.6861F, 108.3569F,
+ 51.3106F, 177.4475F, 69.0944F, -111.1996F, -202.9647F, 42.3005F, -83.6978F,
+ 30.1802F, -55.2034F, 78.5647F, -47.9833F, -191.5273F, -51.2293F, 23.2575F,
+ -5.5372F, -75.8171F, -203.4011F, -289.5156F, 106.7613F, 141.4280F, -13.0810F,
+ -141.4010F, -221.2458F, -112.2780F, -89.1527F, 63.0527F, 92.4026F, 123.8935F,
+ -105.1256F, 76.2826F, -29.3279F, -146.3319F, -79.8275F, 4.2937F, 30.2187F,
+ -50.0448F, -103.1965F, -61.1121F, -87.1858F, -185.4814F, 103.5567F, 10.4906F,
+ 483.7709F, 447.9613F, 357.9065F, 269.2391F, 168.5860F, 81.9800F, -109.5565F,
+ 312.3829F, 259.3732F, 343.4722F, 283.4192F, 160.6555F, 62.4472F, -64.0786F,
+ 177.4189F, 268.0235F, 209.2622F, 107.3129F, 57.2866F, 17.7874F, 43.3733F,
+ 118.3413F, 189.8245F, 200.1482F, 138.5254F, 93.9936F, 70.6362F, -26.8448F,
+ 30.9857F, 35.8345F, 11.3604F, 57.5567F, 90.9626F, 20.1319F, 6.8180F,
+ -66.7255F, 112.7395F, 51.2972F, 171.5931F, 105.7922F, 1.0289F, -4.0888F,
+ 161.4374F, 94.0077F, 56.1444F, 67.9007F, 60.5061F, -0.5993F, 5.5333F,
+ 22.6145F, 84.7579F, 96.3842F, 85.7332F, 58.1820F, 68.5529F, -7.0445F,
+ 89.2476F, -2.9310F, -93.5695F, -80.5243F, -200.4216F, -74.7223F, 78.7932F,
+ -37.6075F, -106.1347F, -177.1898F, 12.7187F, -117.0868F, -224.7555F, 18.0710F,
+ -3.9184F, -42.1867F, -96.2393F, -135.5441F, -300.7351F, -209.1140F, 3.3638F,
+ -127.2731F, -168.0130F, -23.6514F, -125.4722F, -275.0623F, -116.8249F, 78.4081F,
+ -0.3268F, -109.2929F, -235.6517F, -163.5220F, -72.4472F, 7.1522F, -14.1950F,
+ -201.5567F, -203.8994F, -147.8831F, -113.7655F, -70.6486F, -37.9403F, 10.4648F,
+ -61.9333F, -122.2785F, -205.0957F, -87.3765F, -199.0248F, -324.4658F, -76.9686F,
+ -114.1747F, -179.4460F, -22.8678F, -120.9749F, -219.5858F, -55.7430F, -137.0347F,
+ 416.5525F, 356.2247F, 246.4192F, 151.7590F, 80.9813F, 33.7425F, -87.5668F,
+ 232.7198F, 199.8298F, 232.8017F, 197.1352F, 122.7492F, 47.7377F, -18.8607F,
+ 307.4450F, 336.4361F, 172.1882F, -36.4639F, -118.2980F, 12.7783F, -74.1220F,
+ 100.4413F, 183.0223F, 131.6807F, 19.7279F, 5.8399F, 116.3680F, -36.1637F,
+ 115.0603F, 28.3727F, -46.6535F, 9.9458F, 14.2165F, 8.8947F, 42.1125F,
+ -11.0346F, -1.0867F, -12.6705F, 44.5022F, 8.2729F, 72.2938F, 41.9570F,
+ 188.4713F, 119.1476F, 5.8222F, -109.1441F, -124.7922F, 20.2470F, 37.4241F,
+ 88.4120F, 18.1026F, 44.8535F, 28.1015F, -53.1688F, 52.0384F, -48.7039F,
+ 7.0136F, -80.7959F, -218.2056F, -230.6367F, -196.4241F, -188.3921F, 125.5651F,
+ -223.0832F, -308.3413F, -371.4560F, -67.3406F, -172.4539F, -210.1611F, 44.0330F,
+ 70.5425F, 5.5613F, -121.1026F, -250.2220F, -391.0280F, -78.8702F, 62.0359F,
+ -53.2080F, -153.5175F, -168.9519F, -200.2387F, -356.0113F, -56.1841F, -8.4833F,
+ 28.1989F, -103.3445F, -275.6373F, -372.5401F, -62.2850F, 20.7805F, 129.8285F,
+ -131.8626F, -230.9837F, -332.7086F, -149.5865F, -154.3909F, 21.7068F, 17.3275F,
+ 16.7300F, -61.8863F, -181.1369F, -350.5149F, -246.6439F, -61.1861F, -114.9767F,
+ -62.9283F, -50.0990F, -128.3168F, -223.8037F, -188.6130F, -48.9473F, 4.2910F,
+ 397.1338F, 354.0856F, 410.7048F, 392.6840F, 265.0492F, 133.1239F, -39.9595F,
+ 140.3398F, 130.2926F, 612.1718F, 513.2461F, 282.4946F, 41.1820F, 3.7939F,
+ -25.5253F, 283.5953F, 206.7656F, 117.4847F, 85.9801F, 16.9447F, -106.7023F,
+ -199.2065F, 170.3263F, 280.7031F, 221.1866F, 139.8684F, 69.7774F, 44.7026F,
+ -218.6125F, 116.3745F, 51.8822F, -46.6960F, 133.6225F, 87.8249F, 5.3826F,
+ -351.2338F, -39.4894F, 84.6148F, 241.0717F, 156.3851F, 57.0277F, -22.5485F,
+ -16.1558F, 137.3482F, 31.9090F, -76.7114F, 15.3505F, 47.2591F, -65.0792F,
+ -82.6497F, 23.1536F, 174.7281F, 111.0391F, 165.1666F, 97.6276F, -66.0758F,
+ -144.8786F, -188.8722F, -232.9240F, 11.8115F, -15.8240F, 97.1230F, 8.4134F,
+ -145.3324F, -253.9705F, -310.2223F, 186.1852F, 173.7029F, 84.4147F, -31.0347F,
+ -137.6416F, 107.5353F, 6.4667F, -172.8744F, -362.7197F, 36.0251F, 7.3423F,
+ -273.1752F, -271.7551F, 168.5304F, 103.1478F, -19.2394F, -121.0773F, 71.0605F,
+ -382.1200F, -84.7432F, -167.9304F, -156.0550F, 39.5436F, 102.1275F, 28.0496F,
+ -362.7133F, -347.0801F, -139.5875F, -5.2563F, 181.0231F, 147.5667F, 92.1709F,
+ -322.5983F, 22.0118F, 11.8984F, -116.7982F, -140.8088F, -50.1710F, -20.0495F,
+ -342.8153F, -116.9352F, -43.2698F, 29.1059F, 25.4655F, 14.1526F, 1.1041F,
+ 319.3257F, 143.9371F, -9.8398F, 138.1817F, 272.2951F, 230.7682F, -67.6844F,
+ 120.5561F, 82.8050F, 86.9118F, 293.3890F, 188.8921F, 54.7609F, -21.7199F,
+ 231.6328F, 148.0905F, 27.2085F, -3.2337F, 100.6721F, 70.2593F, 42.8315F,
+ 64.4154F, -17.9857F, 99.5439F, 116.0344F, 85.7395F, 106.6537F, 41.0177F,
+ 62.6236F, -27.4056F, -139.7237F, -70.5707F, 148.2318F, 128.9077F, 124.7000F,
+ -92.9236F, -144.0688F, -77.1586F, 288.9071F, 226.4347F, 124.6281F, -55.6669F,
+ 78.3503F, 42.4807F, -79.0042F, -178.3122F, 128.1446F, 107.8855F, -55.1806F,
+ 79.1238F, 66.4433F, 43.2504F, 16.2992F, 80.8281F, 140.7251F, 73.5809F,
+ -134.6119F, -155.8599F, -200.3194F, -90.9865F, 253.7969F, 164.9683F, 31.5576F,
+ -248.1197F, -375.5200F, -476.6351F, 180.7157F, 210.6575F, 79.8609F, 81.7351F,
+ 78.7261F, -9.7665F, -75.8617F, -194.4922F, -307.4282F, 75.4347F, -56.0501F,
+ -175.4331F, -210.0029F, 75.9892F, -41.3638F, -129.4197F, 26.7040F, 24.1293F,
+ -89.1388F, -186.3199F, -327.9780F, -225.0781F, 123.8019F, 49.8056F, 110.5614F,
+ -262.0009F, -365.9398F, -315.0958F, -44.6833F, 152.6366F, 130.9091F, -24.3555F,
+ 96.1914F, 0.9431F, -122.7709F, -265.0437F, -118.4077F, 70.4388F, -34.3324F,
+ -41.7155F, -106.2450F, 35.3080F, -77.1729F, -11.0485F, 113.3317F, -43.5801F,
+ 345.8234F, 448.9382F, 398.8093F, 278.1467F, 193.7783F, 109.9307F, -32.5084F,
+ 105.2215F, 192.0218F, 307.4095F, 251.2213F, 135.6460F, 27.1659F, 48.2501F,
+ 131.1255F, 248.6208F, 194.8135F, 35.9742F, -89.6413F, -70.1114F, 74.4933F,
+ 10.3277F, 157.1341F, 220.2146F, 132.8669F, 58.2022F, -4.2414F, 52.5998F,
+ -171.9997F, 219.1700F, 183.7592F, 79.7388F, -28.2743F, -72.7875F, 54.8047F,
+ -281.0813F, 5.4272F, 138.6439F, 89.6476F, 26.7423F, -52.0621F, 181.8158F,
+ 42.9908F, 121.1063F, 40.1449F, 4.6961F, 41.3091F, 11.3680F, 61.7374F,
+ -69.6739F, 44.0933F, 62.9511F, 55.3414F, 47.1718F, 45.0520F, 10.5398F,
+ -254.2462F, -161.6377F, -252.0311F, -59.3082F, -64.1228F, -5.1355F, -167.6060F,
+ -249.7012F, -368.7658F, -266.1853F, -40.5172F, -31.5949F, 20.3852F, -73.7292F,
+ -259.0964F, -63.9727F, -123.4555F, -266.6797F, -372.6790F, -79.9634F, -32.2913F,
+ -237.8991F, -261.1591F, -67.3100F, -201.9258F, -271.1355F, 110.5556F, -31.4253F,
+ -252.1870F, -59.5241F, -149.7008F, -264.8359F, -95.9333F, -15.7623F, -55.9292F,
+ -291.6127F, -310.8436F, -291.0997F, -152.3425F, -38.1903F, 16.9302F, 107.5521F,
+ -234.1635F, -77.8775F, -155.4929F, -169.1375F, -170.1633F, -210.0618F, 12.2871F,
+ -432.5516F, -222.0327F, -146.7204F, -103.4423F, -49.3643F, -8.0516F, 0.3778F,
+ 330.7150F, 223.7578F, 120.2566F, 152.9689F, 119.1688F, 39.3462F, 21.3169F,
+ 106.4649F, 114.2936F, 78.3297F, 104.4772F, 135.1724F, 78.5670F, 48.1339F,
+ 284.0033F, 187.5895F, 88.2418F, 0.6583F, -25.3445F, -53.7671F, 63.9802F,
+ 106.5275F, 81.1295F, 67.7705F, 114.2483F, 4.6206F, 98.6728F, 68.0557F,
+ 132.7267F, 80.9311F, 70.2013F, 34.2614F, 45.4356F, 17.9487F, 185.5185F,
+ -179.6926F, -64.9953F, -11.8397F, 5.1401F, 42.9932F, 67.5337F, 154.7699F,
+ 53.6060F, 34.2805F, 16.7478F, -53.4059F, -36.7348F, 13.1978F, 110.7422F,
+ 37.6082F, -5.5267F, 88.1530F, 15.7336F, 24.4194F, 27.1976F, 50.6641F,
+ -182.5485F, -287.0959F, -395.1311F, -458.4781F, -119.8993F, 119.0388F, -26.2634F,
+ -239.2084F, -359.3420F, -447.6111F, -221.6196F, -3.2312F, 35.8538F, -9.6860F,
+ -70.9599F, -105.8073F, -192.0091F, -294.5047F, -334.6240F, 111.9638F, -29.3527F,
+ -193.0902F, -307.5872F, -268.9553F, -266.8591F, -276.8985F, 53.4395F, -127.3159F,
+ -112.3830F, -214.7503F, -352.5892F, -431.6330F, 130.6462F, 125.3650F, -24.3701F,
+ -138.4310F, -254.9568F, -325.5955F, -173.9416F, 0.3136F, 147.4202F, -59.5469F,
+ -63.4081F, -119.3462F, -237.6156F, -366.1194F, -116.1935F, 96.5096F, -74.8714F,
+ -91.5009F, -186.5192F, -95.3213F, -190.6698F, -103.7853F, 133.5730F, -129.6124F
+};
+
+/*
+ * 2nd stage codebook; 1st split: isf2_0 to isf2_2
+ */
+const Float32 E_ROM_dico21_isf[SIZE_BK21 * 3] = {
+ 128.4688F, 159.8148F, 97.2755F,
+ -12.9836F, 197.1542F, 62.3669F,
+ -11.1370F, -5.4038F, 227.1786F,
+ -102.5247F, 49.5302F, 138.2452F,
+ 56.6014F, 92.4597F, 68.2462F,
+ -59.4614F, 95.8021F, 47.7671F,
+ 10.6214F, 16.4206F, 132.7432F,
+ -33.0052F, -36.4880F, 121.6274F,
+ 111.3621F, 86.8573F, -60.9301F,
+ 18.4019F, -16.9460F, -196.8595F,
+ 91.2159F, 47.1568F, 150.3417F,
+ 40.7444F, -123.8314F, 17.6656F,
+ 68.7560F, 76.0870F, 3.0834F,
+ 40.5189F, -22.9558F, -36.8239F,
+ 68.9463F, 20.8592F, 75.1641F,
+ -13.4297F, -49.7472F, 59.4394F,
+ 222.6512F, 108.2263F, -13.1594F,
+ -26.2678F, -128.5232F, -249.6796F,
+ -61.3770F, -106.3253F, 180.3803F,
+ -69.2195F, -180.5594F, 77.3840F,
+ 125.7118F, 69.8739F, 44.7696F,
+ -150.6344F, 66.9866F, 7.4132F,
+ 7.5039F, -4.7150F, 76.2746F,
+ -46.9159F, -98.2953F, 78.4325F,
+ 118.5603F, 14.1695F, -131.2373F,
+ -50.1565F, -86.1739F, -148.3825F,
+ 66.6965F, -72.1903F, 115.4583F,
+ -94.5599F, -121.9918F, 8.8523F,
+ 77.1679F, 15.2443F, 6.1163F,
+ -1.0987F, -69.2605F, -43.3316F,
+ 43.3928F, -36.3404F, 29.4998F,
+ -36.0829F, -87.1134F, 1.6094F,
+ 69.0548F, 158.6352F, -17.3680F,
+ -65.7580F, 148.4039F, -58.1224F,
+ -1.4207F, 106.6547F, 129.4115F,
+ -163.9787F, 200.5753F, 108.3887F,
+ 8.0981F, 96.4962F, 18.4523F,
+ -22.7513F, 51.0308F, -0.8203F,
+ -1.3389F, 52.2067F, 70.5057F,
+ -56.5316F, 15.5148F, 68.5082F,
+ 73.6822F, 28.9345F, -56.5083F,
+ -10.5212F, -17.6820F, -126.8611F,
+ 144.6737F, -44.4661F, -8.2446F,
+ -32.2712F, -161.9950F, -67.5138F,
+ 29.9266F, 37.2667F, -20.0451F,
+ -15.7787F, -11.7016F, -26.2432F,
+ 27.7648F, 34.4647F, 33.4065F,
+ -13.8614F, -38.4420F, 5.6107F,
+ 27.0098F, 76.8588F, -130.2875F,
+ -76.5280F, 30.9527F, -90.1727F,
+ -135.8326F, -53.3710F, 85.3346F,
+ -137.4852F, -34.8750F, -33.3215F,
+ 18.2807F, 78.3958F, -50.7970F,
+ -64.5101F, 14.5083F, -5.6925F,
+ -16.6084F, 1.0141F, 33.5889F,
+ -63.0082F, -42.0433F, 31.0393F,
+ 32.2577F, 8.3123F, -92.4112F,
+ -31.6346F, -58.2893F, -92.9305F,
+ 58.7086F, -72.6659F, -98.0877F,
+ -72.8089F, -97.1838F, -63.2264F,
+ -7.5866F, 25.6299F, -54.3822F,
+ -10.3321F, -19.4552F, -70.7729F,
+ 9.4725F, 4.3403F, 0.0721F,
+ -50.7563F, -41.0679F, -38.2745F
+};
+
+/*
+ * 2nd stage codebook; 2nd split: isf2_3 to isf2_5
+ */
+const Float32 E_ROM_dico22_isf[SIZE_BK22 * 3] = {
+ -49.5271F, 121.1295F, 16.4769F,
+ -94.4022F, 76.8061F, 2.1280F,
+ -58.8683F, 32.7926F, -6.6703F,
+ -83.7461F, 49.5749F, -58.1205F,
+ -96.5332F, -51.1816F, 62.2310F,
+ -104.6874F, -104.4218F, -36.9709F,
+ -84.8023F, 0.4441F, -31.0082F,
+ -105.8907F, -31.0867F, -72.0962F,
+ -17.4561F, 170.2726F, 62.0341F,
+ 64.3231F, 77.6492F, 152.6545F,
+ -13.0558F, 31.6496F, 73.1381F,
+ -25.9540F, -16.3235F, 138.6579F,
+ -116.2904F, -22.1347F, 133.9606F,
+ -42.0923F, -209.9028F, 88.4509F,
+ -56.0897F, -9.1734F, 75.5450F,
+ 68.7883F, -157.0452F, 33.8343F,
+ 20.5838F, 115.6837F, 9.8136F,
+ -32.8948F, 98.7358F, -40.4656F,
+ -22.8099F, 41.1383F, -49.3496F,
+ -66.1700F, 67.9190F, -122.8227F,
+ -18.8196F, 17.0630F, -114.9884F,
+ -64.0458F, -162.7084F, -94.5118F,
+ -54.2084F, 1.0923F, -75.9526F,
+ -60.5415F, -80.9324F, -82.4130F,
+ 46.5760F, 125.8621F, 83.1458F,
+ 129.9934F, 19.7027F, 148.2803F,
+ 92.6546F, 96.4434F, -0.8040F,
+ 181.9977F, -6.0791F, 78.6212F,
+ 93.0392F, -99.5781F, -41.6073F,
+ 26.0437F, -172.0070F, -58.1634F,
+ 47.8475F, -34.2895F, -54.2498F,
+ 34.4187F, -96.6345F, -28.5027F,
+ -15.8270F, 90.1190F, 65.2787F,
+ -24.1274F, 60.7006F, 6.3059F,
+ -25.2307F, 6.3412F, 30.0794F,
+ -26.6845F, -0.7965F, -24.5917F,
+ -59.0614F, -117.3599F, 62.4002F,
+ -7.0821F, -130.0555F, 20.9710F,
+ -21.7086F, -36.6794F, 1.9468F,
+ 0.6440F, -74.2564F, 5.5161F,
+ 35.9276F, 57.9971F, 81.4502F,
+ 42.2272F, 3.3575F, 106.2218F,
+ 42.1565F, 13.6719F, 43.0135F,
+ 55.6116F, -33.1310F, 56.8126F,
+ 18.4410F, -61.4055F, 109.0841F,
+ 1.0223F, -125.1248F, 96.1657F,
+ 16.9404F, -28.1707F, 26.5748F,
+ 33.5245F, -84.6827F, 52.6704F,
+ 14.2066F, 54.8716F, 30.7506F,
+ 21.9479F, 68.4119F, -19.0589F,
+ 10.1034F, 17.7161F, 1.1122F,
+ 28.3594F, 21.5207F, -39.3190F,
+ 42.6619F, -71.6784F, -94.4716F,
+ -1.6345F, -110.6804F, -94.5938F,
+ 18.7091F, -26.5385F, -18.5676F,
+ -2.2267F, -59.7051F, -47.6606F,
+ 63.0633F, 76.6895F, 37.6845F,
+ 90.5993F, 31.2041F, 74.2520F,
+ 64.4418F, 37.7231F, 4.2748F,
+ 100.9151F, -12.1708F, 27.5607F,
+ 104.1606F, -30.0584F, -35.7097F,
+ 121.5339F, -81.6812F, 34.1503F,
+ 59.3840F, -5.5457F, -8.5514F,
+ 58.5319F, -58.3782F, 3.4649F,
+ -126.3823F, 217.4185F, 72.9956F,
+ -149.8116F, 119.9919F, 17.7920F,
+ -98.1555F, 10.6050F, 30.1117F,
+ -142.4950F, 30.1718F, -20.4500F,
+ -188.3500F, -32.7229F, 62.5055F,
+ -165.4842F, -201.2336F, -25.1871F,
+ -114.8346F, -46.6803F, -1.4401F,
+ -185.9166F, -45.3806F, -42.6756F,
+ -37.7442F, 124.2892F, 142.7720F,
+ 41.5423F, 244.7676F, 173.7613F,
+ -74.1037F, 46.8818F, 112.0588F,
+ -57.0922F, 25.5056F, 241.9654F,
+ -166.9268F, 94.6864F, 141.8443F,
+ -141.0368F, -145.0649F, 168.9254F,
+ -135.5530F, 39.8468F, 65.4743F,
+ -245.6494F, 76.1803F, -5.6309F,
+ -25.5608F, 185.7902F, -18.2246F,
+ -116.1471F, 125.0659F, -65.5997F,
+ -21.6448F, 139.2267F, -103.0516F,
+ -152.7089F, 32.1737F, -111.7466F,
+ -19.9673F, -12.1771F, -217.1499F,
+ -69.4452F, -156.0378F, -228.9529F,
+ -79.9513F, -19.3186F, -140.5787F,
+ -134.0792F, -92.8863F, -131.5222F,
+ 85.7696F, 178.6823F, 22.5404F,
+ 219.0179F, 182.4547F, 100.9819F,
+ 132.7898F, 105.4102F, -65.5694F,
+ 175.6583F, 30.2382F, -109.3055F,
+ 23.2833F, 65.0492F, -161.3234F,
+ 51.9178F, -98.2708F, -192.0347F,
+ 84.2797F, 61.1831F, -113.4513F,
+ 110.0580F, 0.1775F, -193.4730F,
+ -88.3674F, 114.5595F, 71.3481F,
+ -61.4713F, 52.7833F, 47.8295F,
+ -61.8477F, -23.0151F, 15.1016F,
+ -52.0862F, -46.0690F, -37.7005F,
+ -129.6202F, -120.6827F, 44.2216F,
+ -62.4412F, -165.8667F, -2.2683F,
+ -58.1508F, -82.2449F, 9.3842F,
+ -31.2569F, -108.3441F, -35.0348F,
+ -4.4143F, 48.6610F, 132.2242F,
+ 50.8942F, -27.6676F, 181.6500F,
+ 2.0066F, -17.6839F, 71.9731F,
+ 92.7139F, -37.1637F, 98.9732F,
+ -54.3785F, -76.9789F, 115.8870F,
+ -7.4354F, -117.3479F, 199.5254F,
+ -24.6757F, -59.5165F, 54.3134F,
+ 97.6902F, -113.0194F, 131.1002F,
+ 48.4163F, 132.4722F, -58.7820F,
+ 13.3327F, 68.6117F, -81.0715F,
+ 66.7414F, 64.6961F, -45.2427F,
+ 36.7779F, 14.7160F, -89.5910F,
+ 29.2181F, -25.5238F, -132.3077F,
+ -30.5052F, -80.0320F, -150.5560F,
+ 0.1157F, -11.7322F, -63.8467F,
+ -21.6912F, -43.0765F, -94.6223F,
+ 125.3290F, 95.1208F, 75.9759F,
+ 197.4010F, 92.9319F, -0.5012F,
+ 123.8246F, 45.4969F, 25.5317F,
+ 120.7415F, 34.4155F, -28.8961F,
+ 176.6600F, -20.0903F, -19.4091F,
+ 130.6288F, -84.9368F, -113.4633F,
+ 82.2281F, 16.0388F, -59.4614F,
+ 93.1589F, -21.5846F, -101.7248F
+};
+
+/*
+ * 2nd stage codebook; 3rd split: isf2_6 to isf2_8
+ */
+const Float32 E_ROM_dico23_isf[SIZE_BK23 * 3] = {
+ -3.8995F, 58.9472F, 140.2168F,
+ 53.1422F, 116.3810F, 87.0383F,
+ 99.7094F, -40.4441F, 113.1331F,
+ 165.1496F, 2.2135F, 71.5223F,
+ -105.3934F, -104.9144F, -38.2897F,
+ -20.3247F, -32.1811F, 5.1214F,
+ -32.0250F, -106.9634F, -37.7452F,
+ 35.0256F, -95.9288F, -28.2073F,
+ -116.9343F, -27.2704F, 164.5334F,
+ -34.2352F, 142.6884F, 167.9453F,
+ 72.9835F, -124.0776F, 148.8355F,
+ 148.2748F, 14.5359F, 190.7047F,
+ -145.5305F, -123.4847F, 30.8224F,
+ -120.2600F, -39.3306F, 2.0939F,
+ -52.9049F, -176.3645F, 3.0609F,
+ 27.9487F, -164.3167F, -60.3281F,
+ 70.4088F, 66.5042F, -47.2043F,
+ 24.2507F, 69.1997F, -15.5014F,
+ 127.5028F, 31.2976F, -40.8233F,
+ 96.9136F, 102.7271F, -1.9768F,
+ -65.7818F, -70.8663F, -86.5155F,
+ -0.6444F, -8.8675F, -61.8361F,
+ -5.3369F, -58.3089F, -47.3390F,
+ 46.4765F, -35.6284F, -57.4718F,
+ 46.3328F, 129.6813F, -59.6592F,
+ 18.9988F, 118.4842F, 13.3515F,
+ 172.5430F, -21.3132F, -26.8827F,
+ 84.7525F, 177.2668F, 22.5077F,
+ -140.2432F, -73.0634F, -146.3583F,
+ -16.3786F, 19.6063F, -107.1305F,
+ -3.0698F, -104.1769F, -97.1330F,
+ 33.2378F, -33.4660F, -134.9635F,
+ -29.8971F, -15.7433F, 134.7990F,
+ 34.9346F, 52.2504F, 85.7197F,
+ 60.8752F, -31.2562F, 62.5970F,
+ 42.3279F, 15.7348F, 45.3299F,
+ -61.8761F, -80.5864F, 11.3831F,
+ 1.9118F, -12.4255F, 68.2023F,
+ -25.4049F, -61.6688F, 57.1412F,
+ 21.3127F, -30.3874F, 28.3554F,
+ -44.5637F, -86.8534F, 137.9897F,
+ -18.2977F, 31.6219F, 82.2796F,
+ 19.0573F, -58.8750F, 104.6892F,
+ 41.1433F, 1.5028F, 117.9977F,
+ -102.7489F, -51.4207F, 71.3300F,
+ -59.0984F, -10.9389F, 78.5554F,
+ -69.1486F, -120.0273F, 65.0256F,
+ 39.6252F, -86.2109F, 50.9690F,
+ 29.0714F, 22.6919F, -38.4256F,
+ 12.6360F, 17.2986F, 5.2183F,
+ 75.9445F, 11.6720F, -55.4942F,
+ 66.2898F, 37.5939F, 3.0594F,
+ -53.0062F, -46.4272F, -35.4140F,
+ -25.4219F, 2.9542F, -21.2949F,
+ 1.3392F, -73.4502F, 4.6640F,
+ 17.5926F, -24.6153F, -19.1614F,
+ 58.2567F, -8.0154F, -7.3521F,
+ 9.4616F, 56.2212F, 37.1474F,
+ 99.2497F, -8.5999F, 23.5678F,
+ 62.8908F, 76.5199F, 37.4883F,
+ -61.5740F, -23.6494F, 18.8743F,
+ -27.4404F, 12.7151F, 31.8660F,
+ -8.8214F, -125.3200F, 22.5806F,
+ 60.3707F, -57.3931F, 1.9729F,
+ -142.0781F, 128.1134F, 29.9265F,
+ -8.1434F, 177.0072F, 67.7176F,
+ -42.2467F, 31.9985F, 246.1330F,
+ 143.5303F, 102.5801F, 81.3050F,
+ -117.3709F, -24.3191F, -68.7836F,
+ -80.1727F, 55.9021F, -61.6700F,
+ -65.9167F, -159.9841F, -103.0851F,
+ 100.4774F, -105.1623F, -39.0393F,
+ -248.4434F, 113.0562F, -0.9632F,
+ -114.2012F, 244.7349F, 67.3892F,
+ -149.2039F, -141.9386F, 151.3480F,
+ 96.8171F, 204.6967F, 174.6282F,
+ -203.4799F, -43.3805F, -41.7327F,
+ -154.4080F, 46.2418F, -107.0591F,
+ -133.7993F, -265.7036F, -48.9596F,
+ -67.3323F, -174.6485F, -259.0245F,
+ 29.4362F, 57.7183F, -143.2330F,
+ -30.9358F, 102.7735F, -36.8946F,
+ 97.2809F, 57.7730F, -111.7326F,
+ 148.5371F, 105.7429F, -63.3760F,
+ -55.6062F, -1.6898F, -72.6741F,
+ -22.0825F, 43.4697F, -48.9841F,
+ -13.6583F, -42.0695F, -99.1267F,
+ 39.0227F, 11.1441F, -94.4170F,
+ -31.1674F, 118.4450F, -103.1298F,
+ -30.5761F, 181.1050F, -22.4168F,
+ 96.8625F, -8.6867F, -192.7743F,
+ 258.0970F, 258.6485F, 17.2359F,
+ -75.4867F, -15.7399F, -128.9883F,
+ -69.4209F, 56.4875F, -131.4587F,
+ -35.1219F, -77.9249F, -156.1559F,
+ -15.4754F, -8.8922F, -194.7119F,
+ -74.8584F, 44.6175F, 122.9601F,
+ -15.9046F, 95.4389F, 74.2532F,
+ 34.5640F, -37.7631F, 189.4453F,
+ 93.9878F, 31.0970F, 82.8675F,
+ -96.2834F, 15.6201F, 33.9921F,
+ -60.9930F, 57.5930F, 52.2667F,
+ -0.7661F, -130.2809F, 93.4385F,
+ 120.2708F, -79.2677F, 42.9508F,
+ -179.2200F, 97.8633F, 164.7641F,
+ -85.0375F, 121.2092F, 89.0752F,
+ -33.4305F, -135.1092F, 255.3923F,
+ 71.7349F, 68.5372F, 165.8218F,
+ -187.7999F, -24.7305F, 65.9037F,
+ -136.4161F, 45.6197F, 73.4184F,
+ -48.8887F, -218.9293F, 120.9648F,
+ 61.8728F, -162.4253F, 36.5784F,
+ 17.9416F, 66.9736F, -75.1315F,
+ -24.6266F, 61.4069F, 5.3953F,
+ 100.0199F, -13.7281F, -105.7749F,
+ 125.9485F, 48.0431F, 20.6117F,
+ -83.4273F, 1.6803F, -29.7397F,
+ -60.9733F, 33.6154F, -6.9071F,
+ 49.9381F, -77.0001F, -90.5842F,
+ 103.7070F, -35.1051F, -38.3706F,
+ -120.2797F, 129.5670F, -56.7507F,
+ -51.1815F, 120.2600F, 22.5398F,
+ 198.7324F, 23.1592F, -132.3752F,
+ 219.6951F, 76.6881F, -5.4836F,
+ -147.6706F, 39.1117F, -18.2240F,
+ -91.4913F, 78.8627F, 0.3161F,
+ 40.5908F, -105.4075F, -192.5737F,
+ 124.6250F, -81.8382F, -127.0619F
+};
+
+
+/*
+ * 2nd stage codebook; 4th split: isf2_9 to isf2_11
+ */
+const Float32 E_ROM_dico24_isf[SIZE_BK24 * 3] = {
+ -30.8071F, -34.8458F, -1.7377F,
+ -66.7509F, 30.0385F, -82.3340F,
+ 62.4748F, -75.5700F, 38.3392F,
+ 47.0287F, -40.0671F, 126.1063F,
+ 12.5178F, -8.7146F, -50.3954F,
+ 27.9620F, 30.3537F, -104.7235F,
+ 71.0260F, -29.6231F, -25.7014F,
+ 120.7753F, 38.6709F, -56.4990F,
+ -89.5313F, -61.4613F, -32.9542F,
+ -149.7260F, 38.4143F, -27.8365F,
+ -35.1587F, -137.6189F, 4.6136F,
+ -110.8198F, -69.6633F, 69.4652F,
+ -25.4794F, -48.9702F, -64.6927F,
+ -34.0250F, -68.5378F, -137.1167F,
+ 16.3769F, -77.3935F, -18.8382F,
+ 60.1539F, -54.6626F, -95.0395F,
+ -29.9828F, 6.8644F, 42.3138F,
+ -15.0985F, 138.6659F, 35.6532F,
+ 34.1357F, 3.3162F, 60.3957F,
+ -1.5046F, 61.8542F, 93.5327F,
+ 49.8233F, 37.2486F, -21.0923F,
+ 2.6462F, 96.2433F, -48.4645F,
+ 100.8559F, 5.8835F, 34.9436F,
+ 80.3813F, 84.4933F, 38.3143F,
+ -78.4639F, 3.3495F, 7.0416F,
+ -121.9442F, 90.8917F, 79.7252F,
+ -15.2997F, -67.8455F, 60.6317F,
+ -56.1035F, -3.5687F, 110.7510F,
+ -22.2741F, 27.4204F, -26.9833F,
+ -61.1362F, 73.0974F, 7.1390F,
+ 21.0362F, -11.6205F, 9.0680F,
+ 9.3252F, 52.8599F, 21.3451F
+};
+
+
+/*
+ * 2nd stage codebook; 5th split: isf2_12 to isf2_15
+ */
+const Float32 E_ROM_dico25_isf[SIZE_BK25 * 4] = {
+ 65.8574F, 55.5896F, -46.5520F, 44.9019F,
+ 80.4838F, -7.7875F, 36.7110F, 88.1867F,
+ -41.5522F, 122.0924F, -8.3769F, 6.2406F,
+ -24.0605F, 63.0705F, 27.8308F, 99.4548F,
+ -34.8725F, 39.6270F, -72.1743F, 48.7995F,
+ 28.2859F, -11.6999F, -78.4246F, 134.1911F,
+ -100.6717F, 12.7337F, -3.2716F, 31.4897F,
+ -40.5514F, -60.1846F, 28.1000F, 115.5554F,
+ 56.1050F, -26.6471F, -104.7202F, -9.7237F,
+ 31.5196F, -30.3722F, -34.0636F, 41.4375F,
+ 8.5013F, 60.4295F, -72.4835F, -46.4772F,
+ -18.1378F, -10.8741F, 10.5206F, 35.6699F,
+ -44.7247F, -14.6405F, -68.4296F, -12.8925F,
+ -36.6233F, -86.8592F, -73.8785F, 47.7951F,
+ -51.6319F, -46.3776F, -74.4907F, -105.4981F,
+ -67.2817F, -67.7186F, 6.9193F, -16.9668F,
+ 108.8168F, 52.7624F, -16.3049F, -50.0846F,
+ 72.9801F, -33.7268F, 89.4150F, -54.0673F,
+ 62.1588F, 93.8928F, 54.7414F, 17.8328F,
+ 26.7626F, 9.6218F, 88.5287F, 29.9594F,
+ 8.1440F, 44.9198F, 5.0806F, 2.9996F,
+ 26.4759F, -96.7328F, 49.0444F, 31.6496F,
+ -58.6349F, 53.6024F, 80.8924F, -3.3883F,
+ -60.0341F, -51.9482F, 112.9073F, 26.0056F,
+ 55.9483F, -14.6255F, -33.5049F, -127.3506F,
+ 70.1847F, -12.4499F, 7.3368F, -8.8635F,
+ 10.1728F, 65.7077F, 45.2101F, -90.9790F,
+ -12.5750F, -10.0652F, 45.9762F, -30.2995F,
+ 1.2805F, -3.2898F, -17.5766F, -44.9828F,
+ 22.1316F, -84.0894F, -21.1065F, -32.5923F,
+ -81.6581F, 43.6873F, -8.6894F, -65.0775F,
+ -35.4129F, -58.9663F, 65.8078F, -102.2045F
+};
+
+/*
+ * isf codebooks: two-stage VQ with split-by-3 in 2nd stage
+ * 1st stage is kept the same as the 46 bit quantizer
+ *
+ * codebook vector dimension number of vectors
+ * ~~~~~~~~ ~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
+ * 1_1 9 256
+ * 1_2 7 256
+ * 2_1 5 128
+ * 2_2 4 128
+ * 2_3 7 64
+ */
+const Float32 E_ROM_dico21_isf_36b[SIZE_BK21_36b * 5] = {
+ -20.3147F, -37.6762F, 82.8575F, 122.9161F, -28.4468F,
+ 31.9756F, -79.5400F, 141.6557F, 53.2923F, -77.0688F,
+ -49.3360F, -129.1711F, 71.5448F, 85.1944F, 55.7117F,
+ -19.1147F, -16.1797F, 217.6729F, 89.8943F, 28.1868F,
+ 0.9668F, -28.5091F, 63.7145F, 147.3305F, 86.3104F,
+ 52.0605F, 43.3415F, 108.6263F, 83.9071F, -42.8628F,
+ -39.7734F, -7.6796F, 110.7755F, 44.0677F, 106.4663F,
+ 32.7239F, 124.4301F, 113.4192F, 7.2217F, 33.0503F,
+ -9.5746F, -1.9619F, 48.6607F, 51.4268F, -79.8193F,
+ -14.9729F, -2.0174F, 111.5604F, -3.5774F, -139.2041F,
+ -54.5000F, -100.1092F, 35.8796F, 45.5500F, -73.7805F,
+ -56.2694F, 74.4424F, 122.2707F, 20.1155F, -38.3887F,
+ 65.2094F, -3.9808F, 17.2638F, 96.6362F, 14.0115F,
+ 148.8982F, 77.1199F, 93.1280F, 28.7596F, 2.2577F,
+ 14.8324F, -159.4414F, 11.4260F, -1.0211F, -33.2422F,
+ 35.9112F, 103.8106F, 61.4044F, -9.7034F, -78.2548F,
+ 62.7658F, -47.4034F, 27.3267F, 32.6865F, -54.7569F,
+ -6.2693F, -33.7779F, 43.5591F, -36.6678F, -73.8111F,
+ -104.9376F, -105.4944F, 137.0911F, 41.7979F, -9.4558F,
+ -26.6750F, -26.3288F, 192.3279F, -40.3915F, -60.3539F,
+ -20.5168F, -51.3274F, 24.2191F, 47.5655F, 3.7810F,
+ 52.7448F, 32.7149F, 110.3630F, -21.5464F, -46.7397F,
+ -4.6471F, -85.4498F, 129.3530F, -31.6973F, 65.0658F,
+ 85.9795F, -53.2356F, 57.2992F, -67.2997F, -16.4516F,
+ 54.7607F, -37.1454F, -42.4738F, -34.5633F, -75.7294F,
+ 0.0517F, -0.6519F, -1.3703F, -12.9917F, -148.9960F,
+ -25.8564F, -84.6818F, 59.5151F, -72.5006F, -156.8837F,
+ 95.5045F, 42.2665F, 60.9475F, -54.5273F, -154.2295F,
+ 44.2810F, -53.2856F, -76.4082F, 42.9736F, -9.5286F,
+ 83.7851F, 46.2184F, 4.1979F, -25.1575F, -51.0520F,
+ -43.1590F, -111.8518F, -2.3420F, -129.5042F, 6.3083F,
+ 36.5568F, 37.9981F, 30.8304F, -113.4959F, -79.9345F,
+ -1.8493F, -15.3605F, -7.7093F, 98.5986F, -37.6177F,
+ 29.8557F, 67.8956F, 39.3578F, 63.5122F, 23.6349F,
+ -27.0502F, -93.1902F, -21.6230F, 155.8476F, 2.5165F,
+ -44.7515F, 124.6855F, 64.1401F, 107.4525F, 76.4296F,
+ -5.6913F, 14.2025F, -18.3757F, 129.1303F, 47.2448F,
+ 88.4045F, 81.8179F, 106.0131F, 126.8375F, 71.9790F,
+ 5.1288F, -31.2676F, -85.3474F, 183.8293F, 137.8851F,
+ 112.3553F, 147.7620F, 6.3634F, -19.8307F, 97.9225F,
+ 68.1479F, 45.1480F, 20.4456F, 58.0360F, -109.0384F,
+ 91.7441F, 107.7617F, 15.1212F, 47.0576F, -18.7769F,
+ 0.0359F, -42.2360F, -42.2471F, 94.1364F, -132.5071F,
+ -36.3673F, 208.5491F, 17.4150F, 13.0281F, -33.9693F,
+ 75.8679F, 58.1435F, -27.7181F, 158.0312F, -17.2012F,
+ 159.6027F, 144.6236F, 31.6370F, -72.6323F, -59.9622F,
+ 9.6094F, -39.8213F, -175.1189F, 48.5059F, -67.6102F,
+ 8.4503F, 159.5329F, -43.0075F, -121.1605F, -83.4178F,
+ -10.0988F, 8.8687F, -32.4219F, 44.4166F, 5.5756F,
+ -42.8299F, 63.9306F, 20.2856F, 86.9213F, -32.1874F,
+ 14.3835F, -9.6605F, -102.7732F, 119.7146F, -5.8143F,
+ -181.8677F, 162.2914F, 114.1354F, 64.3820F, -7.2207F,
+ 11.2529F, -7.2901F, -66.7670F, 60.6365F, 71.2140F,
+ 69.9911F, 56.0744F, -10.7183F, 90.0489F, 100.9538F,
+ -40.2531F, -96.6451F, -154.5512F, 92.9078F, 43.9867F,
+ 146.6528F, -60.2643F, -42.7063F, -1.4891F, 60.9280F,
+ 38.2143F, 33.0628F, -113.9071F, -1.8860F, -48.5082F,
+ 45.4740F, 54.2829F, -45.4768F, -38.2865F, -114.7585F,
+ -5.4061F, -32.4176F, -108.6457F, -45.8426F, -147.6796F,
+ 41.4813F, 12.9066F, -41.5456F, -134.2382F, -189.2112F,
+ 46.4330F, 6.8074F, -160.9846F, 53.8969F, 64.9889F,
+ 149.8519F, 39.6080F, -79.5860F, 34.3934F, -61.0983F,
+ -47.2568F, -110.8652F, -117.2089F, -0.3717F, -64.7306F,
+ 109.4393F, 12.8368F, -59.4424F, -122.1797F, -31.4694F,
+ -14.4126F, 8.5189F, 89.4622F, 59.7035F, 14.3509F,
+ -23.3690F, -32.3486F, 92.0827F, -3.3169F, -16.0022F,
+ -66.1460F, -89.0215F, 49.1022F, -7.9295F, 141.6034F,
+ -91.8393F, 6.6528F, 142.3305F, -60.9383F, 61.1140F,
+ -9.9035F, -11.7998F, 27.9396F, 56.3528F, 60.7524F,
+ 59.7717F, -10.3224F, 100.1088F, 37.9471F, 56.4210F,
+ -8.0706F, -14.3273F, 18.7969F, -25.3479F, 97.6871F,
+ 24.5711F, 30.0075F, 106.4596F, -49.8085F, 48.5911F,
+ -50.4430F, -10.2232F, 15.4334F, 3.6211F, -45.0851F,
+ -2.3100F, 32.1923F, 14.7250F, -35.3260F, -71.2667F,
+ -131.2863F, -5.1029F, 11.0382F, 61.7451F, 35.4884F,
+ -11.6345F, 94.0117F, 53.4418F, -66.3264F, -6.6649F,
+ 57.0155F, 5.4850F, -4.4053F, 12.7554F, 23.6955F,
+ 74.8564F, 77.0331F, 21.2315F, -32.6182F, 33.2036F,
+ 9.1670F, -78.1914F, -30.2862F, -11.1652F, 54.5347F,
+ 47.7388F, 92.4139F, 41.3020F, -133.3741F, 53.0528F,
+ -22.2909F, -55.2830F, -33.2798F, -6.2896F, -28.8257F,
+ -23.1116F, -35.0033F, -3.2927F, -72.9685F, -7.7727F,
+ -82.3073F, -104.1028F, 84.5118F, -69.8221F, -43.1637F,
+ -19.5349F, -2.7976F, 85.8117F, -104.2825F, -27.2739F,
+ -22.1902F, -16.4648F, -6.6730F, -5.7920F, 27.7237F,
+ 12.5658F, 8.3566F, 24.7755F, -53.6096F, 12.7618F,
+ -53.5741F, -68.1802F, 40.6279F, -26.4454F, 38.0614F,
+ -26.1757F, -16.7503F, 52.0974F, -117.6298F, 86.4284F,
+ -45.3502F, -78.0491F, -31.6007F, -35.9389F, -106.1265F,
+ -24.8954F, -15.9989F, -21.2401F, -95.2454F, -86.1251F,
+ -112.2460F, -94.4001F, -19.4652F, -33.9923F, -34.6433F,
+ -95.7000F, 92.3440F, 39.8654F, -64.8912F, -115.0483F,
+ 25.8969F, 9.4794F, -63.2644F, -27.6289F, 36.9308F,
+ 25.6901F, 52.9741F, -35.3425F, -86.0458F, -14.2567F,
+ -38.4101F, -62.7105F, -86.5748F, -73.4519F, 11.4446F,
+ -7.0262F, 6.9787F, -7.4983F, -161.9427F, 3.4520F,
+ 19.1677F, 23.8207F, 38.9733F, 15.3764F, -21.7743F,
+ -43.1688F, 31.9400F, 52.7685F, -11.9674F, 20.1452F,
+ -35.0128F, -59.7929F, -36.1783F, 73.7702F, 71.2205F,
+ -83.5945F, 115.1128F, 46.5742F, -28.7420F, 110.8292F,
+ 0.6347F, 53.5489F, 14.3686F, 18.4025F, 71.1819F,
+ 35.9728F, 45.7217F, 71.9726F, -20.7319F, 145.8423F,
+ -8.1019F, -5.6290F, -13.8278F, 53.1928F, 152.8343F,
+ 57.0881F, 50.3240F, -64.1728F, -11.0774F, 129.9089F,
+ 36.0925F, 31.0887F, -32.6698F, 39.1693F, -52.3060F,
+ -3.1405F, 84.8560F, -12.4226F, 1.0655F, -18.3673F,
+ -58.9719F, 98.0129F, -83.8334F, 55.3139F, 35.7679F,
+ -87.3652F, 121.2513F, -67.0447F, -107.5562F, 38.2622F,
+ 62.0513F, 60.4638F, -69.1208F, 43.6854F, 20.7579F,
+ 79.9694F, 10.7071F, 3.2196F, -93.6621F, 75.1450F,
+ 66.1122F, 46.9324F, -124.5950F, -78.3322F, 41.3915F,
+ 4.3229F, 13.8757F, -33.6575F, -92.7601F, 177.5551F,
+ -42.5067F, -60.2164F, -63.5331F, 67.8862F, -21.5990F,
+ -14.9811F, 12.6046F, -39.5598F, -30.2755F, -22.9980F,
+ -80.2668F, -125.5028F, -37.7023F, 27.0213F, 31.0364F,
+ -121.0989F, 17.0095F, 6.9604F, -72.1639F, 13.2205F,
+ -45.0105F, -7.6587F, -57.9626F, -15.4159F, 79.2983F,
+ -11.3128F, 60.2083F, -11.6157F, -61.5281F, 64.7932F,
+ -17.6502F, -51.3289F, -123.9766F, -9.4275F, 141.7024F,
+ -64.4806F, -80.0931F, -43.9064F, -86.7513F, 103.4672F,
+ -12.6910F, -17.1597F, -58.5736F, 21.2452F, -75.2569F,
+ -2.3195F, -14.7279F, -99.6098F, -65.8753F, -44.8940F,
+ -103.7556F, 33.9613F, -73.7263F, -13.9038F, -66.1526F,
+ -23.2670F, -33.9743F, -103.9167F, -170.2949F, -66.2644F,
+ -26.4354F, -31.7233F, -108.7190F, 9.2282F, 14.7962F,
+ -9.0340F, -7.5327F, -60.7032F, -100.1385F, 55.1481F,
+ -23.7530F, -88.2969F, -220.5980F, -68.4569F, 27.6805F,
+ 3.3643F, -11.1758F, -92.5898F, -201.1381F, 102.8789F
+};
+
+const Float32 E_ROM_dico22_isf_36b[SIZE_BK22_36b * 4] = {
+ -116.4826F, -2.3267F, 37.0276F, 11.9585F,
+ -83.2536F, -34.0855F, -47.5833F, 101.8900F,
+ 1.6666F, -19.3089F, 81.2133F, 5.5915F,
+ -50.2199F, -43.0204F, 11.8773F, 45.9389F,
+ -83.6736F, 100.7533F, 42.9626F, -91.7069F,
+ -15.8879F, -6.8432F, -49.2481F, 46.8567F,
+ 40.2748F, 25.3026F, 49.6150F, -14.6042F,
+ 49.1020F, -13.9172F, -9.5624F, 9.9442F,
+ -53.7549F, -26.0755F, -108.5515F, -72.7670F,
+ -64.1594F, -75.7696F, -78.4742F, 30.5700F,
+ -82.2540F, -34.1100F, -20.0480F, -86.1655F,
+ -68.0474F, -31.0203F, -36.5615F, -15.3976F,
+ 8.8102F, -2.3252F, -61.3614F, -93.8460F,
+ 8.4465F, -43.1451F, -59.6402F, -26.4485F,
+ 57.8873F, -1.8283F, -0.9150F, -58.1355F,
+ -0.3760F, -52.6396F, -15.1757F, -69.7872F,
+ 26.6552F, 140.6710F, -45.5320F, -5.9904F,
+ 53.5205F, 18.1777F, -108.7393F, 57.1700F,
+ 53.1281F, 101.4898F, 52.8254F, 25.2450F,
+ 23.9310F, 45.2712F, -17.5932F, 37.8318F,
+ 90.1549F, 147.8806F, 33.8829F, -46.8215F,
+ 132.2255F, 69.0079F, -106.1068F, 1.3402F,
+ 103.9284F, 60.8167F, 10.9874F, -26.8688F,
+ 101.6619F, 32.7808F, -33.2101F, 33.7802F,
+ -103.9522F, 60.0893F, -100.1459F, -71.1324F,
+ -6.7456F, -25.3835F, -118.9063F, -2.2439F,
+ -15.7859F, 68.4583F, -59.0835F, -70.2552F,
+ -10.4160F, 10.4323F, -34.1781F, -24.5999F,
+ 47.1747F, 44.4596F, -64.8288F, -183.2536F,
+ 62.0332F, -25.7788F, -126.3596F, -90.0926F,
+ 83.7341F, 59.4975F, -55.2472F, -82.6595F,
+ 53.3482F, 14.1273F, -71.7379F, -20.0471F,
+ -110.1113F, -92.4130F, 15.5809F, 3.7302F,
+ -18.8013F, -91.7902F, -14.6105F, 98.1369F,
+ -21.2096F, -126.2513F, 53.1438F, 11.3308F,
+ -34.3197F, -67.9178F, 83.0592F, 77.2733F,
+ -152.4262F, 38.6895F, -24.6967F, -146.6594F,
+ 41.7355F, -66.1454F, -64.2312F, 165.7005F,
+ 27.0772F, -43.2220F, 54.9943F, -65.1872F,
+ 28.8899F, -50.2606F, 25.5035F, 56.2652F,
+ -137.7163F, -80.7691F, -80.0014F, -42.7037F,
+ -62.3651F, -150.7820F, -138.8149F, 38.1900F,
+ -68.7802F, -192.5785F, -7.8749F, -55.9578F,
+ -98.5983F, -168.6083F, -0.7398F, 84.2329F,
+ -35.1656F, -67.9774F, -65.6374F, -160.6224F,
+ 4.9446F, -110.8514F, -89.3759F, -62.4133F,
+ -34.1288F, -108.8451F, 13.3702F, -98.1466F,
+ -29.4614F, -102.8405F, -22.8325F, -16.4528F,
+ 163.9105F, 20.5337F, -82.4577F, -139.6505F,
+ 149.8660F, -13.6016F, -146.1693F, 154.5116F,
+ 26.6673F, -89.2330F, 126.1283F, -0.6475F,
+ 65.0738F, -119.9143F, 75.1351F, 75.9130F,
+ 179.3039F, 128.5647F, -1.9070F, -129.8349F,
+ 146.4228F, 30.7058F, -2.7357F, 122.1955F,
+ 110.1199F, -48.4108F, 78.0568F, -35.8715F,
+ 105.8916F, -63.1848F, -27.3019F, 70.1234F,
+ -61.4940F, -116.2433F, -200.7709F, -120.8167F,
+ 22.5673F, -63.6047F, -213.1464F, 7.0661F,
+ 48.3577F, -141.9964F, 65.3628F, -93.1012F,
+ 32.5991F, -160.4748F, -45.5903F, 37.6377F,
+ 54.6730F, -43.7561F, -151.6335F, -243.7797F,
+ 101.1397F, -52.0073F, -123.8756F, 16.0909F,
+ 63.7439F, -50.8957F, -25.0308F, -130.5887F,
+ 88.2969F, -64.3814F, -48.5324F, -43.0123F,
+ -181.9705F, -24.0096F, 2.3863F, 89.5185F,
+ -59.5915F, 80.1714F, -56.6992F, 94.5562F,
+ -62.1659F, 18.9433F, 76.0160F, 57.8553F,
+ -22.4665F, 10.7743F, 12.0918F, 108.9830F,
+ -118.1671F, 72.3971F, 109.1443F, -1.3839F,
+ -23.8459F, 76.9232F, 22.9444F, 33.4435F,
+ -44.5975F, 47.9554F, 65.6020F, -20.3018F,
+ 13.6440F, 14.2271F, 38.9794F, 49.0774F,
+ -159.0490F, 40.0263F, -30.2347F, -15.6526F,
+ -132.0447F, -0.4802F, -133.5965F, 61.0673F,
+ -69.7882F, 40.8409F, -13.3128F, -38.0654F,
+ -72.3667F, 32.7089F, -13.7936F, 42.2054F,
+ -51.7645F, 41.9187F, -35.3954F, -139.3463F,
+ -70.4106F, 21.2248F, -89.5260F, 9.2659F,
+ -17.3511F, 18.5094F, 18.3073F, -71.0465F,
+ -25.6477F, 4.9120F, 17.7504F, 1.3904F,
+ -132.5788F, 97.9003F, 25.0501F, 88.4524F,
+ -16.3421F, 39.3618F, -136.5657F, 107.5423F,
+ -38.7664F, 155.3425F, 55.5880F, 47.1198F,
+ 43.2628F, 4.6910F, -39.9914F, 101.5498F,
+ 0.0830F, 197.2389F, 101.6377F, -36.9070F,
+ 62.8279F, 111.5018F, -37.6259F, 87.5036F,
+ -1.4618F, 80.2742F, 122.5196F, 12.8147F,
+ 65.1409F, 54.2334F, 34.3093F, 79.7332F,
+ -91.6271F, 123.5048F, -23.6092F, -9.5877F,
+ -3.2208F, -58.6010F, -121.8443F, 78.4266F,
+ -14.0112F, 114.0430F, 23.9902F, -40.4777F,
+ -15.4729F, 68.1635F, -63.4068F, 16.5519F,
+ -8.1780F, 157.1093F, -11.2800F, -137.0649F,
+ 8.0606F, 59.4657F, -140.5838F, -36.3320F,
+ 22.2676F, 74.5499F, 82.8755F, -76.6792F,
+ 29.5054F, 61.7793F, -8.0867F, -27.0956F,
+ -128.1797F, -72.1649F, 129.2723F, 46.4323F,
+ -20.7709F, 111.3353F, 22.0263F, 131.4695F,
+ -41.9162F, -9.2182F, 158.1064F, 11.2798F,
+ -7.1545F, 53.6140F, 106.2812F, 108.0610F,
+ -99.5471F, 8.6443F, 67.7713F, -74.7187F,
+ 115.0857F, 125.6656F, 126.8208F, 118.1528F,
+ 8.3489F, -10.6246F, 129.8214F, -69.4937F,
+ 46.4587F, 5.2711F, 105.7244F, 50.4485F,
+ -177.6754F, -70.1548F, 45.4547F, -74.5236F,
+ -88.7724F, 24.0424F, -57.8465F, 204.7888F,
+ -68.8890F, -112.1224F, 110.3182F, -61.1447F,
+ -94.7905F, 5.0186F, 77.6790F, 167.9779F,
+ -23.0125F, -19.1513F, 44.8958F, -142.4394F,
+ 28.0225F, -67.2659F, -53.6584F, 36.2990F,
+ -54.0239F, -49.3550F, 55.1522F, -32.8946F,
+ 2.0792F, -48.4861F, 14.9542F, -7.9957F,
+ -100.8337F, 121.3744F, 234.8044F, 83.3187F,
+ 36.5393F, 50.8425F, -23.7400F, 196.1698F,
+ -0.3059F, -61.1762F, 189.5078F, 122.4017F,
+ 57.0232F, -28.8934F, 61.7134F, 134.6930F,
+ 107.9555F, 52.8736F, 109.5032F, -22.1311F,
+ 191.2912F, 98.4213F, 38.7853F, 16.9729F,
+ 104.1509F, -28.9315F, 167.6925F, 40.9011F,
+ 108.7356F, -8.7976F, 46.5837F, 36.6080F,
+ -211.7768F, 190.5028F, 100.4753F, -45.0833F,
+ -32.7791F, -95.3684F, -171.2339F, 186.7766F,
+ -44.0395F, -212.9286F, 151.2602F, 39.5958F,
+ -37.2152F, -119.5092F, 43.4460F, 194.5965F,
+ 37.2023F, 64.8673F, 8.5289F, -117.5366F,
+ 163.8890F, -5.9760F, -22.5312F, -30.3817F,
+ 105.4272F, 11.3735F, 47.6228F, -110.1422F,
+ 62.3479F, -93.6059F, 19.4353F, -14.9112F
+};
+
+const Float32 E_ROM_dico23_isf_36b[SIZE_BK23_36b * 7] = {
+ 31.6601F, -7.0021F, 26.7324F, -10.6919F, -47.7440F, -109.3316F, -1.6793F,
+ 17.6152F, -69.1639F, 81.7745F, -11.6557F, -53.0002F, -28.8501F, 51.3155F,
+ -17.3392F, 39.6296F, -29.4208F, -34.2716F, -18.7475F, -53.4279F, -21.0682F,
+ -95.6211F, -11.0108F, 24.5639F, -6.9345F, -43.8606F, -40.3930F, 22.5841F,
+ -30.9469F, -2.2484F, 85.8968F, -25.2118F, 44.4649F, -13.7549F, -19.6283F,
+ 42.5807F, -25.3893F, 55.9790F, -44.6039F, 50.3451F, 29.5180F, 49.0040F,
+ 64.7422F, 35.0105F, -24.0120F, -94.6131F, 72.4785F, -29.0560F, -16.8213F,
+ -17.7762F, -36.1097F, 19.1423F, -88.8131F, 9.4121F, -60.6212F, 15.2182F,
+ 26.1194F, 33.0214F, 38.6243F, -16.4898F, 20.5108F, -71.7754F, -109.7775F,
+ 55.6133F, -47.5797F, 0.0746F, 8.1716F, -55.6639F, -5.8260F, -6.7666F,
+ 86.9148F, 36.0665F, -8.0422F, -18.6522F, -31.9936F, -5.4779F, -65.2340F,
+ 20.0656F, -14.5303F, -94.7449F, -11.7982F, -35.2031F, 6.9138F, -22.0461F,
+ 20.9060F, 41.0458F, 29.0299F, 33.4933F, 27.0675F, 5.1646F, -39.4529F,
+ 76.7175F, 28.2216F, -34.8562F, 16.7304F, 25.2291F, 7.4912F, 15.3906F,
+ 47.1053F, 13.3625F, 50.9902F, -31.9588F, 9.8596F, 83.1329F, -61.0081F,
+ 39.4355F, -39.6936F, -53.1235F, -8.1282F, 22.3882F, 83.7131F, 8.6440F,
+ 13.9302F, -48.4179F, 80.1925F, 79.6573F, 22.8321F, -61.0888F, -32.5848F,
+ 32.2601F, -45.5857F, 53.4300F, 53.4773F, 33.0895F, 45.4420F, 17.2865F,
+ -36.0406F, -57.6566F, -26.6841F, 4.2674F, -39.8452F, -76.9236F, -85.9930F,
+ -29.8696F, -72.1261F, -22.6802F, 51.6689F, -10.3407F, -71.6716F, 33.3209F,
+ -2.6190F, -11.9459F, -0.7138F, 9.1651F, 80.0695F, -58.7987F, 3.7833F,
+ -10.6521F, -14.2910F, -1.7854F, -6.9002F, 114.1547F, 51.0851F, 0.4936F,
+ 45.5988F, -65.6262F, 3.5076F, -36.3037F, 31.3412F, -22.8916F, -48.6823F,
+ -71.1623F, -95.4642F, 38.3287F, -9.4939F, 52.9002F, -8.4421F, 36.7283F,
+ 86.2675F, 37.9505F, 41.2317F, 16.4269F, 16.7260F, -62.6682F, 32.6168F,
+ 9.9181F, -25.0994F, -8.3770F, 2.2985F, 5.3157F, -6.0428F, 60.1555F,
+ 49.0247F, 6.0545F, -54.7919F, 58.6261F, -3.9732F, -80.9565F, -44.3777F,
+ 30.6734F, -24.5101F, -82.4513F, -27.4901F, -10.8146F, -84.7650F, 64.6334F,
+ 18.0553F, 14.7350F, -8.7675F, 109.6707F, 51.4393F, -24.1075F, 42.7732F,
+ 43.6601F, 21.1278F, -43.7223F, -36.3814F, 81.3688F, 10.3561F, 115.5857F,
+ 44.7304F, 4.0203F, -57.4008F, 16.1462F, 84.4927F, 16.5958F, -107.7931F,
+ 19.3887F, -44.8683F, -99.3061F, 65.1051F, 45.6203F, -0.6984F, 23.6828F,
+ 6.4828F, 56.2769F, 13.3073F, -28.0424F, -72.7066F, -58.5212F, 106.1769F,
+ -11.1674F, -25.7849F, -34.9574F, -36.9812F, -58.1843F, 50.2182F, 98.0044F,
+ 47.6759F, 0.1786F, -19.4605F, -91.2611F, -35.5267F, 13.8815F, 10.2127F,
+ -41.1350F, -39.8329F, -34.1829F, -47.4437F, -91.9939F, -2.6788F, -4.2821F,
+ -79.6033F, 42.6213F, 2.0653F, -74.4526F, 41.0602F, -5.7905F, 63.6539F,
+ -31.4071F, 12.4383F, -9.2647F, -81.5461F, 16.0430F, 114.6936F, 27.3863F,
+ -41.2719F, -36.6253F, -79.4997F, -46.2467F, 46.8034F, -19.4146F, -14.6126F,
+ -31.9554F, -93.9975F, 17.8233F, -51.0152F, -11.4389F, 58.4455F, -21.6241F,
+ 12.9670F, 60.7166F, 46.9564F, -34.6928F, -3.1553F, 2.7762F, 24.2978F,
+ 83.1108F, 31.8670F, 23.6533F, 6.8663F, -63.0785F, 56.1031F, 59.2073F,
+ 11.6877F, 51.3190F, 25.3083F, -33.9761F, -99.5482F, -6.6294F, -41.7488F,
+ -3.1041F, 33.3329F, -24.8851F, 20.0947F, -63.3399F, 87.2565F, -20.6208F,
+ -52.2549F, 102.0059F, 26.9280F, -22.0208F, 85.2782F, 28.3108F, -43.2782F,
+ 0.8584F, 60.5987F, -44.2357F, -33.9700F, 19.1247F, 33.1631F, -10.8275F,
+ -63.5371F, 16.2471F, -0.2828F, -76.6458F, 2.8322F, 15.2373F, -95.8412F,
+ 5.5912F, -53.4989F, -30.8518F, 4.1365F, -62.3116F, 79.0018F, -114.5611F,
+ -36.8596F, 12.7812F, 81.1609F, 39.2434F, 21.9162F, -17.2064F, 127.1804F,
+ -30.4279F, -15.8549F, 90.5057F, 4.9324F, -55.6202F, 88.7264F, 31.2457F,
+ -6.4338F, -33.9992F, 78.4675F, 12.7460F, -51.8920F, 5.7002F, -71.3454F,
+ -22.6305F, -75.0886F, -18.4430F, 71.6854F, -49.9613F, 51.9112F, 38.5919F,
+ -80.1990F, 4.2373F, -60.6613F, 30.4453F, 20.4006F, 28.0162F, 55.1546F,
+ -96.2887F, 10.3433F, 38.5883F, 59.1444F, 23.2247F, 45.0000F, -24.9305F,
+ -30.9055F, -18.2692F, -6.1201F, -5.6460F, 2.1550F, 18.2502F, -16.8166F,
+ -28.0966F, -69.3654F, -10.5762F, 63.4193F, 43.8444F, 16.6643F, -67.9380F,
+ -68.3269F, 93.1501F, 72.8030F, 27.6125F, -21.1484F, -73.4926F, -29.7929F,
+ -88.0045F, 91.0304F, 15.1885F, -15.1144F, -61.6391F, 47.5526F, 17.2017F,
+ -10.0973F, 16.8435F, 32.7608F, 50.6231F, -36.3173F, -19.8196F, 8.7833F,
+ 1.1920F, 35.7643F, -58.4480F, 53.1925F, -71.1458F, -22.3426F, 37.8118F,
+ -51.2779F, 69.9477F, -30.3236F, 31.2621F, 35.5419F, -64.6025F, 35.1224F,
+ -0.6572F, 57.9364F, 5.6749F, 50.6782F, 25.3456F, 68.4492F, 45.6955F,
+ -53.8176F, 44.6419F, -53.4407F, 51.5645F, 1.3456F, -4.0462F, -72.5604F,
+ 54.6610F, -1.6150F, -14.3009F, 99.1775F, -24.2467F, 36.0557F, -42.7052F
+};
+
+/*
+ * isf codebooks: split-by-5 VQ
+ *
+ * codebook vector dimension number of vectors
+ * ~~~~~~~~ ~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
+ * 1 2 64
+ * 2 3 64
+ * 3 3 64
+ * 4 4 32
+ * 5 4 32
+ */
+
+/*
+ * 1st split: isf0 to isf1
+ */
+const Float32 E_ROM_dico1_isf_noise[SIZE_BK_NOISE1 * 2] = {
+ -105.0619F, -262.8448F,
+ -86.6322F, -209.7320F,
+ -91.1931F, -168.0481F,
+ -53.8753F, -176.1473F,
+ -82.7923F, -129.2635F,
+ -75.0845F, -93.9859F,
+ -33.9476F, -90.3333F,
+ -74.4463F, -50.0451F,
+ -27.3422F, -41.3458F,
+ -64.0658F, -2.5361F,
+ 28.8179F, -70.0786F,
+ 10.5059F, -12.8463F,
+ -39.9581F, 28.7359F,
+ -63.4034F, 44.7503F,
+ -36.8732F, 67.0368F,
+ -2.3563F, 50.6058F,
+ -55.9412F, 91.2822F,
+ 5.5577F, 85.1171F,
+ -25.2586F, 105.6009F,
+ 34.3216F, 71.1726F,
+ -48.3043F, 133.1605F,
+ -17.0366F, 148.8321F,
+ 14.8305F, 130.6908F,
+ 45.5592F, 106.8464F,
+ -43.7865F, 177.4889F,
+ 28.9675F, 168.2081F,
+ -1.7812F, 190.4731F,
+ 68.4806F, 149.8876F,
+ -32.5396F, 218.9960F,
+ 47.8438F, 206.6539F,
+ 8.1960F, 234.8430F,
+ 89.3668F, 188.0221F,
+ 90.4035F, 118.3064F,
+ 88.4263F, 237.5410F,
+ 117.3136F, 145.4498F,
+ 82.0645F, 73.1093F,
+ 119.3943F, 103.4796F,
+ 128.2321F, 184.8528F,
+ 149.1563F, 129.2199F,
+ 144.9058F, 51.5776F,
+ 54.4305F, 22.6608F,
+ 142.5451F, 8.2812F,
+ 97.4966F, -31.8767F,
+ 173.0963F, 84.9898F,
+ 188.5170F, 42.9719F,
+ 166.5772F, 162.2136F,
+ 226.1740F, 86.5496F,
+ 202.2992F, 129.9512F,
+ 223.9365F, 175.1483F,
+ 177.6235F, 206.6174F,
+ 267.4435F, 128.4469F,
+ 129.8694F, 226.5438F,
+ 232.5047F, 231.7147F,
+ 182.8960F, 252.1132F,
+ 297.7026F, 201.9668F,
+ 127.2108F, 277.0716F,
+ 189.5906F, 309.6084F,
+ 50.8926F, 267.2207F,
+ 262.1367F, 287.8791F,
+ 138.4480F, 342.2196F,
+ 34.3804F, 314.8025F,
+ -25.4771F, 275.9066F,
+ -13.5804F, 397.0122F,
+ 103.9035F, 438.8237F
+};
+
+/*
+ * 2nd split: isf2 to isf4
+ */
+const Float32 E_ROM_dico2_isf_noise[SIZE_BK_NOISE2 * 3] = {
+ -322.0252F, -345.3659F, -370.7835F,
+ -314.5226F, -178.1928F, -163.4712F,
+ -172.6074F, -171.2812F, -211.3224F,
+ -84.6538F, -225.6710F, -309.6982F,
+ -65.7865F, -173.3148F, -227.1618F,
+ -112.2154F, -192.0593F, -106.9376F,
+ -215.4487F, -115.9810F, -117.3159F,
+ -63.6069F, -129.9179F, -139.6890F,
+ -144.6460F, -90.4563F, -90.4457F,
+ -68.4568F, -140.0307F, -62.0772F,
+ -148.8729F, -8.2807F, -139.6018F,
+ -71.8488F, -61.9658F, -63.2677F,
+ -20.5518F, -74.4279F, -109.2530F,
+ 7.0237F, -104.2936F, -83.9866F,
+ -53.7369F, 23.9918F, -110.5212F,
+ 27.5927F, -37.1603F, -114.8537F,
+ 5.1437F, -60.8316F, -213.2375F,
+ -0.0302F, -32.5161F, -30.9893F,
+ 17.0532F, 37.8947F, -123.4512F,
+ 69.4656F, -20.4364F, -83.2673F,
+ 86.8486F, -101.9140F, -164.6497F,
+ 92.7595F, -46.0582F, -17.0665F,
+ 55.0807F, 56.5797F, -51.6089F,
+ 141.9268F, 31.5952F, -111.9348F,
+ 83.1350F, 25.3995F, 13.2634F,
+ -41.6305F, 36.7624F, -1.8806F,
+ 35.5619F, -11.1360F, 49.0468F,
+ -138.6944F, 20.1165F, -16.0470F,
+ -85.7227F, -29.5173F, 56.5419F,
+ -24.5306F, 39.2035F, 95.3233F,
+ -280.8913F, 17.3520F, 10.4723F,
+ -223.4287F, -48.5814F, 60.3781F,
+ -165.0790F, 52.0898F, 122.9863F,
+ -358.1462F, 27.5800F, 87.6394F,
+ -104.6460F, 124.2969F, 51.2676F,
+ -36.4609F, -74.1586F, 163.9110F,
+ -38.0255F, 47.6372F, 191.7725F,
+ -30.7896F, 123.7246F, 138.8302F,
+ 50.7064F, 39.0454F, 126.9589F,
+ 33.4334F, -114.5499F, 82.0810F,
+ 52.0289F, 100.6551F, 62.9260F,
+ 68.9398F, -28.6776F, 181.7511F,
+ 76.3353F, 117.0400F, 150.0834F,
+ 135.9951F, 8.5581F, 86.5077F,
+ 146.9219F, 71.3024F, 159.6375F,
+ 147.3144F, 111.7858F, 78.8838F,
+ 94.6612F, 83.2958F, 257.4856F,
+ 100.5727F, 220.5308F, 96.9196F,
+ 134.4751F, 159.3021F, -29.6067F,
+ 158.3509F, 171.9108F, 198.9399F,
+ 238.9283F, 150.3837F, 148.0492F,
+ 209.2346F, 237.2747F, 84.4977F,
+ -21.9723F, 227.3437F, 75.1847F,
+ 39.1823F, 202.0239F, 221.5619F,
+ -142.6753F, 174.8218F, 173.9311F,
+ 284.1931F, 135.5243F, 4.0420F,
+ 197.3545F, 139.2970F, 296.6173F,
+ 248.5921F, 227.1523F, 257.1579F,
+ 130.8344F, 201.7665F, 332.6679F,
+ 147.8451F, 316.0691F, 223.3704F,
+ -76.1983F, 342.8470F, 323.9619F,
+ 206.5931F, 276.1481F, 385.6192F,
+ 358.4664F, 283.4258F, 153.2502F,
+ 488.2212F, 389.4155F, 415.1465F
+};
+
+/*
+ * 3rd split: isf5 to isf7
+ */
+const Float32 E_ROM_dico3_isf_noise[SIZE_BK_NOISE3 * 3] = {
+ -314.4522F, -327.3454F, -302.2017F,
+ -203.9117F, -244.9068F, -323.6309F,
+ -186.2536F, -189.6962F, -235.4297F,
+ -115.3995F, -187.7246F, -247.4612F,
+ -142.8871F, -150.1942F, -153.3509F,
+ -72.7072F, -161.6552F, -154.8560F,
+ -92.6058F, -153.8863F, -41.3953F,
+ -98.5994F, -78.7129F, -107.5332F,
+ -23.9335F, -69.1898F, -172.7805F,
+ -32.7960F, -77.3107F, -77.6193F,
+ -69.7610F, -48.7327F, -12.2728F,
+ -28.2008F, -18.3660F, -63.7045F,
+ -116.3960F, -85.9584F, 84.0164F,
+ -24.9241F, -65.7832F, 98.1712F,
+ -51.8131F, 60.9599F, -23.0835F,
+ -11.5386F, -0.7831F, 49.5084F,
+ 20.9367F, 25.8838F, -24.0191F,
+ -91.0503F, 8.0161F, 98.1430F,
+ 81.8089F, -19.4694F, 12.5661F,
+ 12.6976F, 75.6776F, 53.0320F,
+ -45.8943F, -7.2062F, 185.7293F,
+ 78.8625F, 17.9396F, 120.6767F,
+ 99.9111F, 72.2135F, 20.5674F,
+ 13.7143F, 77.9979F, 152.4088F,
+ 78.0738F, 102.8484F, 94.6295F,
+ -84.5040F, 118.1050F, 114.7064F,
+ 50.0596F, 139.6647F, -0.1577F,
+ 7.5966F, 168.3675F, 112.1363F,
+ 87.3316F, 174.4695F, 109.2434F,
+ 143.4298F, 64.6162F, 83.1959F,
+ 155.2307F, 122.7478F, 124.7551F,
+ 149.4719F, 147.9446F, 29.2261F,
+ 108.3426F, 127.0695F, 180.3353F,
+ 153.8867F, 197.0929F, 130.5922F,
+ 98.1956F, 38.2729F, -83.1688F,
+ 175.9048F, 59.9165F, 174.8273F,
+ 220.7233F, 88.4354F, 29.6527F,
+ 183.5505F, 149.7702F, 195.9197F,
+ 248.2375F, 152.2900F, 108.7161F,
+ 92.6034F, 52.6123F, 242.1773F,
+ 133.7155F, 156.6441F, 253.6524F,
+ 129.4868F, 215.2826F, 202.4702F,
+ 50.8526F, 163.2149F, 231.3041F,
+ 207.4225F, 119.3517F, 287.7008F,
+ 284.9414F, 152.0429F, 226.6699F,
+ 194.1092F, 217.5607F, 272.9373F,
+ 115.7381F, 149.7147F, 341.2299F,
+ 110.4872F, 243.8135F, 296.4818F,
+ 49.2583F, 242.9759F, 185.7527F,
+ 218.4281F, 232.2570F, 184.3956F,
+ 149.3219F, 300.8763F, 240.4531F,
+ 280.7402F, 239.3506F, 291.1599F,
+ 210.7589F, 249.5308F, 362.4219F,
+ 201.8519F, 322.7530F, 312.7221F,
+ 267.0336F, 316.7373F, 236.0985F,
+ 293.8933F, 307.2101F, 334.8007F,
+ 364.5740F, 258.0872F, 136.8430F,
+ 271.0491F, 175.6599F, 414.3537F,
+ 219.3663F, 355.8581F, 410.6574F,
+ 321.8781F, 317.4617F, 431.4073F,
+ 295.9753F, 408.9221F, 344.4007F,
+ 445.2552F, 358.3636F, 347.1212F,
+ 405.7584F, 486.9081F, 556.9660F,
+ 579.1823F, 650.5953F, 732.6415F
+};
+
+/*
+ * 4th split: isf8 to isf11
+ */
+const Float32 E_ROM_dico4_isf_noise[SIZE_BK_NOISE4 * 4] = {
+ -303.1361F, -333.7803F, -347.8725F, -359.4826F,
+ -215.7523F, -238.3714F, -259.0660F, -289.4405F,
+ -125.2913F, -144.5697F, -186.1030F, -220.5702F,
+ 107.0201F, -62.5400F, -178.2959F, 78.3558F,
+ 103.6377F, 26.1626F, -62.5396F, -119.5691F,
+ -2.9518F, -82.1288F, 30.9020F, 106.1641F,
+ 63.5315F, 92.0127F, 120.0751F, 120.2205F,
+ 225.8191F, 123.6829F, 24.8449F, 116.4136F,
+ -3.5121F, 76.7992F, 133.5771F, 242.3746F,
+ 133.9970F, 90.5385F, 122.6116F, 242.8362F,
+ 67.7067F, 58.1366F, 214.2467F, 205.7587F,
+ 139.2159F, 144.6370F, 188.0780F, 146.8699F,
+ 52.7259F, 173.3530F, 190.5093F, 217.0651F,
+ 152.5843F, 183.9790F, 190.4016F, 255.0127F,
+ 89.0815F, 165.5783F, 224.8295F, 325.9805F,
+ 164.7109F, 145.4724F, 282.2096F, 266.3416F,
+ 115.0926F, 262.9259F, 270.8098F, 248.1893F,
+ 210.4561F, 232.8534F, 230.5395F, 175.4710F,
+ 185.5563F, 241.3006F, 257.2568F, 319.6433F,
+ 287.0131F, 201.7823F, 191.6938F, 262.7153F,
+ 234.9706F, 135.0743F, 100.3842F, 342.4814F,
+ 244.1460F, 248.1535F, 331.5106F, 281.3059F,
+ 283.8415F, 319.6996F, 272.8347F, 232.3501F,
+ 255.2254F, 187.9562F, 269.5668F, 445.0594F,
+ 318.1439F, 297.7580F, 274.9042F, 354.5264F,
+ 198.0688F, 291.9682F, 350.7645F, 365.4872F,
+ 331.2469F, 333.9341F, 361.1275F, 306.5865F,
+ 252.3140F, 405.2271F, 344.4444F, 310.3618F,
+ 301.5996F, 329.9839F, 399.8752F, 449.5998F,
+ 442.5639F, 384.1796F, 319.3500F, 359.8945F,
+ 367.3365F, 417.2813F, 488.9795F, 508.7549F,
+ 620.4818F, 690.0919F, 671.0975F, 590.9387F
+};
+
+/*
+ * 5th split: isf12 to isf15
+ */
+const Float32 E_ROM_dico5_isf_noise[SIZE_BK_NOISE5 * 4] = {
+ -316.2941F, -343.3920F, -368.9643F, -99.0392F,
+ 97.0450F, 71.7080F, 262.1754F, 50.0767F,
+ 112.4468F, 274.7287F, 358.7211F, 38.6232F,
+ 257.1795F, 217.8952F, 258.6022F, 85.4104F,
+ 215.6079F, 228.7031F, 355.6118F, 81.4276F,
+ 218.4167F, 314.1638F, 296.3636F, 46.5526F,
+ 236.5851F, 302.2603F, 359.7074F, -54.3647F,
+ 305.5962F, 297.4161F, 292.2765F, 81.3061F,
+ 295.4005F, 276.4861F, 384.1555F, 21.9038F,
+ 212.3865F, 337.6641F, 394.4713F, 59.4888F,
+ 287.8841F, 272.8244F, 385.4754F, 116.6899F,
+ 301.1416F, 360.9641F, 343.2708F, 40.2882F,
+ 209.5407F, 306.5670F, 375.3650F, 158.1632F,
+ 260.4655F, 357.6203F, 312.8495F, 128.1323F,
+ 288.3843F, 275.2455F, 301.9735F, 171.2988F,
+ 321.4736F, 340.3829F, 387.3967F, 138.5811F,
+ 250.1021F, 392.3276F, 410.9932F, 144.0109F,
+ 282.6727F, 320.9480F, 370.8150F, 233.3823F,
+ 161.9622F, 255.8086F, 284.8333F, 188.2323F,
+ 393.9827F, 349.8717F, 309.8297F, 141.6719F,
+ 354.6675F, 313.7792F, 268.4562F, -9.8681F,
+ 396.7580F, 327.4283F, 395.0635F, 73.8789F,
+ 369.8889F, 434.5653F, 367.9579F, 86.8706F,
+ 356.9169F, 409.7761F, 383.1727F, 205.7493F,
+ 373.4236F, 385.5478F, 394.8253F, -47.0644F,
+ 305.1456F, 409.5952F, 437.7072F, 36.1164F,
+ 460.1152F, 411.4012F, 345.2657F, 18.4203F,
+ 438.6750F, 413.5906F, 461.8582F, 46.2207F,
+ 364.6111F, 379.8415F, 498.6693F, 139.3899F,
+ 433.1401F, 358.6805F, 429.9292F, 196.6537F,
+ 405.9484F, 502.2995F, 476.5874F, 123.6977F,
+ 527.5430F, 471.6736F, 394.4862F, 127.2615F
+};
+
+/*
+ * Hamming_cos window for LPC analysis.
+ */
+const Float32 E_ROM_hamming_cos[L_WINDOW] = {
+ 0.0800000F, 0.0800348F, 0.0801391F, 0.0803129F, 0.0805563F,
+ 0.0808691F, 0.0812513F, 0.0817028F, 0.0822237F, 0.0828138F,
+ 0.0834730F, 0.0842012F, 0.0849983F, 0.0858642F, 0.0867987F,
+ 0.0878018F, 0.0888733F, 0.0900129F, 0.0912206F, 0.0924962F,
+ 0.0938394F, 0.0952500F, 0.0967279F, 0.0982728F, 0.0998845F,
+ 0.101563F, 0.103307F, 0.105118F, 0.106994F, 0.108936F,
+ 0.110943F, 0.113014F, 0.115151F, 0.117351F, 0.119616F,
+ 0.121944F, 0.124335F, 0.126789F, 0.129306F, 0.131884F,
+ 0.134525F, 0.137226F, 0.139989F, 0.142812F, 0.145695F,
+ 0.148638F, 0.151639F, 0.154700F, 0.157819F, 0.160995F,
+ 0.164229F, 0.167520F, 0.170867F, 0.174270F, 0.177728F,
+ 0.181241F, 0.184808F, 0.188429F, 0.192103F, 0.195829F,
+ 0.199608F, 0.203438F, 0.207319F, 0.211250F, 0.215231F,
+ 0.219261F, 0.223340F, 0.227466F, 0.231640F, 0.235860F,
+ 0.240126F, 0.244438F, 0.248794F, 0.253195F, 0.257638F,
+ 0.262125F, 0.266653F, 0.271223F, 0.275833F, 0.280483F,
+ 0.285173F, 0.289901F, 0.294667F, 0.299470F, 0.304309F,
+ 0.309184F, 0.314094F, 0.319038F, 0.324015F, 0.329025F,
+ 0.334067F, 0.339140F, 0.344244F, 0.349377F, 0.354538F,
+ 0.359728F, 0.364946F, 0.370189F, 0.375458F, 0.380753F,
+ 0.386071F, 0.391412F, 0.396776F, 0.402162F, 0.407568F,
+ 0.412995F, 0.418441F, 0.423905F, 0.429386F, 0.434885F,
+ 0.440399F, 0.445928F, 0.451472F, 0.457029F, 0.462598F,
+ 0.468179F, 0.473771F, 0.479373F, 0.484984F, 0.490604F,
+ 0.496231F, 0.501865F, 0.507504F, 0.513148F, 0.518797F,
+ 0.524448F, 0.530102F, 0.535757F, 0.541413F, 0.547069F,
+ 0.552724F, 0.558377F, 0.564027F, 0.569673F, 0.575315F,
+ 0.580952F, 0.586582F, 0.592205F, 0.597821F, 0.603428F,
+ 0.609025F, 0.614611F, 0.620187F, 0.625750F, 0.631300F,
+ 0.636837F, 0.642359F, 0.647865F, 0.653355F, 0.658828F,
+ 0.664283F, 0.669719F, 0.675136F, 0.680532F, 0.685907F,
+ 0.691260F, 0.696590F, 0.701896F, 0.707178F, 0.712435F,
+ 0.717665F, 0.722869F, 0.728045F, 0.733192F, 0.738311F,
+ 0.743399F, 0.748457F, 0.753483F, 0.758477F, 0.763438F,
+ 0.768365F, 0.773257F, 0.778115F, 0.782936F, 0.787720F,
+ 0.792467F, 0.797176F, 0.801846F, 0.806477F, 0.811067F,
+ 0.815616F, 0.820124F, 0.824589F, 0.829011F, 0.833389F,
+ 0.837723F, 0.842012F, 0.846256F, 0.850453F, 0.854603F,
+ 0.858706F, 0.862760F, 0.866766F, 0.870722F, 0.874628F,
+ 0.878484F, 0.882288F, 0.886041F, 0.889741F, 0.893389F,
+ 0.896983F, 0.900523F, 0.904009F, 0.907439F, 0.910814F,
+ 0.914133F, 0.917395F, 0.920601F, 0.923748F, 0.926838F,
+ 0.929869F, 0.932842F, 0.935755F, 0.938608F, 0.941401F,
+ 0.944133F, 0.946804F, 0.949413F, 0.951961F, 0.954446F,
+ 0.956869F, 0.959229F, 0.961525F, 0.963758F, 0.965926F,
+ 0.968030F, 0.970070F, 0.972044F, 0.973953F, 0.975796F,
+ 0.977574F, 0.979285F, 0.980930F, 0.982509F, 0.984020F,
+ 0.985464F, 0.986841F, 0.988151F, 0.989392F, 0.990566F,
+ 0.991671F, 0.992709F, 0.993678F, 0.994578F, 0.995409F,
+ 0.996172F, 0.996866F, 0.997490F, 0.998046F, 0.998532F,
+ 0.998949F, 0.999296F, 0.999574F, 0.999783F, 0.999922F,
+ 0.999991F, 1.00000F, 0.999924F, 0.999698F, 0.999320F,
+ 0.998791F, 0.998111F, 0.997280F, 0.996298F, 0.995166F,
+ 0.993883F, 0.992450F, 0.990867F, 0.989134F, 0.987252F,
+ 0.985220F, 0.983039F, 0.980710F, 0.978233F, 0.975607F,
+ 0.972834F, 0.969914F, 0.966848F, 0.963635F, 0.960277F,
+ 0.956773F, 0.953125F, 0.949332F, 0.945396F, 0.941317F,
+ 0.937096F, 0.932733F, 0.928229F, 0.923585F, 0.918801F,
+ 0.913879F, 0.908818F, 0.903619F, 0.898284F, 0.892814F,
+ 0.887208F, 0.881468F, 0.875595F, 0.869589F, 0.863452F,
+ 0.857185F, 0.850788F, 0.844262F, 0.837609F, 0.830829F,
+ 0.823923F, 0.816893F, 0.809739F, 0.802463F, 0.795066F,
+ 0.787548F, 0.779911F, 0.772157F, 0.764285F, 0.756298F,
+ 0.748197F, 0.739983F, 0.731657F, 0.723220F, 0.714674F,
+ 0.706019F, 0.697258F, 0.688392F, 0.679421F, 0.670348F,
+ 0.661174F, 0.651899F, 0.642526F, 0.633056F, 0.623490F,
+ 0.613830F, 0.604077F, 0.594233F, 0.584299F, 0.574276F,
+ 0.564167F, 0.553972F, 0.543694F, 0.533333F, 0.522892F,
+ 0.512372F, 0.501774F, 0.491101F, 0.480353F, 0.469533F,
+ 0.458641F, 0.447680F, 0.436652F, 0.425558F, 0.414399F,
+ 0.403177F, 0.391895F, 0.380553F, 0.369154F, 0.357699F,
+ 0.346190F, 0.334629F, 0.323017F, 0.311356F, 0.299648F,
+ 0.287895F, 0.276098F, 0.264260F, 0.252381F, 0.240465F,
+ 0.228512F, 0.216524F, 0.204504F, 0.192453F, 0.180373F,
+ 0.168265F, 0.156132F, 0.143976F, 0.131797F, 0.119599F,
+ 0.107383F, 0.0951502F, 0.0829032F, 0.0706437F, 0.0583736F,
+ 0.0460946F, 0.0338087F, 0.0215176F, 0.00922329F
+};
+
+
+/*
+ * Quantization table for VQ of pitch and innovation gains.
+ */
+const Float32 E_ROM_qua_gain6b[NB_QUA_GAIN6B * 2] = {
+ 0.095577F, 0.650507F,
+ 0.096232F, 1.737050F,
+ 0.187418F, 3.168846F,
+ 0.255896F, 4.962348F,
+ 0.274392F, 1.237365F,
+ 0.306340F, 2.191559F,
+ 0.340913F, 7.624112F,
+ 0.349443F, 0.694540F,
+ 0.393850F, 0.283414F,
+ 0.410411F, 3.335519F,
+ 0.467326F, 1.722400F,
+ 0.492699F, 1.024880F,
+ 0.502447F, 2.596945F,
+ 0.538748F, 4.284797F,
+ 0.594507F, 1.400231F,
+ 0.601562F, 0.715119F,
+ 0.615667F, 6.097708F,
+ 0.625075F, 2.174328F,
+ 0.662782F, 3.231284F,
+ 0.690967F, 1.751661F,
+ 0.696845F, 0.878992F,
+ 0.710639F, 1.185743F,
+ 0.715220F, 0.482280F,
+ 0.751490F, 2.486668F,
+ 0.764345F, 4.108078F,
+ 0.767472F, 12.8F,
+ 0.769099F, 1.658386F,
+ 0.803928F, 0.792686F,
+ 0.810832F, 1.183175F,
+ 0.818967F, 2.972155F,
+ 0.821480F, 6.255056F,
+ 0.833469F, 1.761157F,
+ 0.861276F, 2.207579F,
+ 0.863275F, 0.599961F,
+ 0.880429F, 0.913681F,
+ 0.880816F, 3.532393F,
+ 0.881643F, 1.383632F,
+ 0.892825F, 4.900598F,
+ 0.906974F, 8.542764F,
+ 0.925368F, 1.772085F,
+ 0.928281F, 2.841080F,
+ 0.933752F, 1.101603F,
+ 0.947124F, 2.305683F,
+ 0.956012F, 0.517399F,
+ 0.961870F, 3.892433F,
+ 0.972823F, 5.841643F,
+ 0.977796F, 1.463091F,
+ 0.981803F, 0.833284F,
+ 1.008362F, 2.077002F,
+ 1.011696F, 3.039251F,
+ 1.031157F, 1.162086F,
+ 1.031888F, 0.332692F,
+ 1.050599F, 4.104371F,
+ 1.074819F, 1.668828F,
+ 1.092217F, 2.572842F,
+ 1.108887F, 5.736302F,
+ 1.112667F, 0.769072F,
+ 1.135654F, 15.9999F,
+ 1.143096F, 10.587959F,
+ 1.168006F, 1.241697F,
+ 1.185414F, 3.211269F,
+ 1.186919F, 2.000422F,
+ 1.187154F, 4.421983F,
+ 1.243327F, 7.268204F
+};
+
+const Float32 E_ROM_qua_gain7b[NB_QUA_GAIN7B * 2] = {
+ 0.012445F, 0.215546F,
+ 0.028326F, 0.965442F,
+ 0.053042F, 0.525819F,
+ 0.065409F, 1.495322F,
+ 0.078212F, 2.323725F,
+ 0.100504F, 0.751276F,
+ 0.112617F, 3.427530F,
+ 0.113124F, 0.309583F,
+ 0.121763F, 1.140685F,
+ 0.143515F, 7.519609F,
+ 0.162430F, 0.568752F,
+ 0.164940F, 1.904113F,
+ 0.165429F, 4.947562F,
+ 0.194985F, 0.855463F,
+ 0.213527F, 1.281019F,
+ 0.223544F, 0.414672F,
+ 0.243135F, 2.781766F,
+ 0.257180F, 1.659565F,
+ 0.269488F, 0.636749F,
+ 0.286539F, 1.003938F,
+ 0.328124F, 2.225436F,
+ 0.328761F, 0.330278F,
+ 0.336807F, 11.500983F,
+ 0.339794F, 3.805726F,
+ 0.344454F, 1.494626F,
+ 0.346165F, 0.738748F,
+ 0.363605F, 1.141454F,
+ 0.398729F, 0.517614F,
+ 0.415276F, 2.928666F,
+ 0.416282F, 0.862935F,
+ 0.423421F, 1.873310F,
+ 0.444151F, 0.202244F,
+ 0.445842F, 1.301113F,
+ 0.455671F, 5.519512F,
+ 0.484764F, 0.387607F,
+ 0.488696F, 0.967884F,
+ 0.488730F, 0.666771F,
+ 0.508189F, 1.516224F,
+ 0.508792F, 2.348662F,
+ 0.531504F, 3.883870F,
+ 0.548649F, 1.112861F,
+ 0.551182F, 0.514986F,
+ 0.564397F, 1.742030F,
+ 0.566598F, 0.796454F,
+ 0.589255F, 3.081743F,
+ 0.598816F, 1.271936F,
+ 0.617654F, 0.333501F,
+ 0.619073F, 2.040522F,
+ 0.625282F, 0.950244F,
+ 0.630798F, 0.594883F,
+ 0.638918F, 4.863197F,
+ 0.650102F, 1.464846F,
+ 0.668412F, 0.747138F,
+ 0.669490F, 2.583027F,
+ 0.683757F, 1.125479F,
+ 0.691216F, 1.739274F,
+ 0.718441F, 3.297789F,
+ 0.722608F, 0.902743F,
+ 0.728827F, 2.194941F,
+ 0.729586F, 0.633849F,
+ 0.730907F, 7.432957F,
+ 0.731017F, 0.431076F,
+ 0.731543F, 1.387847F,
+ 0.759183F, 1.045210F,
+ 0.768606F, 1.789648F,
+ 0.771245F, 4.085637F,
+ 0.772613F, 0.778145F,
+ 0.786483F, 1.283204F,
+ 0.792467F, 2.412891F,
+ 0.802393F, 0.544588F,
+ 0.807156F, 0.255978F,
+ 0.814280F, 1.544409F,
+ 0.817839F, 0.938798F,
+ 0.826959F, 2.910633F,
+ 0.830453F, 0.684066F,
+ 0.833431F, 1.171532F,
+ 0.841208F, 1.908628F,
+ 0.846440F, 5.333522F,
+ 0.868280F, 0.841519F,
+ 0.868662F, 1.435230F,
+ 0.871449F, 3.675784F,
+ 0.881317F, 2.245058F,
+ 0.882020F, 0.480249F,
+ 0.882476F, 1.105804F,
+ 0.902856F, 0.684850F,
+ 0.904419F, 1.682113F,
+ 0.909384F, 2.787801F,
+ 0.916558F, 7.500981F,
+ 0.918444F, 0.950341F,
+ 0.919721F, 1.296319F,
+ 0.940272F, 4.682978F,
+ 0.940273F, 1.991736F,
+ 0.950291F, 3.507281F,
+ 0.957455F, 1.116284F,
+ 0.957723F, 0.793034F,
+ 0.958217F, 1.497824F,
+ 0.962628F, 2.514156F,
+ 0.968507F, 0.588605F,
+ 0.974739F, 0.339933F,
+ 0.991738F, 1.750201F,
+ 0.997210F, 0.936131F,
+ 1.002422F, 1.250008F,
+ 1.006040F, 2.167232F,
+ 1.008848F, 3.129940F,
+ 1.014404F, 5.842819F,
+ 1.027798F, 4.287319F,
+ 1.039404F, 1.489295F,
+ 1.039628F, 8.947958F,
+ 1.043214F, 0.765733F,
+ 1.045089F, 2.537806F,
+ 1.058994F, 1.031496F,
+ 1.060415F, 0.478612F,
+ 1.072132F, 12.8F,
+ 1.074778F, 1.910049F,
+ 1.076570F, 15.9999F,
+ 1.107853F, 3.843067F,
+ 1.110673F, 1.228576F,
+ 1.110969F, 2.758471F,
+ 1.140058F, 1.603077F,
+ 1.155384F, 0.668935F,
+ 1.176229F, 6.717108F,
+ 1.179008F, 2.011940F,
+ 1.187735F, 0.963552F,
+ 1.199569F, 4.891432F,
+ 1.206311F, 3.316329F,
+ 1.215323F, 2.507536F,
+ 1.223150F, 1.387102F,
+ 1.296012F, 9.684225F
+};
+
+/*
+ * 1/4 resolution interpolation filter (-3 dB at 0.791*fs/2)
+ */
+const Float32 E_ROM_inter4_1[UP_SAMP * L_INTERPOL1 + 1] = {
+ /* cut-off frequency at 0.9*fs/2 */
+ 0.900000F,
+ 0.818959F, 0.604850F, 0.331379F, 0.083958F,
+ -0.075795F, -0.130717F, -0.105685F, -0.046774F,
+ 0.004467F, 0.027789F, 0.025642F, 0.012571F,
+ 0.001927F, -0.001571F, -0.000753F, 0.000000f
+};
+
+const Word16 E_ROM_inter4_2[UP_SAMP * 2 * L_INTERPOL2] = {
+ 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
+};
+
+/*
+ * High band gain table for 23.85 kbit/s mode
+ * For synthesis of signal at 16kHz with HF extension.
+ */
+const Float32 E_ROM_hp_gain[16] = {
+ 0.2212F, 0.2852F, 0.3416F, 0.3954F,
+ 0.4532F, 0.5114F, 0.5691F, 0.6265F,
+ 0.6842F, 0.7450F, 0.8173F, 0.9060F,
+ 1.0236F, 1.1996F, 1.4825F, 1.9976F
+};
+
+
+/*
+ * isp and isf tables for initialization
+ */
+const Word16 E_ROM_isp[M] = {
+ 32138, 30274, 27246, 23170, 18205, 12540, 6393, 0,
+ -6393, -12540, -18205, -23170, -27246, -30274, -32138, 1475
+};
+
+const Float32 E_ROM_isf[M] = {
+ 400.0, 800.0, 1200.0, 1600.0, 2000.0, 2400.0, 2800.0, 3200.0,
+ 3600.0, 4000.0, 4400.0, 4800.0, 5200.0, 5600.0, 6000.0, 1500.0
+};
+
+/*
+ * Table of lag_window for autocorrelation.
+ * noise floor = 1.0001 = (0.9999 on r[1] ..r[16])
+ * Bandwidth expansion = 60 Hz
+ * Sampling frequency = 12800 Hz
+ */
+const Float32 E_ROM_lag_window[M] = { /*1.00000000 (not stored)*/
+ 0.99946642F,
+ 0.99816680F,
+ 0.99600452F,
+ 0.99298513F,
+ 0.98911655F,
+ 0.98440880F,
+ 0.97887397F,
+ 0.97252619F,
+ 0.96538186F,
+ 0.95745903F,
+ 0.94877797F,
+ 0.93936038F,
+ 0.92922986F,
+ 0.91841155F,
+ 0.90693212F,
+ 0.89481968F
+};
+
+/*
+ * means of ISFs
+ */
+const Word16 E_ROM_mean_isf[ORDER] = {
+
+ 738, 1326, 2336, 3578, 4596, 5662, 6711, 7730,
+ 8750, 9753, 10705, 11728, 12833, 13971, 15043, 4037
+};
+
+const Float32 E_ROM_f_mean_isf[ORDER] = {
+ 288.411774F,
+ 518.149414F,
+ 912.352051F,
+ 1397.743652F,
+ 1795.418823F,
+ 2211.536133F,
+ 2621.461182F,
+ 3019.680176F,
+ 3417.989746F,
+ 3809.700928F,
+ 4181.547363F,
+ 4581.064941F,
+ 5012.819824F,
+ 5457.521484F,
+ 5876.145020F,
+ 1576.906494F
+};
+
+/* ISF mean for comfort noise */
+const Float32 E_ROM_mean_isf_noise[16] = {
+ 186.625259F,
+ 429.613403F,
+ 864.525085F,
+ 1276.010254F,
+ 1648.228394F,
+ 2039.998535F,
+ 2420.943115F,
+ 2828.022461F,
+ 3214.584961F,
+ 3575.200195F,
+ 3944.685303F,
+ 4338.971191F,
+ 4743.657227F,
+ 5149.993164F,
+ 5533.081055F,
+ 1485.457031F
+};
+
+/*
+ * Upsample FIR filter coefficients.
+ * 1/5 resolution interpolation filter (in Q14)
+ * -1.5dB @ 6kHz, -6dB @ 6.4kHz, -10dB @ 6.6kHz, -20dB @ 6.9kHz, -25dB @ 7kHz, -55dB @ 8kHz
+ */
+const Word16 E_ROM_fir_up[120] = {
+ -1, -4, -7, -6, 0,
+ 12, 24, 30, 23, 0,
+ -33, -62, -73, -52, 0,
+ 68, 124, 139, 96, 0,
+ -119, -213, -235, -160, 0,
+ 191, 338, 368, 247, 0,
+ -291, -510, -552, -369, 0,
+ 430, 752, 812, 542, 0,
+ -634, -1111, -1204, -809, 0,
+ 963, 1708, 1881, 1288, 0,
+ -1616, -2974, -3432, -2496, 0,
+ 3792, 8219, 12368, 15317, 16384,
+ 15317, 12368, 8219, 3792, 0,
+ -2496, -3432, -2974, -1616, 0,
+ 1288, 1881, 1708, 963, 0,
+ -809, -1204, -1111, -634, 0,
+ 542, 812, 752, 430, 0,
+ -369, -552, -510, -291, 0,
+ 247, 368, 338, 191, 0,
+ -160, -235, -213, -119, 0,
+ 96, 139, 124, 68, 0,
+ -52, -73, -62, -33, 0,
+ 23, 30, 24, 12, 0,
+ -6, -7, -4, -1, 0
+};
+
+/*
+ * Downsample FIR filter coefficients (x4/5)
+ */
+const Word16 E_ROM_fir_down[120] = {
+ -1, -3, -6, -5,
+ 0, 9, 19, 24,
+ 18, 0, -26, -50,
+ -58, -41, 0, 54,
+ 99, 111, 77, 0,
+ -95, -170, -188, -128,
+ 0, 153, 270, 294,
+ 198, 0, -233, -408,
+ -441, -295, 0, 344,
+ 601, 649, 434, 0,
+ -507, -888, -964, -647,
+ 0, 770, 1366, 1505,
+ 1030, 0, -1293, -2379,
+ -2746, -1997, 0, 3034,
+ 6575, 9894, 12254, 13107,
+ 12254, 9894, 6575, 3034,
+ 0, -1997, -2746, -2379,
+ -1293, 0, 1030, 1505,
+ 1366, 770, 0, -647,
+ -964, -888, -507, 0,
+ 434, 649, 601, 344,
+ 0, -295, -441, -408,
+ -233, 0, 198, 294,
+ 270, 153, 0, -128,
+ -188, -170, -95, 0,
+ 77, 111, 99, 54,
+ 0, -41, -58, -50,
+ -26, 0, 18, 24,
+ 19, 9, 0, -5,
+ -6, -3, -1, 0
+};
+
+/* 16-byte align end */
+
+/* weighting of the correlation function in open loop LTP search */
+const Float32 E_ROM_corrweight[199]= {
+ 0.32872895427062F, 0.32940279686838F, 0.33008397607000F, 0.33077263774882F,
+ 0.33146893201434F, 0.33217301337469F, 0.33288504090694F, 0.33360517843561F,
+ 0.33433359471985F, 0.33507046364991F, 0.33581596445331F, 0.33657028191132F,
+ 0.33733360658650F, 0.33810613506181F, 0.33888807019203F, 0.33967962136837F,
+ 0.34048100479698F, 0.34129244379225F, 0.34211416908597F, 0.34294641915312F,
+ 0.34378944055574F, 0.34464348830569F, 0.34550882624786F, 0.34638572746505F,
+ 0.34727447470606F, 0.34817536083854F, 0.34908868932841F, 0.35001477474762F,
+ 0.35095394331240F, 0.35190653345404F, 0.35287289642476F, 0.35385339694105F,
+ 0.35484841386753F, 0.35585834094415F, 0.35688358756025F, 0.35792457957894F,
+ 0.35898176021598F, 0.36005559097716F, 0.36114655265930F, 0.36225514641972F,
+ 0.36338189491998F, 0.36452734355021F, 0.36569206174066F, 0.36687664436818F,
+ 0.36808171326584F, 0.36930791884477F, 0.37055594183846F, 0.37182649518049F,
+ 0.37312032602824F, 0.37443821794611F, 0.37578099326358F, 0.37714951562500F,
+ 0.37854469274995F, 0.37996747942529F, 0.38141888075233F, 0.38289995567554F,
+ 0.38441182082240F, 0.38595565468744F, 0.38753270219810F, 0.38914427970450F,
+ 0.39079178044081F, 0.39247668051248F, 0.39420054547049F, 0.39596503754272F,
+ 0.39777192360213F, 0.39962308396279F, 0.40152052210853F, 0.40346637547426F,
+ 0.40546292741845F, 0.40751262054712F, 0.40961807157476F, 0.41178208793838F,
+ 0.41400768641652F, 0.41629811404829F, 0.41865687169900F, 0.42108774068111F,
+ 0.42359481291430F, 0.42618252519967F, 0.42885569829436F, 0.43161958160963F,
+ 0.43447990452326F, 0.43744293550645F, 0.44051555052483F, 0.44370531250000F,
+ 0.44702056402976F, 0.45047053608887F, 0.45406547610287F, 0.45781679965235F,
+ 0.46173727119116F, 0.46584122063850F, 0.47014480466210F, 0.47466632408736F,
+ 0.47942661240838F, 0.48444951522162F, 0.49000000000000F, 0.50000000000000F,
+ 0.50000000000000F, 0.50000000000000F, 0.50000000000000F, 0.50000000000000F,
+ 0.50000000000000F, 0.50000000000000F, 0.49000000000000F, 0.48444951522162F,
+ 0.47942661240838F, 0.47466632408736F, 0.47014480466210F, 0.46584122063850F,
+ 0.46173727119116F, 0.45781679965235F, 0.45406547610287F, 0.45047053608887F,
+ 0.44702056402976F, 0.44370531250000F, 0.44051555052483F, 0.43744293550645F,
+ 0.43447990452326F, 0.43161958160963F, 0.42885569829436F, 0.42618252519967F,
+ 0.42359481291430F, 0.42108774068111F, 0.41865687169900F, 0.41629811404829F,
+ 0.41400768641652F, 0.41178208793838F, 0.40961807157476F, 0.40751262054712F,
+ 0.40546292741845F, 0.40346637547426F, 0.40152052210853F, 0.39962308396279F,
+ 0.39777192360213F, 0.39596503754272F, 0.39420054547049F, 0.39247668051248F,
+ 0.39079178044081F, 0.38914427970450F, 0.38753270219810F, 0.38595565468744F,
+ 0.38441182082240F, 0.38289995567554F, 0.38141888075233F, 0.37996747942529F,
+ 0.37854469274995F, 0.37714951562500F, 0.37578099326358F, 0.37443821794611F,
+ 0.37312032602824F, 0.37182649518049F, 0.37055594183846F, 0.36930791884477F,
+ 0.36808171326584F, 0.36687664436818F, 0.36569206174066F, 0.36452734355021F,
+ 0.36338189491998F, 0.36225514641972F, 0.36114655265930F, 0.36005559097716F,
+ 0.35898176021598F, 0.35792457957894F, 0.35688358756025F, 0.35585834094415F,
+ 0.35484841386753F, 0.35385339694105F, 0.35287289642476F, 0.35190653345404F,
+ 0.35095394331240F, 0.35001477474762F, 0.34908868932841F, 0.34817536083854F,
+ 0.34727447470606F, 0.34638572746505F, 0.34550882624786F, 0.34464348830569F,
+ 0.34378944055574F, 0.34294641915312F, 0.34211416908597F, 0.34129244379225F,
+ 0.34048100479698F, 0.33967962136837F, 0.33888807019203F, 0.33810613506181F,
+ 0.33733360658650F, 0.33657028191132F, 0.33581596445331F, 0.33507046364991F,
+ 0.33433359471985F, 0.33360517843561F, 0.33288504090694F, 0.33217301337469F,
+ 0.33146893201434F, 0.33077263774882F, 0.33008397607000F, 0.32940279686838F,
+ 0.32872895427062F, 0.32806230648432F, 0.32740271564992F
+};
+
+const UWord8 E_ROM_tipos[36] = {
+ 0, 1, 2, 3, /* starting point &ipos[0], 1st iter */
+ 1, 2, 3, 0, /* starting point &ipos[4], 2nd iter */
+ 2, 3, 0, 1, /* starting point &ipos[8], 3rd iter */
+ 3, 0, 1, 2, /* starting point &ipos[12], 4th iter */
+ 0, 1, 2, 3,
+ 1, 2, 3, 0,
+ 2, 3, 0, 1,
+ 3, 0, 1, 2,
+ 0, 1, 2, 3 /* end point for 24 pulses &ipos[35], 4th iter */
+};
+
+/*
+ * Chebyshev polynomial grid points
+ *
+ * grid[0] = 1.0;
+ * grid[grid_points + 1] = -1.0;
+ * for (i = 1; i < grid_points; i++)
+ * grid[i] = cos((6.283185307*i)/(2.0*grid_points));
+ *
+ */
+const Float32 E_ROM_grid[101] = {
+ 1.00000F, 0.999507F, 0.998027F, 0.995562F, 0.992115F,
+ 0.987688F, 0.982287F, 0.975917F, 0.968583F, 0.960294F,
+ 0.951057F, 0.940881F, 0.929776F, 0.917755F, 0.904827F,
+ 0.891007F, 0.876307F, 0.860742F, 0.844328F, 0.827081F,
+ 0.809017F, 0.790155F, 0.770513F, 0.750111F, 0.728969F,
+ 0.707107F, 0.684547F, 0.661312F, 0.637424F, 0.612907F,
+ 0.587785F, 0.562083F, 0.535827F, 0.509041F, 0.481754F,
+ 0.453990F, 0.425779F, 0.397148F, 0.368124F, 0.338738F,
+ 0.309017F, 0.278991F, 0.248690F, 0.218143F, 0.187381F,
+ 0.156434F, 0.125333F, 0.0941082F, 0.0627904F, 0.0314107F,
+ -8.09643e-008F,
+ -0.0314108F, -0.0627906F, -0.0941084F, -0.125333F, -0.156435F,
+ -0.187381F, -0.218143F, -0.248690F, -0.278991F, -0.309017F,
+ -0.338738F, -0.368125F, -0.397148F, -0.425779F, -0.453991F,
+ -0.481754F, -0.509041F, -0.535827F, -0.562083F, -0.587785F,
+ -0.612907F, -0.637424F, -0.661312F, -0.684547F, -0.707107F,
+ -0.728969F, -0.750111F, -0.770513F, -0.790155F, -0.809017F,
+ -0.827081F, -0.844328F, -0.860742F, -0.876307F, -0.891007F,
+ -0.904827F, -0.917755F, -0.929777F, -0.940881F, -0.951057F,
+ -0.960294F, -0.968583F, -0.975917F, -0.982287F, -0.987688F,
+ -0.992115F, -0.995562F, -0.998027F, -0.999507F, -1.00000F
+};
+
+/*
+ * Bandpass FIR filter coefficients for higher band generation (gain=4.0)
+ */
+const Float32 E_ROM_fir_6k_7k[31] = {
+ -0.001005F, 0.001428F, 0.000965F, -0.000863F, -0.011296F,
+ 0.034231F, -0.043397F, -0.000000F, 0.115906F, -0.271028F,
+ 0.376868F, -0.335243F, 0.108276F, 0.237003F, -0.549363F,
+ 0.675000F, -0.549363F, 0.237003F, 0.108276F, -0.335243F,
+ 0.376868F, -0.271028F, 0.115906F, -0.000000F, -0.043397F,
+ 0.034231F, -0.011296F, -0.000863F, 0.000965F, 0.001428F,
+ -0.001005F
+};
+
+/*
+ * LTP gain & fixed codebook gain consealement
+ */
+
+/* attenuation factors for codebook gain in lost frames */
+const Word16 E_ROM_cdown_unusable[7] = {32767, 16384, 8192, 8192, 8192, 4915, 3277};
+
+const Word16 E_ROM_cdown_usable[7] = {32767, 32113, 32113, 32113, 32113, 32113, 22938};
+
+/* attenuation factors for adaptive codebook gain in lost frames */
+const Word16 E_ROM_pdown_unusable[7] = {32767, 31130, 29491, 24576, 7537, 1638, 328};
+/* attenuation factors for adaptive codebook gain in bad frames */
+const Word16 E_ROM_pdown_usable[7] = {32767, 32113, 31457, 24576, 7537, 1638, 328};
+
+
+/* FIR filter coefficients (interpol) */
+const Float32 E_ROM_fir_ipol[61] = {
+ 0.999980F,
+ 0.934870F, 0.754870F, 0.501632F, 0.231474F, -0.000000F,
+ -0.152337F, -0.209502F, -0.181536F, -0.098630F, 0.000000F,
+ 0.078607F, 0.114831F, 0.104252F, 0.058760F, -0.000000F,
+ -0.049374F, -0.073516F, -0.067781F, -0.038681F, 0.000000F,
+ 0.033082F, 0.049550F, 0.045881F, 0.026258F, -0.000000F,
+ -0.022499F, -0.033672F, -0.031122F, -0.017761F, 0.000000F,
+ 0.015088F, 0.022452F, 0.020614F, 0.011674F, -0.000000F,
+ -0.009736F, -0.014331F, -0.012999F, -0.007264F, 0.000000F,
+ 0.005872F, 0.008488F, 0.007546F, 0.004123F, -0.000000F,
+ -0.003163F, -0.004431F, -0.003804F, -0.001997F, 0.000000F,
+ 0.001388F, 0.001829F, 0.001459F, 0.000702F, -0.000000F,
+ -0.000383F, -0.000424F, -0.000267F, -0.000091F, 0.000000F
+};
+
+
+/*
+ * LPC interpolation coef
+ */
+const Float32 E_ROM_f_interpol_frac[NB_SUBFR] = {0.45F, 0.8F, 0.96F, 1.0F};
+
+/*
+ * LPC interpolation coef in Q15
+ */
+const Word16 E_ROM_interpol_frac[NB_SUBFR] = {14746, 26214, 31457, 32767};
+
+/*
+ * Math tables
+ */
+
+/* table used in power of two computation */
+const Word16 E_ROM_pow2[33] = {
+ 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, 32767
+};
+
+/* table used in inverse square root computation */
+const Word16 E_ROM_isqrt[49] = {
+ 32767, 31790, 30894, 30070, 29309, 28602, 27945, 27330, 26755, 26214,
+ 25705, 25225, 24770, 24339, 23930, 23541, 23170, 22817, 22479, 22155,
+ 21845, 21548, 21263, 20988, 20724, 20470, 20225, 19988, 19760, 19539,
+ 19326, 19119, 18919, 18725, 18536, 18354, 18176, 18004, 17837, 17674,
+ 17515, 17361, 17211, 17064, 16921, 16782, 16646, 16514, 16384
+};
+
+/* table used in logarithm computation */
+const Word16 E_ROM_log2[33] = {
+ 0, 1455, 2866, 4236, 5568, 6863, 8124, 9352, 10549, 11716,
+ 12855, 13967, 15054, 16117, 17156, 18172, 19167, 20142, 21097, 22033,
+ 22951, 23852, 24735, 25603, 26455, 27291, 28113, 28922, 29716, 30497,
+ 31266, 32023, 32767
+};
+
+/* table of cos(x) in Q15 */
+const Word16 E_ROM_cos[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
+};
+
+
+/*
+ * excitation energy adjustment depending on speech coder mode used
+ */
+const Float32 E_ROM_en_adjust[9] = {
+ -1.7969F, /* mode0 = 7k : -5.4dB */
+ -1.3984F, /* mode1 = 9k : -4.2dB */
+ -1.1016F, /* mode2 = 12k : -3.3dB */
+ -1.0000F, /* mode3 = 14k : -3.0dB */
+ -0.9531F, /* mode4 = 16k : -2.85dB */
+ -0.8984F, /* mode5 = 18k : -2.7dB */
+ -0.8984F, /* mode6 = 20k : -2.7dB */
+ -0.8984F, /* mode7 = 23k : -2.7dB */
+ -0.8984F /* mode8 = 24k : -2.7dB */
+};
+
+
+
+
+
+
+
+
+
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_util.c b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_util.c
new file mode 100644
index 000000000..3359700ca
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_util.c
@@ -0,0 +1,1316 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#include <math.h>
+#include <memory.h>
+#include "typedef.h"
+#include "enc_main.h"
+#include "enc_lpc.h"
+
+#ifdef WIN32
+#pragma warning( disable : 4310)
+#endif
+
+#define MAX_16 (Word16)0x7FFF
+#define MIN_16 (Word16)0x8000
+#define MAX_31 (Word32)0x3FFFFFFF
+#define MIN_31 (Word32)0xC0000000
+#define L_FRAME16k 320 /* Frame size at 16kHz */
+#define L_SUBFR16k 80 /* Subframe size at 16kHz */
+#define L_SUBFR 64 /* Subframe size */
+#define M16k 20 /* Order of LP filter */
+#define L_WINDOW 384 /* window size in LP analysis */
+#define PREEMPH_FAC 0.68F /* preemphasis factor */
+
+extern const Word16 E_ROM_pow2[];
+extern const Word16 E_ROM_log2[];
+extern const Word16 E_ROM_isqrt[];
+extern const Float32 E_ROM_fir_6k_7k[];
+extern const Float32 E_ROM_hp_gain[];
+extern const Float32 E_ROM_fir_ipol[];
+extern const Float32 E_ROM_hamming_cos[];
+
+/*
+ * E_UTIL_random
+ *
+ * Parameters:
+ * seed I/O: seed for random number
+ *
+ * Function:
+ * Signed 16 bits random generator.
+ *
+ * Returns:
+ * random number
+ */
+Word16 E_UTIL_random(Word16 *seed)
+{
+ /*static Word16 seed = 21845;*/
+
+ *seed = (Word16) (*seed * 31821L + 13849L);
+
+ return(*seed);
+}
+
+/*
+ * E_UTIL_saturate
+ *
+ * Parameters:
+ * inp I: 32-bit number
+ *
+ * Function:
+ * Saturation to 16-bit number
+ *
+ * Returns:
+ * 16-bit number
+ */
+Word16 E_UTIL_saturate(Word32 inp)
+{
+ Word16 out;
+
+ if ((inp < MAX_16) & (inp > MIN_16))
+ {
+ out = (Word16)inp;
+ }
+ else
+ {
+ if (inp > 0)
+ {
+ out = MAX_16;
+ }
+ else
+ {
+ out = MIN_16;
+ }
+ }
+
+ return(out);
+}
+
+/*
+ * E_UTIL_saturate_31
+ *
+ * Parameters:
+ * inp I: 32-bit number
+ *
+ * Function:
+ * Saturation to 31-bit number
+ *
+ * Returns:
+ * 31(32)-bit number
+ */
+Word32 E_UTIL_saturate_31(Word32 inp)
+{
+ Word32 out;
+
+ if ((inp < MAX_31) & (inp > MIN_31))
+ {
+ out = inp;
+ }
+ else
+ {
+ if (inp > 0)
+ {
+ out = MAX_31;
+ }
+ else
+ {
+ out = MIN_31;
+ }
+ }
+
+ return(out);
+}
+
+/*
+ * E_UTIL_norm_s
+ *
+ * Parameters:
+ * L_var1 I: 32 bit Word32 signed integer (Word32) whose value
+ * falls in the range 0xffff 8000 <= var1 <= 0x0000 7fff.
+ *
+ * Function:
+ * Produces the number of left shift needed to normalize the 16 bit
+ * variable 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.
+ *
+ * Returns:
+ * 16 bit Word16 signed integer (Word16) whose value falls in the range
+ * 0x0000 0000 <= var_out <= 0x0000 000f.
+ */
+Word16 E_UTIL_norm_s (Word16 var1)
+{
+ Word16 var_out;
+
+ if (var1 == 0)
+ {
+ var_out = 0;
+ }
+ else
+ {
+ if (var1 == -1)
+ {
+ var_out = 15;
+ }
+ else
+ {
+ if (var1 < 0)
+ {
+ var1 = (Word16)~var1;
+ }
+ for (var_out = 0; var1 < 0x4000; var_out++)
+ {
+ var1 <<= 1;
+ }
+ }
+ }
+
+ return (var_out);
+}
+
+/*
+ * E_UTIL_norm_l
+ *
+ * Parameters:
+ * L_var1 I: 32 bit Word32 signed integer (Word32) whose value
+ * falls in the range 0x8000 0000 <= var1 <= 0x7fff ffff.
+ *
+ * Function:
+ * Produces the number of left shifts needed to normalize the 32 bit
+ * variable L_var1 for positive values on the interval with minimum of
+ * 1073741824 and maximum of 2147483647, and for negative values on
+ * the interval 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)).
+ *
+ * Returns:
+ * 16 bit Word16 signed integer (Word16) whose value falls in the range
+ * 0x0000 0000 <= var_out <= 0x0000 001f.
+ */
+Word16 E_UTIL_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;
+ }
+ }
+ }
+
+ return (var_out);
+}
+
+/*
+ * E_UTIL_l_extract
+ *
+ * Parameters:
+ * L_32 I: 32 bit integer.
+ * hi O: b16 to b31 of L_32
+ * lo O: (L_32 - hi<<16)>>1
+ *
+ * Function:
+ * Extract from a 32 bit integer two 16 bit DPF.
+ *
+ * Returns:
+ * void
+ */
+void E_UTIL_l_extract(Word32 L_32, Word16 *hi, Word16 *lo)
+{
+ *hi = (Word16)(L_32 >> 16);
+ *lo = (Word16)((L_32 >> 1) - ((*hi * 16384) << 1));
+ return;
+}
+
+/*
+ * E_UTIL_mpy_32_16
+ *
+ * Parameters:
+ * hi I: hi part of 32 bit number
+ * lo I: lo part of 32 bit number
+ * n I: 16 bit number
+ *
+ * Function:
+ * 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
+ *
+ * Returns:
+ * 32 bit result
+ */
+Word32 E_UTIL_mpy_32_16 (Word16 hi, Word16 lo, Word16 n)
+{
+ Word32 L_32;
+
+ L_32 = (hi * n) << 1;
+ L_32 = L_32 + (((lo * n) >> 15) << 1);
+
+ return (L_32);
+}
+
+/*
+ * E_UTIL_pow2
+ *
+ * Parameters:
+ * exponant I: (Q0) Integer part. (range: 0 <= val <= 30)
+ * fraction I: (Q15) Fractionnal part. (range: 0.0 <= val < 1.0)
+ *
+ * Function:
+ * 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)
+ *
+ * Returns:
+ * range 0 <= val <= 0x7fffffff
+ */
+Word32 E_UTIL_pow2(Word16 exponant, Word16 fraction)
+{
+ Word32 L_x, tmp, i, exp;
+ Word16 a;
+
+ L_x = fraction * 32; /* L_x = fraction<<6 */
+ i = L_x >> 15; /* Extract b10-b16 of fraction */
+ a = (Word16)(L_x); /* Extract b0-b9 of fraction */
+ a = (Word16)(a & (Word16)0x7fff);
+ L_x = E_ROM_pow2[i] << 16; /* table[i] << 16 */
+ tmp = E_ROM_pow2[i] - E_ROM_pow2[i + 1]; /* table[i] - table[i+1] */
+ L_x = L_x - ((tmp * a) << 1); /* L_x -= tmp*a*2 */
+ exp = 30 - exponant;
+ L_x = (L_x + (1 << (exp - 1))) >> exp;
+
+ return(L_x);
+}
+
+/*
+ * E_UTIL_normalised_log2
+ *
+ * Parameters:
+ * L_x I: input value (normalized)
+ * exp I: norm_l (L_x)
+ * exponent O: Integer part of Log2. (range: 0<=val<=30)
+ * fraction O: Fractional part of Log2. (range: 0<=val<1)
+ *
+ * Function:
+ * 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.
+ *
+ * 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
+ *
+ *
+ * Returns:
+ * void
+ */
+static void E_UTIL_normalised_log2(Word32 L_x, Word16 exp, Word16 *exponent,
+ Word16 *fraction)
+{
+ Word32 i, a, tmp;
+ Word32 L_y;
+
+ if (L_x <= 0)
+ {
+ *exponent = 0;
+ *fraction = 0;
+ return;
+ }
+
+ *exponent = (Word16)(30 - exp);
+
+ L_x = L_x >> 10;
+ i = L_x >> 15; /* Extract b25-b31 */
+ a = L_x; /* Extract b10-b24 of fraction */
+ a = a & 0x00007fff;
+ i = i - 32;
+ L_y = E_ROM_log2[i] << 16; /* table[i] << 16 */
+ tmp = E_ROM_log2[i] - E_ROM_log2[i + 1]; /* table[i] - table[i+1] */
+ L_y = L_y - ((tmp * a) << 1); /* L_y -= tmp*a*2 */
+ *fraction = (Word16)(L_y >> 16);
+
+ return;
+}
+
+
+/*
+ * E_UTIL_log2
+ *
+ * Parameters:
+ * L_x I: input value
+ * exponent O: Integer part of Log2. (range: 0<=val<=30)
+ * fraction O: Fractional part of Log2. (range: 0<=val<1)
+ *
+ * Function:
+ * Computes log2(L_x), where L_x is positive.
+ * If L_x is negative or zero, the result is 0.
+ *
+ * Returns:
+ * void
+ */
+void E_UTIL_log2_32 (Word32 L_x, Word16 *exponent, Word16 *fraction)
+{
+ Word16 exp;
+
+ exp = E_UTIL_norm_l(L_x);
+ E_UTIL_normalised_log2((L_x << exp), exp, exponent, fraction);
+}
+
+/*
+ * E_UTIL_interpol
+ *
+ * Parameters:
+ * x I: input vector
+ * fir I: filter coefficient
+ * frac I: fraction (0..resol)
+ * resol I: resolution
+ * nb_coef I: number of coefficients
+ *
+ * Function:
+ * Fractional interpolation of signal at position (frac/up_samp)
+ *
+ * Returns:
+ * result of interpolation
+ */
+static Float32 E_UTIL_interpol(Float32 *x, Word32 frac, Word32 up_samp,
+ Word32 nb_coef)
+{
+ Word32 i;
+ Float32 s;
+ Float32 *x1, *x2;
+ const Float32 *c1, *c2;
+
+ x1 = &x[0];
+ x2 = &x[1];
+ c1 = &E_ROM_fir_ipol[frac];
+ c2 = &E_ROM_fir_ipol[up_samp - frac];
+
+ s = 0.0;
+
+ for(i = 0; i < nb_coef; i++)
+ {
+ s += x1[-i] * c1[up_samp * i] + x2[i] * c2[up_samp * i];
+ }
+
+ return s;
+}
+
+/*
+ * E_UTIL_hp50_12k8
+ *
+ * Parameters:
+ * signal I/O: signal
+ * lg I: lenght of signal
+ * mem I/O: filter memory [6]
+ *
+ * Function:
+ * 2nd order high pass filter with cut off frequency at 50 Hz.
+ *
+ * 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];
+ *
+ * b[3] = {0.989501953f, -1.979003906f, 0.989501953f};
+ * a[3] = {1.000000000F, 1.978881836f,-0.966308594f};
+ *
+ *
+ * Returns:
+ * void
+ */
+void E_UTIL_hp50_12k8(Float32 signal[], Word32 lg, Float32 mem[])
+{
+ Word32 i;
+ Float32 x0, x1, x2, y0, y1, y2;
+
+ y1 = mem[0];
+ y2 = mem[1];
+ x0 = mem[2];
+ x1 = mem[3];
+
+ for(i = 0; i < lg; i++)
+ {
+ x2 = x1;
+ x1 = x0;
+ x0 = signal[i];
+
+ y0 = y1 * 1.978881836F + y2 * -0.979125977F + x0 * 0.989501953F +
+ x1 * -1.979003906F + x2 * 0.989501953F;
+
+ signal[i] = y0;
+ y2 = y1;
+ y1 = y0;
+ }
+
+ mem[0] = ((y1 > 1e-10) | (y1 < -1e-10)) ? y1 : 0;
+ mem[1] = ((y2 > 1e-10) | (y2 < -1e-10)) ? y2 : 0;
+ mem[2] = ((x0 > 1e-10) | (x0 < -1e-10)) ? x0 : 0;
+ mem[3] = ((x1 > 1e-10) | (x1 < -1e-10)) ? x1 : 0;
+
+ return;
+}
+
+/*
+ * E_UTIL_hp400_12k8
+ *
+ * Parameters:
+ * signal I/O: signal
+ * lg I: lenght of signal
+ * mem I/O: filter memory [4]
+ *
+ * Function:
+ * 2nd order high pass filter with cut off frequency at 400 Hz.
+ *
+ * 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];
+ *
+ * b[3] = {0.893554687, -1.787109375, 0.893554687};
+ * a[3] = {1.000000000, 1.787109375, -0.864257812};
+ *
+ *
+ * Returns:
+ * void
+ */
+static void E_UTIL_hp400_12k8(Float32 signal[], Word32 lg, Float32 mem[])
+{
+ Word32 i;
+
+ Float32 x0, x1, x2;
+ Float32 y0, y1, y2;
+
+ y1 = mem[0];
+ y2 = mem[1];
+ x0 = mem[2];
+ x1 = mem[3];
+
+ for(i = 0; i < lg; i++)
+ {
+ x2 = x1;
+ x1 = x0;
+ x0 = signal[i];
+ y0 = y1 * 1.787109375F + y2 * -0.864257812F + x0 * 0.893554687F + x1 * -
+ 1.787109375F + x2 * 0.893554687F;
+ signal[i] = y0;
+ y2 = y1;
+ y1 = y0;
+ }
+
+ mem[0] = y1;
+ mem[1] = y2;
+ mem[2] = x0;
+ mem[3] = x1;
+
+ return;
+}
+
+/*
+ * E_UTIL_bp_6k_7k
+ *
+ * Parameters:
+ * signal I/O: signal
+ * lg I: lenght of signal
+ * mem I/O: filter memory [4]
+ *
+ * Function:
+ * 15th order band pass 6kHz to 7kHz FIR filter.
+ *
+ * Returns:
+ * void
+ */
+static void E_UTIL_bp_6k_7k(Float32 signal[], Word32 lg, Float32 mem[])
+{
+ Float32 x[L_SUBFR16k + 30];
+ Float32 s0, s1, s2, s3;
+ Float32 *px;
+ Word32 i, j;
+
+ memcpy(x, mem, 30 * sizeof(Float32));
+ memcpy(x + 30, signal, lg * sizeof(Float32));
+
+ px = x;
+
+ for(i = 0; i < lg; i++)
+ {
+ s0 = 0;
+ s1 = px[0] * E_ROM_fir_6k_7k[0];
+ s2 = px[1] * E_ROM_fir_6k_7k[1];
+ s3 = px[2] * E_ROM_fir_6k_7k[2];
+
+ for(j = 3; j < 31; j += 4)
+ {
+ s0 += px[j] * E_ROM_fir_6k_7k[j];
+ s1 += px[j + 1] * E_ROM_fir_6k_7k[j + 1];
+ s2 += px[j + 2] * E_ROM_fir_6k_7k[j + 2];
+ s3 += px[j + 3] * E_ROM_fir_6k_7k[j + 3];
+ }
+
+ px++;
+
+ signal[i] = (Float32)((s0 + s1 + s2 + s3) * 0.25F); /* gain of coef = 4.0 */
+ }
+
+ memcpy(mem, x + lg, 30 * sizeof(Float32));
+
+ return;
+}
+
+/*
+ * E_UTIL_preemph
+ *
+ * Parameters:
+ * x I/O: signal
+ * mu I: preemphasis factor
+ * lg I: vector size
+ * mem I/O: memory (x[-1])
+ *
+ * Function:
+ * Filtering through 1 - mu z^-1
+ *
+ *
+ * Returns:
+ * void
+ */
+void E_UTIL_preemph(Word16 x[], Word16 mu, Word32 lg, Word16 *mem)
+{
+ Word32 i, L_tmp;
+ Word16 temp;
+
+ temp = x[lg - 1];
+
+ for (i = lg - 1; i > 0; i--)
+ {
+ L_tmp = x[i] << 15;
+ L_tmp -= x[i - 1] * mu;
+ x[i] = (Word16)((L_tmp + 0x4000) >> 15);
+ }
+
+ L_tmp = (x[0] << 15);
+ L_tmp -= *mem * mu;
+ x[0] = (Word16)((L_tmp + 0x4000) >> 15);
+
+ *mem = temp;
+
+ return;
+}
+
+void E_UTIL_f_preemph(Float32 *signal, Float32 mu, Word32 L, Float32 *mem)
+{
+ Word32 i;
+ Float32 temp;
+
+ temp = signal[L - 1];
+
+ for (i = L - 1; i > 0; i--)
+ {
+ signal[i] = signal[i] - mu * signal[i - 1];
+ }
+
+ signal[0] -= mu * (*mem);
+ *mem = temp;
+
+ return;
+}
+
+/*
+ * E_UTIL_deemph
+ *
+ * Parameters:
+ * signal I/O: signal
+ * mu I: deemphasis factor
+ * L I: vector size
+ * mem I/O: memory (signal[-1])
+ *
+ * Function:
+ * Filtering through 1/(1-mu z^-1)
+ * Signal is divided by 2.
+ *
+ * Returns:
+ * void
+ */
+void E_UTIL_deemph(Float32 *signal, Float32 mu, Word32 L, Float32 *mem)
+{
+ Word32 i;
+
+ signal[0] = signal[0] + mu * (*mem);
+
+ for (i = 1; i < L; i++)
+ {
+ signal[i] = signal[i] + mu * signal[i - 1];
+ }
+
+ *mem = signal[L - 1];
+
+ if ((*mem < 1e-10) & (*mem > -1e-10))
+ {
+ *mem = 0;
+ }
+
+ return;
+}
+
+/*
+ * E_UTIL_synthesis
+ *
+ * Parameters:
+ * a I: LP filter coefficients
+ * m I: order of LP filter
+ * x I: input signal
+ * y O: output signal
+ * lg I: size of filtering
+ * mem I/O: initial filter states
+ * update_m I: update memory flag
+ *
+ * Function:
+ * Perform the synthesis filtering 1/A(z).
+ * Memory size is always M.
+ *
+ * Returns:
+ * void
+ */
+void E_UTIL_synthesis(Float32 a[], Float32 x[], Float32 y[], Word32 l,
+ Float32 mem[], Word32 update_m)
+{
+
+ Float32 buf[L_FRAME16k + M16k]; /* temporary synthesis buffer */
+ Float32 s;
+ Float32 *yy;
+ Word32 i, j;
+
+ /* copy initial filter states into synthesis buffer */
+ memcpy(buf, mem, M * sizeof(Float32));
+ yy = &buf[M];
+
+ for (i = 0; i < l; i++)
+ {
+ s = x[i];
+
+ for (j = 1; j <= M; j += 4)
+ {
+ s -= a[j] * yy[i - j];
+ s -= a[j + 1] * yy[i - (j + 1)];
+ s -= a[j + 2] * yy[i - (j + 2)];
+ s -= a[j + 3] * yy[i - (j + 3)];
+ }
+
+ yy[i] = s;
+ y[i] = s;
+ }
+
+ /* Update memory if required */
+ if (update_m)
+ {
+ memcpy(mem, &yy[l - M], M * sizeof(Float32));
+ }
+
+ return;
+}
+
+/*
+ * E_UTIL_down_samp
+ *
+ * Parameters:
+ * res I: signal to down sample
+ * res_d O: down sampled signal
+ * L_frame_d I: length of output
+ *
+ * Function:
+ * Down sample to 4/5
+ *
+ * Returns:
+ * void
+ */
+static void E_UTIL_down_samp(Float32 *res, Float32 *res_d, Word32 L_frame_d)
+{
+ Word32 i, j, frac;
+ Float32 pos, fac;
+
+ fac = 0.8F;
+ pos = 0;
+
+ for(i = 0; i < L_frame_d; i++)
+ {
+ j = (Word32)pos; /* j = (Word32)( (Float32)i * inc); */
+ frac = (Word32)(((pos - (Float32)j) * 4) + 0.5);
+ res_d[i] = fac * E_UTIL_interpol(&res[j], frac, 4, 15);
+ pos += 1.25F;
+ }
+
+ return;
+}
+
+/*
+ * E_UTIL_decim_12k8
+ *
+ * Parameters:
+ * sig16k I: signal to decimate
+ * lg I: length of input
+ * sig12k8 O: decimated signal
+ * mem I/O: memory (2*15)
+ *
+ * Function:
+ * Decimation of 16kHz signal to 12.8kHz.
+ *
+ * Returns:
+ * void
+ */
+void E_UTIL_decim_12k8(Float32 sig16k[], Word32 lg, Float32 sig12k8[],
+ Float32 mem[])
+{
+ Float32 signal[(2 * 15) + L_FRAME16k];
+
+ memcpy(signal, mem, 2 * 15 * sizeof(Float32));
+ memcpy(&signal[2 * 15], sig16k, lg * sizeof(Float32));
+
+ E_UTIL_down_samp(signal + 15, sig12k8, lg * 4 / 5);
+
+ memcpy(mem, &signal[lg], 2 * 15 * sizeof(Float32));
+
+ return;
+}
+
+/*
+ * E_UTIL_residu
+ *
+ * Parameters:
+ * a I: LP filter coefficients (Q12)
+ * x I: input signal (usually speech)
+ * y O: output signal (usually residual)
+ * l I: size of filtering
+ *
+ * Function:
+ * Compute the LP residual by filtering the input speech through A(z).
+ * Order of LP filter = M.
+ *
+ * Returns:
+ * void
+ */
+void E_UTIL_residu(Float32 *a, Float32 *x, Float32 *y, Word32 l)
+{
+ Float32 s;
+ Word32 i;
+
+ for (i = 0; i < l; i++)
+ {
+ s = x[i];
+ s += a[1] * x[i - 1];
+ s += a[2] * x[i - 2];
+ s += a[3] * x[i - 3];
+ s += a[4] * x[i - 4];
+ s += a[5] * x[i - 5];
+ s += a[6] * x[i - 6];
+ s += a[7] * x[i - 7];
+ s += a[8] * x[i - 8];
+ s += a[9] * x[i - 9];
+ s += a[10] * x[i - 10];
+ s += a[11] * x[i - 11];
+ s += a[12] * x[i - 12];
+ s += a[13] * x[i - 13];
+ s += a[14] * x[i - 14];
+ s += a[15] * x[i - 15];
+ s += a[16] * x[i - 16];
+ y[i] = s;
+ }
+
+ return;
+}
+
+/*
+ * E_UTIL_convolve
+ *
+ * Parameters:
+ * x I: input vector
+ * h I: impulse response (or second input vector) (Q15)
+ * y O: output vetor (result of convolution)
+ *
+ * Function:
+ * Perform the convolution between two vectors x[] and h[] and
+ * write the result in the vector y[]. All vectors are of length L.
+ * Only the first L samples of the convolution are considered.
+ * Vector size = L_SUBFR
+ *
+ * Returns:
+ * void
+ */
+void E_UTIL_convolve(Word16 x[], Word16 q, Float32 h[], Float32 y[])
+{
+ Float32 fx[L_SUBFR];
+ Float32 temp, scale;
+ Word32 i, n;
+
+ scale = (Float32)pow(2, -q);
+
+ for (i = 0; i < L_SUBFR; i++)
+ {
+ fx[i] = (Float32)(scale * x[i]);
+ }
+
+ for (n = 0; n < L_SUBFR; n += 2)
+ {
+ temp = 0.0;
+ for (i = 0; i <= n; i++)
+ {
+ temp += (Float32)(fx[i] * h[n - i]);
+ }
+ y[n] = temp;
+
+ temp = 0.0;
+ for (i = 0; i <= (n + 1); i += 2)
+ {
+ temp += (Float32)(fx[i] * h[(n + 1) - i]);
+ temp += (Float32)(fx[i + 1] * h[n - i]);
+ }
+ y[n + 1] = temp;
+
+ }
+
+ return;
+}
+
+void E_UTIL_f_convolve(Float32 x[], Float32 h[], Float32 y[])
+{
+ Float32 temp;
+ Word32 i, n;
+
+ for (n = 0; n < L_SUBFR; n += 2)
+ {
+ temp = 0.0;
+
+ for (i = 0; i <= n; i++)
+ {
+ temp += x[i] * h[n - i];
+ }
+
+ y[n] = temp;
+
+ temp = 0.0;
+
+ for (i = 0; i <= (n + 1); i += 2)
+ {
+ temp += x[i] * h[(n + 1) - i];
+ temp += x[i + 1] * h[n - i];
+ }
+
+ y[n + 1] = temp;
+ }
+
+ return;
+}
+
+/*
+ * E_UTIL_signal_up_scale
+ *
+ * Parameters:
+ * x I/O: signal to scale
+ * exp I: exponent: x = round(x << exp)
+ *
+ * Function:
+ * Scale signal up to get maximum of dynamic.
+ *
+ * Returns:
+ * void
+ */
+void E_UTIL_signal_up_scale(Word16 x[], Word16 exp)
+{
+ Word32 i;
+ Word32 tmp;
+
+ for (i = 0; i < (PIT_MAX + L_INTERPOL + L_SUBFR); i++)
+ {
+ tmp = x[i] << exp;
+ x[i] = E_UTIL_saturate(tmp);
+ }
+
+ return;
+}
+
+/*
+ * E_UTIL_signal_down_scale
+ *
+ * Parameters:
+ * x I/O: signal to scale
+ * lg I: size of x[]
+ * exp I: exponent: x = round(x << exp)
+ *
+ * Function:
+ * Scale signal up to get maximum of dynamic.
+ *
+ * Returns:
+ * 32 bit result
+ */
+void E_UTIL_signal_down_scale(Word16 x[], Word32 lg, Word16 exp)
+{
+ Word32 i, tmp;
+
+ for (i = 0; i < lg; i++)
+ {
+ tmp = x[i] << 16;
+ tmp = tmp >> exp;
+ x[i] = (Word16)((tmp + 0x8000) >> 16);
+ }
+
+ return;
+}
+
+
+/*
+ * E_UTIL_dot_product12
+ *
+ * Parameters:
+ * x I: 12bit x vector
+ * y I: 12bit y vector
+ * lg I: vector length (x*4)
+ * exp O: exponent of result (0..+30)
+ *
+ * Function:
+ * Compute scalar product of <x[],y[]> using accumulator.
+ * The result is normalized (in Q31) with exponent (0..30).
+ *
+ * Returns:
+ * Q31 normalised result (1 < val <= -1)
+ */
+Word32 E_UTIL_dot_product12(Word16 x[], Word16 y[], Word32 lg, Word32 *exp)
+{
+ Word32 i, sft, L_sum, L_sum1, L_sum2, L_sum3, L_sum4;
+
+ L_sum1 = 0L;
+ L_sum2 = 0L;
+ L_sum3 = 0L;
+ L_sum4 = 0L;
+
+ for (i = 0; i < lg; i += 4)
+ {
+ L_sum1 += x[i] * y[i];
+ L_sum2 += x[i + 1] * y[i + 1];
+ L_sum3 += x[i + 2] * y[i + 2];
+ L_sum4 += x[i + 3] * y[i + 3];
+ }
+
+ L_sum1 = E_UTIL_saturate_31(L_sum1);
+ L_sum2 = E_UTIL_saturate_31(L_sum2);
+ L_sum3 = E_UTIL_saturate_31(L_sum3);
+ L_sum4 = E_UTIL_saturate_31(L_sum4);
+ L_sum1 += L_sum3;
+ L_sum2 += L_sum4;
+ L_sum1 = E_UTIL_saturate_31(L_sum1);
+ L_sum2 = E_UTIL_saturate_31(L_sum2);
+ L_sum = L_sum1 + L_sum2;
+ L_sum = (E_UTIL_saturate_31(L_sum) << 1) + 1;
+
+ /* Normalize acc in Q31 */
+
+ sft = E_UTIL_norm_l(L_sum);
+ L_sum = (L_sum << sft);
+
+ *exp = (30 - sft); /* exponent = 0..30 */
+
+ return (L_sum);
+}
+
+/*
+ * E_UTIL_normalised_inverse_sqrt
+ *
+ * Parameters:
+ * frac I/O: (Q31) normalized value (1.0 < frac <= 0.5)
+ * exp I/O: exponent (value = frac x 2^exponent)
+ *
+ * Function:
+ * Compute 1/sqrt(value).
+ * If value is negative or zero, result is 1 (frac=7fffffff, exp=0).
+ *
+ * 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
+ *
+ * Returns:
+ * void
+ */
+void E_UTIL_normalised_inverse_sqrt(Word32 *frac, Word16 *exp)
+{
+ Word32 i, a, tmp;
+
+ if (*frac <= (Word32) 0)
+ {
+ *exp = 0;
+ *frac = 0x7fffffffL;
+ return;
+ }
+
+ if ((Word16) (*exp & 1) == 1) /* If exponant odd -> shift right */
+ {
+ *frac = (*frac >> 1);
+ }
+
+ *exp = (Word16)(-((*exp - 1) >> 1));
+
+ *frac = (*frac >> 9);
+ i = *frac >> 16; /* Extract b25-b31 */
+ *frac = (*frac >> 1);
+ a = (Word16)*frac; /* Extract b10-b24 */
+ a = a & 0x00007fff;
+
+ i = i - 16;
+
+ *frac = E_ROM_isqrt[i] << 16; /* table[i] << 16 */
+ tmp = E_ROM_isqrt[i] - E_ROM_isqrt[i + 1]; /* table[i] - table[i+1]) */
+
+ *frac = *frac - ((tmp * a) << 1); /* frac -= tmp*a*2 */
+
+ return;
+}
+
+/*
+ * E_UTIL_enc_synthesis
+ *
+ * Parameters:
+ * Aq I: quantized Az
+ * exc I: excitation at 12kHz
+ * synth16k O: 16kHz synthesis signal
+ * st I/O: State structure
+ *
+ * Function:
+ * Synthesis of signal at 16kHz with HF extension.
+ *
+ * Returns:
+ * The quantised gain index when using the highest mode, otherwise zero
+ */
+Word32 E_UTIL_enc_synthesis(Float32 Aq[], Float32 exc[], Float32 synth16k[],
+ Coder_State *st)
+{
+ Float32 synth[L_SUBFR];
+ Float32 HF[L_SUBFR16k]; /* High Frequency vector */
+ Float32 Ap[M + 1];
+ Float32 HF_SP[L_SUBFR16k]; /* High Frequency vector (from original signal) */
+ Float32 HP_est_gain, HP_calc_gain, HP_corr_gain, fac, tmp, ener, dist_min;
+ Float32 dist, gain2;
+ Word32 i, hp_gain_ind = 0;
+
+ /*
+ * speech synthesis
+ * ----------------
+ * - Find synthesis speech corresponding to exc2[].
+ * - Perform fixed deemphasis and hp 50hz filtering.
+ * - Oversampling from 12.8kHz to 16kHz.
+ */
+ E_UTIL_synthesis(Aq, exc, synth, L_SUBFR, st->mem_syn2, 1);
+ E_UTIL_deemph(synth, PREEMPH_FAC, L_SUBFR, &(st->mem_deemph));
+ E_UTIL_hp50_12k8(synth, L_SUBFR, st->mem_sig_out);
+
+ /* Original speech signal as reference for high band gain quantisation */
+ memcpy(HF_SP, synth16k, L_SUBFR16k * sizeof(Float32));
+
+ /*
+ * HF noise synthesis
+ * ------------------
+ * - Generate HF noise between 6 and 7 kHz.
+ * - Set energy of noise according to synthesis tilt.
+ * tilt > 0.8 ==> - 14 dB (voiced)
+ * tilt 0.5 ==> - 6 dB (voiced or noise)
+ * tilt < 0.0 ==> 0 dB (noise)
+ */
+ /* generate white noise vector */
+ for(i = 0; i < L_SUBFR16k; i++)
+ {
+ HF[i] = (Float32)E_UTIL_random(&(st->mem_seed));
+ }
+
+ /* set energy of white noise to energy of excitation */
+ ener = 0.01F;
+ tmp = 0.01F;
+
+ for(i = 0; i < L_SUBFR; i++)
+ {
+ ener += exc[i] * exc[i];
+ }
+
+ for(i = 0; i < L_SUBFR16k; i++)
+ {
+ tmp += HF[i] * HF[i];
+ }
+
+ tmp = (Float32)(sqrt(ener / tmp));
+
+ for(i = 0; i < L_SUBFR16k; i++)
+ {
+ HF[i] *= tmp;
+ }
+
+ /* find tilt of synthesis speech (tilt: 1=voiced, -1=unvoiced) */
+ E_UTIL_hp400_12k8(synth, L_SUBFR, st->mem_hp400);
+ ener = 0.001f;
+ tmp = 0.001f;
+
+ for(i = 1; i < L_SUBFR; i++)
+ {
+ ener += synth[i] * synth[i];
+ tmp += synth[i] * synth[i - 1];
+ }
+
+ fac = tmp / ener;
+
+ /* modify energy of white noise according to synthesis tilt */
+ HP_est_gain = 1.0F - fac;
+ gain2 = (1.0F - fac) * 1.25F;
+
+ if(st->mem_vad_hist)
+ {
+ HP_est_gain = gain2;
+ }
+
+ if(HP_est_gain < 0.1)
+ {
+ HP_est_gain = 0.1f;
+ }
+
+ if(HP_est_gain > 1.0)
+ {
+ HP_est_gain = 1.0f;
+ }
+
+ /* synthesis of noise: 4.8kHz..5.6kHz --> 6kHz..7kHz */
+ E_LPC_a_weight(Aq, Ap, 0.6f, M);
+ E_UTIL_synthesis(Ap, HF, HF, L_SUBFR16k, st->mem_syn_hf, 1);
+
+ /* noise High Pass filtering (0.94ms of delay) */
+ E_UTIL_bp_6k_7k(HF, L_SUBFR16k, st->mem_hf);
+
+ /* noise High Pass filtering (0.94ms of delay) */
+ E_UTIL_bp_6k_7k(HF_SP, L_SUBFR16k, st->mem_hf2);
+
+ ener = 0.001F;
+ tmp = 0.001F;
+
+ for(i = 0; i < L_SUBFR16k; i++)
+ {
+ ener += HF_SP[i] * HF_SP[i];
+ tmp += HF[i] * HF[i];
+ }
+
+ HP_calc_gain = (Float32)sqrt(ener /tmp);
+ st->mem_gain_alpha *= st->dtx_encSt->mem_dtx_hangover_count / 7;
+
+ if(st->dtx_encSt->mem_dtx_hangover_count > 6)
+ {
+ st->mem_gain_alpha = 1.0F;
+ }
+
+ HP_corr_gain = (HP_calc_gain * st->mem_gain_alpha) +
+ ((1.0F - st->mem_gain_alpha) * HP_est_gain);
+
+ /* Quantise the correction gain */
+ dist_min = 100000.0F;
+
+ for(i = 0; i < 16; i++)
+ {
+ dist = (HP_corr_gain - E_ROM_hp_gain[i]) * (HP_corr_gain - E_ROM_hp_gain[i]);
+
+ if(dist_min > dist)
+ {
+ dist_min = dist;
+ hp_gain_ind = i;
+ }
+ }
+
+ HP_corr_gain = (Float32)E_ROM_hp_gain[hp_gain_ind];
+
+ /* return the quantised gain index when using the highest mode, otherwise zero */
+ return(hp_gain_ind);
+}
+
+/*
+ * E_UTIL_autocorr
+ *
+ * Parameters:
+ * x I: input signal
+ * r_h O: autocorrelations
+ *
+ * Function:
+ * Compute the autocorrelations of windowed speech signal.
+ * order of LP filter is M. Window size is L_WINDOW.
+ * Analysis window is "window".
+ *
+ * Returns:
+ * void
+ */
+void E_UTIL_autocorr(Float32 *x, Float32 *r)
+{
+ Float32 t[L_WINDOW + M];
+ Word32 i, j;
+
+ for (i = 0; i < L_WINDOW; i += 4)
+ {
+ t[i] = x[i] * E_ROM_hamming_cos[i];
+ t[i + 1] = x[i + 1] * E_ROM_hamming_cos[i + 1];
+ t[i + 2] = x[i + 2] * E_ROM_hamming_cos[i + 2];
+ t[i + 3] = x[i + 3] * E_ROM_hamming_cos[i + 3];
+ }
+
+ memset(&t[L_WINDOW], 0, M * sizeof(Float32));
+ memset(r, 0, (M + 1) * sizeof(Float32));
+
+ for (j = 0; j < L_WINDOW; j++)
+ {
+ r[0] += t[j] * t[j];
+ r[1] += t[j] * t[j + 1];
+ r[2] += t[j] * t[j + 2];
+ r[3] += t[j] * t[j + 3];
+ r[4] += t[j] * t[j + 4];
+ r[5] += t[j] * t[j + 5];
+ r[6] += t[j] * t[j + 6];
+ r[7] += t[j] * t[j + 7];
+ r[8] += t[j] * t[j + 8];
+ r[9] += t[j] * t[j + 9];
+ r[10] += t[j] * t[j + 10];
+ r[11] += t[j] * t[j + 11];
+ r[12] += t[j] * t[j + 12];
+ r[13] += t[j] * t[j + 13];
+ r[14] += t[j] * t[j + 14];
+ r[15] += t[j] * t[j + 15];
+ r[16] += t[j] * t[j + 16];
+ }
+
+ if (r[0] < 1.0F)
+ {
+ r[0] = 1.0F;
+ }
+
+ return;
+}
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_util.h b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_util.h
new file mode 100644
index 000000000..45cc758b7
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/enc_util.h
@@ -0,0 +1,43 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef ENC_UTIL_H
+#define ENC_UTIL_H
+
+#include "typedef.h"
+#include "enc_main.h"
+
+Word16 E_UTIL_saturate(Word32 inp);
+Word32 E_UTIL_saturate_31(Word32 inp);
+Word16 E_UTIL_random(Word16 *seed);
+Word32 E_UTIL_mpy_32_16 (Word16 hi, Word16 lo, Word16 n);
+Word32 E_UTIL_pow2(Word16 exponant, Word16 fraction);
+void E_UTIL_log2_32 (Word32 L_x, Word16 *exponent, Word16 *fraction);
+void E_UTIL_normalised_inverse_sqrt(Word32 *frac, Word16 *exp);
+Word32 E_UTIL_dot_product12(Word16 x[], Word16 y[], Word32 lg, Word32 *exp);
+Word16 E_UTIL_norm_s (Word16 var1);
+Word16 E_UTIL_norm_l (Word32 L_var1);
+void E_UTIL_l_extract(Word32 L_32, Word16 *hi, Word16 *lo);
+void E_UTIL_hp50_12k8(Float32 signal[], Word32 lg, Float32 mem[]);
+void E_UTIL_preemph(Word16 x[], Word16 mu, Word32 lg, Word16 *mem);
+void E_UTIL_f_preemph(Float32 *signal, Float32 mu, Word32 L, Float32 *mem);
+void E_UTIL_deemph(Float32 *signal, Float32 mu, Word32 L, Float32 *mem);
+void E_UTIL_deemph_32(Word16 x_hi[], Word16 x_lo[], Word16 y[],
+ Word16 mu, Word16 L, Word16 *mem);
+void E_UTIL_decim_12k8(Float32 sig16k[], Word32 lg, Float32 sig12k8[],
+ Float32 mem[]);
+void E_UTIL_residu(Float32 *a, Float32 *x, Float32 *y, Word32 l);
+void E_UTIL_convolve(Word16 x[], Word16 q, Float32 h[], Float32 y[]);
+void E_UTIL_f_convolve(Float32 x[], Float32 h[], Float32 y[]);
+void E_UTIL_autocorr(Float32 *x, Float32 *r);
+void E_UTIL_signal_up_scale(Word16 x[], Word16 exp);
+void E_UTIL_signal_down_scale(Word16 x[], Word32 lg, Word16 exp);
+void E_UTIL_synthesis(Float32 a[], Float32 x[], Float32 y[],
+ Word32 l, Float32 mem[], Word32 update_m);
+Word32 E_UTIL_enc_synthesis(Float32 Aq[], Float32 exc[], Float32 synth16k[],
+ Coder_State *st);
+
+
+#endif
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/encoder.c b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/encoder.c
new file mode 100644
index 000000000..4de34c9f2
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/encoder.c
@@ -0,0 +1,194 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "typedef.h"
+#include "enc_if.h"
+
+#ifndef IF2
+#define AMRWB_MAGIC_NUMBER "#!AMR-WB\n"
+#endif
+
+/*
+ * ENCODER.C
+ *
+ * Usage : encoder (-dtx) mode speech_file bitstream_file
+ *
+ * Format for speech_file:
+ * Speech is read from a binary file of 16 bits data.
+ *
+ * Format for bitstream_file:
+ * Described in TS26.201
+ *
+ * mode = 0..8 (bit rate = 6.60 to 23.85 k)
+ *
+ * -dtx if DTX is ON
+ */
+
+int main(int argc, char *argv[])
+{
+ FILE *f_speech = NULL; /* File of speech data */
+ FILE *f_serial = NULL; /* File of serial bits for transmission */
+ FILE *f_mode = NULL; /* File of modes for each frame */
+
+ Word32 serial_size, frame;
+ Word16 signal[L_FRAME16k]; /* Buffer for speech @ 16kHz */
+ Word16 coding_mode = 0, allow_dtx, mode_file, mode = 0;
+ UWord8 serial[NB_SERIAL_MAX];
+ void *st;
+
+ fprintf(stderr, "\n");
+ fprintf(stderr, "===================================================================\n");
+ fprintf(stderr, " 3GPP AMR-WB Floating-point Speech Coder, v6.0.0, Dec 14, 2004\n");
+ fprintf(stderr, "===================================================================\n");
+ fprintf(stderr, "\n");
+
+ /*
+ * Open speech file and result file (output serial bit stream)
+ */
+
+ if ((argc < 4) || (argc > 6))
+ {
+ fprintf(stderr, "Usage : encoder (-dtx) mode speech_file bitstream_file\n");
+ fprintf(stderr, "\n");
+ fprintf(stderr, "Format for speech_file:\n");
+ fprintf(stderr, " Speech is read form a binary file of 16 bits data.\n");
+ fprintf(stderr, "\n");
+ fprintf(stderr, "Format for bitstream_file:\n");
+#ifdef IF2
+ fprintf(stderr, " Described in TS26.201.\n");
+#else
+ fprintf(stderr, " Described in RFC 3267 (Sections 5.1 and 5.3).\n");
+#endif
+ fprintf(stderr, "\n");
+ fprintf(stderr, "mode: 0 to 8 (9 bits rates) or\n");
+ fprintf(stderr, " -modefile filename\n");
+ fprintf(stderr, " ===================================================================\n");
+ fprintf(stderr, " mode : (0) (1) (2) (3) (4) (5) (6) (7) (8) \n");
+ fprintf(stderr, " bitrate: 6.60 8.85 12.65 14.25 15.85 18.25 19.85 23.05 23.85 kbit/s\n");
+ fprintf(stderr, " ===================================================================\n");
+ fprintf(stderr, "\n");
+ fprintf(stderr, "-dtx if DTX is ON, default is OFF\n");
+ fprintf(stderr, "\n");
+ exit(0);
+ }
+ allow_dtx = 0;
+ if (strcmp(argv[1], "-dtx") == 0)
+ {
+ allow_dtx = 1;
+ argv++;
+ }
+ mode_file = 0;
+ if (strcmp(argv[1], "-modefile") == 0)
+ {
+ mode_file = 1;
+ argv++;
+ if ((f_mode = fopen(argv[1], "r")) == NULL)
+ {
+ fprintf(stderr, "Error opening input file %s !!\n", argv[1]);
+ exit(0);
+ }
+ fprintf(stderr, "Mode file: %s\n", argv[1]);
+ }
+ else
+ {
+ mode = (Word16) atoi(argv[1]);
+ if ((mode < 0) || (mode > 8))
+ {
+ fprintf(stderr, " error in bit rate mode %d: use 0 to 8\n", mode);
+ exit(0);
+ }
+ }
+
+ if ((f_speech = fopen(argv[2], "rb")) == NULL)
+ {
+ fprintf(stderr, "Error opening input file %s !!\n", argv[2]);
+ exit(0);
+ }
+ fprintf(stderr, "Input speech file: %s\n", argv[2]);
+
+ if ((f_serial = fopen(argv[3], "wb")) == NULL)
+ {
+ fprintf(stderr, "Error opening output bitstream file %s !!\n", argv[3]);
+ exit(0);
+ }
+ fprintf(stderr, "Output bitstream file: %s\n", argv[3]);
+
+ /*
+ * Initialisation
+ */
+
+ st = E_IF_init();
+
+#ifndef IF2
+
+ /* If MMS output is selected, write the magic number at the beginning of the
+ * bitstream file
+ */
+
+ fwrite(AMRWB_MAGIC_NUMBER, sizeof(char), strlen(AMRWB_MAGIC_NUMBER), f_serial);
+
+#endif
+
+ /*
+ * Loop for every analysis/transmission frame.
+ * -New L_FRAME data are read. (L_FRAME = number of speech data per frame)
+ * -Conversion of the speech data from 16 bit integer to real
+ * -Call coder to encode the speech.
+ * -The compressed serial output stream is written to a file.
+ */
+
+ fprintf(stderr, "\n --- Running ---\n");
+
+ frame = 0;
+
+ while (fread(signal, sizeof(Word16), L_FRAME16k, f_speech) == L_FRAME16k)
+ {
+ if (mode_file)
+ {
+ if (fscanf(f_mode, "%hd", &mode) == EOF)
+ {
+ mode = coding_mode;
+ fprintf(stderr, "\n end of mode control file reached\n");
+ fprintf(stderr, " From now on using mode: %hd.\n", mode);
+ mode_file = 0;
+ }
+
+ if ((mode < 0) || (mode > 8))
+ {
+ fprintf(stderr, " error in bit rate mode %hd: use 0 to 8\n", mode);
+ E_IF_exit(st);
+ fclose(f_speech);
+ fclose(f_serial);
+ fclose(f_mode);
+ exit(0);
+ }
+ }
+
+ coding_mode = mode;
+
+ frame++;
+ fprintf(stderr, " Frames processed: %ld\r", frame);
+
+ serial_size = E_IF_encode(st, coding_mode, signal, serial, allow_dtx);
+
+ fwrite(serial, 1, serial_size, f_serial);
+
+ }
+
+ E_IF_exit(st);
+
+ fclose(f_speech);
+ fclose(f_serial);
+
+ if (f_mode != NULL)
+ {
+ fclose(f_mode);
+ }
+
+ return 0;
+}
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/if_rom.c b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/if_rom.c
new file mode 100644
index 000000000..e602ec11d
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/if_rom.c
@@ -0,0 +1,1022 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef IF_H
+#define IF_H
+
+#include "typedef.h"
+
+/*
+ * definition of constants
+ */
+#define NUM_OF_SPMODES 9
+
+/* number of parameters */
+#define PRMNO_7k 18
+#define PRMNO_9k 32
+#define PRMNO_12k 36
+#define PRMNO_14k 36
+#define PRMNO_16k 36
+#define PRMNO_18k 52
+#define PRMNO_20k 52
+#define PRMNO_23k 52
+#define PRMNO_24k 56
+#define PRMNO_SID 7
+#define NB_PARM_MAX PRMNO_24k
+
+/* number of bits */
+#ifndef NBBITS_7k
+#define NBBITS_7k 132
+#define NBBITS_9k 177
+#define NBBITS_12k 253
+#define NBBITS_14k 285
+#define NBBITS_16k 317
+#define NBBITS_18k 365
+#define NBBITS_20k 397
+#define NBBITS_23k 461
+#define NBBITS_24k 477
+#define NBBITS_SID 35
+#endif
+
+/* number of total bits */
+#define HEADER_SIZE 6 /* real size + 1 */
+#define T_NBBITS_7k (NBBITS_7k + HEADER_SIZE)
+#define T_NBBITS_9k (NBBITS_9k + HEADER_SIZE)
+#define T_NBBITS_12k (NBBITS_12k + HEADER_SIZE)
+#define T_NBBITS_14k (NBBITS_14k + HEADER_SIZE)
+#define T_NBBITS_16k (NBBITS_16k + HEADER_SIZE)
+#define T_NBBITS_18k (NBBITS_18k + HEADER_SIZE)
+#define T_NBBITS_20k (NBBITS_20k + HEADER_SIZE)
+#define T_NBBITS_23k (NBBITS_23k + HEADER_SIZE)
+#define T_NBBITS_24k (NBBITS_24k + HEADER_SIZE)
+#define T_NBBITS_SID (NBBITS_SID + HEADER_SIZE)
+
+#define TX_SPEECH 0
+#define TX_SID_FIRST 1
+#define TX_SID_UPDATE 2
+#define TX_NO_DATA 3
+
+#define RX_SPEECH_GOOD 0
+#define RX_SPEECH_PROBABLY_DEGRADED 1
+#define RX_SPEECH_LOST 2
+#define RX_SPEECH_BAD 3
+#define RX_SID_FIRST 4
+#define RX_SID_UPDATE 5
+#define RX_SID_BAD 6
+#define RX_NO_DATA 7
+
+/* One encoded frame (bytes) */
+/*
+ * 6 bytes are used both for mode 9 and 10.
+ * Mode 9 is used in encoder and mode 10 in IF2
+ */
+#ifdef IF2
+const UWord8 block_size[16]= {18, 23, 33, 37, 41, 47, 51, 59, 61, 6, 6, 0, 0, 0, 1, 1};
+#else
+const UWord8 block_size[16]= {18, 24, 33, 37, 41, 47, 51, 59, 61, 6, 6, 0, 0, 0, 1, 1};
+#endif
+/*
+ * tables
+ */
+
+const Word16 mode_7k[NBBITS_7k << 1] = {
+ 0, 0x1, 1, 0x8, 1, 0x4, 1, 0x2,
+ 8, 0x2, 11, 0x2, 14, 0x2, 17, 0x2,
+ 8, 0x1, 11, 0x1, 1, 0x1, 1, 0x10,
+ 6, 0x80, 6, 0x40, 6, 0x20, 6, 0x10,
+ 8, 0x10, 11, 0x10, 14, 0x10, 17, 0x10,
+ 8, 0x4, 11, 0x4, 14, 0x4, 17, 0x4,
+ 14, 0x1, 17, 0x1, 17, 0x8, 6, 0x8,
+ 6, 0x4, 11, 0x20, 17, 0x20, 1, 0x80,
+ 1, 0x20, 8, 0x20, 14, 0x20, 11, 0x8,
+ 14, 0x8, 8, 0x8, 1, 0x40, 9, 0x10,
+ 15, 0x10, 15, 0x8, 12, 0x10, 3, 0x10,
+ 3, 0x2, 3, 0x1, 9, 0x8, 12, 0x8,
+ 3, 0x20, 3, 0x8, 3, 0x4, 3, 0x40,
+ 2, 0x8, 12, 0x4, 6, 0x2, 12, 0x2,
+ 9, 0x4, 15, 0x4, 2, 0x4, 4, 0x40,
+ 4, 0x20, 4, 0x10, 4, 0x8, 4, 0x4,
+ 2, 0x2, 2, 0x1, 6, 0x1, 12, 0x1,
+ 9, 0x2, 15, 0x2, 2, 0x80, 2, 0x20,
+ 2, 0x40, 2, 0x10, 9, 0x1, 15, 0x1,
+ 4, 0x2, 4, 0x1, 5, 0x20, 5, 0x10,
+ 5, 0x4, 5, 0x8, 5, 0x2, 5, 0x1,
+ 7, 0x800, 7, 0x20, 10, 0x800, 10, 0x20,
+ 13, 0x800, 13, 0x20, 16, 0x800, 16, 0x20,
+ 7, 0x400, 10, 0x400, 13, 0x400, 16, 0x400,
+ 7, 0x10, 10, 0x10, 13, 0x10, 16, 0x10,
+ 7, 0x200, 10, 0x200, 13, 0x200, 16, 0x200,
+ 7, 0x8, 10, 0x8, 13, 0x8, 16, 0x8,
+ 7, 0x100, 10, 0x100, 13, 0x100, 16, 0x100,
+ 7, 0x4, 10, 0x4, 13, 0x4, 16, 0x4,
+ 7, 0x80, 10, 0x80, 13, 0x80, 16, 0x80,
+ 7, 0x2, 10, 0x2, 13, 0x2, 16, 0x2,
+ 7, 0x40, 10, 0x40, 13, 0x40, 16, 0x40,
+ 7, 0x1, 10, 0x1, 13, 0x1, 16, 0x1
+};
+
+const Word16 mode_9k[NBBITS_9k << 1] = {
+ 0, 0x1, 1, 0x10, 1, 0x4, 1, 0x2,
+ 1, 0x8, 1, 0x20, 8, 0x80, 8, 0x40,
+ 8, 0x20, 20, 0x80, 20, 0x40, 20, 0x20,
+ 13, 0x20, 19, 0x20, 25, 0x20, 31, 0x20,
+ 13, 0x1, 19, 0x1, 25, 0x1, 31, 0x1,
+ 13, 0x8, 19, 0x8, 25, 0x8, 31, 0x8,
+ 13, 0x4, 19, 0x4, 25, 0x4, 31, 0x4,
+ 13, 0x2, 19, 0x2, 25, 0x2, 31, 0x2,
+ 13, 0x10, 19, 0x10, 25, 0x10, 31, 0x10,
+ 8, 0x10, 20, 0x10, 8, 0x8, 1, 0x40,
+ 1, 0x80, 14, 0x10, 20, 0x8, 26, 0x10,
+ 3, 0x8, 3, 0x2, 2, 0x10, 3, 0x20,
+ 3, 0x10, 3, 0x4, 2, 0x1, 4, 0x10,
+ 2, 0x8, 2, 0x40, 2, 0x4, 4, 0x20,
+ 4, 0x40, 3, 0x1, 4, 0x8, 1, 0x1,
+ 2, 0x2, 8, 0x4, 20, 0x4, 5, 0x20,
+ 14, 0x8, 26, 0x8, 2, 0x80, 5, 0x8,
+ 2, 0x20, 14, 0x4, 26, 0x4, 8, 0x2,
+ 20, 0x2, 4, 0x2, 4, 0x4, 14, 0x2,
+ 26, 0x2, 5, 0x4, 5, 0x2, 4, 0x1,
+ 7, 0x1, 5, 0x10, 5, 0x40, 8, 0x1,
+ 20, 0x1, 6, 0x10, 5, 0x1, 6, 0x4,
+ 6, 0x8, 6, 0x2, 14, 0x1, 26, 0x1,
+ 6, 0x1, 7, 0x10, 7, 0x8, 7, 0x4,
+ 7, 0x2, 9, 0x10, 10, 0x10, 11, 0x10,
+ 12, 0x10, 15, 0x10, 16, 0x10, 17, 0x10,
+ 18, 0x10, 21, 0x10, 22, 0x10, 23, 0x10,
+ 24, 0x10, 27, 0x10, 28, 0x10, 29, 0x10,
+ 30, 0x10, 9, 0x8, 15, 0x8, 21, 0x8,
+ 27, 0x8, 10, 0x8, 16, 0x8, 22, 0x8,
+ 28, 0x8, 11, 0x8, 17, 0x8, 23, 0x8,
+ 29, 0x8, 12, 0x8, 18, 0x8, 24, 0x8,
+ 30, 0x8, 9, 0x4, 15, 0x4, 21, 0x4,
+ 27, 0x4, 10, 0x4, 16, 0x4, 22, 0x4,
+ 28, 0x4, 11, 0x4, 17, 0x4, 23, 0x4,
+ 29, 0x4, 12, 0x4, 18, 0x4, 24, 0x4,
+ 30, 0x4, 9, 0x2, 15, 0x2, 21, 0x2,
+ 27, 0x2, 10, 0x2, 16, 0x2, 22, 0x2,
+ 28, 0x2, 11, 0x2, 17, 0x2, 23, 0x2,
+ 29, 0x2, 12, 0x2, 18, 0x2, 24, 0x2,
+ 30, 0x2, 9, 0x1, 15, 0x1, 21, 0x1,
+ 27, 0x1, 10, 0x1, 16, 0x1, 22, 0x1,
+ 28, 0x1, 11, 0x1, 17, 0x1, 23, 0x1,
+ 29, 0x1, 12, 0x1, 18, 0x1, 24, 0x1,
+ 30, 0x1
+};
+
+const Word16 mode_12k[NBBITS_12k << 1] = {
+ 0, 0x1, 1, 0x10, 1, 0x4, 14, 0x40,
+ 21, 0x40, 28, 0x40, 35, 0x40, 1, 0x2,
+ 1, 0x8, 1, 0x20, 8, 0x100, 8, 0x80,
+ 8, 0x40, 8, 0x20, 8, 0x10, 22, 0x100,
+ 22, 0x80, 22, 0x40, 22, 0x20, 22, 0x10,
+ 14, 0x20, 21, 0x20, 28, 0x20, 35, 0x20,
+ 14, 0x1, 21, 0x1, 28, 0x1, 35, 0x1,
+ 14, 0x8, 21, 0x8, 28, 0x8, 35, 0x8,
+ 14, 0x4, 21, 0x4, 28, 0x4, 35, 0x4,
+ 15, 0x20, 29, 0x20, 14, 0x2, 21, 0x2,
+ 28, 0x2, 35, 0x2, 14, 0x10, 21, 0x10,
+ 28, 0x10, 35, 0x10, 8, 0x8, 1, 0x40,
+ 1, 0x80, 15, 0x10, 29, 0x10, 22, 0x8,
+ 3, 0x8, 3, 0x2, 2, 0x10, 3, 0x20,
+ 3, 0x10, 3, 0x4, 2, 0x1, 4, 0x10,
+ 2, 0x8, 2, 0x40, 2, 0x4, 4, 0x20,
+ 4, 0x40, 3, 0x1, 4, 0x8, 1, 0x1,
+ 2, 0x2, 8, 0x4, 22, 0x4, 5, 0x20,
+ 15, 0x8, 29, 0x8, 2, 0x80, 5, 0x8,
+ 2, 0x20, 15, 0x4, 29, 0x4, 8, 0x2,
+ 22, 0x2, 4, 0x2, 4, 0x4, 15, 0x2,
+ 29, 0x2, 5, 0x4, 5, 0x2, 4, 0x1,
+ 7, 0x1, 5, 0x10, 5, 0x40, 8, 0x1,
+ 22, 0x1, 6, 0x10, 5, 0x1, 6, 0x4,
+ 6, 0x8, 6, 0x2, 15, 0x1, 29, 0x1,
+ 6, 0x1, 7, 0x10, 7, 0x8, 7, 0x4,
+ 7, 0x2, 9, 0x1, 16, 0x1, 23, 0x1,
+ 30, 0x1, 10, 0x100, 11, 0x100, 12, 0x100,
+ 13, 0x100, 17, 0x100, 18, 0x100, 19, 0x100,
+ 20, 0x100, 24, 0x100, 25, 0x100, 26, 0x100,
+ 27, 0x100, 31, 0x100, 32, 0x100, 33, 0x100,
+ 34, 0x100, 10, 0x80, 17, 0x80, 24, 0x80,
+ 31, 0x80, 10, 0x8, 17, 0x8, 24, 0x8,
+ 31, 0x8, 11, 0x80, 18, 0x80, 25, 0x80,
+ 32, 0x80, 11, 0x8, 18, 0x8, 25, 0x8,
+ 32, 0x8, 12, 0x80, 19, 0x80, 26, 0x80,
+ 33, 0x80, 12, 0x8, 19, 0x8, 26, 0x8,
+ 33, 0x8, 13, 0x80, 20, 0x80, 27, 0x80,
+ 34, 0x80, 13, 0x8, 20, 0x8, 27, 0x8,
+ 34, 0x8, 10, 0x40, 17, 0x40, 24, 0x40,
+ 31, 0x40, 10, 0x4, 17, 0x4, 24, 0x4,
+ 31, 0x4, 11, 0x40, 18, 0x40, 25, 0x40,
+ 32, 0x40, 11, 0x4, 18, 0x4, 25, 0x4,
+ 32, 0x4, 12, 0x40, 19, 0x40, 26, 0x40,
+ 33, 0x40, 12, 0x4, 19, 0x4, 26, 0x4,
+ 33, 0x4, 13, 0x40, 20, 0x40, 27, 0x40,
+ 34, 0x40, 13, 0x4, 20, 0x4, 27, 0x4,
+ 34, 0x4, 10, 0x20, 17, 0x20, 24, 0x20,
+ 31, 0x20, 10, 0x2, 17, 0x2, 24, 0x2,
+ 31, 0x2, 11, 0x20, 18, 0x20, 25, 0x20,
+ 32, 0x20, 11, 0x2, 18, 0x2, 25, 0x2,
+ 32, 0x2, 12, 0x20, 19, 0x20, 26, 0x20,
+ 33, 0x20, 12, 0x2, 19, 0x2, 26, 0x2,
+ 33, 0x2, 13, 0x20, 20, 0x20, 27, 0x20,
+ 34, 0x20, 13, 0x2, 20, 0x2, 27, 0x2,
+ 34, 0x2, 10, 0x10, 17, 0x10, 24, 0x10,
+ 31, 0x10, 10, 0x1, 17, 0x1, 24, 0x1,
+ 31, 0x1, 11, 0x10, 18, 0x10, 25, 0x10,
+ 32, 0x10, 11, 0x1, 18, 0x1, 25, 0x1,
+ 32, 0x1, 12, 0x10, 19, 0x10, 26, 0x10,
+ 33, 0x10, 12, 0x1, 19, 0x1, 26, 0x1,
+ 33, 0x1, 13, 0x10, 20, 0x10, 27, 0x10,
+ 34, 0x10, 13, 0x1, 20, 0x1, 27, 0x1,
+ 34, 0x1
+};
+
+const Word16 mode_14k[NBBITS_14k << 1] = {
+ 0, 0x1, 1, 0x10, 1, 0x4, 14, 0x40,
+ 21, 0x40, 28, 0x40, 35, 0x40, 1, 0x2,
+ 1, 0x8, 1, 0x20, 8, 0x100, 8, 0x80,
+ 8, 0x40, 8, 0x20, 8, 0x10, 22, 0x100,
+ 22, 0x80, 22, 0x40, 22, 0x20, 22, 0x10,
+ 14, 0x20, 21, 0x20, 28, 0x20, 35, 0x20,
+ 14, 0x1, 21, 0x1, 28, 0x1, 35, 0x1,
+ 14, 0x8, 21, 0x8, 28, 0x8, 35, 0x8,
+ 14, 0x4, 21, 0x4, 28, 0x4, 35, 0x4,
+ 15, 0x20, 29, 0x20, 14, 0x2, 21, 0x2,
+ 28, 0x2, 35, 0x2, 14, 0x10, 21, 0x10,
+ 28, 0x10, 35, 0x10, 8, 0x8, 1, 0x40,
+ 1, 0x80, 15, 0x10, 29, 0x10, 22, 0x8,
+ 3, 0x8, 3, 0x2, 2, 0x10, 3, 0x20,
+ 3, 0x10, 3, 0x4, 2, 0x1, 4, 0x10,
+ 2, 0x8, 2, 0x40, 2, 0x4, 4, 0x20,
+ 4, 0x40, 3, 0x1, 4, 0x8, 1, 0x1,
+ 2, 0x2, 8, 0x4, 22, 0x4, 5, 0x20,
+ 15, 0x8, 29, 0x8, 2, 0x80, 5, 0x8,
+ 2, 0x20, 15, 0x4, 29, 0x4, 8, 0x2,
+ 22, 0x2, 4, 0x2, 4, 0x4, 15, 0x2,
+ 29, 0x2, 5, 0x4, 5, 0x2, 4, 0x1,
+ 7, 0x1, 5, 0x10, 5, 0x40, 8, 0x1,
+ 22, 0x1, 6, 0x10, 5, 0x1, 6, 0x4,
+ 6, 0x8, 6, 0x2, 15, 0x1, 29, 0x1,
+ 6, 0x1, 7, 0x10, 7, 0x8, 7, 0x4,
+ 7, 0x2, 9, 0x1, 16, 0x1, 23, 0x1,
+ 30, 0x1, 10, 0x80, 17, 0x80, 24, 0x80,
+ 31, 0x80, 11, 0x80, 18, 0x80, 25, 0x80,
+ 32, 0x80, 10, 0x1000, 17, 0x1000, 24, 0x1000,
+ 31, 0x1000, 10, 0x40, 17, 0x40, 24, 0x40,
+ 31, 0x40, 11, 0x1000, 18, 0x1000, 25, 0x1000,
+ 32, 0x1000, 11, 0x40, 18, 0x40, 25, 0x40,
+ 32, 0x40, 12, 0x100, 19, 0x100, 26, 0x100,
+ 33, 0x100, 13, 0x100, 20, 0x100, 27, 0x100,
+ 34, 0x100, 12, 0x80, 19, 0x80, 26, 0x80,
+ 33, 0x80, 13, 0x80, 20, 0x80, 27, 0x80,
+ 34, 0x80, 12, 0x40, 19, 0x40, 26, 0x40,
+ 33, 0x40, 13, 0x40, 20, 0x40, 27, 0x40,
+ 34, 0x40, 12, 0x20, 19, 0x20, 26, 0x20,
+ 33, 0x20, 13, 0x20, 20, 0x20, 27, 0x20,
+ 34, 0x20, 10, 0x20, 17, 0x20, 24, 0x20,
+ 31, 0x20, 11, 0x20, 18, 0x20, 25, 0x20,
+ 32, 0x20, 10, 0x10, 17, 0x10, 24, 0x10,
+ 31, 0x10, 11, 0x10, 18, 0x10, 25, 0x10,
+ 32, 0x10, 12, 0x10, 19, 0x10, 26, 0x10,
+ 33, 0x10, 13, 0x10, 20, 0x10, 27, 0x10,
+ 34, 0x10, 10, 0x800, 17, 0x800, 24, 0x800,
+ 31, 0x800, 10, 0x8, 17, 0x8, 24, 0x8,
+ 31, 0x8, 11, 0x800, 18, 0x800, 25, 0x800,
+ 32, 0x800, 11, 0x8, 18, 0x8, 25, 0x8,
+ 32, 0x8, 12, 0x8, 19, 0x8, 26, 0x8,
+ 33, 0x8, 13, 0x8, 20, 0x8, 27, 0x8,
+ 34, 0x8, 10, 0x400, 17, 0x400, 24, 0x400,
+ 31, 0x400, 10, 0x4, 17, 0x4, 24, 0x4,
+ 31, 0x4, 11, 0x400, 18, 0x400, 25, 0x400,
+ 32, 0x400, 11, 0x4, 18, 0x4, 25, 0x4,
+ 32, 0x4, 12, 0x4, 19, 0x4, 26, 0x4,
+ 33, 0x4, 13, 0x4, 20, 0x4, 27, 0x4,
+ 34, 0x4, 10, 0x200, 17, 0x200, 24, 0x200,
+ 31, 0x200, 10, 0x2, 17, 0x2, 24, 0x2,
+ 31, 0x2, 11, 0x200, 18, 0x200, 25, 0x200,
+ 32, 0x200, 11, 0x2, 18, 0x2, 25, 0x2,
+ 32, 0x2, 12, 0x2, 19, 0x2, 26, 0x2,
+ 33, 0x2, 13, 0x2, 20, 0x2, 27, 0x2,
+ 34, 0x2, 10, 0x100, 17, 0x100, 24, 0x100,
+ 31, 0x100, 10, 0x1, 17, 0x1, 24, 0x1,
+ 31, 0x1, 11, 0x100, 18, 0x100, 25, 0x100,
+ 32, 0x100, 11, 0x1, 18, 0x1, 25, 0x1,
+ 32, 0x1, 12, 0x1, 19, 0x1, 26, 0x1,
+ 33, 0x1, 13, 0x1, 20, 0x1, 27, 0x1,
+ 34, 0x1
+};
+
+const Word16 mode_16k[NBBITS_16k << 1] = {
+ 0, 0x1, 1, 0x10, 1, 0x4, 14, 0x40,
+ 21, 0x40, 28, 0x40, 35, 0x40, 1, 0x2,
+ 1, 0x8, 1, 0x20, 8, 0x100, 8, 0x80,
+ 8, 0x40, 8, 0x20, 8, 0x10, 22, 0x100,
+ 22, 0x80, 22, 0x40, 22, 0x20, 22, 0x10,
+ 14, 0x20, 21, 0x20, 28, 0x20, 35, 0x20,
+ 14, 0x1, 21, 0x1, 28, 0x1, 35, 0x1,
+ 14, 0x8, 21, 0x8, 28, 0x8, 35, 0x8,
+ 14, 0x4, 21, 0x4, 28, 0x4, 35, 0x4,
+ 15, 0x20, 29, 0x20, 14, 0x2, 21, 0x2,
+ 28, 0x2, 35, 0x2, 14, 0x10, 21, 0x10,
+ 28, 0x10, 35, 0x10, 8, 0x8, 1, 0x40,
+ 1, 0x80, 15, 0x10, 29, 0x10, 22, 0x8,
+ 3, 0x8, 3, 0x2, 2, 0x10, 3, 0x20,
+ 3, 0x10, 3, 0x4, 2, 0x1, 4, 0x10,
+ 2, 0x8, 2, 0x40, 2, 0x4, 4, 0x20,
+ 4, 0x40, 3, 0x1, 4, 0x8, 1, 0x1,
+ 2, 0x2, 8, 0x4, 22, 0x4, 5, 0x20,
+ 15, 0x8, 29, 0x8, 2, 0x80, 5, 0x8,
+ 2, 0x20, 15, 0x4, 29, 0x4, 8, 0x2,
+ 22, 0x2, 4, 0x2, 4, 0x4, 15, 0x2,
+ 29, 0x2, 5, 0x4, 5, 0x2, 4, 0x1,
+ 7, 0x1, 5, 0x10, 5, 0x40, 8, 0x1,
+ 22, 0x1, 6, 0x10, 5, 0x1, 6, 0x4,
+ 6, 0x8, 6, 0x2, 15, 0x1, 29, 0x1,
+ 6, 0x1, 7, 0x10, 7, 0x8, 7, 0x4,
+ 7, 0x2, 9, 0x1, 16, 0x1, 23, 0x1,
+ 30, 0x1, 10, 0x40, 17, 0x40, 24, 0x40,
+ 31, 0x40, 11, 0x40, 18, 0x40, 25, 0x40,
+ 32, 0x40, 12, 0x40, 19, 0x40, 26, 0x40,
+ 33, 0x40, 13, 0x40, 20, 0x40, 27, 0x40,
+ 34, 0x40, 10, 0x1000, 17, 0x1000, 24, 0x1000,
+ 31, 0x1000, 11, 0x1000, 18, 0x1000, 25, 0x1000,
+ 32, 0x1000, 12, 0x1000, 19, 0x1000, 26, 0x1000,
+ 33, 0x1000, 13, 0x1000, 20, 0x1000, 27, 0x1000,
+ 34, 0x1000, 10, 0x80, 17, 0x80, 24, 0x80,
+ 31, 0x80, 11, 0x80, 18, 0x80, 25, 0x80,
+ 32, 0x80, 12, 0x80, 19, 0x80, 26, 0x80,
+ 33, 0x80, 13, 0x80, 20, 0x80, 27, 0x80,
+ 34, 0x80, 10, 0x800, 17, 0x800, 24, 0x800,
+ 31, 0x800, 11, 0x800, 18, 0x800, 25, 0x800,
+ 32, 0x800, 12, 0x800, 19, 0x800, 26, 0x800,
+ 33, 0x800, 13, 0x800, 20, 0x800, 27, 0x800,
+ 34, 0x800, 10, 0x400, 17, 0x400, 24, 0x400,
+ 31, 0x400, 10, 0x20, 17, 0x20, 24, 0x20,
+ 31, 0x20, 10, 0x4, 17, 0x4, 24, 0x4,
+ 31, 0x4, 11, 0x400, 18, 0x400, 25, 0x400,
+ 32, 0x400, 11, 0x20, 18, 0x20, 25, 0x20,
+ 32, 0x20, 11, 0x4, 18, 0x4, 25, 0x4,
+ 32, 0x4, 12, 0x400, 19, 0x400, 26, 0x400,
+ 33, 0x400, 12, 0x20, 19, 0x20, 26, 0x20,
+ 33, 0x20, 12, 0x4, 19, 0x4, 26, 0x4,
+ 33, 0x4, 13, 0x400, 20, 0x400, 27, 0x400,
+ 34, 0x400, 13, 0x20, 20, 0x20, 27, 0x20,
+ 34, 0x20, 13, 0x4, 20, 0x4, 27, 0x4,
+ 34, 0x4, 10, 0x200, 17, 0x200, 24, 0x200,
+ 31, 0x200, 10, 0x10, 17, 0x10, 24, 0x10,
+ 31, 0x10, 10, 0x2, 17, 0x2, 24, 0x2,
+ 31, 0x2, 11, 0x200, 18, 0x200, 25, 0x200,
+ 32, 0x200, 11, 0x10, 18, 0x10, 25, 0x10,
+ 32, 0x10, 11, 0x2, 18, 0x2, 25, 0x2,
+ 32, 0x2, 12, 0x200, 19, 0x200, 26, 0x200,
+ 33, 0x200, 12, 0x10, 19, 0x10, 26, 0x10,
+ 33, 0x10, 12, 0x2, 19, 0x2, 26, 0x2,
+ 33, 0x2, 13, 0x200, 20, 0x200, 27, 0x200,
+ 34, 0x200, 13, 0x10, 20, 0x10, 27, 0x10,
+ 34, 0x10, 13, 0x2, 20, 0x2, 27, 0x2,
+ 34, 0x2, 10, 0x100, 17, 0x100, 24, 0x100,
+ 31, 0x100, 10, 0x8, 17, 0x8, 24, 0x8,
+ 31, 0x8, 10, 0x1, 17, 0x1, 24, 0x1,
+ 31, 0x1, 11, 0x100, 18, 0x100, 25, 0x100,
+ 32, 0x100, 11, 0x8, 18, 0x8, 25, 0x8,
+ 32, 0x8, 11, 0x1, 18, 0x1, 25, 0x1,
+ 32, 0x1, 12, 0x100, 19, 0x100, 26, 0x100,
+ 33, 0x100, 12, 0x8, 19, 0x8, 26, 0x8,
+ 33, 0x8, 12, 0x1, 19, 0x1, 26, 0x1,
+ 33, 0x1, 13, 0x100, 20, 0x100, 27, 0x100,
+ 34, 0x100, 13, 0x8, 20, 0x8, 27, 0x8,
+ 34, 0x8, 13, 0x1, 20, 0x1, 27, 0x1,
+ 34, 0x1
+};
+
+const Word16 mode_18k[NBBITS_18k << 1] = {
+ 0, 0x1, 1, 0x10, 1, 0x4, 18, 0x40,
+ 29, 0x40, 40, 0x40, 51, 0x40, 1, 0x2,
+ 1, 0x8, 1, 0x20, 8, 0x100, 8, 0x80,
+ 8, 0x40, 8, 0x20, 8, 0x10, 30, 0x100,
+ 30, 0x80, 30, 0x40, 30, 0x20, 30, 0x10,
+ 18, 0x20, 29, 0x20, 40, 0x20, 51, 0x20,
+ 18, 0x1, 29, 0x1, 40, 0x1, 51, 0x1,
+ 18, 0x8, 29, 0x8, 40, 0x8, 51, 0x8,
+ 18, 0x4, 29, 0x4, 40, 0x4, 51, 0x4,
+ 19, 0x20, 41, 0x20, 18, 0x2, 29, 0x2,
+ 40, 0x2, 51, 0x2, 18, 0x10, 29, 0x10,
+ 40, 0x10, 51, 0x10, 8, 0x8, 1, 0x40,
+ 1, 0x80, 19, 0x10, 41, 0x10, 30, 0x8,
+ 3, 0x8, 3, 0x2, 2, 0x10, 3, 0x20,
+ 3, 0x10, 3, 0x4, 2, 0x1, 4, 0x10,
+ 2, 0x8, 2, 0x40, 2, 0x4, 4, 0x20,
+ 4, 0x40, 3, 0x1, 4, 0x8, 1, 0x1,
+ 2, 0x2, 8, 0x4, 30, 0x4, 5, 0x20,
+ 19, 0x8, 41, 0x8, 2, 0x80, 5, 0x8,
+ 2, 0x20, 19, 0x4, 41, 0x4, 8, 0x2,
+ 30, 0x2, 4, 0x2, 4, 0x4, 19, 0x2,
+ 41, 0x2, 5, 0x4, 5, 0x2, 4, 0x1,
+ 7, 0x1, 5, 0x10, 5, 0x40, 8, 0x1,
+ 30, 0x1, 6, 0x10, 5, 0x1, 6, 0x4,
+ 6, 0x8, 6, 0x2, 19, 0x1, 41, 0x1,
+ 6, 0x1, 7, 0x10, 7, 0x8, 7, 0x4,
+ 7, 0x2, 9, 0x1, 20, 0x1, 31, 0x1,
+ 42, 0x1, 28, 0x1, 45, 0x1, 21, 0x1,
+ 17, 0x1, 22, 0x1, 11, 0x1, 39, 0x1,
+ 10, 0x1, 12, 0x1, 50, 0x1, 23, 0x2,
+ 23, 0x1, 43, 0x1, 25, 0x1, 10, 0x2,
+ 33, 0x1, 44, 0x1, 13, 0x2, 32, 0x1,
+ 22, 0x2, 26, 0x1, 46, 0x2, 35, 0x2,
+ 13, 0x1, 16, 0x1, 12, 0x2, 14, 0x1,
+ 43, 0x2, 15, 0x1, 24, 0x1, 24, 0x2,
+ 21, 0x2, 34, 0x1, 44, 0x2, 46, 0x1,
+ 49, 0x1, 11, 0x2, 45, 0x2, 27, 0x1,
+ 48, 0x1, 47, 0x1, 34, 0x2, 32, 0x2,
+ 38, 0x1, 37, 0x1, 33, 0x2, 36, 0x1,
+ 50, 0x20, 35, 0x1, 26, 0x2000, 15, 0x40,
+ 27, 0x2000, 15, 0x20, 26, 0x40, 50, 0x40,
+ 17, 0x200, 47, 0x2000, 14, 0x2000, 27, 0x40,
+ 17, 0x20, 48, 0x40, 14, 0x40, 28, 0x40,
+ 16, 0x20, 27, 0x20, 16, 0x2000, 14, 0x20,
+ 28, 0x20, 25, 0x20, 49, 0x40, 47, 0x40,
+ 25, 0x2000, 39, 0x20, 14, 0x200, 48, 0x20,
+ 26, 0x20, 25, 0x40, 16, 0x200, 49, 0x20,
+ 17, 0x400, 47, 0x20, 49, 0x2000, 39, 0x40,
+ 14, 0x400, 17, 0x2000, 27, 0x200, 37, 0x40,
+ 17, 0x40, 15, 0x2000, 17, 0x80, 28, 0x200,
+ 37, 0x20, 38, 0x40, 27, 0x400, 14, 0x80,
+ 28, 0x2000, 16, 0x400, 50, 0x2000, 16, 0x40,
+ 48, 0x80, 15, 0x200, 49, 0x200, 48, 0x2000,
+ 49, 0x400, 38, 0x2000, 26, 0x200, 50, 0x200,
+ 25, 0x200, 15, 0x400, 39, 0x400, 36, 0x20,
+ 38, 0x20, 47, 0x80, 50, 0x10, 50, 0x400,
+ 26, 0x80, 36, 0x40, 47, 0x200, 48, 0x200,
+ 28, 0x400, 39, 0x200, 25, 0x400, 27, 0x80,
+ 39, 0x2000, 50, 0x80, 38, 0x200, 15, 0x80,
+ 25, 0x80, 17, 0x10, 28, 0x80, 26, 0x400,
+ 37, 0x2000, 38, 0x80, 49, 0x80, 47, 0x400,
+ 38, 0x400, 15, 0x10, 36, 0x2000, 16, 0x80,
+ 49, 0x10, 36, 0x80, 36, 0x200, 36, 0x400,
+ 39, 0x80, 37, 0x200, 37, 0x400, 48, 0x400,
+ 36, 0x10, 47, 0x10, 16, 0x10, 14, 0x10,
+ 27, 0x10, 39, 0x10, 14, 0x1000, 28, 0x10,
+ 25, 0x10, 48, 0x10, 27, 0x1000, 37, 0x10,
+ 37, 0x80, 38, 0x10, 17, 0x8, 26, 0x1000,
+ 26, 0x10, 50, 0x8, 14, 0x8, 25, 0x1000,
+ 17, 0x1000, 47, 0x8, 16, 0x1000, 28, 0x1000,
+ 47, 0x1000, 15, 0x1000, 36, 0x8, 15, 0x8,
+ 28, 0x8, 17, 0x100, 49, 0x8, 27, 0x8,
+ 50, 0x1000, 48, 0x1000, 48, 0x8, 39, 0x8,
+ 37, 0x1000, 26, 0x8, 17, 0x4, 47, 0x4,
+ 14, 0x100, 50, 0x4, 48, 0x4, 38, 0x1000,
+ 28, 0x100, 27, 0x100, 39, 0x100, 16, 0x4,
+ 16, 0x100, 25, 0x8, 16, 0x8, 15, 0x4,
+ 14, 0x4, 39, 0x1000, 39, 0x4, 37, 0x8,
+ 36, 0x1000, 38, 0x8, 27, 0x4, 15, 0x100,
+ 25, 0x4, 36, 0x4, 49, 0x100, 26, 0x4,
+ 49, 0x1000, 28, 0x4, 49, 0x4, 37, 0x4,
+ 26, 0x100, 47, 0x100, 25, 0x100, 50, 0x100,
+ 38, 0x4, 48, 0x100, 38, 0x100, 37, 0x100,
+ 36, 0x100, 50, 0x2, 26, 0x800, 17, 0x2,
+ 14, 0x800, 28, 0x800, 27, 0x800, 25, 0x800,
+ 37, 0x800, 14, 0x2, 47, 0x800, 49, 0x800,
+ 47, 0x2, 49, 0x2, 17, 0x800, 38, 0x800,
+ 15, 0x800, 39, 0x2, 16, 0x2, 15, 0x2,
+ 50, 0x800, 48, 0x800, 27, 0x2, 37, 0x2,
+ 28, 0x2, 48, 0x2, 16, 0x800, 25, 0x2,
+ 26, 0x2, 39, 0x800, 36, 0x800, 36, 0x2,
+ 38, 0x2
+};
+
+const Word16 mode_20k[NBBITS_20k << 1] = {
+ 0, 0x1, 1, 0x10, 1, 0x4, 18, 0x40,
+ 29, 0x40, 40, 0x40, 51, 0x40, 1, 0x2,
+ 1, 0x8, 1, 0x20, 8, 0x100, 8, 0x80,
+ 8, 0x40, 8, 0x20, 8, 0x10, 30, 0x100,
+ 30, 0x80, 30, 0x40, 30, 0x20, 30, 0x10,
+ 18, 0x20, 29, 0x20, 40, 0x20, 51, 0x20,
+ 18, 0x1, 29, 0x1, 40, 0x1, 51, 0x1,
+ 18, 0x8, 29, 0x8, 40, 0x8, 51, 0x8,
+ 18, 0x4, 29, 0x4, 40, 0x4, 51, 0x4,
+ 19, 0x20, 41, 0x20, 18, 0x2, 29, 0x2,
+ 40, 0x2, 51, 0x2, 18, 0x10, 29, 0x10,
+ 40, 0x10, 51, 0x10, 8, 0x8, 1, 0x40,
+ 1, 0x80, 19, 0x10, 41, 0x10, 30, 0x8,
+ 3, 0x8, 3, 0x2, 2, 0x10, 3, 0x20,
+ 3, 0x10, 3, 0x4, 2, 0x1, 4, 0x10,
+ 2, 0x8, 2, 0x40, 2, 0x4, 4, 0x20,
+ 4, 0x40, 3, 0x1, 4, 0x8, 1, 0x1,
+ 2, 0x2, 8, 0x4, 30, 0x4, 5, 0x20,
+ 19, 0x8, 41, 0x8, 2, 0x80, 5, 0x8,
+ 2, 0x20, 19, 0x4, 41, 0x4, 8, 0x2,
+ 30, 0x2, 4, 0x2, 4, 0x4, 19, 0x2,
+ 41, 0x2, 5, 0x4, 5, 0x2, 4, 0x1,
+ 7, 0x1, 5, 0x10, 5, 0x40, 8, 0x1,
+ 30, 0x1, 6, 0x10, 5, 0x1, 6, 0x4,
+ 6, 0x8, 6, 0x2, 19, 0x1, 41, 0x1,
+ 6, 0x1, 7, 0x10, 7, 0x8, 7, 0x4,
+ 7, 0x2, 9, 0x1, 20, 0x1, 31, 0x1,
+ 42, 0x1, 10, 0x8, 11, 0x8, 15, 0x100,
+ 46, 0x2, 14, 0x100, 43, 0x8, 21, 0x8,
+ 48, 0x100, 22, 0x8, 44, 0x8, 24, 0x2,
+ 45, 0x2, 26, 0x100, 23, 0x2, 35, 0x2,
+ 12, 0x2, 25, 0x100, 36, 0x100, 22, 0x200,
+ 47, 0x100, 10, 0x200, 33, 0x8, 32, 0x8,
+ 13, 0x2, 34, 0x2, 24, 0x1, 11, 0x200,
+ 13, 0x1, 28, 0x2000, 16, 0x2000, 37, 0x100,
+ 21, 0x200, 23, 0x1, 46, 0x1, 35, 0x1,
+ 45, 0x1, 27, 0x2000, 50, 0x2000, 43, 0x200,
+ 12, 0x1, 44, 0x200, 49, 0x2000, 17, 0x2000,
+ 32, 0x200, 33, 0x200, 34, 0x1, 39, 0x2000,
+ 38, 0x2000, 10, 0x10, 10, 0x100, 22, 0x10,
+ 11, 0x100, 15, 0x80, 26, 0x80, 43, 0x100,
+ 21, 0x10, 25, 0x80, 22, 0x100, 11, 0x10,
+ 50, 0x10, 44, 0x100, 44, 0x10, 47, 0x80,
+ 16, 0x1000, 14, 0x80, 21, 0x100, 32, 0x100,
+ 43, 0x10, 17, 0x10, 33, 0x100, 27, 0x100,
+ 48, 0x80, 32, 0x10, 10, 0x4, 33, 0x10,
+ 28, 0x1000, 28, 0x20, 21, 0x4, 17, 0x1000,
+ 44, 0x4, 37, 0x80, 32, 0x4, 39, 0x10,
+ 27, 0x1000, 27, 0x10, 39, 0x20, 15, 0x40,
+ 27, 0x20, 36, 0x80, 17, 0x20, 49, 0x1000,
+ 50, 0x20, 16, 0x20, 43, 0x4, 49, 0x10,
+ 25, 0x40, 49, 0x20, 14, 0x40, 16, 0x10,
+ 39, 0x100, 26, 0x40, 11, 0x4, 28, 0x10,
+ 27, 0x200, 16, 0x100, 39, 0x1000, 28, 0x200,
+ 49, 0x100, 50, 0x100, 50, 0x1000, 28, 0x100,
+ 48, 0x40, 17, 0x40, 17, 0x200, 17, 0x100,
+ 50, 0x40, 22, 0x4, 16, 0x200, 16, 0x40,
+ 38, 0x1000, 50, 0x200, 39, 0x200, 38, 0x20,
+ 38, 0x10, 47, 0x40, 28, 0x40, 37, 0x40,
+ 33, 0x4, 49, 0x200, 50, 0x8, 39, 0x8,
+ 39, 0x40, 36, 0x40, 17, 0x8, 49, 0x40,
+ 27, 0x8, 15, 0x8, 27, 0x40, 38, 0x8,
+ 28, 0x8, 38, 0x100, 38, 0x200, 26, 0x8,
+ 49, 0x8, 14, 0x8, 22, 0x80, 38, 0x40,
+ 10, 0x80, 47, 0x8, 43, 0x1, 26, 0x4,
+ 11, 0x1, 16, 0x8, 44, 0x80, 28, 0x800,
+ 47, 0x4, 11, 0x80, 15, 0x4, 21, 0x1,
+ 21, 0x80, 27, 0x800, 10, 0x1, 43, 0x80,
+ 44, 0x1, 25, 0x8, 48, 0x8, 33, 0x1,
+ 27, 0x4, 25, 0x4, 36, 0x4, 36, 0x8,
+ 17, 0x4, 32, 0x1, 27, 0x80, 14, 0x4,
+ 50, 0x2, 17, 0x800, 15, 0x20, 50, 0x4,
+ 16, 0x4, 48, 0x4, 38, 0x4, 33, 0x80,
+ 16, 0x800, 37, 0x8, 39, 0x4, 25, 0x20,
+ 22, 0x1, 32, 0x80, 37, 0x4, 17, 0x2,
+ 49, 0x4, 26, 0x20, 39, 0x800, 14, 0x20,
+ 50, 0x800, 39, 0x2, 17, 0x80, 16, 0x80,
+ 49, 0x800, 47, 0x20, 48, 0x20, 28, 0x4,
+ 38, 0x800, 28, 0x2, 10, 0x2, 50, 0x80,
+ 38, 0x2, 28, 0x80, 16, 0x2, 25, 0x2,
+ 15, 0x2, 39, 0x80, 49, 0x2, 49, 0x80,
+ 27, 0x2, 36, 0x20, 26, 0x2, 44, 0x2,
+ 44, 0x40, 22, 0x2, 37, 0x20, 36, 0x2,
+ 33, 0x2, 32, 0x2, 11, 0x2, 47, 0x2,
+ 21, 0x2, 10, 0x40, 14, 0x2, 43, 0x40,
+ 22, 0x40, 37, 0x2, 48, 0x2, 43, 0x2,
+ 11, 0x40, 38, 0x80, 25, 0x200, 21, 0x40,
+ 48, 0x200, 14, 0x200, 15, 0x200, 50, 0x1,
+ 37, 0x200, 33, 0x40, 26, 0x200, 32, 0x40,
+ 27, 0x400, 36, 0x200, 28, 0x400, 47, 0x200,
+ 17, 0x1, 17, 0x400, 39, 0x1, 16, 0x400,
+ 50, 0x400, 26, 0x10, 16, 0x1, 49, 0x1,
+ 27, 0x1, 15, 0x10, 39, 0x400, 25, 0x10,
+ 28, 0x1, 49, 0x400, 38, 0x400, 14, 0x10,
+ 38, 0x1, 47, 0x1, 47, 0x10, 48, 0x10,
+ 36, 0x10, 26, 0x1, 25, 0x1, 37, 0x10,
+ 14, 0x1, 15, 0x1, 21, 0x20, 43, 0x20,
+ 37, 0x1, 48, 0x1, 11, 0x20, 44, 0x20,
+ 10, 0x20, 36, 0x1, 22, 0x20, 33, 0x20,
+ 32, 0x20
+};
+
+const Word16 mode_23k[NBBITS_23k << 1] = {
+ 0, 0x1, 1, 0x10, 1, 0x4, 18, 0x40,
+ 29, 0x40, 40, 0x40, 51, 0x40, 1, 0x2,
+ 1, 0x8, 1, 0x20, 8, 0x100, 8, 0x80,
+ 8, 0x40, 8, 0x20, 8, 0x10, 30, 0x100,
+ 30, 0x80, 30, 0x40, 30, 0x20, 30, 0x10,
+ 18, 0x20, 29, 0x20, 40, 0x20, 51, 0x20,
+ 18, 0x1, 29, 0x1, 40, 0x1, 51, 0x1,
+ 18, 0x8, 29, 0x8, 40, 0x8, 51, 0x8,
+ 18, 0x4, 29, 0x4, 40, 0x4, 51, 0x4,
+ 19, 0x20, 41, 0x20, 18, 0x2, 29, 0x2,
+ 40, 0x2, 51, 0x2, 18, 0x10, 29, 0x10,
+ 40, 0x10, 51, 0x10, 8, 0x8, 1, 0x40,
+ 1, 0x80, 19, 0x10, 41, 0x10, 30, 0x8,
+ 3, 0x8, 3, 0x2, 2, 0x10, 3, 0x20,
+ 3, 0x10, 3, 0x4, 2, 0x1, 4, 0x10,
+ 2, 0x8, 2, 0x40, 2, 0x4, 4, 0x20,
+ 4, 0x40, 3, 0x1, 4, 0x8, 1, 0x1,
+ 2, 0x2, 8, 0x4, 30, 0x4, 5, 0x20,
+ 19, 0x8, 41, 0x8, 2, 0x80, 5, 0x8,
+ 2, 0x20, 19, 0x4, 41, 0x4, 8, 0x2,
+ 30, 0x2, 4, 0x2, 4, 0x4, 19, 0x2,
+ 41, 0x2, 5, 0x4, 5, 0x2, 4, 0x1,
+ 7, 0x1, 5, 0x10, 5, 0x40, 8, 0x1,
+ 30, 0x1, 6, 0x10, 5, 0x1, 6, 0x4,
+ 6, 0x8, 6, 0x2, 19, 0x1, 41, 0x1,
+ 6, 0x1, 7, 0x10, 7, 0x8, 7, 0x4,
+ 7, 0x2, 9, 0x1, 20, 0x1, 31, 0x1,
+ 42, 0x1, 23, 0x400, 24, 0x400, 22, 0x400,
+ 12, 0x400, 10, 0x400, 46, 0x400, 13, 0x400,
+ 21, 0x400, 35, 0x400, 44, 0x400, 43, 0x400,
+ 33, 0x400, 11, 0x400, 23, 0x100, 45, 0x400,
+ 34, 0x400, 24, 0x100, 35, 0x100, 13, 0x100,
+ 11, 0x100, 23, 0x200, 46, 0x100, 22, 0x100,
+ 10, 0x100, 13, 0x200, 10, 0x200, 46, 0x200,
+ 43, 0x100, 21, 0x100, 12, 0x100, 21, 0x200,
+ 32, 0x400, 22, 0x200, 12, 0x200, 45, 0x200,
+ 45, 0x100, 44, 0x200, 44, 0x100, 24, 0x200,
+ 35, 0x200, 11, 0x200, 32, 0x100, 32, 0x200,
+ 43, 0x200, 33, 0x100, 34, 0x100, 33, 0x200,
+ 34, 0x200, 23, 0x80, 10, 0x80, 24, 0x80,
+ 12, 0x80, 13, 0x80, 11, 0x80, 43, 0x80,
+ 46, 0x80, 22, 0x80, 21, 0x80, 50, 0x200,
+ 35, 0x80, 45, 0x80, 13, 0x4, 11, 0x4,
+ 33, 0x80, 10, 0x40, 32, 0x80, 43, 0x4,
+ 17, 0x200, 47, 0x200, 21, 0x4, 14, 0x200,
+ 44, 0x80, 24, 0x4, 12, 0x4, 22, 0x4,
+ 10, 0x4, 13, 0x40, 25, 0x200, 16, 0x200,
+ 11, 0x40, 39, 0x200, 23, 0x4, 35, 0x4,
+ 44, 0x40, 45, 0x4, 49, 0x200, 35, 0x40,
+ 27, 0x200, 46, 0x4, 34, 0x80, 28, 0x200,
+ 15, 0x200, 26, 0x200, 23, 0x40, 16, 0x20,
+ 36, 0x200, 46, 0x40, 15, 0x40, 37, 0x200,
+ 24, 0x40, 38, 0x200, 43, 0x40, 48, 0x200,
+ 22, 0x40, 10, 0x8, 45, 0x40, 12, 0x40,
+ 48, 0x40, 26, 0x20, 17, 0x400, 23, 0x8,
+ 49, 0x400, 15, 0x400, 48, 0x10, 17, 0x20,
+ 33, 0x40, 21, 0x40, 49, 0x40, 25, 0x20,
+ 50, 0x40, 26, 0x40, 28, 0x400, 27, 0x40,
+ 13, 0x8, 34, 0x4, 44, 0x4, 27, 0x20,
+ 21, 0x8, 32, 0x40, 22, 0x8, 50, 0x400,
+ 27, 0x400, 48, 0x20, 14, 0x400, 32, 0x4,
+ 17, 0x40, 16, 0x40, 34, 0x40, 15, 0x20,
+ 39, 0x10, 24, 0x8, 47, 0x40, 13, 0x20,
+ 17, 0x10, 28, 0x40, 47, 0x400, 45, 0x8,
+ 25, 0x10, 16, 0x10, 33, 0x4, 39, 0x20,
+ 14, 0x40, 28, 0x20, 49, 0x20, 12, 0x8,
+ 36, 0x400, 50, 0x20, 25, 0x400, 39, 0x40,
+ 23, 0x20, 14, 0x10, 26, 0x10, 47, 0x20,
+ 38, 0x40, 37, 0x400, 14, 0x20, 36, 0x20,
+ 15, 0x10, 16, 0x400, 11, 0x20, 25, 0x40,
+ 48, 0x400, 26, 0x400, 44, 0x8, 43, 0x8,
+ 49, 0x10, 10, 0x20, 43, 0x20, 39, 0x400,
+ 11, 0x8, 50, 0x10, 21, 0x2, 37, 0x40,
+ 21, 0x20, 28, 0x10, 47, 0x10, 37, 0x20,
+ 35, 0x8, 24, 0x20, 38, 0x20, 46, 0x20,
+ 32, 0x8, 10, 0x10, 23, 0x1, 37, 0x10,
+ 13, 0x10, 21, 0x1, 27, 0x10, 33, 0x20,
+ 36, 0x40, 23, 0x10, 46, 0x8, 12, 0x20,
+ 24, 0x2, 13, 0x1, 10, 0x1, 44, 0x20,
+ 22, 0x20, 38, 0x10, 24, 0x1, 38, 0x400,
+ 32, 0x20, 45, 0x20, 43, 0x1, 44, 0x10,
+ 34, 0x8, 35, 0x1, 46, 0x1, 22, 0x2,
+ 33, 0x1, 36, 0x10, 35, 0x20, 43, 0x10,
+ 45, 0x1, 23, 0x2, 22, 0x1, 12, 0x1,
+ 13, 0x2, 14, 0x100, 27, 0x8, 11, 0x1,
+ 12, 0x2, 11, 0x2, 17, 0x100, 44, 0x1,
+ 21, 0x10, 24, 0x10, 45, 0x10, 16, 0x100,
+ 22, 0x10, 48, 0x8, 11, 0x10, 43, 0x2,
+ 28, 0x100, 27, 0x100, 10, 0x2, 32, 0x2,
+ 33, 0x8, 17, 0x8, 35, 0x2, 47, 0x100,
+ 15, 0x100, 12, 0x10, 16, 0x8, 39, 0x8,
+ 15, 0x8, 34, 0x20, 34, 0x1, 44, 0x2,
+ 27, 0x4, 45, 0x2, 35, 0x10, 46, 0x10,
+ 33, 0x2, 50, 0x100, 48, 0x100, 26, 0x8,
+ 25, 0x8, 25, 0x100, 50, 0x8, 14, 0x8,
+ 32, 0x1, 49, 0x100, 26, 0x100, 39, 0x100,
+ 38, 0x8, 17, 0x4, 28, 0x8, 37, 0x100,
+ 46, 0x2, 50, 0x4, 36, 0x100, 34, 0x10,
+ 15, 0x4, 14, 0x4, 33, 0x10, 49, 0x8,
+ 32, 0x10, 48, 0x4, 38, 0x100, 34, 0x2,
+ 47, 0x4, 25, 0x4, 36, 0x8, 26, 0x4,
+ 37, 0x8, 16, 0x4, 48, 0x2, 28, 0x4,
+ 37, 0x4, 39, 0x4, 47, 0x8, 36, 0x4,
+ 17, 0x2, 38, 0x4, 49, 0x4, 27, 0x2,
+ 14, 0x2, 25, 0x2, 50, 0x2, 28, 0x2,
+ 15, 0x2, 47, 0x2, 39, 0x2, 26, 0x2,
+ 16, 0x2, 49, 0x2, 37, 0x2, 47, 0x80,
+ 36, 0x2, 38, 0x2, 16, 0x80, 14, 0x80,
+ 17, 0x80, 50, 0x80, 39, 0x80, 28, 0x80,
+ 49, 0x80, 15, 0x80, 38, 0x80, 25, 0x80,
+ 37, 0x80, 26, 0x80, 27, 0x80, 48, 0x80,
+ 50, 0x1, 36, 0x80, 39, 0x1, 14, 0x1,
+ 49, 0x1, 26, 0x1, 25, 0x1, 15, 0x1,
+ 48, 0x1, 38, 0x1, 27, 0x1, 28, 0x1,
+ 16, 0x1, 17, 0x1, 47, 0x1, 37, 0x1,
+ 36, 0x1
+};
+
+const Word16 mode_24k[NBBITS_24k << 1] = {
+ 0, 0x1, 1, 0x10, 1, 0x4, 18, 0x40,
+ 30, 0x40, 42, 0x40, 54, 0x40, 1, 0x2,
+ 1, 0x8, 1, 0x20, 8, 0x100, 8, 0x80,
+ 8, 0x40, 8, 0x20, 8, 0x10, 32, 0x100,
+ 32, 0x80, 32, 0x40, 32, 0x20, 32, 0x10,
+ 18, 0x20, 30, 0x20, 42, 0x20, 54, 0x20,
+ 18, 0x1, 30, 0x1, 42, 0x1, 54, 0x1,
+ 18, 0x8, 30, 0x8, 42, 0x8, 54, 0x8,
+ 18, 0x4, 30, 0x4, 42, 0x4, 54, 0x4,
+ 20, 0x20, 44, 0x20, 18, 0x2, 30, 0x2,
+ 42, 0x2, 54, 0x2, 18, 0x10, 30, 0x10,
+ 42, 0x10, 54, 0x10, 8, 0x8, 1, 0x40,
+ 1, 0x80, 20, 0x10, 44, 0x10, 32, 0x8,
+ 3, 0x8, 3, 0x2, 2, 0x10, 3, 0x20,
+ 3, 0x10, 3, 0x4, 2, 0x1, 4, 0x10,
+ 2, 0x8, 2, 0x40, 2, 0x4, 4, 0x20,
+ 4, 0x40, 3, 0x1, 4, 0x8, 1, 0x1,
+ 2, 0x2, 8, 0x4, 32, 0x4, 5, 0x20,
+ 19, 0x8, 19, 0x4, 19, 0x2, 19, 0x1,
+ 31, 0x8, 31, 0x4, 31, 0x2, 31, 0x1,
+ 43, 0x8, 43, 0x4, 43, 0x2, 43, 0x1,
+ 55, 0x8, 55, 0x4, 55, 0x2, 55, 0x1,
+ 20, 0x8, 44, 0x8, 2, 0x80, 5, 0x8,
+ 2, 0x20, 20, 0x4, 44, 0x4, 8, 0x2,
+ 32, 0x2, 4, 0x2, 4, 0x4, 20, 0x2,
+ 44, 0x2, 5, 0x4, 5, 0x2, 4, 0x1,
+ 7, 0x1, 5, 0x10, 5, 0x40, 8, 0x1,
+ 32, 0x1, 6, 0x10, 5, 0x1, 6, 0x4,
+ 6, 0x8, 6, 0x2, 20, 0x1, 44, 0x1,
+ 6, 0x1, 7, 0x10, 7, 0x8, 7, 0x4,
+ 7, 0x2, 9, 0x1, 21, 0x1, 33, 0x1,
+ 45, 0x1, 24, 0x400, 25, 0x400, 23, 0x400,
+ 12, 0x400, 10, 0x400, 49, 0x400, 13, 0x400,
+ 22, 0x400, 37, 0x400, 47, 0x400, 46, 0x400,
+ 35, 0x400, 11, 0x400, 24, 0x100, 48, 0x400,
+ 36, 0x400, 25, 0x100, 37, 0x100, 13, 0x100,
+ 11, 0x100, 24, 0x200, 49, 0x100, 23, 0x100,
+ 10, 0x100, 13, 0x200, 10, 0x200, 49, 0x200,
+ 46, 0x100, 22, 0x100, 12, 0x100, 22, 0x200,
+ 34, 0x400, 23, 0x200, 12, 0x200, 48, 0x200,
+ 48, 0x100, 47, 0x200, 47, 0x100, 25, 0x200,
+ 37, 0x200, 11, 0x200, 34, 0x100, 34, 0x200,
+ 46, 0x200, 35, 0x100, 36, 0x100, 35, 0x200,
+ 36, 0x200, 24, 0x80, 10, 0x80, 25, 0x80,
+ 12, 0x80, 13, 0x80, 11, 0x80, 46, 0x80,
+ 49, 0x80, 23, 0x80, 22, 0x80, 53, 0x200,
+ 37, 0x80, 48, 0x80, 13, 0x4, 11, 0x4,
+ 35, 0x80, 10, 0x40, 34, 0x80, 46, 0x4,
+ 17, 0x200, 50, 0x200, 22, 0x4, 14, 0x200,
+ 47, 0x80, 25, 0x4, 12, 0x4, 23, 0x4,
+ 10, 0x4, 13, 0x40, 26, 0x200, 16, 0x200,
+ 11, 0x40, 41, 0x200, 24, 0x4, 37, 0x4,
+ 47, 0x40, 48, 0x4, 52, 0x200, 37, 0x40,
+ 28, 0x200, 49, 0x4, 36, 0x80, 29, 0x200,
+ 15, 0x200, 27, 0x200, 24, 0x40, 16, 0x20,
+ 38, 0x200, 49, 0x40, 15, 0x40, 39, 0x200,
+ 25, 0x40, 40, 0x200, 46, 0x40, 51, 0x200,
+ 23, 0x40, 10, 0x8, 48, 0x40, 12, 0x40,
+ 51, 0x40, 27, 0x20, 17, 0x400, 24, 0x8,
+ 52, 0x400, 15, 0x400, 51, 0x10, 17, 0x20,
+ 35, 0x40, 22, 0x40, 52, 0x40, 26, 0x20,
+ 53, 0x40, 27, 0x40, 29, 0x400, 28, 0x40,
+ 13, 0x8, 36, 0x4, 47, 0x4, 28, 0x20,
+ 22, 0x8, 34, 0x40, 23, 0x8, 53, 0x400,
+ 28, 0x400, 51, 0x20, 14, 0x400, 34, 0x4,
+ 17, 0x40, 16, 0x40, 36, 0x40, 15, 0x20,
+ 41, 0x10, 25, 0x8, 50, 0x40, 13, 0x20,
+ 17, 0x10, 29, 0x40, 50, 0x400, 48, 0x8,
+ 26, 0x10, 16, 0x10, 35, 0x4, 41, 0x20,
+ 14, 0x40, 29, 0x20, 52, 0x20, 12, 0x8,
+ 38, 0x400, 53, 0x20, 26, 0x400, 41, 0x40,
+ 24, 0x20, 14, 0x10, 27, 0x10, 50, 0x20,
+ 40, 0x40, 39, 0x400, 14, 0x20, 38, 0x20,
+ 15, 0x10, 16, 0x400, 11, 0x20, 26, 0x40,
+ 51, 0x400, 27, 0x400, 47, 0x8, 46, 0x8,
+ 52, 0x10, 10, 0x20, 46, 0x20, 41, 0x400,
+ 11, 0x8, 53, 0x10, 22, 0x2, 39, 0x40,
+ 22, 0x20, 29, 0x10, 50, 0x10, 39, 0x20,
+ 37, 0x8, 25, 0x20, 40, 0x20, 49, 0x20,
+ 34, 0x8, 10, 0x10, 24, 0x1, 39, 0x10,
+ 13, 0x10, 22, 0x1, 28, 0x10, 35, 0x20,
+ 38, 0x40, 24, 0x10, 49, 0x8, 12, 0x20,
+ 25, 0x2, 13, 0x1, 10, 0x1, 47, 0x20,
+ 23, 0x20, 40, 0x10, 25, 0x1, 40, 0x400,
+ 34, 0x20, 48, 0x20, 46, 0x1, 47, 0x10,
+ 36, 0x8, 37, 0x1, 49, 0x1, 23, 0x2,
+ 35, 0x1, 38, 0x10, 37, 0x20, 46, 0x10,
+ 48, 0x1, 24, 0x2, 23, 0x1, 12, 0x1,
+ 13, 0x2, 14, 0x100, 28, 0x8, 11, 0x1,
+ 12, 0x2, 11, 0x2, 17, 0x100, 47, 0x1,
+ 22, 0x10, 25, 0x10, 48, 0x10, 16, 0x100,
+ 23, 0x10, 51, 0x8, 11, 0x10, 46, 0x2,
+ 29, 0x100, 28, 0x100, 10, 0x2, 34, 0x2,
+ 35, 0x8, 17, 0x8, 37, 0x2, 50, 0x100,
+ 15, 0x100, 12, 0x10, 16, 0x8, 41, 0x8,
+ 15, 0x8, 36, 0x20, 36, 0x1, 47, 0x2,
+ 28, 0x4, 48, 0x2, 37, 0x10, 49, 0x10,
+ 35, 0x2, 53, 0x100, 51, 0x100, 27, 0x8,
+ 26, 0x8, 26, 0x100, 53, 0x8, 14, 0x8,
+ 34, 0x1, 52, 0x100, 27, 0x100, 41, 0x100,
+ 40, 0x8, 17, 0x4, 29, 0x8, 39, 0x100,
+ 49, 0x2, 53, 0x4, 38, 0x100, 36, 0x10,
+ 15, 0x4, 14, 0x4, 35, 0x10, 52, 0x8,
+ 34, 0x10, 51, 0x4, 40, 0x100, 36, 0x2,
+ 50, 0x4, 26, 0x4, 38, 0x8, 27, 0x4,
+ 39, 0x8, 16, 0x4, 51, 0x2, 29, 0x4,
+ 39, 0x4, 41, 0x4, 50, 0x8, 38, 0x4,
+ 17, 0x2, 40, 0x4, 52, 0x4, 28, 0x2,
+ 14, 0x2, 26, 0x2, 53, 0x2, 29, 0x2,
+ 15, 0x2, 50, 0x2, 41, 0x2, 27, 0x2,
+ 16, 0x2, 52, 0x2, 39, 0x2, 50, 0x80,
+ 38, 0x2, 40, 0x2, 16, 0x80, 14, 0x80,
+ 17, 0x80, 53, 0x80, 41, 0x80, 29, 0x80,
+ 52, 0x80, 15, 0x80, 40, 0x80, 26, 0x80,
+ 39, 0x80, 27, 0x80, 28, 0x80, 51, 0x80,
+ 53, 0x1, 38, 0x80, 41, 0x1, 14, 0x1,
+ 52, 0x1, 27, 0x1, 26, 0x1, 15, 0x1,
+ 51, 0x1, 40, 0x1, 28, 0x1, 29, 0x1,
+ 16, 0x1, 17, 0x1, 50, 0x1, 39, 0x1,
+ 38, 0x1
+};
+
+const Word16 mode_DTX[NBBITS_SID << 1] = {
+ 0, 0x20, 0, 0x10, 0, 0x8, 0, 0x4,
+ 0, 0x2, 0, 0x1, 1, 0x20, 1, 0x10,
+ 1, 0x8, 1, 0x4, 1, 0x2, 1, 0x1,
+ 2, 0x20, 2, 0x10, 2, 0x8, 2, 0x4,
+ 2, 0x2, 2, 0x1, 3, 0x10, 3, 0x8,
+ 3, 0x4, 3, 0x2, 3, 0x1, 4, 0x10,
+ 4, 0x8, 4, 0x4, 4, 0x2, 4, 0x1,
+ 5, 0x20, 5, 0x10, 5, 0x8, 5, 0x4,
+ 5, 0x2, 5, 0x1, 6, 0x1
+};
+
+const Word16 nb_of_param[NUM_OF_SPMODES]= {
+ PRMNO_7k, PRMNO_9k, PRMNO_12k,
+ PRMNO_14k, PRMNO_16k, PRMNO_18k,
+ PRMNO_20k, PRMNO_23k, PRMNO_24k
+};
+
+const Word16 dfh_M7k[PRMNO_7k] = {
+ 0, 49, 131,
+ 84, 5, 50,
+ 29, 2015, 8,
+ 0, 2061, 8,
+ 1, 3560, 8,
+ 0, 2981, 8
+};
+
+const Word16 dfh_M9k[PRMNO_9k] = {
+ 0, 49, 131,
+ 55, 49, 38,
+ 26, 29, 29,
+ 3, 15, 7,
+ 15, 8, 16,
+ 13, 7, 17,
+ 16, 8, 0,
+ 16, 20, 16,
+ 27, 8, 23,
+ 0, 27, 0,
+ 27, 8
+};
+
+const Word16 dfh_M12k[PRMNO_12k] = {
+ 0, 49, 131,
+ 55, 49, 38,
+ 26, 29, 58,
+ 1, 7, 63,
+ 127, 15, 70,
+ 37, 1, 209,
+ 210, 224, 96,
+ 31, 7, 1,
+ 256, 260, 271,
+ 443, 31, 47,
+ 0, 400, 238,
+ 436, 347, 31
+};
+
+const Word16 dfh_M14k[PRMNO_14k] = {
+ 0, 49, 131,
+ 55, 49, 38,
+ 26, 29, 58,
+ 1, 3847, 3845,
+ 63, 127, 70,
+ 34, 0, 3128,
+ 4517, 192, 96,
+ 0, 2, 1,
+ 4160, 8036, 267,
+ 443, 31, 46,
+ 0, 3840, 7091,
+ 432, 395, 31
+};
+
+const Word16 dfh_M16k[PRMNO_16k] = {
+ 0, 49, 131,
+ 55, 49, 38,
+ 26, 29, 58,
+ 1, 3847, 3845,
+ 3847, 3843, 70,
+ 31, 0, 3648,
+ 4764, 824, 2864,
+ 0, 6, 1,
+ 4160, 5220, 4319,
+ 7131, 31, 47,
+ 0, 112, 3764,
+ 219, 211, 31
+};
+
+const Word16 dfh_M18k[PRMNO_18k] = {
+ 0, 49, 131,
+ 55, 49, 38,
+ 26, 29, 58,
+ 1, 3, 2,
+ 3, 2, 7223,
+ 703, 7223, 703,
+ 70, 0, 1,
+ 3, 2, 2,
+ 3, 9475, 9483,
+ 3090, 8737, 0,
+ 0, 1, 0,
+ 0, 2, 0,
+ 4112, 4400, 8415,
+ 14047, 31, 38,
+ 0, 2, 1,
+ 3, 1, 91,
+ 426, 13545, 12955,
+ 0
+};
+
+const Word16 dfh_M20k[PRMNO_20k] = {
+ 0, 49, 131,
+ 55, 49, 38,
+ 26, 29, 58,
+ 1, 161, 759,
+ 3, 2, 127,
+ 516, 6167, 447,
+ 70, 11, 1,
+ 264, 641, 2,
+ 3, 123, 562,
+ 8347, 4354, 0,
+ 1, 1, 264,
+ 408, 3, 0,
+ 256, 308, 9487,
+ 14047, 31, 46,
+ 0, 320, 885,
+ 2, 2, 464,
+ 439, 11347, 12739,
+ 0
+};
+
+const Word16 dfh_M23k[PRMNO_23k] = {
+ 0, 49, 131,
+ 55, 49, 38,
+ 26, 29, 58,
+ 1, 1154, 1729,
+ 1154, 1761, 447,
+ 1519, 959, 495,
+ 70, 27, 1,
+ 1800, 1253, 665,
+ 1960, 546, 164,
+ 1043, 335, 0,
+ 28, 1, 580,
+ 196, 1187, 383,
+ 1031, 1052, 359,
+ 1531, 31, 45,
+ 1, 1024, 893,
+ 1272, 1920, 101,
+ 876, 203, 1119,
+ 31
+};
+
+const Word16 dfh_M24k[PRMNO_24k] = {
+ 0, 49, 131,
+ 55, 49, 38,
+ 26, 29, 58,
+ 1, 1729, 1154,
+ 1761, 1154, 1519,
+ 959, 495, 447,
+ 70, 3, 42,
+ 1, 580, 1436,
+ 1362, 1250, 901,
+ 714, 24, 45,
+ 0, 0, 0,
+ 1, 68, 708,
+ 1212, 383, 1048,
+ 1611, 1756, 1467,
+ 31, 1, 23,
+ 0, 1536, 1460,
+ 861, 1554, 410,
+ 1368, 1008, 594,
+ 31, 0
+};
+
+/*
+ * overall table with the parameters of the
+ * decoder homing frames for all modes
+ */
+
+const Word16 *dhf[10] = {
+ dfh_M7k,
+ dfh_M9k,
+ dfh_M12k,
+ dfh_M14k,
+ dfh_M16k,
+ dfh_M18k,
+ dfh_M20k,
+ dfh_M23k,
+ dfh_M24k,
+ dfh_M24k
+};
+
+#endif
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/if_rom.h b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/if_rom.h
new file mode 100644
index 000000000..661c442f2
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/if_rom.h
@@ -0,0 +1,70 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef IF_ROM_H
+#define IF_ROM_H
+
+#include "typedef.h"
+
+/*
+ * definition of constants
+ */
+#define NUM_OF_SPMODES 9
+
+/* number of parameters */
+#define PRMNO_7k 18
+#define PRMNO_9k 32
+#define PRMNO_12k 36
+#define PRMNO_14k 36
+#define PRMNO_16k 36
+#define PRMNO_18k 52
+#define PRMNO_20k 52
+#define PRMNO_23k 52
+#define PRMNO_24k 56
+#define PRMNO_SID 7
+#define NB_PARM_MAX PRMNO_24k
+
+/* number of bits */
+#ifndef NBBITS_7k
+#define NBBITS_7k 132
+#define NBBITS_9k 177
+#define NBBITS_12k 253
+#define NBBITS_14k 285
+#define NBBITS_16k 317
+#define NBBITS_18k 365
+#define NBBITS_20k 397
+#define NBBITS_23k 461
+#define NBBITS_24k 477
+#define NBBITS_SID 35
+#endif
+
+/* number of total bits */
+#define HEADER_SIZE 6 /* real size + 1 */
+#define T_NBBITS_7k (NBBITS_7k + HEADER_SIZE)
+#define T_NBBITS_9k (NBBITS_9k + HEADER_SIZE)
+#define T_NBBITS_12k (NBBITS_12k + HEADER_SIZE)
+#define T_NBBITS_14k (NBBITS_14k + HEADER_SIZE)
+#define T_NBBITS_16k (NBBITS_16k + HEADER_SIZE)
+#define T_NBBITS_18k (NBBITS_18k + HEADER_SIZE)
+#define T_NBBITS_20k (NBBITS_20k + HEADER_SIZE)
+#define T_NBBITS_23k (NBBITS_23k + HEADER_SIZE)
+#define T_NBBITS_24k (NBBITS_24k + HEADER_SIZE)
+#define T_NBBITS_SID (NBBITS_SID + HEADER_SIZE)
+
+#define TX_SPEECH 0
+#define TX_SID_FIRST 1
+#define TX_SID_UPDATE 2
+#define TX_NO_DATA 3
+
+#define RX_SPEECH_GOOD 0
+#define RX_SPEECH_PROBABLY_DEGRADED 1
+#define RX_SPEECH_LOST 2
+#define RX_SPEECH_BAD 3
+#define RX_SID_FIRST 4
+#define RX_SID_UPDATE 5
+#define RX_SID_BAD 6
+#define RX_NO_DATA 7
+
+#endif
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/typedef.h b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/typedef.h
new file mode 100644
index 000000000..8d1035912
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/amrwb/typedef.h
@@ -0,0 +1,18 @@
+/*
+ *===================================================================
+ * 3GPP AMR Wideband Floating-point Speech Codec
+ *===================================================================
+ */
+#ifndef typedef_h
+#define typedef_h
+
+/* change these typedef declarations to correspond with your platform */
+typedef char Word8;
+typedef unsigned char UWord8;
+typedef short Word16;
+typedef unsigned short UWord16;
+typedef long Word32;
+typedef double Float64;
+typedef float Float32;
+
+#endif \ No newline at end of file
diff --git a/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/libamr.c b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/libamr.c
new file mode 100644
index 000000000..21e1e343a
--- /dev/null
+++ b/src/filters/transform/mpcvideodec/ffmpeg/libavcodec/libamr.c
@@ -0,0 +1,446 @@
+/*
+ * AMR Audio decoder stub
+ * Copyright (c) 2003 the ffmpeg project
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+ /** @file
+ * Adaptive Multi-Rate (AMR) Audio decoder stub.
+ *
+ * This code implements both an AMR-NarrowBand (AMR-NB) and an AMR-WideBand
+ * (AMR-WB) audio encoder/decoder through external reference code from
+ * http://www.3gpp.org/. The license of the code from 3gpp is unclear so you
+ * have to download the code separately.
+ *
+ * \section AMR-NB
+ *
+ * The float version (default) can be downloaded from:
+ * http://www.3gpp.org/ftp/Specs/archive/26_series/26.104/26104-610.zip
+ *
+ * \subsection Specification
+ * The specification for AMR-NB can be found in TS 26.071
+ * (http://www.3gpp.org/ftp/Specs/html-info/26071.htm) and some other
+ * info at http://www.3gpp.org/ftp/Specs/html-info/26-series.htm.
+ *
+ * \section AMR-WB
+ *
+ * The reference code can be downloaded from:
+ * http://www.3gpp.org/ftp/Specs/archive/26_series/26.204/26204-600.zip
+ *
+ * \subsection Specification
+ * The specification for AMR-WB can be found in TS 26.171
+ * (http://www.3gpp.org/ftp/Specs/html-info/26171.htm) and some other
+ * info at http://www.3gpp.org/ftp/Specs/html-info/26-series.htm.
+ *
+ */
+
+#include "avcodec.h"
+
+static void amr_decode_fix_avctx(AVCodecContext *avctx)
+{
+ const int is_amr_wb = 1 + (avctx->codec_id == CODEC_ID_AMR_WB);
+
+ if (!avctx->sample_rate)
+ avctx->sample_rate = 8000 * is_amr_wb;
+
+ if (!avctx->channels)
+ avctx->channels = 1;
+
+ avctx->frame_size = 160 * is_amr_wb;
+ avctx->sample_fmt = SAMPLE_FMT_S16;
+}
+
+#if CONFIG_LIBAMR_NB
+
+#include <amrnb/interf_dec.h>
+#include <amrnb/interf_enc.h>
+
+static const char nb_bitrate_unsupported[] =
+ "bitrate not supported: use one of 4.75k, 5.15k, 5.9k, 6.7k, 7.4k, 7.95k, 10.2k or 12.2k\n";
+
+typedef struct AMR_bitrates {
+ int rate;
+ enum Mode mode;
+} AMR_bitrates;
+
+/* Match desired bitrate */
+static int getBitrateMode(int bitrate)
+{
+ /* make the correspondance between bitrate and mode */
+ AMR_bitrates rates[] = { { 4750, MR475},
+ { 5150, MR515},
+ { 5900, MR59},
+ { 6700, MR67},
+ { 7400, MR74},
+ { 7950, MR795},
+ {10200, MR102},
+ {12200, MR122}, };
+ int i;
+
+ for (i = 0; i < 8; i++)
+ if (rates[i].rate == bitrate)
+ return rates[i].mode;
+ /* no bitrate matching, return an error */
+ return -1;
+}
+
+typedef struct AMRContext {
+ int frameCount;
+ void *decState;
+ int *enstate;
+ int enc_bitrate;
+} AMRContext;
+
+static av_cold int amr_nb_decode_init(AVCodecContext *avctx)
+{
+ AMRContext *s = avctx->priv_data;
+
+ s->frameCount = 0;
+ s->decState = Decoder_Interface_init();
+ if (!s->decState) {
+ av_log(avctx, AV_LOG_ERROR, "Decoder_Interface_init error\r\n");
+ return -1;
+ }
+
+ amr_decode_fix_avctx(avctx);
+
+ if (avctx->channels > 1) {
+ av_log(avctx, AV_LOG_ERROR, "amr_nb: multichannel decoding not supported\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+static av_cold int amr_nb_decode_close(AVCodecContext *avctx)
+{
+ AMRContext *s = avctx->priv_data;
+
+ Decoder_Interface_exit(s->decState);
+ return 0;
+}
+
+static int amr_nb_decode_frame(AVCodecContext *avctx, void *data,
+ int *data_size, const uint8_t * buf, int buf_size)
+
+{
+
+ AMRContext *s = avctx->priv_data;
+ const uint8_t *amrData = buf;
+ static const uint8_t block_size[16] = { 12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0 };
+ enum Mode dec_mode;
+ int packet_size;
+
+ /* av_log(NULL, AV_LOG_DEBUG, "amr_decode_frame buf=%p buf_size=%d frameCount=%d!!\n",
+ buf, buf_size, s->frameCount); */
+
+ dec_mode = (buf[0] >> 3) & 0x000F;
+ packet_size = block_size[dec_mode] + 1;
+
+ if (packet_size > buf_size) {
+ av_log(avctx, AV_LOG_ERROR, "amr frame too short (%u, should be %u)\n",
+ buf_size, packet_size);
+ return -1;
+ }
+
+ s->frameCount++;
+ /* av_log(NULL, AV_LOG_DEBUG, "packet_size=%d amrData= 0x%X %X %X %X\n",
+ packet_size, amrData[0], amrData[1], amrData[2], amrData[3]); */
+ /* call decoder */
+ Decoder_Interface_Decode(s->decState, amrData, data, 0);
+ *data_size = 160 * 2;
+
+ return packet_size;
+}
+
+AVCodec libamr_nb_decoder = {
+ "libamr_nb",
+ CODEC_TYPE_AUDIO,
+ CODEC_ID_AMR_NB,
+ sizeof(AMRContext),
+ amr_nb_decode_init,
+ NULL,
+ amr_nb_decode_close,
+ amr_nb_decode_frame,
+ .long_name = NULL_IF_CONFIG_SMALL("libamr-nb Adaptive Multi-Rate (AMR) Narrow-Band"),
+};
+
+static av_cold int amr_nb_encode_init(AVCodecContext *avctx)
+{
+ AMRContext *s = avctx->priv_data;
+
+ s->frameCount = 0;
+
+ if (avctx->sample_rate != 8000) {
+ av_log(avctx, AV_LOG_ERROR, "Only 8000Hz sample rate supported\n");
+ return -1;
+ }
+
+ if (avctx->channels != 1) {
+ av_log(avctx, AV_LOG_ERROR, "Only mono supported\n");
+ return -1;
+ }
+
+ avctx->frame_size = 160;
+ avctx->coded_frame = avcodec_alloc_frame();
+
+ s->enstate=Encoder_Interface_init(0);
+ if (!s->enstate) {
+ av_log(avctx, AV_LOG_ERROR, "Encoder_Interface_init error\n");
+ return -1;
+ }
+
+ if ((s->enc_bitrate = getBitrateMode(avctx->bit_rate)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, nb_bitrate_unsupported);
+ return -1;
+ }
+
+ return 0;
+}
+
+static av_cold int amr_nb_encode_close(AVCodecContext *avctx)
+{
+ AMRContext *s = avctx->priv_data;
+
+ Encoder_Interface_exit(s->enstate);
+ av_freep(&avctx->coded_frame);
+ return 0;
+}
+
+static int amr_nb_encode_frame(AVCodecContext *avctx,
+ unsigned char *frame/*out*/,
+ int buf_size, void *data/*in*/)
+{
+ AMRContext *s = avctx->priv_data;
+ int written;
+
+ if ((s->enc_bitrate = getBitrateMode(avctx->bit_rate)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, nb_bitrate_unsupported);
+ return -1;
+ }
+
+ written = Encoder_Interface_Encode(s->enstate, s->enc_bitrate, data,
+ frame, 0);
+ /* av_log(NULL, AV_LOG_DEBUG, "amr_nb_encode_frame encoded %u bytes, bitrate %u, first byte was %#02x\n",
+ written, s->enc_bitrate, frame[0] ); */
+
+ return written;
+}
+
+AVCodec libamr_nb_encoder = {
+ "libamr_nb",
+ CODEC_TYPE_AUDIO,
+ CODEC_ID_AMR_NB,
+ sizeof(AMRContext),
+ amr_nb_encode_init,
+ amr_nb_encode_frame,
+ amr_nb_encode_close,
+ NULL,
+ .sample_fmts = (enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
+ .long_name = NULL_IF_CONFIG_SMALL("libamr-nb Adaptive Multi-Rate (AMR) Narrow-Band"),
+};
+
+#endif
+
+/* -----------AMR wideband ------------*/
+#if CONFIG_LIBAMR_WB
+
+#ifdef _TYPEDEF_H
+//To avoid duplicate typedefs from typedef in amr-nb
+#define typedef_h
+#endif
+
+#include <amrwb/dec_if.h>
+#include <amrwb/if_rom.h>
+
+static const char wb_bitrate_unsupported[] =
+ "bitrate not supported: use one of 6.6k, 8.85k, 12.65k, 14.25k, 15.85k, 18.25k, 19.85k, 23.05k, or 23.85k\n";
+
+typedef struct AMRWB_bitrates {
+ int rate;
+ int mode;
+} AMRWB_bitrates;
+
+typedef struct AMRWBContext {
+ int frameCount;
+ void *state;
+ int mode;
+ Word16 allow_dtx;
+} AMRWBContext;
+
+#if CONFIG_LIBAMR_WB_ENCODER
+
+#include <amrwb/enc_if.h>
+
+static int getWBBitrateMode(int bitrate)
+{
+ /* make the correspondance between bitrate and mode */
+ AMRWB_bitrates rates[] = { { 6600, 0},
+ { 8850, 1},
+ {12650, 2},
+ {14250, 3},
+ {15850, 4},
+ {18250, 5},
+ {19850, 6},
+ {23050, 7},
+ {23850, 8}, };
+ int i;
+
+ for (i = 0; i < 9; i++)
+ if (rates[i].rate == bitrate)
+ return rates[i].mode;
+ /* no bitrate matching, return an error */
+ return -1;
+}
+
+static av_cold int amr_wb_encode_init(AVCodecContext *avctx)
+{
+ AMRWBContext *s = avctx->priv_data;
+
+ s->frameCount = 0;
+
+ if (avctx->sample_rate != 16000) {
+ av_log(avctx, AV_LOG_ERROR, "Only 16000Hz sample rate supported\n");
+ return -1;
+ }
+
+ if (avctx->channels != 1) {
+ av_log(avctx, AV_LOG_ERROR, "Only mono supported\n");
+ return -1;
+ }
+
+ if ((s->mode = getWBBitrateMode(avctx->bit_rate)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, wb_bitrate_unsupported);
+ return -1;
+ }
+
+ avctx->frame_size = 320;
+ avctx->coded_frame = avcodec_alloc_frame();
+
+ s->state = E_IF_init();
+ s->allow_dtx = 0;
+
+ return 0;
+}
+
+static int amr_wb_encode_close(AVCodecContext *avctx)
+{
+ AMRWBContext *s = avctx->priv_data;
+
+ E_IF_exit(s->state);
+ av_freep(&avctx->coded_frame);
+ s->frameCount++;
+ return 0;
+}
+
+static int amr_wb_encode_frame(AVCodecContext *avctx,
+ unsigned char *frame/*out*/,
+ int buf_size, void *data/*in*/)
+{
+ AMRWBContext *s = avctx->priv_data;
+ int size;
+
+ if ((s->mode = getWBBitrateMode(avctx->bit_rate)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, wb_bitrate_unsupported);
+ return -1;
+ }
+ size = E_IF_encode(s->state, s->mode, data, frame, s->allow_dtx);
+ return size;
+}
+
+AVCodec libamr_wb_encoder = {
+ "libamr_wb",
+ CODEC_TYPE_AUDIO,
+ CODEC_ID_AMR_WB,
+ sizeof(AMRWBContext),
+ amr_wb_encode_init,
+ amr_wb_encode_frame,
+ amr_wb_encode_close,
+ NULL,
+ .sample_fmts = (enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
+ .long_name = NULL_IF_CONFIG_SMALL("libamr-wb Adaptive Multi-Rate (AMR) Wide-Band"),
+};
+
+#endif
+
+static av_cold int amr_wb_decode_init(AVCodecContext *avctx)
+{
+ AMRWBContext *s = avctx->priv_data;
+
+ s->frameCount = 0;
+ s->state = D_IF_init();
+
+ amr_decode_fix_avctx(avctx);
+
+ if (avctx->channels > 1) {
+ av_log(avctx, AV_LOG_ERROR, "amr_wb: multichannel decoding not supported\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+static int amr_wb_decode_frame(AVCodecContext *avctx, void *data,
+ int *data_size, const uint8_t * buf, int buf_size)
+{
+ AMRWBContext *s = avctx->priv_data;
+ const uint8_t *amrData = buf;
+ int mode;
+ int packet_size;
+ static const uint8_t block_size[16] = {18, 24, 33, 37, 41, 47, 51, 59, 61, 6, 6, 0, 0, 0, 1, 1};
+
+ if (!buf_size)
+ /* nothing to do */
+ return 0;
+
+ mode = (amrData[0] >> 3) & 0x000F;
+ packet_size = block_size[mode];
+
+ if (packet_size > buf_size) {
+ av_log(avctx, AV_LOG_ERROR, "amr frame too short (%u, should be %u)\n",
+ buf_size, packet_size + 1);
+ return -1;
+ }
+
+ s->frameCount++;
+ D_IF_decode(s->state, amrData, data, _good_frame);
+ *data_size = 320 * 2;
+ return packet_size;
+}
+
+static int amr_wb_decode_close(AVCodecContext *avctx)
+{
+ AMRWBContext *s = avctx->priv_data;
+
+ D_IF_exit(s->state);
+ return 0;
+}
+
+AVCodec libamr_wb_decoder = {
+ "libamr_wb",
+ CODEC_TYPE_AUDIO,
+ CODEC_ID_AMR_WB,
+ sizeof(AMRWBContext),
+ amr_wb_decode_init,
+ NULL,
+ amr_wb_decode_close,
+ amr_wb_decode_frame,
+ .long_name = NULL_IF_CONFIG_SMALL("libamr-wb Adaptive Multi-Rate (AMR) Wide-Band"),
+};
+
+#endif //CONFIG_LIBAMR_WB