From 5a73062c173dfb3b358f10ab4333a1386ffbfa51 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 10 Aug 2023 18:50:39 +0200 Subject: [PATCH 01/12] rename folder "lc3plus" to "lib_lc3plus" --- CMakeLists.txt | 20 +- Makefile | 2 +- Workspace_msvc/LC3plus.vcxproj | 182 ------------------ Workspace_msvc/Workspace_msvc.sln | 2 +- Workspace_msvc/lib_com.vcxproj | 6 +- Workspace_msvc/lib_dec.vcxproj | 6 +- Workspace_msvc/lib_enc.vcxproj | 6 +- Workspace_msvc/lib_rend.vcxproj | 8 +- Workspace_msvc/lib_util.vcxproj | 4 +- Workspace_msvc/renderer.vcxproj | 6 +- {lc3plus => lib_lc3plus}/adjust_global_gain.c | 0 {lc3plus => lib_lc3plus}/al_fec_fl.c | 0 {lc3plus => lib_lc3plus}/apply_global_gain.c | 0 {lc3plus => lib_lc3plus}/ari_codec.c | 0 {lc3plus => lib_lc3plus}/attack_detector.c | 0 {lc3plus => lib_lc3plus}/clib.h | 0 {lc3plus => lib_lc3plus}/constants.c | 0 {lc3plus => lib_lc3plus}/constants.h | 0 {lc3plus => lib_lc3plus}/cutoff_bandwidth.c | 0 {lc3plus => lib_lc3plus}/dct4.c | 0 {lc3plus => lib_lc3plus}/dec_entropy.c | 0 {lc3plus => lib_lc3plus}/dec_lc3_fl.c | 0 {lc3plus => lib_lc3plus}/defines.h | 0 .../detect_cutoff_warped.c | 0 {lc3plus => lib_lc3plus}/enc_entropy.c | 0 {lc3plus => lib_lc3plus}/enc_lc3_fl.c | 0 .../estimate_global_gain.c | 0 {lc3plus => lib_lc3plus}/fft/cfft.c | 0 {lc3plus => lib_lc3plus}/fft/cfft.h | 0 {lc3plus => lib_lc3plus}/fft/fft_15_16.h | 0 {lc3plus => lib_lc3plus}/fft/fft_240_480.h | 0 {lc3plus => lib_lc3plus}/fft/fft_2_9.h | 0 {lc3plus => lib_lc3plus}/fft/fft_32.h | 0 {lc3plus => lib_lc3plus}/fft/fft_384_768.h | 0 {lc3plus => lib_lc3plus}/fft/fft_60_128.h | 0 {lc3plus => lib_lc3plus}/fft/fft_generic.h | 0 {lc3plus => lib_lc3plus}/fft/iis_fft.c | 0 {lc3plus => lib_lc3plus}/fft/iis_fft.h | 0 {lc3plus => lib_lc3plus}/fft/iisfft.c | 0 {lc3plus => lib_lc3plus}/fft/iisfft.h | 0 {lc3plus => lib_lc3plus}/functions.h | 0 {lc3plus => lib_lc3plus}/imdct.c | 0 {lc3plus => lib_lc3plus}/lc3.c | 0 {lc3plus => lib_lc3plus}/lc3.h | 0 {lc3plus => lib_lc3plus}/lc3plus_fft.c | 0 {lc3plus => lib_lc3plus}/license.h | 0 {lc3plus => lib_lc3plus}/ltpf_coder.c | 0 {lc3plus => lib_lc3plus}/ltpf_decoder.c | 0 {lc3plus => lib_lc3plus}/mdct.c | 0 {lc3plus => lib_lc3plus}/mdct_shaping.c | 0 .../near_nyquist_detector.c | 0 {lc3plus => lib_lc3plus}/noise_factor.c | 0 {lc3plus => lib_lc3plus}/noise_filling.c | 0 {lc3plus => lib_lc3plus}/olpa.c | 0 {lc3plus => lib_lc3plus}/pc_apply.c | 0 {lc3plus => lib_lc3plus}/pc_classify.c | 0 {lc3plus => lib_lc3plus}/pc_main.c | 0 {lc3plus => lib_lc3plus}/pc_update.c | 0 {lc3plus => lib_lc3plus}/per_band_energy.c | 0 {lc3plus => lib_lc3plus}/plc_classify.c | 0 .../plc_compute_stab_fac.c | 0 .../plc_damping_scrambling.c | 0 {lc3plus => lib_lc3plus}/plc_main.c | 0 .../plc_noise_substitution.c | 0 .../plc_phecu_f0_refine_first.c | 0 {lc3plus => lib_lc3plus}/plc_phecu_fec_hq.c | 0 {lc3plus => lib_lc3plus}/plc_phecu_hq_ecu.c | 0 .../plc_phecu_lf_peak_analysis.c | 0 .../plc_phecu_rec_frame.c | 0 {lc3plus => lib_lc3plus}/plc_phecu_setf0hz.c | 0 {lc3plus => lib_lc3plus}/plc_phecu_spec_ana.c | 0 .../plc_phecu_subst_spec.c | 0 .../plc_phecu_tba_per_band_gain.c | 0 .../plc_phecu_tba_spect_Xavg.c | 0 .../plc_phecu_tba_trans_dect_gains.c | 0 .../plc_phecu_trans_burst_ana_sub.c | 0 {lc3plus => lib_lc3plus}/plc_tdc.c | 0 {lc3plus => lib_lc3plus}/plc_tdc_tdac.c | 0 {lc3plus => lib_lc3plus}/plc_update.c | 0 {lc3plus => lib_lc3plus}/quantize_spec.c | 0 {lc3plus => lib_lc3plus}/reorder_bitstream.c | 0 {lc3plus => lib_lc3plus}/resamp12k8.c | 0 {lc3plus => lib_lc3plus}/residual_coding.c | 0 {lc3plus => lib_lc3plus}/residual_decoding.c | 0 {lc3plus => lib_lc3plus}/setup_com_lc3.c | 0 {lc3plus => lib_lc3plus}/setup_dec_lc3.c | 0 {lc3plus => lib_lc3plus}/setup_dec_lc3.h | 0 {lc3plus => lib_lc3plus}/setup_enc_lc3.c | 0 {lc3plus => lib_lc3plus}/setup_enc_lc3.h | 0 {lc3plus => lib_lc3plus}/sns_compute_scf.c | 0 .../sns_interpolate_scf.c | 0 {lc3plus => lib_lc3plus}/sns_quantize_scf.c | 0 {lc3plus => lib_lc3plus}/structs.h | 0 {lc3plus => lib_lc3plus}/tns_coder.c | 0 {lc3plus => lib_lc3plus}/tns_decoder.c | 0 {lc3plus => lib_lc3plus}/util.h | 0 scripts/prepare_delivery.sh | 2 +- scripts/prepare_instrumentation.sh | 3 +- 98 files changed, 32 insertions(+), 215 deletions(-) delete mode 100644 Workspace_msvc/LC3plus.vcxproj rename {lc3plus => lib_lc3plus}/adjust_global_gain.c (100%) rename {lc3plus => lib_lc3plus}/al_fec_fl.c (100%) rename {lc3plus => lib_lc3plus}/apply_global_gain.c (100%) rename {lc3plus => lib_lc3plus}/ari_codec.c (100%) rename {lc3plus => lib_lc3plus}/attack_detector.c (100%) rename {lc3plus => lib_lc3plus}/clib.h (100%) rename {lc3plus => lib_lc3plus}/constants.c (100%) rename {lc3plus => lib_lc3plus}/constants.h (100%) rename {lc3plus => lib_lc3plus}/cutoff_bandwidth.c (100%) rename {lc3plus => lib_lc3plus}/dct4.c (100%) rename {lc3plus => lib_lc3plus}/dec_entropy.c (100%) rename {lc3plus => lib_lc3plus}/dec_lc3_fl.c (100%) rename {lc3plus => lib_lc3plus}/defines.h (100%) rename {lc3plus => lib_lc3plus}/detect_cutoff_warped.c (100%) rename {lc3plus => lib_lc3plus}/enc_entropy.c (100%) rename {lc3plus => lib_lc3plus}/enc_lc3_fl.c (100%) rename {lc3plus => lib_lc3plus}/estimate_global_gain.c (100%) rename {lc3plus => lib_lc3plus}/fft/cfft.c (100%) rename {lc3plus => lib_lc3plus}/fft/cfft.h (100%) rename {lc3plus => lib_lc3plus}/fft/fft_15_16.h (100%) rename {lc3plus => lib_lc3plus}/fft/fft_240_480.h (100%) rename {lc3plus => lib_lc3plus}/fft/fft_2_9.h (100%) rename {lc3plus => lib_lc3plus}/fft/fft_32.h (100%) rename {lc3plus => lib_lc3plus}/fft/fft_384_768.h (100%) rename {lc3plus => lib_lc3plus}/fft/fft_60_128.h (100%) rename {lc3plus => lib_lc3plus}/fft/fft_generic.h (100%) rename {lc3plus => lib_lc3plus}/fft/iis_fft.c (100%) rename {lc3plus => lib_lc3plus}/fft/iis_fft.h (100%) rename {lc3plus => lib_lc3plus}/fft/iisfft.c (100%) rename {lc3plus => lib_lc3plus}/fft/iisfft.h (100%) rename {lc3plus => lib_lc3plus}/functions.h (100%) rename {lc3plus => lib_lc3plus}/imdct.c (100%) rename {lc3plus => lib_lc3plus}/lc3.c (100%) rename {lc3plus => lib_lc3plus}/lc3.h (100%) rename {lc3plus => lib_lc3plus}/lc3plus_fft.c (100%) rename {lc3plus => lib_lc3plus}/license.h (100%) rename {lc3plus => lib_lc3plus}/ltpf_coder.c (100%) rename {lc3plus => lib_lc3plus}/ltpf_decoder.c (100%) rename {lc3plus => lib_lc3plus}/mdct.c (100%) rename {lc3plus => lib_lc3plus}/mdct_shaping.c (100%) rename {lc3plus => lib_lc3plus}/near_nyquist_detector.c (100%) rename {lc3plus => lib_lc3plus}/noise_factor.c (100%) rename {lc3plus => lib_lc3plus}/noise_filling.c (100%) rename {lc3plus => lib_lc3plus}/olpa.c (100%) rename {lc3plus => lib_lc3plus}/pc_apply.c (100%) rename {lc3plus => lib_lc3plus}/pc_classify.c (100%) rename {lc3plus => lib_lc3plus}/pc_main.c (100%) rename {lc3plus => lib_lc3plus}/pc_update.c (100%) rename {lc3plus => lib_lc3plus}/per_band_energy.c (100%) rename {lc3plus => lib_lc3plus}/plc_classify.c (100%) rename {lc3plus => lib_lc3plus}/plc_compute_stab_fac.c (100%) rename {lc3plus => lib_lc3plus}/plc_damping_scrambling.c (100%) rename {lc3plus => lib_lc3plus}/plc_main.c (100%) rename {lc3plus => lib_lc3plus}/plc_noise_substitution.c (100%) rename {lc3plus => lib_lc3plus}/plc_phecu_f0_refine_first.c (100%) rename {lc3plus => lib_lc3plus}/plc_phecu_fec_hq.c (100%) rename {lc3plus => lib_lc3plus}/plc_phecu_hq_ecu.c (100%) rename {lc3plus => lib_lc3plus}/plc_phecu_lf_peak_analysis.c (100%) rename {lc3plus => lib_lc3plus}/plc_phecu_rec_frame.c (100%) rename {lc3plus => lib_lc3plus}/plc_phecu_setf0hz.c (100%) rename {lc3plus => lib_lc3plus}/plc_phecu_spec_ana.c (100%) rename {lc3plus => lib_lc3plus}/plc_phecu_subst_spec.c (100%) rename {lc3plus => lib_lc3plus}/plc_phecu_tba_per_band_gain.c (100%) rename {lc3plus => lib_lc3plus}/plc_phecu_tba_spect_Xavg.c (100%) rename {lc3plus => lib_lc3plus}/plc_phecu_tba_trans_dect_gains.c (100%) rename {lc3plus => lib_lc3plus}/plc_phecu_trans_burst_ana_sub.c (100%) rename {lc3plus => lib_lc3plus}/plc_tdc.c (100%) rename {lc3plus => lib_lc3plus}/plc_tdc_tdac.c (100%) rename {lc3plus => lib_lc3plus}/plc_update.c (100%) rename {lc3plus => lib_lc3plus}/quantize_spec.c (100%) rename {lc3plus => lib_lc3plus}/reorder_bitstream.c (100%) rename {lc3plus => lib_lc3plus}/resamp12k8.c (100%) rename {lc3plus => lib_lc3plus}/residual_coding.c (100%) rename {lc3plus => lib_lc3plus}/residual_decoding.c (100%) rename {lc3plus => lib_lc3plus}/setup_com_lc3.c (100%) rename {lc3plus => lib_lc3plus}/setup_dec_lc3.c (100%) rename {lc3plus => lib_lc3plus}/setup_dec_lc3.h (100%) rename {lc3plus => lib_lc3plus}/setup_enc_lc3.c (100%) rename {lc3plus => lib_lc3plus}/setup_enc_lc3.h (100%) rename {lc3plus => lib_lc3plus}/sns_compute_scf.c (100%) rename {lc3plus => lib_lc3plus}/sns_interpolate_scf.c (100%) rename {lc3plus => lib_lc3plus}/sns_quantize_scf.c (100%) rename {lc3plus => lib_lc3plus}/structs.h (100%) rename {lc3plus => lib_lc3plus}/tns_coder.c (100%) rename {lc3plus => lib_lc3plus}/tns_decoder.c (100%) rename {lc3plus => lib_lc3plus}/util.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index d08135676c..fe7d0cbd48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,7 +130,7 @@ add_library(lib_com ${libComSrcs} ${libComHeaders}) if(UNIX) target_link_libraries(lib_com PRIVATE m) endif() -target_include_directories(lib_com PUBLIC lib_com PRIVATE lib_enc lib_dec lib_rend lib_debug lc3plus) +target_include_directories(lib_com PUBLIC lib_com PRIVATE lib_enc lib_dec lib_rend lib_debug lib_lc3plus) file(GLOB libDebugSrcs "lib_debug/*.c") file(GLOB libDebugHeaders "lib_debug/*.h") @@ -142,15 +142,15 @@ file(GLOB libEncSrcs "lib_enc/*.c") file(GLOB libEncHeaders "lib_enc/*.h") add_library(lib_enc ${libEncSrcs} ${libEncHeaders}) target_link_libraries(lib_enc lib_com lib_debug) -target_include_directories(lib_enc PUBLIC lib_enc PRIVATE lib_dec lib_rend lc3plus) +target_include_directories(lib_enc PUBLIC lib_enc PRIVATE lib_dec lib_rend lib_lc3plus) -file(GLOB libLC3plusSrcs "lc3plus/*.c") -file(GLOB libLC3plusHeaders "lc3plus/*.h") -add_library(lc3plus ${libLC3plusSrcs} ${libLC3plusHeaders}) -target_include_directories(lc3plus PUBLIC lc3plus) -target_link_libraries(lc3plus lib_com) # For including options.h, which is needed for instrumentation to work correctly +file(GLOB libLC3plusSrcs "lib_lc3plus/*.c") +file(GLOB libLC3plusHeaders "lib_lc3plus/*.h") +add_library(lib_lc3plus ${libLC3plusSrcs} ${libLC3plusHeaders}) +target_include_directories(lib_lc3plus PUBLIC lib_lc3plus) +target_link_libraries(lib_lc3plus lib_com) # For including options.h, which is needed for instrumentation to work correctly if(WMOPS) - target_link_libraries(lc3plus lib_debug) + target_link_libraries(lib_lc3plus lib_debug) endif() file(GLOB libCldfbTransCodecSrcs "lib_rend/ivas_cldfb_trans_codec/*.c") @@ -158,7 +158,7 @@ file(GLOB libCldfbTransCodecHeaders "lib_rend/ivas_cldfb_trans_codec/*.h") file(GLOB libRendSrcs "lib_rend/*.c") file(GLOB libRendHeaders "lib_rend/*.h") add_library(lib_rend ${libRendSrcs} ${libCldfbTransCodecSrcs} ${libRendHeaders} ${libCldfbTransCodecHeaders}) -target_link_libraries(lib_rend lib_dec lib_com lib_debug lc3plus) # Todo refactor: This dependency on lib_dec should be removed. +target_link_libraries(lib_rend lib_dec lib_com lib_debug lib_lc3plus) # Todo refactor: This dependency on lib_dec should be removed. target_include_directories(lib_rend PUBLIC lib_rend PRIVATE lib_enc) @@ -171,7 +171,7 @@ target_include_directories(lib_dec PUBLIC lib_dec lib_rend PRIVATE lib_enc) file(GLOB libUtilSrcs "lib_util/*.c") file(GLOB libUtilHeaders "lib_util/*.h") add_library(lib_util ${libUtilSrcs} ${libUtilHeaders}) -target_include_directories(lib_util PUBLIC lib_util PRIVATE lib_com lib_enc lib_dec lib_rend lib_debug lc3plus) +target_include_directories(lib_util PUBLIC lib_util PRIVATE lib_com lib_enc lib_dec lib_rend lib_debug lib_lc3plus) if(NOT WMOPS) file(GLOB unitTestIvasLc3plusSrcs "scripts/split_rendering/lc3plus/*.c") diff --git a/Makefile b/Makefile index 138a4cdaed..988422313f 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ SRC_LIBDEBUG = lib_debug SRC_LIBDEC = lib_dec SRC_LIBENC = lib_enc SRC_LIBREND = lib_rend -SRC_LC3PLUS = lc3plus lc3plus/fft +SRC_LC3PLUS = lib_lc3plus lib_lc3plus/fft SRC_LIBUTIL = lib_util SRC_APP = apps BUILD = build diff --git a/Workspace_msvc/LC3plus.vcxproj b/Workspace_msvc/LC3plus.vcxproj deleted file mode 100644 index 7cefc1816b..0000000000 --- a/Workspace_msvc/LC3plus.vcxproj +++ /dev/null @@ -1,182 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {95030B82-70CD-4C6B-84D4-61096035BEA2} - Win32Proj - LC3_FL - 10.0.17763.0 - - - - StaticLibrary - true - v141 - Unicode - - - StaticLibrary - false - v141 - true - Unicode - - - - - - - - - - - - - - - LC3plus - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\Obj\ - - - LC3plus - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\Obj\ - - - - - - Level3 - ..\lib_com;%(AdditionalIncludeDirectories) - Disabled - MultiThreadedDebug - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - 4305;4244;4996 - OldStyle - - - Console - true - - - - - Level3 - - - ..\lib_com;%(AdditionalIncludeDirectories) - MaxSpeed - MultiThreaded - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - 4244;4305;4996 - - - Console - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Workspace_msvc/Workspace_msvc.sln b/Workspace_msvc/Workspace_msvc.sln index 1d8e08ac9f..f7a8d6f9e8 100644 --- a/Workspace_msvc/Workspace_msvc.sln +++ b/Workspace_msvc/Workspace_msvc.sln @@ -20,7 +20,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "encoder", "encoder.vcxproj" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "renderer", "renderer.vcxproj", "{12B4C8A5-1E06-4E30-B443-D1F916F52B47}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LC3plus", "LC3plus.vcxproj", "{95030B82-70CD-4C6B-84D4-61096035BEA2}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LC3plus", "lib_lc3plus.vcxproj", "{95030B82-70CD-4C6B-84D4-61096035BEA2}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{51160D4C-55C9-4C16-A792-D94507225746}" ProjectSection(SolutionItems) = preProject diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index 0769491d34..b8bfb3c423 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -78,7 +78,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lc3plus;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks @@ -109,7 +109,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lc3plus;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) @@ -147,7 +147,7 @@ Neither false false - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lc3plus;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) true diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index d627c3e216..75d2526a1f 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -89,7 +89,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lc3plus;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks @@ -126,7 +126,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_util;..\lib_rend;..\lc3plus;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_util;..\lib_rend;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) @@ -169,7 +169,7 @@ Neither false false - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lc3plus;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) true diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj index e13746ea0e..4e2bdbbdb7 100644 --- a/Workspace_msvc/lib_enc.vcxproj +++ b/Workspace_msvc/lib_enc.vcxproj @@ -89,7 +89,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lc3plus;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks @@ -129,7 +129,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lc3plus;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) @@ -176,7 +176,7 @@ Neither false false - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lc3plus;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) true diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index 852cb8f14b..2d9e0b447d 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -89,7 +89,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lc3plus;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks @@ -126,7 +126,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_util;..\lc3plus;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_util;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) @@ -169,7 +169,7 @@ Neither false false - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lc3plus;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) true @@ -278,7 +278,7 @@ {54509728-928b-44d9-a118-a6f92f08b34f} false - + {95030B82-70CD-4C6B-84D4-61096035BEA2} false diff --git a/Workspace_msvc/lib_util.vcxproj b/Workspace_msvc/lib_util.vcxproj index 4938d0b2ce..a9cbccf8ae 100644 --- a/Workspace_msvc/lib_util.vcxproj +++ b/Workspace_msvc/lib_util.vcxproj @@ -73,7 +73,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_util;..\lc3plus;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_util;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);ZLIB_WINAPI;%(PreprocessorDefinitions) false @@ -117,7 +117,7 @@ AnySuitable false false - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_util;..\lc3plus;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_util;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);ZLIB_WINAPI;%(PreprocessorDefinitions) true diff --git a/Workspace_msvc/renderer.vcxproj b/Workspace_msvc/renderer.vcxproj index eee6eed340..7d9115f57e 100644 --- a/Workspace_msvc/renderer.vcxproj +++ b/Workspace_msvc/renderer.vcxproj @@ -86,7 +86,7 @@ Disabled - ..\lib_com;..\lib_dec;..\lib_enc;..\lib_debug;..\lib_util;..\lib_rend;..\lc3plus;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_dec;..\lib_enc;..\lib_debug;..\lib_util;..\lib_rend;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;WIN32;$(Macros);%(PreprocessorDefinitions) EnableFastChecks @@ -130,7 +130,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_util;..\lib_rend;..\lc3plus;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_util;..\lib_rend;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;WIN32;$(Macros);%(PreprocessorDefinitions) @@ -180,7 +180,7 @@ Neither false false - ..\lib_com;..\lib_dec;..\lib_enc;..\lib_debug;..\lib_util;..\lib_rend;..\lc3plus;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_dec;..\lib_enc;..\lib_debug;..\lib_util;..\lib_rend;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) true diff --git a/lc3plus/adjust_global_gain.c b/lib_lc3plus/adjust_global_gain.c similarity index 100% rename from lc3plus/adjust_global_gain.c rename to lib_lc3plus/adjust_global_gain.c diff --git a/lc3plus/al_fec_fl.c b/lib_lc3plus/al_fec_fl.c similarity index 100% rename from lc3plus/al_fec_fl.c rename to lib_lc3plus/al_fec_fl.c diff --git a/lc3plus/apply_global_gain.c b/lib_lc3plus/apply_global_gain.c similarity index 100% rename from lc3plus/apply_global_gain.c rename to lib_lc3plus/apply_global_gain.c diff --git a/lc3plus/ari_codec.c b/lib_lc3plus/ari_codec.c similarity index 100% rename from lc3plus/ari_codec.c rename to lib_lc3plus/ari_codec.c diff --git a/lc3plus/attack_detector.c b/lib_lc3plus/attack_detector.c similarity index 100% rename from lc3plus/attack_detector.c rename to lib_lc3plus/attack_detector.c diff --git a/lc3plus/clib.h b/lib_lc3plus/clib.h similarity index 100% rename from lc3plus/clib.h rename to lib_lc3plus/clib.h diff --git a/lc3plus/constants.c b/lib_lc3plus/constants.c similarity index 100% rename from lc3plus/constants.c rename to lib_lc3plus/constants.c diff --git a/lc3plus/constants.h b/lib_lc3plus/constants.h similarity index 100% rename from lc3plus/constants.h rename to lib_lc3plus/constants.h diff --git a/lc3plus/cutoff_bandwidth.c b/lib_lc3plus/cutoff_bandwidth.c similarity index 100% rename from lc3plus/cutoff_bandwidth.c rename to lib_lc3plus/cutoff_bandwidth.c diff --git a/lc3plus/dct4.c b/lib_lc3plus/dct4.c similarity index 100% rename from lc3plus/dct4.c rename to lib_lc3plus/dct4.c diff --git a/lc3plus/dec_entropy.c b/lib_lc3plus/dec_entropy.c similarity index 100% rename from lc3plus/dec_entropy.c rename to lib_lc3plus/dec_entropy.c diff --git a/lc3plus/dec_lc3_fl.c b/lib_lc3plus/dec_lc3_fl.c similarity index 100% rename from lc3plus/dec_lc3_fl.c rename to lib_lc3plus/dec_lc3_fl.c diff --git a/lc3plus/defines.h b/lib_lc3plus/defines.h similarity index 100% rename from lc3plus/defines.h rename to lib_lc3plus/defines.h diff --git a/lc3plus/detect_cutoff_warped.c b/lib_lc3plus/detect_cutoff_warped.c similarity index 100% rename from lc3plus/detect_cutoff_warped.c rename to lib_lc3plus/detect_cutoff_warped.c diff --git a/lc3plus/enc_entropy.c b/lib_lc3plus/enc_entropy.c similarity index 100% rename from lc3plus/enc_entropy.c rename to lib_lc3plus/enc_entropy.c diff --git a/lc3plus/enc_lc3_fl.c b/lib_lc3plus/enc_lc3_fl.c similarity index 100% rename from lc3plus/enc_lc3_fl.c rename to lib_lc3plus/enc_lc3_fl.c diff --git a/lc3plus/estimate_global_gain.c b/lib_lc3plus/estimate_global_gain.c similarity index 100% rename from lc3plus/estimate_global_gain.c rename to lib_lc3plus/estimate_global_gain.c diff --git a/lc3plus/fft/cfft.c b/lib_lc3plus/fft/cfft.c similarity index 100% rename from lc3plus/fft/cfft.c rename to lib_lc3plus/fft/cfft.c diff --git a/lc3plus/fft/cfft.h b/lib_lc3plus/fft/cfft.h similarity index 100% rename from lc3plus/fft/cfft.h rename to lib_lc3plus/fft/cfft.h diff --git a/lc3plus/fft/fft_15_16.h b/lib_lc3plus/fft/fft_15_16.h similarity index 100% rename from lc3plus/fft/fft_15_16.h rename to lib_lc3plus/fft/fft_15_16.h diff --git a/lc3plus/fft/fft_240_480.h b/lib_lc3plus/fft/fft_240_480.h similarity index 100% rename from lc3plus/fft/fft_240_480.h rename to lib_lc3plus/fft/fft_240_480.h diff --git a/lc3plus/fft/fft_2_9.h b/lib_lc3plus/fft/fft_2_9.h similarity index 100% rename from lc3plus/fft/fft_2_9.h rename to lib_lc3plus/fft/fft_2_9.h diff --git a/lc3plus/fft/fft_32.h b/lib_lc3plus/fft/fft_32.h similarity index 100% rename from lc3plus/fft/fft_32.h rename to lib_lc3plus/fft/fft_32.h diff --git a/lc3plus/fft/fft_384_768.h b/lib_lc3plus/fft/fft_384_768.h similarity index 100% rename from lc3plus/fft/fft_384_768.h rename to lib_lc3plus/fft/fft_384_768.h diff --git a/lc3plus/fft/fft_60_128.h b/lib_lc3plus/fft/fft_60_128.h similarity index 100% rename from lc3plus/fft/fft_60_128.h rename to lib_lc3plus/fft/fft_60_128.h diff --git a/lc3plus/fft/fft_generic.h b/lib_lc3plus/fft/fft_generic.h similarity index 100% rename from lc3plus/fft/fft_generic.h rename to lib_lc3plus/fft/fft_generic.h diff --git a/lc3plus/fft/iis_fft.c b/lib_lc3plus/fft/iis_fft.c similarity index 100% rename from lc3plus/fft/iis_fft.c rename to lib_lc3plus/fft/iis_fft.c diff --git a/lc3plus/fft/iis_fft.h b/lib_lc3plus/fft/iis_fft.h similarity index 100% rename from lc3plus/fft/iis_fft.h rename to lib_lc3plus/fft/iis_fft.h diff --git a/lc3plus/fft/iisfft.c b/lib_lc3plus/fft/iisfft.c similarity index 100% rename from lc3plus/fft/iisfft.c rename to lib_lc3plus/fft/iisfft.c diff --git a/lc3plus/fft/iisfft.h b/lib_lc3plus/fft/iisfft.h similarity index 100% rename from lc3plus/fft/iisfft.h rename to lib_lc3plus/fft/iisfft.h diff --git a/lc3plus/functions.h b/lib_lc3plus/functions.h similarity index 100% rename from lc3plus/functions.h rename to lib_lc3plus/functions.h diff --git a/lc3plus/imdct.c b/lib_lc3plus/imdct.c similarity index 100% rename from lc3plus/imdct.c rename to lib_lc3plus/imdct.c diff --git a/lc3plus/lc3.c b/lib_lc3plus/lc3.c similarity index 100% rename from lc3plus/lc3.c rename to lib_lc3plus/lc3.c diff --git a/lc3plus/lc3.h b/lib_lc3plus/lc3.h similarity index 100% rename from lc3plus/lc3.h rename to lib_lc3plus/lc3.h diff --git a/lc3plus/lc3plus_fft.c b/lib_lc3plus/lc3plus_fft.c similarity index 100% rename from lc3plus/lc3plus_fft.c rename to lib_lc3plus/lc3plus_fft.c diff --git a/lc3plus/license.h b/lib_lc3plus/license.h similarity index 100% rename from lc3plus/license.h rename to lib_lc3plus/license.h diff --git a/lc3plus/ltpf_coder.c b/lib_lc3plus/ltpf_coder.c similarity index 100% rename from lc3plus/ltpf_coder.c rename to lib_lc3plus/ltpf_coder.c diff --git a/lc3plus/ltpf_decoder.c b/lib_lc3plus/ltpf_decoder.c similarity index 100% rename from lc3plus/ltpf_decoder.c rename to lib_lc3plus/ltpf_decoder.c diff --git a/lc3plus/mdct.c b/lib_lc3plus/mdct.c similarity index 100% rename from lc3plus/mdct.c rename to lib_lc3plus/mdct.c diff --git a/lc3plus/mdct_shaping.c b/lib_lc3plus/mdct_shaping.c similarity index 100% rename from lc3plus/mdct_shaping.c rename to lib_lc3plus/mdct_shaping.c diff --git a/lc3plus/near_nyquist_detector.c b/lib_lc3plus/near_nyquist_detector.c similarity index 100% rename from lc3plus/near_nyquist_detector.c rename to lib_lc3plus/near_nyquist_detector.c diff --git a/lc3plus/noise_factor.c b/lib_lc3plus/noise_factor.c similarity index 100% rename from lc3plus/noise_factor.c rename to lib_lc3plus/noise_factor.c diff --git a/lc3plus/noise_filling.c b/lib_lc3plus/noise_filling.c similarity index 100% rename from lc3plus/noise_filling.c rename to lib_lc3plus/noise_filling.c diff --git a/lc3plus/olpa.c b/lib_lc3plus/olpa.c similarity index 100% rename from lc3plus/olpa.c rename to lib_lc3plus/olpa.c diff --git a/lc3plus/pc_apply.c b/lib_lc3plus/pc_apply.c similarity index 100% rename from lc3plus/pc_apply.c rename to lib_lc3plus/pc_apply.c diff --git a/lc3plus/pc_classify.c b/lib_lc3plus/pc_classify.c similarity index 100% rename from lc3plus/pc_classify.c rename to lib_lc3plus/pc_classify.c diff --git a/lc3plus/pc_main.c b/lib_lc3plus/pc_main.c similarity index 100% rename from lc3plus/pc_main.c rename to lib_lc3plus/pc_main.c diff --git a/lc3plus/pc_update.c b/lib_lc3plus/pc_update.c similarity index 100% rename from lc3plus/pc_update.c rename to lib_lc3plus/pc_update.c diff --git a/lc3plus/per_band_energy.c b/lib_lc3plus/per_band_energy.c similarity index 100% rename from lc3plus/per_band_energy.c rename to lib_lc3plus/per_band_energy.c diff --git a/lc3plus/plc_classify.c b/lib_lc3plus/plc_classify.c similarity index 100% rename from lc3plus/plc_classify.c rename to lib_lc3plus/plc_classify.c diff --git a/lc3plus/plc_compute_stab_fac.c b/lib_lc3plus/plc_compute_stab_fac.c similarity index 100% rename from lc3plus/plc_compute_stab_fac.c rename to lib_lc3plus/plc_compute_stab_fac.c diff --git a/lc3plus/plc_damping_scrambling.c b/lib_lc3plus/plc_damping_scrambling.c similarity index 100% rename from lc3plus/plc_damping_scrambling.c rename to lib_lc3plus/plc_damping_scrambling.c diff --git a/lc3plus/plc_main.c b/lib_lc3plus/plc_main.c similarity index 100% rename from lc3plus/plc_main.c rename to lib_lc3plus/plc_main.c diff --git a/lc3plus/plc_noise_substitution.c b/lib_lc3plus/plc_noise_substitution.c similarity index 100% rename from lc3plus/plc_noise_substitution.c rename to lib_lc3plus/plc_noise_substitution.c diff --git a/lc3plus/plc_phecu_f0_refine_first.c b/lib_lc3plus/plc_phecu_f0_refine_first.c similarity index 100% rename from lc3plus/plc_phecu_f0_refine_first.c rename to lib_lc3plus/plc_phecu_f0_refine_first.c diff --git a/lc3plus/plc_phecu_fec_hq.c b/lib_lc3plus/plc_phecu_fec_hq.c similarity index 100% rename from lc3plus/plc_phecu_fec_hq.c rename to lib_lc3plus/plc_phecu_fec_hq.c diff --git a/lc3plus/plc_phecu_hq_ecu.c b/lib_lc3plus/plc_phecu_hq_ecu.c similarity index 100% rename from lc3plus/plc_phecu_hq_ecu.c rename to lib_lc3plus/plc_phecu_hq_ecu.c diff --git a/lc3plus/plc_phecu_lf_peak_analysis.c b/lib_lc3plus/plc_phecu_lf_peak_analysis.c similarity index 100% rename from lc3plus/plc_phecu_lf_peak_analysis.c rename to lib_lc3plus/plc_phecu_lf_peak_analysis.c diff --git a/lc3plus/plc_phecu_rec_frame.c b/lib_lc3plus/plc_phecu_rec_frame.c similarity index 100% rename from lc3plus/plc_phecu_rec_frame.c rename to lib_lc3plus/plc_phecu_rec_frame.c diff --git a/lc3plus/plc_phecu_setf0hz.c b/lib_lc3plus/plc_phecu_setf0hz.c similarity index 100% rename from lc3plus/plc_phecu_setf0hz.c rename to lib_lc3plus/plc_phecu_setf0hz.c diff --git a/lc3plus/plc_phecu_spec_ana.c b/lib_lc3plus/plc_phecu_spec_ana.c similarity index 100% rename from lc3plus/plc_phecu_spec_ana.c rename to lib_lc3plus/plc_phecu_spec_ana.c diff --git a/lc3plus/plc_phecu_subst_spec.c b/lib_lc3plus/plc_phecu_subst_spec.c similarity index 100% rename from lc3plus/plc_phecu_subst_spec.c rename to lib_lc3plus/plc_phecu_subst_spec.c diff --git a/lc3plus/plc_phecu_tba_per_band_gain.c b/lib_lc3plus/plc_phecu_tba_per_band_gain.c similarity index 100% rename from lc3plus/plc_phecu_tba_per_band_gain.c rename to lib_lc3plus/plc_phecu_tba_per_band_gain.c diff --git a/lc3plus/plc_phecu_tba_spect_Xavg.c b/lib_lc3plus/plc_phecu_tba_spect_Xavg.c similarity index 100% rename from lc3plus/plc_phecu_tba_spect_Xavg.c rename to lib_lc3plus/plc_phecu_tba_spect_Xavg.c diff --git a/lc3plus/plc_phecu_tba_trans_dect_gains.c b/lib_lc3plus/plc_phecu_tba_trans_dect_gains.c similarity index 100% rename from lc3plus/plc_phecu_tba_trans_dect_gains.c rename to lib_lc3plus/plc_phecu_tba_trans_dect_gains.c diff --git a/lc3plus/plc_phecu_trans_burst_ana_sub.c b/lib_lc3plus/plc_phecu_trans_burst_ana_sub.c similarity index 100% rename from lc3plus/plc_phecu_trans_burst_ana_sub.c rename to lib_lc3plus/plc_phecu_trans_burst_ana_sub.c diff --git a/lc3plus/plc_tdc.c b/lib_lc3plus/plc_tdc.c similarity index 100% rename from lc3plus/plc_tdc.c rename to lib_lc3plus/plc_tdc.c diff --git a/lc3plus/plc_tdc_tdac.c b/lib_lc3plus/plc_tdc_tdac.c similarity index 100% rename from lc3plus/plc_tdc_tdac.c rename to lib_lc3plus/plc_tdc_tdac.c diff --git a/lc3plus/plc_update.c b/lib_lc3plus/plc_update.c similarity index 100% rename from lc3plus/plc_update.c rename to lib_lc3plus/plc_update.c diff --git a/lc3plus/quantize_spec.c b/lib_lc3plus/quantize_spec.c similarity index 100% rename from lc3plus/quantize_spec.c rename to lib_lc3plus/quantize_spec.c diff --git a/lc3plus/reorder_bitstream.c b/lib_lc3plus/reorder_bitstream.c similarity index 100% rename from lc3plus/reorder_bitstream.c rename to lib_lc3plus/reorder_bitstream.c diff --git a/lc3plus/resamp12k8.c b/lib_lc3plus/resamp12k8.c similarity index 100% rename from lc3plus/resamp12k8.c rename to lib_lc3plus/resamp12k8.c diff --git a/lc3plus/residual_coding.c b/lib_lc3plus/residual_coding.c similarity index 100% rename from lc3plus/residual_coding.c rename to lib_lc3plus/residual_coding.c diff --git a/lc3plus/residual_decoding.c b/lib_lc3plus/residual_decoding.c similarity index 100% rename from lc3plus/residual_decoding.c rename to lib_lc3plus/residual_decoding.c diff --git a/lc3plus/setup_com_lc3.c b/lib_lc3plus/setup_com_lc3.c similarity index 100% rename from lc3plus/setup_com_lc3.c rename to lib_lc3plus/setup_com_lc3.c diff --git a/lc3plus/setup_dec_lc3.c b/lib_lc3plus/setup_dec_lc3.c similarity index 100% rename from lc3plus/setup_dec_lc3.c rename to lib_lc3plus/setup_dec_lc3.c diff --git a/lc3plus/setup_dec_lc3.h b/lib_lc3plus/setup_dec_lc3.h similarity index 100% rename from lc3plus/setup_dec_lc3.h rename to lib_lc3plus/setup_dec_lc3.h diff --git a/lc3plus/setup_enc_lc3.c b/lib_lc3plus/setup_enc_lc3.c similarity index 100% rename from lc3plus/setup_enc_lc3.c rename to lib_lc3plus/setup_enc_lc3.c diff --git a/lc3plus/setup_enc_lc3.h b/lib_lc3plus/setup_enc_lc3.h similarity index 100% rename from lc3plus/setup_enc_lc3.h rename to lib_lc3plus/setup_enc_lc3.h diff --git a/lc3plus/sns_compute_scf.c b/lib_lc3plus/sns_compute_scf.c similarity index 100% rename from lc3plus/sns_compute_scf.c rename to lib_lc3plus/sns_compute_scf.c diff --git a/lc3plus/sns_interpolate_scf.c b/lib_lc3plus/sns_interpolate_scf.c similarity index 100% rename from lc3plus/sns_interpolate_scf.c rename to lib_lc3plus/sns_interpolate_scf.c diff --git a/lc3plus/sns_quantize_scf.c b/lib_lc3plus/sns_quantize_scf.c similarity index 100% rename from lc3plus/sns_quantize_scf.c rename to lib_lc3plus/sns_quantize_scf.c diff --git a/lc3plus/structs.h b/lib_lc3plus/structs.h similarity index 100% rename from lc3plus/structs.h rename to lib_lc3plus/structs.h diff --git a/lc3plus/tns_coder.c b/lib_lc3plus/tns_coder.c similarity index 100% rename from lc3plus/tns_coder.c rename to lib_lc3plus/tns_coder.c diff --git a/lc3plus/tns_decoder.c b/lib_lc3plus/tns_decoder.c similarity index 100% rename from lc3plus/tns_decoder.c rename to lib_lc3plus/tns_decoder.c diff --git a/lc3plus/util.h b/lib_lc3plus/util.h similarity index 100% rename from lc3plus/util.h rename to lib_lc3plus/util.h diff --git a/scripts/prepare_delivery.sh b/scripts/prepare_delivery.sh index 7db462bfdc..dd437bfd3e 100755 --- a/scripts/prepare_delivery.sh +++ b/scripts/prepare_delivery.sh @@ -60,7 +60,7 @@ cp -R ${ROOT}/lib_dec $OUTDIR cp -R ${ROOT}/lib_enc $OUTDIR cp -R ${ROOT}/lib_util $OUTDIR cp -R ${ROOT}/lib_rend $OUTDIR -cp -R ${ROOT}/lc3plus $OUTDIR +cp -R ${ROOT}/lib_lc3plus $OUTDIR cp -R ${ROOT}/apps $OUTDIR mkdir $OUTDIR/lib_debug cp ${ROOT}/lib_debug/wmc_auto.[ch] $OUTDIR/lib_debug diff --git a/scripts/prepare_instrumentation.sh b/scripts/prepare_instrumentation.sh index 4052b8a10e..c125df3515 100755 --- a/scripts/prepare_instrumentation.sh +++ b/scripts/prepare_instrumentation.sh @@ -63,7 +63,6 @@ mkdir $targetdir # copy files from source-dir cp -R ../lib_* $targetdir -cp -R ../lc3plus $targetdir cp -R ../apps $targetdir cp -R ../Makefile $targetdir cp -R ../CMakeLists.txt $targetdir @@ -106,7 +105,7 @@ find $targetdir -name "*.[ch]" -exec sed -i.bak -e "s/\(0x[0-9a-fA-F]*\)UL/\(\(u # run wmc_tool "tools/$system/wmc_tool" -m "$targetdir/apps/encoder.c" "$targetdir/lib_enc/*.c" "$targetdir/lib_com/*.c" >> /dev/null "tools/$system/wmc_tool" -m "$targetdir/apps/decoder.c" "$targetdir/lib_dec/*.c" "$targetdir/lib_rend/*.c" >> /dev/null -"tools/$system/wmc_tool" -m "$targetdir/apps/renderer.c" "$targetdir/lib_rend/*.c" "$targetdir/lc3plus/*.c" "$targetdir/lc3plus/fft/*.c" >> /dev/null +"tools/$system/wmc_tool" -m "$targetdir/apps/renderer.c" "$targetdir/lib_rend/*.c" "$targetdir/lib_lc3plus/*.c" "$targetdir/lib_lc3plus/fft/*.c" >> /dev/null # automatically enable #define WMOPS in options.h sed -i.bak -e "s/\/\*[[:space:]]*\(#define[[:space:]]*WMOPS\)[[:space:]]*\*\//\1/g" $targetdir/lib_com/options.h -- GitLab From d1816da1bd4306257071426895ccfc8ce5eb8ce7 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 11 Aug 2023 08:24:26 +0200 Subject: [PATCH 02/12] clang-format --- lib_lc3plus/adjust_global_gain.c | 97 +- lib_lc3plus/al_fec_fl.c | 3364 +++++++++------ lib_lc3plus/apply_global_gain.c | 22 +- lib_lc3plus/ari_codec.c | 1066 ++--- lib_lc3plus/attack_detector.c | 100 +- lib_lc3plus/clib.h | 16 +- lib_lc3plus/constants.c | 3852 +++++++++--------- lib_lc3plus/constants.h | 136 +- lib_lc3plus/cutoff_bandwidth.c | 33 +- lib_lc3plus/dct4.c | 117 +- lib_lc3plus/dec_entropy.c | 253 +- lib_lc3plus/dec_lc3_fl.c | 349 +- lib_lc3plus/defines.h | 301 +- lib_lc3plus/detect_cutoff_warped.c | 72 +- lib_lc3plus/enc_entropy.c | 128 +- lib_lc3plus/enc_lc3_fl.c | 286 +- lib_lc3plus/estimate_global_gain.c | 136 +- lib_lc3plus/functions.h | 409 +- lib_lc3plus/imdct.c | 70 +- lib_lc3plus/lc3.c | 386 +- lib_lc3plus/lc3.h | 183 +- lib_lc3plus/lc3plus_fft.c | 74 +- lib_lc3plus/license.h | 16 +- lib_lc3plus/ltpf_coder.c | 247 +- lib_lc3plus/ltpf_decoder.c | 362 +- lib_lc3plus/mdct.c | 186 +- lib_lc3plus/mdct_shaping.c | 24 +- lib_lc3plus/near_nyquist_detector.c | 28 +- lib_lc3plus/noise_factor.c | 91 +- lib_lc3plus/noise_filling.c | 64 +- lib_lc3plus/olpa.c | 128 +- lib_lc3plus/pc_apply.c | 80 +- lib_lc3plus/pc_classify.c | 163 +- lib_lc3plus/pc_main.c | 41 +- lib_lc3plus/pc_update.c | 44 +- lib_lc3plus/per_band_energy.c | 67 +- lib_lc3plus/plc_classify.c | 160 +- lib_lc3plus/plc_compute_stab_fac.c | 52 +- lib_lc3plus/plc_damping_scrambling.c | 183 +- lib_lc3plus/plc_main.c | 301 +- lib_lc3plus/plc_noise_substitution.c | 23 +- lib_lc3plus/plc_phecu_f0_refine_first.c | 87 +- lib_lc3plus/plc_phecu_fec_hq.c | 161 +- lib_lc3plus/plc_phecu_hq_ecu.c | 189 +- lib_lc3plus/plc_phecu_lf_peak_analysis.c | 130 +- lib_lc3plus/plc_phecu_rec_frame.c | 225 +- lib_lc3plus/plc_phecu_setf0hz.c | 23 +- lib_lc3plus/plc_phecu_spec_ana.c | 737 ++-- lib_lc3plus/plc_phecu_subst_spec.c | 352 +- lib_lc3plus/plc_phecu_tba_per_band_gain.c | 31 +- lib_lc3plus/plc_phecu_tba_spect_Xavg.c | 44 +- lib_lc3plus/plc_phecu_tba_trans_dect_gains.c | 291 +- lib_lc3plus/plc_phecu_trans_burst_ana_sub.c | 51 +- lib_lc3plus/plc_tdc.c | 1087 ++--- lib_lc3plus/plc_tdc_tdac.c | 41 +- lib_lc3plus/plc_update.c | 206 +- lib_lc3plus/quantize_spec.c | 170 +- lib_lc3plus/reorder_bitstream.c | 43 +- lib_lc3plus/resamp12k8.c | 88 +- lib_lc3plus/residual_coding.c | 57 +- lib_lc3plus/residual_decoding.c | 74 +- lib_lc3plus/setup_com_lc3.c | 37 +- lib_lc3plus/setup_dec_lc3.c | 501 +-- lib_lc3plus/setup_dec_lc3.h | 110 +- lib_lc3plus/setup_enc_lc3.c | 543 +-- lib_lc3plus/setup_enc_lc3.h | 38 +- lib_lc3plus/sns_compute_scf.c | 164 +- lib_lc3plus/sns_interpolate_scf.c | 95 +- lib_lc3plus/sns_quantize_scf.c | 322 +- lib_lc3plus/structs.h | 242 +- lib_lc3plus/tns_coder.c | 304 +- lib_lc3plus/tns_decoder.c | 60 +- lib_lc3plus/util.h | 219 +- 73 files changed, 11030 insertions(+), 9402 deletions(-) diff --git a/lib_lc3plus/adjust_global_gain.c b/lib_lc3plus/adjust_global_gain.c index e7674dd710..0566f716c8 100644 --- a/lib_lc3plus/adjust_global_gain.c +++ b/lib_lc3plus/adjust_global_gain.c @@ -1,86 +1,103 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -void processAdjustGlobalGain_fl(LC3_INT* gg_idx, LC3_INT gg_idx_min, LC3_INT gg_idx_off, LC3_FLOAT* gain, LC3_INT target, LC3_INT nBits, LC3_INT* gainChange, LC3_INT fs_idx - , LC3_INT16 hrmode, LC3_INT16 frame_dms - ) +void processAdjustGlobalGain_fl( LC3_INT *gg_idx, LC3_INT gg_idx_min, LC3_INT gg_idx_off, LC3_FLOAT *gain, LC3_INT target, LC3_INT nBits, LC3_INT *gainChange, LC3_INT fs_idx, LC3_INT16 hrmode, LC3_INT16 frame_dms ) { - LC3_FLOAT delta = 0; - LC3_INT delta2 = 0; - LC3_INT gg_idx_inc; - LC3_INT factor; + LC3_FLOAT delta = 0; + LC3_INT delta2 = 0; + LC3_INT gg_idx_inc; + LC3_INT factor; - if (frame_dms == 25) + if ( frame_dms == 25 ) { - if (target < 520) + if ( target < 520 ) { factor = 3; - } else { + } + else + { factor = 4; } - } else if (frame_dms == 50) + } + else if ( frame_dms == 50 ) { factor = 2; - } else + } + else { factor = 1; } - if (nBits < gg_p1[fs_idx]) { - delta = (nBits + 48.0) / 16.0; - } else if (nBits < gg_p2[fs_idx]) { - delta = (nBits + gg_d[fs_idx]) * gg_c[fs_idx]; - } else if (nBits < gg_p3[fs_idx]) { + if ( nBits < gg_p1[fs_idx] ) + { + delta = ( nBits + 48.0 ) / 16.0; + } + else if ( nBits < gg_p2[fs_idx] ) + { + delta = ( nBits + gg_d[fs_idx] ) * gg_c[fs_idx]; + } + else if ( nBits < gg_p3[fs_idx] ) + { delta = nBits / 48.0; - } else { + } + else + { delta = gg_p3[fs_idx] / 48.0; } - delta = round(delta); + delta = round( delta ); delta2 = delta + 2; *gainChange = 0; - if (*gg_idx == 255 && nBits > target) { + if ( *gg_idx == 255 && nBits > target ) + { *gainChange = 1; } - if ((*gg_idx < 255 && nBits > target) || (*gg_idx > 0 && nBits < target - delta2)) { - if (hrmode) + if ( ( *gg_idx < 255 && nBits > target ) || ( *gg_idx > 0 && nBits < target - delta2 ) ) + { + if ( hrmode ) { - if (nBits > target) { - gg_idx_inc = (int) factor * (((nBits - target)/ delta) + 1); - gg_idx_inc = MIN(gg_idx_inc, 10 * factor); - + if ( nBits > target ) + { + gg_idx_inc = (int) factor * ( ( ( nBits - target ) / delta ) + 1 ); + gg_idx_inc = MIN( gg_idx_inc, 10 * factor ); + *gg_idx += gg_idx_inc; } - *gg_idx = MIN(*gg_idx, 255); + *gg_idx = MIN( *gg_idx, 255 ); } else { - if (nBits < target - delta2) { + if ( nBits < target - delta2 ) + { *gg_idx = *gg_idx - 1; - } else if (*gg_idx == 254 || nBits < target + delta) { + } + else if ( *gg_idx == 254 || nBits < target + delta ) + { *gg_idx = *gg_idx + 1; - } else { + } + else + { *gg_idx = *gg_idx + 2; } } - *gg_idx = MAX(*gg_idx, gg_idx_min - gg_idx_off); - *gain = LC3_POW(10, (LC3_FLOAT)(*gg_idx + gg_idx_off) / 28); + *gg_idx = MAX( *gg_idx, gg_idx_min - gg_idx_off ); + *gain = LC3_POW( 10, (LC3_FLOAT) ( *gg_idx + gg_idx_off ) / 28 ); *gainChange = 1; } } diff --git a/lib_lc3plus/al_fec_fl.c b/lib_lc3plus/al_fec_fl.c index 0cae36dade..d177a23b02 100644 --- a/lib_lc3plus/al_fec_fl.c +++ b/lib_lc3plus/al_fec_fl.c @@ -1,12 +1,12 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "stdint.h" @@ -20,31 +20,31 @@ /* channel coder specific constants and macros */ #define RS16_CW_LEN_MAX 15 -#define FEC_N_MODES 4 -#define FEC_N_SYNDROMES_MAX 6 -#define FEC_N_ERR_POS_MAX 3 -#define FEC_N_ELP_COEFF_MAX 4 -#define FEC_N_ERR_SYMB_MAX 3 +#define FEC_N_MODES 4 +#define FEC_N_SYNDROMES_MAX 6 +#define FEC_N_ERR_POS_MAX 3 +#define FEC_N_ELP_COEFF_MAX 4 +#define FEC_N_ERR_SYMB_MAX 3 #define FEC_N_MODE_DETECTION_CW 6 -#define SYNDROME_IDX(mode_index, cw_index) (((mode_index)*FEC_N_MODE_DETECTION_CW + (cw_index)) * FEC_N_SYNDROMES_MAX) -#define ELP_IDX(mode_index, cw_index) (((mode_index)*FEC_N_MODE_DETECTION_CW + (cw_index)) * FEC_N_ELP_COEFF_MAX) -#define ERR_POS_IDX(mode_index, cw_index) (((mode_index)*FEC_N_MODE_DETECTION_CW + (cw_index)) * FEC_N_ERR_POS_MAX) -#define ERR_SYMB_IDX(mode_index, cw_index) (((mode_index)*FEC_N_MODE_DETECTION_CW + (cw_index)) * FEC_N_ERR_SYMB_MAX) -#define DEG_ELP_IDX(mode_index, cw_index) ((mode_index)*FEC_N_MODE_DETECTION_CW + (cw_index)) - -#define FEC_TOTAL_SYNDROME_SIZE (FEC_N_SYNDROMES_MAX * FEC_N_MODES * FEC_N_MODE_DETECTION_CW) -#define FEC_TOTAL_ELP_SIZE (FEC_N_ELP_COEFF_MAX * FEC_N_MODES * FEC_N_MODE_DETECTION_CW) -#define FEC_TOTAL_ERR_POS_SIZE (FEC_N_ERR_POS_MAX * FEC_N_MODES * FEC_N_MODE_DETECTION_CW) -#define FEC_TOTAL_ERROR_SIZE (FEC_N_ERR_SYMB_MAX * FEC_N_MODES * FEC_N_MODE_DETECTION_CW) -#define FEC_TOTAL_DEG_ELP_SIZE (FEC_N_MODES * FEC_N_MODE_DETECTION_CW) - -#define ERROR_REPORT_BEC_MASK ((0x0FFF)>>1) -#define ERROR_REPORT_EP1_OK ((0x1000)>>1) -#define ERROR_REPORT_EP2_OK ((0x2000)>>1) -#define ERROR_REPORT_EP3_OK ((0x4000)>>1) -#define ERROR_REPORT_EP4_OK ((0x8000)>>1) -#define ERROR_REPORT_ALL_OK (ERROR_REPORT_EP1_OK | ERROR_REPORT_EP2_OK | ERROR_REPORT_EP3_OK | ERROR_REPORT_EP4_OK) +#define SYNDROME_IDX( mode_index, cw_index ) ( ( (mode_index) *FEC_N_MODE_DETECTION_CW + ( cw_index ) ) * FEC_N_SYNDROMES_MAX ) +#define ELP_IDX( mode_index, cw_index ) ( ( (mode_index) *FEC_N_MODE_DETECTION_CW + ( cw_index ) ) * FEC_N_ELP_COEFF_MAX ) +#define ERR_POS_IDX( mode_index, cw_index ) ( ( (mode_index) *FEC_N_MODE_DETECTION_CW + ( cw_index ) ) * FEC_N_ERR_POS_MAX ) +#define ERR_SYMB_IDX( mode_index, cw_index ) ( ( (mode_index) *FEC_N_MODE_DETECTION_CW + ( cw_index ) ) * FEC_N_ERR_SYMB_MAX ) +#define DEG_ELP_IDX( mode_index, cw_index ) ( (mode_index) *FEC_N_MODE_DETECTION_CW + ( cw_index ) ) + +#define FEC_TOTAL_SYNDROME_SIZE ( FEC_N_SYNDROMES_MAX * FEC_N_MODES * FEC_N_MODE_DETECTION_CW ) +#define FEC_TOTAL_ELP_SIZE ( FEC_N_ELP_COEFF_MAX * FEC_N_MODES * FEC_N_MODE_DETECTION_CW ) +#define FEC_TOTAL_ERR_POS_SIZE ( FEC_N_ERR_POS_MAX * FEC_N_MODES * FEC_N_MODE_DETECTION_CW ) +#define FEC_TOTAL_ERROR_SIZE ( FEC_N_ERR_SYMB_MAX * FEC_N_MODES * FEC_N_MODE_DETECTION_CW ) +#define FEC_TOTAL_DEG_ELP_SIZE ( FEC_N_MODES * FEC_N_MODE_DETECTION_CW ) + +#define ERROR_REPORT_BEC_MASK ( ( 0x0FFF ) >> 1 ) +#define ERROR_REPORT_EP1_OK ( ( 0x1000 ) >> 1 ) +#define ERROR_REPORT_EP2_OK ( ( 0x2000 ) >> 1 ) +#define ERROR_REPORT_EP3_OK ( ( 0x4000 ) >> 1 ) +#define ERROR_REPORT_EP4_OK ( ( 0x8000 ) >> 1 ) +#define ERROR_REPORT_ALL_OK ( ERROR_REPORT_EP1_OK | ERROR_REPORT_EP2_OK | ERROR_REPORT_EP3_OK | ERROR_REPORT_EP4_OK ) /* debugging switches */ @@ -63,9 +63,9 @@ * Behind this is the assumption that one would store GF16 elements in LC3_INT16 for strict BASOP * implementation. */ -#define GF16_MUL(a, b) gf16_mult_table[(a) | (b << 4)] -#define GF16_MUL0(a, b) gf16_mult_table[(a) | (b)] -#define GF16_ADD(a, b) ((a) ^ (b)) +#define GF16_MUL( a, b ) gf16_mult_table[( a ) | ( b << 4 )] +#define GF16_MUL0( a, b ) gf16_mult_table[( a ) | ( b )] +#define GF16_ADD( a, b ) ( ( a ) ^ ( b ) ) /* tables for finite field arithmetic */ /* tables for arithmetic in GF(16) * @@ -75,110 +75,849 @@ static const LC3_UINT8 gf16_mult_table[256] = { /* gf16_mult_table[a | (b << 4)] contains the product of a and b in GF(16) */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, - 13, 14, 15, 0, 2, 4, 6, 8, 10, 12, 14, 3, 1, 7, 5, 11, 9, 15, 13, 0, 3, 6, 5, 12, 15, 10, 9, 11, 8, - 13, 14, 7, 4, 1, 2, 0, 4, 8, 12, 3, 7, 11, 15, 6, 2, 14, 10, 5, 1, 13, 9, 0, 5, 10, 15, 7, 2, 13, - 8, 14, 11, 4, 1, 9, 12, 3, 6, 0, 6, 12, 10, 11, 13, 7, 1, 5, 3, 9, 15, 14, 8, 2, 4, 0, 7, 14, 9, - 15, 8, 1, 6, 13, 10, 3, 4, 2, 5, 12, 11, 0, 8, 3, 11, 6, 14, 5, 13, 12, 4, 15, 7, 10, 2, 9, 1, 0, - 9, 1, 8, 2, 11, 3, 10, 4, 13, 5, 12, 6, 15, 7, 14, 0, 10, 7, 13, 14, 4, 9, 3, 15, 5, 8, 2, 1, 11, - 6, 12, 0, 11, 5, 14, 10, 1, 15, 4, 7, 12, 2, 9, 13, 6, 8, 3, 0, 12, 11, 7, 5, 9, 14, 2, 10, 6, 1, - 13, 15, 3, 4, 8, 0, 13, 9, 4, 1, 12, 8, 5, 2, 15, 11, 6, 3, 14, 10, 7, 0, 14, 15, 1, 13, 3, 2, 12, - 9, 7, 6, 8, 4, 10, 11, 5, 0, 15, 13, 2, 9, 6, 4, 11, 1, 14, 12, 3, 8, 7, 5, 10, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 0, + 2, + 4, + 6, + 8, + 10, + 12, + 14, + 3, + 1, + 7, + 5, + 11, + 9, + 15, + 13, + 0, + 3, + 6, + 5, + 12, + 15, + 10, + 9, + 11, + 8, + 13, + 14, + 7, + 4, + 1, + 2, + 0, + 4, + 8, + 12, + 3, + 7, + 11, + 15, + 6, + 2, + 14, + 10, + 5, + 1, + 13, + 9, + 0, + 5, + 10, + 15, + 7, + 2, + 13, + 8, + 14, + 11, + 4, + 1, + 9, + 12, + 3, + 6, + 0, + 6, + 12, + 10, + 11, + 13, + 7, + 1, + 5, + 3, + 9, + 15, + 14, + 8, + 2, + 4, + 0, + 7, + 14, + 9, + 15, + 8, + 1, + 6, + 13, + 10, + 3, + 4, + 2, + 5, + 12, + 11, + 0, + 8, + 3, + 11, + 6, + 14, + 5, + 13, + 12, + 4, + 15, + 7, + 10, + 2, + 9, + 1, + 0, + 9, + 1, + 8, + 2, + 11, + 3, + 10, + 4, + 13, + 5, + 12, + 6, + 15, + 7, + 14, + 0, + 10, + 7, + 13, + 14, + 4, + 9, + 3, + 15, + 5, + 8, + 2, + 1, + 11, + 6, + 12, + 0, + 11, + 5, + 14, + 10, + 1, + 15, + 4, + 7, + 12, + 2, + 9, + 13, + 6, + 8, + 3, + 0, + 12, + 11, + 7, + 5, + 9, + 14, + 2, + 10, + 6, + 1, + 13, + 15, + 3, + 4, + 8, + 0, + 13, + 9, + 4, + 1, + 12, + 8, + 5, + 2, + 15, + 11, + 6, + 3, + 14, + 10, + 7, + 0, + 14, + 15, + 1, + 13, + 3, + 2, + 12, + 9, + 7, + 6, + 8, + 4, + 10, + 11, + 5, + 0, + 15, + 13, + 2, + 9, + 6, + 4, + 11, + 1, + 14, + 12, + 3, + 8, + 7, + 5, + 10, }; static const LC3_UINT8 rs16_elp_deg2_table[256] = { /* If the polynomial x^2 + ax + b has distinct non-zero roots z1 and z2 in GF(16), * * then table entry a + 16*b contains log_g(z1) | log_g(z2) << 4, and otherwise it * * contains 0. */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 165, 0, 0, 0, 0, - 105, 195, 0, 210, 0, 225, 0, 180, 120, 0, 0, 121, 0, 16, 0, 211, 0, 0, 181, 0, 0, 106, - 196, 226, 0, 0, 0, 214, 64, 0, 199, 0, 0, 0, 0, 0, 49, 184, 0, 154, 0, 229, 0, 227, - 182, 0, 0, 32, 0, 0, 0, 197, 0, 0, 122, 0, 212, 152, 0, 203, 0, 158, 128, 0, 0, 0, - 98, 113, 218, 0, 0, 0, 53, 0, 0, 65, 0, 0, 185, 110, 215, 80, 0, 0, 200, 0, 50, 0, - 0, 0, 0, 130, 205, 115, 0, 0, 160, 190, 145, 0, 0, 0, 0, 0, 0, 100, 0, 0, 168, 198, - 0, 183, 33, 0, 0, 48, 228, 213, 0, 0, 0, 0, 0, 0, 0, 0, 164, 0, 179, 0, 224, 104, - 0, 194, 149, 0, 0, 209, 0, 0, 0, 189, 99, 84, 0, 129, 0, 0, 0, 144, 0, 0, 234, 114, - 0, 0, 82, 0, 0, 0, 0, 217, 202, 0, 112, 52, 232, 0, 97, 0, 0, 0, 126, 0, 81, 201, - 0, 36, 216, 186, 0, 0, 0, 96, 0, 0, 0, 0, 0, 88, 0, 0, 0, 103, 0, 148, 178, 0, - 208, 193, 0, 58, 0, 0, 0, 0, 0, 161, 206, 0, 116, 0, 101, 0, 0, 56, 146, 176, 0, 0, - 147, 162, 222, 0, 132, 0, 0, 0, 0, 0, 177, 117, 192, 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 165, + 0, + 0, + 0, + 0, + 105, + 195, + 0, + 210, + 0, + 225, + 0, + 180, + 120, + 0, + 0, + 121, + 0, + 16, + 0, + 211, + 0, + 0, + 181, + 0, + 0, + 106, + 196, + 226, + 0, + 0, + 0, + 214, + 64, + 0, + 199, + 0, + 0, + 0, + 0, + 0, + 49, + 184, + 0, + 154, + 0, + 229, + 0, + 227, + 182, + 0, + 0, + 32, + 0, + 0, + 0, + 197, + 0, + 0, + 122, + 0, + 212, + 152, + 0, + 203, + 0, + 158, + 128, + 0, + 0, + 0, + 98, + 113, + 218, + 0, + 0, + 0, + 53, + 0, + 0, + 65, + 0, + 0, + 185, + 110, + 215, + 80, + 0, + 0, + 200, + 0, + 50, + 0, + 0, + 0, + 0, + 130, + 205, + 115, + 0, + 0, + 160, + 190, + 145, + 0, + 0, + 0, + 0, + 0, + 0, + 100, + 0, + 0, + 168, + 198, + 0, + 183, + 33, + 0, + 0, + 48, + 228, + 213, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 164, + 0, + 179, + 0, + 224, + 104, + 0, + 194, + 149, + 0, + 0, + 209, + 0, + 0, + 0, + 189, + 99, + 84, + 0, + 129, + 0, + 0, + 0, + 144, + 0, + 0, + 234, + 114, + 0, + 0, + 82, + 0, + 0, + 0, + 0, + 217, + 202, + 0, + 112, + 52, + 232, + 0, + 97, + 0, + 0, + 0, + 126, + 0, + 81, + 201, + 0, + 36, + 216, + 186, + 0, + 0, + 0, + 96, + 0, + 0, + 0, + 0, + 0, + 88, + 0, + 0, + 0, + 103, + 0, + 148, + 178, + 0, + 208, + 193, + 0, + 58, + 0, + 0, + 0, + 0, + 0, + 161, + 206, + 0, + 116, + 0, + 101, + 0, + 0, + 56, + 146, + 176, + 0, + 0, + 147, + 162, + 222, + 0, + 132, + 0, + 0, + 0, + 0, + 0, + 177, + 117, + 192, + 0, }; static const LC3_UINT16 rs16_elp_deg3_table[256] = { /* If the polynomial x^3 + ax + b has distinct roots z1, z2 and z3 in GF(16), * * then table entry a + 16*b contains z1) | z2 << 4 | z3 << 8, and otherwise it * * contains 0. */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1889, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2977, 0, 0, 0, 0, 0, 3990, 1859, 0, - 0, 0, 0, 0, 0, 0, 3521, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1874, 0, 3718, 0, 0, 0, - 0, 0, 0, 2433, 0, 0, 1619, 0, 0, 0, 0, 3495, 0, 0, 0, 0, 0, 0, 4065, 0, 0, 0, - 0, 0, 0, 3255, 0, 0, 0, 1602, 0, 3735, 0, 0, 0, 0, 3238, 801, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 3510, 0, 0, 0, 0, 1345, 3975, 0, 0, 0, 0, 0, 0, 0, 0, 3778, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2947, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 3476, 0, 4005, 0, 3461, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 3748, 0, 0, 2962, 0, 0, 0, 0, 4035, 0, 0, 4020, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3221, 0, 0, 0, 0, 0, 0, 2690, - 0, 0, 0, 3795, 0, 0, 0, 4050, 0, 0, 0, 0, 0, 3204, 3765, 0, 0, 0, 0, 0, 2707, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1889, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 2977, + 0, + 0, + 0, + 0, + 0, + 3990, + 1859, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 3521, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1874, + 0, + 3718, + 0, + 0, + 0, + 0, + 0, + 0, + 2433, + 0, + 0, + 1619, + 0, + 0, + 0, + 0, + 3495, + 0, + 0, + 0, + 0, + 0, + 0, + 4065, + 0, + 0, + 0, + 0, + 0, + 0, + 3255, + 0, + 0, + 0, + 1602, + 0, + 3735, + 0, + 0, + 0, + 0, + 3238, + 801, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 3510, + 0, + 0, + 0, + 0, + 1345, + 3975, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 3778, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 2947, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 3476, + 0, + 4005, + 0, + 3461, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 3748, + 0, + 0, + 2962, + 0, + 0, + 0, + 0, + 4035, + 0, + 0, + 4020, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 3221, + 0, + 0, + 0, + 0, + 0, + 0, + 2690, + 0, + 0, + 0, + 3795, + 0, + 0, + 0, + 4050, + 0, + 0, + 0, + 0, + 0, + 3204, + 3765, + 0, + 0, + 0, + 0, + 0, + 2707, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, }; -static const LC3_UINT8 gf16_g_pow[16] = {1, 2, 4, 8, 3, 6, 12, 11, 5, 10, 7, 14, 15, 13, 9, 1}; +static const LC3_UINT8 gf16_g_pow[16] = { 1, 2, 4, 8, 3, 6, 12, 11, 5, 10, 7, 14, 15, 13, 9, 1 }; /* g_pow[i] contains g^i*/ -static const LC3_UINT8 gf16_log_g[16] = {255, 0, 1, 4, 2, 8, 5, 10, 3, 14, 9, 7, 6, 13, 11, 12}; +static const LC3_UINT8 gf16_log_g[16] = { 255, 0, 1, 4, 2, 8, 5, 10, 3, 14, 9, 7, 6, 13, 11, 12 }; /* log_g[n] contains contains the value i such that g^i = n for n=1, 2, ..., 15, log_g[0] is set to 255 */ -static const LC3_UINT8 gf16_inv_table[16] = {255, 1, 9, 14, 13, 11, 7, 6, 15, 2, 12, 5, 10, 4, 3, 8}; +static const LC3_UINT8 gf16_inv_table[16] = { 255, 1, 9, 14, 13, 11, 7, 6, 15, 2, 12, 5, 10, 4, 3, 8 }; /* gf16_inv_table[n] contains the multiplicative inverse of n in GF(16) (1/0 is set to 255)*/ /* RS16 generating polynomials (from lowest to highest coefficient without leading 1)*/ -static const LC3_UINT8 rs16_gp_d3[] = {8, 6}; -static const LC3_UINT8 rs16_gp_d5[] = {7, 8, 12, 13}; -static const LC3_UINT8 rs16_gp_d7[] = {12, 10, 12, 3, 9, 7}; +static const LC3_UINT8 rs16_gp_d3[] = { 8, 6 }; +static const LC3_UINT8 rs16_gp_d5[] = { 7, 8, 12, 13 }; +static const LC3_UINT8 rs16_gp_d7[] = { 12, 10, 12, 3, 9, 7 }; /* FEC mode signaling polynomials */ #define EP_SIG_POLY_DEG 12 -static const LC3_UINT8 sig_polys[4][15] = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {7, 15, 5, 6, 14, 9, 1, 3, 12, 10, 13, 3, 2, 0, 0}, - {7, 11, 14, 1, 2, 3, 12, 11, 6, 15, 7, 6, 12, 0, 0}, - {6, 15, 12, 2, 9, 15, 2, 8, 12, 3, 10, 5, 4, 0, 0}}; +static const LC3_UINT8 sig_polys[4][15] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { 7, 15, 5, 6, 14, 9, 1, 3, 12, 10, 13, 3, 2, 0, 0 }, + { 7, 11, 14, 1, 2, 3, 12, 11, 6, 15, 7, 6, 12, 0, 0 }, + { 6, 15, 12, 2, 9, 15, 2, 8, 12, 3, 10, 5, 4, 0, 0 } }; static const LC3_UINT8 sig_poly_syndr[4][6] = { - {0, 0, 0, 0, 0, 0}, {0, 4, 5, 11, 5, 8}, {0, 5, 9, 0, 1, 7}, {0, 12, 5, 12, 9, 8}}; + { 0, 0, 0, 0, 0, 0 }, + { 0, 4, 5, 11, 5, 8 }, + { 0, 5, 9, 0, 1, 7 }, + { 0, 12, 5, 12, 9, 8 } +}; /* bit count table for error report (0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111) */ -static const LC3_UINT8 rs16_bit_count_table[] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4}; +static const LC3_UINT8 rs16_bit_count_table[] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 }; /* List of RS16 generators by Hamming distance */ -static const LC3_UINT8 *const rs16_gp_by_hd[8] = {NULL, NULL, NULL, rs16_gp_d3, NULL, rs16_gp_d5, NULL, rs16_gp_d7}; +static const LC3_UINT8 *const rs16_gp_by_hd[8] = { NULL, NULL, NULL, rs16_gp_d3, NULL, rs16_gp_d5, NULL, rs16_gp_d7 }; /* fec config data */ -static const LC3_UINT8 hamming_distance_by_mode0[] = {1, 3, 3, 5, 7}; -static const LC3_UINT8 hamming_distance_by_mode1[] = {1, 1, 3, 5, 7}; +static const LC3_UINT8 hamming_distance_by_mode0[] = { 1, 3, 3, 5, 7 }; +static const LC3_UINT8 hamming_distance_by_mode1[] = { 1, 1, 3, 5, 7 }; -static const LC3_UINT8 crc1_bytes_by_mode0[] = {0, 3, 2, 2, 2}; -static const LC3_UINT8 crc1_bytes_by_mode1[] = {0, 3, 3, 3, 3}; -static const LC3_UINT8 crc2_bytes_by_mode[] = {0, 0, 2, 2, 2}; +static const LC3_UINT8 crc1_bytes_by_mode0[] = { 0, 3, 2, 2, 2 }; +static const LC3_UINT8 crc1_bytes_by_mode1[] = { 0, 3, 3, 3, 3 }; +static const LC3_UINT8 crc2_bytes_by_mode[] = { 0, 0, 2, 2, 2 }; /* fec mode risk table */ typedef struct { LC3_UINT32 mantissa; - LC3_INT16 exponent; + LC3_INT16 exponent; } simple_float; -static const simple_float risk_table_f[4][4] = {{{16384, 0}, {16384, 0}, {16384, 0}, {16384, 0}}, - {{16384, -8}, {26880, -1}, {16384, 0}, {16384, 0}}, - {{16384, -16}, {26880, -9}, {20475, -2}, {16384, 0}}, - {{16384, -24}, {26880, -17}, {20475, -10}, {19195, -4}}}; +static const simple_float risk_table_f[4][4] = { { { 16384, 0 }, { 16384, 0 }, { 16384, 0 }, { 16384, 0 } }, + { { 16384, -8 }, { 26880, -1 }, { 16384, 0 }, { 16384, 0 } }, + { { 16384, -16 }, { 26880, -9 }, { 20475, -2 }, { 16384, 0 } }, + { { 16384, -24 }, { 26880, -17 }, { 20475, -10 }, { 19195, -4 } } }; /* bit error limits for slot size 40 */ -static LC3_INT16 const low_br_max_bit_errors_by_mode[] = {0, 0, 3, 9, 18}; +static LC3_INT16 const low_br_max_bit_errors_by_mode[] = { 0, 0, 3, 9, 18 }; /* corresponding float values: @@ -190,81 +929,75 @@ corresponding float values: /* internal encoder routines */ -FEC_STATIC void fec_interleave_pack(LC3_UINT8 *out, LC3_UINT8 *in, LC3_INT16 n_nibbles, LC3_INT16 n_codewords); +FEC_STATIC void fec_interleave_pack( LC3_UINT8 *out, LC3_UINT8 *in, LC3_INT16 n_nibbles, LC3_INT16 n_codewords ); -FEC_STATIC void rs16_enc(LC3_UINT8 *iobuf, LC3_INT16 codeword_length, LC3_INT16 hamming_distance, LC3_INT16 fec_mode, - LC3_INT16 signal_mode); +FEC_STATIC void rs16_enc( LC3_UINT8 *iobuf, LC3_INT16 codeword_length, LC3_INT16 hamming_distance, LC3_INT16 fec_mode, LC3_INT16 signal_mode ); /* internal decoder routines */ -FEC_STATIC void fec_deinterleave_unpack(LC3_UINT8 *out, LC3_UINT8 *in, LC3_INT16 n_nibbles, LC3_INT16 n_codewords); +FEC_STATIC void fec_deinterleave_unpack( LC3_UINT8 *out, LC3_UINT8 *in, LC3_INT16 n_nibbles, LC3_INT16 n_codewords ); -FEC_STATIC LC3_INT16 fec_data_preproc(LC3_INT16 mode, LC3_INT16 epmr, LC3_UINT8 *iobuf, LC3_UINT8 *cw_buf, LC3_INT16 data_bytes, - LC3_INT16 slot_bytes, LC3_INT16 pc_split); +FEC_STATIC LC3_INT16 fec_data_preproc( LC3_INT16 mode, LC3_INT16 epmr, LC3_UINT8 *iobuf, LC3_UINT8 *cw_buf, LC3_INT16 data_bytes, LC3_INT16 slot_bytes, LC3_INT16 pc_split ); -FEC_STATIC void fec_data_postproc(LC3_INT16 mode, LC3PLUS_EpModeRequest *epmr, LC3_UINT8 *iobuf, LC3_INT16 data_bytes, LC3_UINT8 *cw_buf, - LC3_INT16 slot_bytes, LC3_INT16 pc_split, LC3_INT32 *bfi); +FEC_STATIC void fec_data_postproc( LC3_INT16 mode, LC3PLUS_EpModeRequest *epmr, LC3_UINT8 *iobuf, LC3_INT16 data_bytes, LC3_UINT8 *cw_buf, LC3_INT16 slot_bytes, LC3_INT16 pc_split, LC3_INT32 *bfi ); -FEC_STATIC LC3_INT32 rs16_detect_and_correct(LC3_UINT8 *iobuf, LC3_INT32 n_symb, LC3_INT32 n_codewords, LC3PLUS_EpModeRequest *epmr, LC3_INT16 *error_report, - LC3_INT32 *bfi, LC3_UINT8 *array_of_trust, LC3_INT32 ccc_flag_flag, LC3_INT16 *n_pccw); +FEC_STATIC LC3_INT32 rs16_detect_and_correct( LC3_UINT8 *iobuf, LC3_INT32 n_symb, LC3_INT32 n_codewords, LC3PLUS_EpModeRequest *epmr, LC3_INT16 *error_report, LC3_INT32 *bfi, LC3_UINT8 *array_of_trust, LC3_INT32 ccc_flag_flag, LC3_INT16 *n_pccw ); -FEC_STATIC void rs16_calculate_six_syndromes(LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg); +FEC_STATIC void rs16_calculate_six_syndromes( LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg ); -FEC_STATIC void rs16_calculate_four_syndromes(LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg); +FEC_STATIC void rs16_calculate_four_syndromes( LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg ); -FEC_STATIC void rs16_calculate_two_syndromes(LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg); +FEC_STATIC void rs16_calculate_two_syndromes( LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg ); -FEC_STATIC LC3_INT8 rs16_calculate_elp(LC3_UINT8 *elp, LC3_UINT8 *syndromes, LC3_INT16 hamming_distance); +FEC_STATIC LC3_INT8 rs16_calculate_elp( LC3_UINT8 *elp, LC3_UINT8 *syndromes, LC3_INT16 hamming_distance ); -FEC_STATIC LC3_INT16 rs16_factorize_elp(LC3_UINT8 *error_locations, LC3_UINT8 *elp, LC3_INT16 deg_elp, LC3_INT16 max_pos); +FEC_STATIC LC3_INT16 rs16_factorize_elp( LC3_UINT8 *error_locations, LC3_UINT8 *elp, LC3_INT16 deg_elp, LC3_INT16 max_pos ); -FEC_STATIC void rs16_calculate_errors(LC3_UINT8 *errors, LC3_UINT8 *err_pos, LC3_UINT8 *syndromes, LC3_INT8 deg_elp, LC3_INT8 t); +FEC_STATIC void rs16_calculate_errors( LC3_UINT8 *errors, LC3_UINT8 *err_pos, LC3_UINT8 *syndromes, LC3_INT8 deg_elp, LC3_INT8 t ); /* auxiliary routines */ -FEC_STATIC LC3_INT16 crc1(LC3_UINT8 *data, LC3_INT16 data_size, LC3_INT16 epmr, LC3_UINT8 *hash_val, LC3_INT16 hash_size, LC3_INT16 check); +FEC_STATIC LC3_INT16 crc1( LC3_UINT8 *data, LC3_INT16 data_size, LC3_INT16 epmr, LC3_UINT8 *hash_val, LC3_INT16 hash_size, LC3_INT16 check ); -FEC_STATIC LC3PLUS_EpModeRequest fec_estimate_epmr_from_cw0(LC3_UINT8 *cw0, LC3_INT8 *t, LC3_UINT8 *syndromes, LC3_UINT8 *elp, LC3_INT8 *deg_elp, - LC3_UINT8 *err_pos, LC3_UINT8 *err_symb, LC3_INT16 n_codewords, LC3_INT16 n_symb); +FEC_STATIC LC3PLUS_EpModeRequest fec_estimate_epmr_from_cw0( LC3_UINT8 *cw0, LC3_INT8 *t, LC3_UINT8 *syndromes, LC3_UINT8 *elp, LC3_INT8 *deg_elp, LC3_UINT8 *err_pos, LC3_UINT8 *err_symb, LC3_INT16 n_codewords, LC3_INT16 n_symb ); -FEC_STATIC void dw0_bitswap(LC3_UINT8 *dw0, LC3_INT16 mode, LC3_INT16 slot_bytes); +FEC_STATIC void dw0_bitswap( LC3_UINT8 *dw0, LC3_INT16 mode, LC3_INT16 slot_bytes ); -FEC_STATIC LC3PLUS_EpModeRequest cw0_get_epmr(LC3_UINT8 *cw0, LC3_INT16 epmr_position); +FEC_STATIC LC3PLUS_EpModeRequest cw0_get_epmr( LC3_UINT8 *cw0, LC3_INT16 epmr_position ); -FEC_STATIC LC3PLUS_EpModeRequest dw0_get_epmr(LC3_UINT8 *dw0, LC3_INT16 mode, LC3_INT16 slot_size); +FEC_STATIC LC3PLUS_EpModeRequest dw0_get_epmr( LC3_UINT8 *dw0, LC3_INT16 mode, LC3_INT16 slot_size ); -FEC_STATIC LC3_INT16 crc2(LC3_UINT8 *data, LC3_INT16 data_size, LC3_UINT8 *hash_val, LC3_INT16 hash_size, LC3_INT16 check); +FEC_STATIC LC3_INT16 crc2( LC3_UINT8 *data, LC3_INT16 data_size, LC3_UINT8 *hash_val, LC3_INT16 hash_size, LC3_INT16 check ); -FEC_STATIC simple_float simple_float_mul(simple_float op1, simple_float op2); +FEC_STATIC simple_float simple_float_mul( simple_float op1, simple_float op2 ); -FEC_STATIC LC3_INT16 simple_float_cmp(simple_float op1, simple_float op2); +FEC_STATIC LC3_INT16 simple_float_cmp( simple_float op1, simple_float op2 ); -FEC_STATIC LC3_INT16 get_total_crc_size(LC3_INT16 slot_bytes, LC3_INT16 fec_mode, LC3_INT16 pc_split); +FEC_STATIC LC3_INT16 get_total_crc_size( LC3_INT16 slot_bytes, LC3_INT16 fec_mode, LC3_INT16 pc_split ); -FEC_STATIC LC3_INT16 get_n_codewords(LC3_INT16 slot_bytes); +FEC_STATIC LC3_INT16 get_n_codewords( LC3_INT16 slot_bytes ); -FEC_STATIC LC3_INT16 get_codeword_length(LC3_INT16 n_codewords, LC3_INT16 slot_nibbles, LC3_INT16 codeword_index); +FEC_STATIC LC3_INT16 get_codeword_length( LC3_INT16 n_codewords, LC3_INT16 slot_nibbles, LC3_INT16 codeword_index ); - -LC3_INT16 fec_get_n_pccw(LC3_INT16 slot_bytes, LC3_INT16 fec_mode, LC3_INT16 ccc_flag) +LC3_INT16 fec_get_n_pccw( LC3_INT16 slot_bytes, LC3_INT16 fec_mode, LC3_INT16 ccc_flag ) { LC3_INT16 n_pccw; - if (fec_mode == 3) + if ( fec_mode == 3 ) { - n_pccw = (LC3_INT16) (0.080447761194030 * slot_bytes - 1.791044776119394 + 0.5); + n_pccw = (LC3_INT16) ( 0.080447761194030 * slot_bytes - 1.791044776119394 + 0.5 ); } - else if (fec_mode == 4) + else if ( fec_mode == 4 ) { - n_pccw = (LC3_INT16) (0.066492537313433 * slot_bytes - 1.970149253731338 + 0.5); + n_pccw = (LC3_INT16) ( 0.066492537313433 * slot_bytes - 1.970149253731338 + 0.5 ); } else { n_pccw = 0; } - if (ccc_flag == 1 || slot_bytes < 80) + if ( ccc_flag == 1 || slot_bytes < 80 ) { n_pccw = 0; } @@ -272,59 +1005,58 @@ LC3_INT16 fec_get_n_pccw(LC3_INT16 slot_bytes, LC3_INT16 fec_mode, LC3_INT16 ccc return n_pccw; } -FEC_STATIC LC3_INT16 get_total_crc_size(LC3_INT16 slot_bytes, LC3_INT16 fec_mode, LC3_INT16 pc_split) +FEC_STATIC LC3_INT16 get_total_crc_size( LC3_INT16 slot_bytes, LC3_INT16 fec_mode, LC3_INT16 pc_split ) { - LC3_INT16 n_crc; + LC3_INT16 n_crc; n_crc = crc1_bytes_by_mode1[fec_mode]; - if (slot_bytes == 40) + if ( slot_bytes == 40 ) { n_crc = crc1_bytes_by_mode0[fec_mode]; } - if (pc_split > 0) + if ( pc_split > 0 ) { n_crc = n_crc + crc2_bytes_by_mode[fec_mode]; } - - + return n_crc; } -FEC_STATIC LC3_INT16 get_n_codewords(LC3_INT16 slot_bytes) +FEC_STATIC LC3_INT16 get_n_codewords( LC3_INT16 slot_bytes ) { - return (2*slot_bytes + 14)/15; + return ( 2 * slot_bytes + 14 ) / 15; } -FEC_STATIC LC3_INT16 get_codeword_length(LC3_INT16 n_codewords, LC3_INT16 slot_nibbles, LC3_INT16 codeword_index) +FEC_STATIC LC3_INT16 get_codeword_length( LC3_INT16 n_codewords, LC3_INT16 slot_nibbles, LC3_INT16 codeword_index ) { - return (slot_nibbles - codeword_index - 1) / n_codewords + 1; + return ( slot_nibbles - codeword_index - 1 ) / n_codewords + 1; } /* Encoder */ -LC3_INT16 fec_get_data_size(LC3_INT16 fec_mode, LC3_INT16 ccc_flag, LC3_INT16 slot_bytes) +LC3_INT16 fec_get_data_size( LC3_INT16 fec_mode, LC3_INT16 ccc_flag, LC3_INT16 slot_bytes ) /* not time critical */ { - LC3_INT16 n_codewords, payload_size; + LC3_INT16 n_codewords, payload_size; - n_codewords = get_n_codewords(slot_bytes); + n_codewords = get_n_codewords( slot_bytes ); - assert(n_codewords == (2 * slot_bytes + RS16_CW_LEN_MAX - 1) / RS16_CW_LEN_MAX); + assert( n_codewords == ( 2 * slot_bytes + RS16_CW_LEN_MAX - 1 ) / RS16_CW_LEN_MAX ); payload_size = slot_bytes; - if (fec_mode > 0) + if ( fec_mode > 0 ) { - if (fec_mode == 1) + if ( fec_mode == 1 ) { - payload_size --; + payload_size--; } else { - payload_size -= (fec_mode - 1) * n_codewords; + payload_size -= ( fec_mode - 1 ) * n_codewords; } - if (slot_bytes == 40) + if ( slot_bytes == 40 ) { payload_size -= crc1_bytes_by_mode0[fec_mode]; } @@ -333,119 +1065,113 @@ LC3_INT16 fec_get_data_size(LC3_INT16 fec_mode, LC3_INT16 ccc_flag, LC3_INT16 sl payload_size -= crc1_bytes_by_mode1[fec_mode]; } - if (ccc_flag == 0 && fec_mode > 2 && slot_bytes >= 80) + if ( ccc_flag == 0 && fec_mode > 2 && slot_bytes >= 80 ) { payload_size -= crc2_bytes_by_mode[fec_mode]; } } - - + return payload_size; } -LC3_INT16 fec_get_n_pc(LC3_INT16 fec_mode, LC3_INT16 n_pccw, LC3_INT16 slot_bytes) +LC3_INT16 fec_get_n_pc( LC3_INT16 fec_mode, LC3_INT16 n_pccw, LC3_INT16 slot_bytes ) /* not time critical */ { - LC3_INT16 n_codewords, pc_split; - LC3_INT32 i; + LC3_INT16 n_codewords, pc_split; + LC3_INT32 i; - n_codewords = get_n_codewords(slot_bytes); + n_codewords = get_n_codewords( slot_bytes ); - assert(n_codewords == (2 * slot_bytes + RS16_CW_LEN_MAX - 1) / RS16_CW_LEN_MAX); + assert( n_codewords == ( 2 * slot_bytes + RS16_CW_LEN_MAX - 1 ) / RS16_CW_LEN_MAX ); - pc_split = - 2*n_pccw*(fec_mode - 1); + pc_split = -2 * n_pccw * ( fec_mode - 1 ); - if (fec_mode == 1 || slot_bytes < 80) + if ( fec_mode == 1 || slot_bytes < 80 ) { pc_split = 0; } else { - for (i = 0; i < n_pccw; i++) + for ( i = 0; i < n_pccw; i++ ) { - pc_split += (2 * slot_bytes + i) / n_codewords; + pc_split += ( 2 * slot_bytes + i ) / n_codewords; } } - - + return pc_split; } /* functions for EPMR handling */ -FEC_STATIC void dw0_bitswap(LC3_UINT8 *dw0, LC3_INT16 mode, LC3_INT16 slot_bytes) +FEC_STATIC void dw0_bitswap( LC3_UINT8 *dw0, LC3_INT16 mode, LC3_INT16 slot_bytes ) /* swap epmr bits with bits that will be positioned at 30 and 32 in code word 0 */ { - LC3_UINT8 tmp; - LC3_INT32 ind0, ind1, position; + LC3_UINT8 tmp; + LC3_INT32 ind0, ind1, position; - position = get_codeword_length(get_n_codewords(slot_bytes), 2*slot_bytes, 0) - 1; + position = get_codeword_length( get_n_codewords( slot_bytes ), 2 * slot_bytes, 0 ) - 1; - if (slot_bytes == 40) + if ( slot_bytes == 40 ) { - ind0 = 2*crc1_bytes_by_mode0[mode] - 1; + ind0 = 2 * crc1_bytes_by_mode0[mode] - 1; } else { - ind0 = 2*crc1_bytes_by_mode1[mode] - 1; + ind0 = 2 * crc1_bytes_by_mode1[mode] - 1; } ind1 = position - hamming_distance_by_mode0[mode] + 1; /* swap bits 2 and 3 of dw0[ind0] with bits 0 and 1 of dw0[ind1] */ - tmp = (dw0[ind0] >> 2) & 3; + tmp = ( dw0[ind0] >> 2 ) & 3; dw0[ind0] = dw0[ind0] & 3; - dw0[ind0] = dw0[ind0] | ((dw0[ind1] & 3) << 2); + dw0[ind0] = dw0[ind0] | ( ( dw0[ind1] & 3 ) << 2 ); dw0[ind1] = dw0[ind1] & 12; dw0[ind1] = dw0[ind1] | tmp; - - } -FEC_STATIC LC3PLUS_EpModeRequest cw0_get_epmr(LC3_UINT8 *cw0, LC3_INT16 position) +FEC_STATIC LC3PLUS_EpModeRequest cw0_get_epmr( LC3_UINT8 *cw0, LC3_INT16 position ) { - return (LC3PLUS_EpModeRequest)(cw0[position] & 3); + return (LC3PLUS_EpModeRequest) ( cw0[position] & 3 ); } -FEC_STATIC LC3PLUS_EpModeRequest dw0_get_epmr(LC3_UINT8 *dw0, LC3_INT16 mode, LC3_INT16 slot_size) +FEC_STATIC LC3PLUS_EpModeRequest dw0_get_epmr( LC3_UINT8 *dw0, LC3_INT16 mode, LC3_INT16 slot_size ) { - LC3_INT32 ncrc1; - LC3PLUS_EpModeRequest epmr; + LC3_INT32 ncrc1; + LC3PLUS_EpModeRequest epmr; ncrc1 = crc1_bytes_by_mode1[mode]; - if (slot_size == 40) + if ( slot_size == 40 ) { ncrc1 = crc1_bytes_by_mode0[mode]; } - epmr = (LC3PLUS_EpModeRequest)(dw0[2 * ncrc1 - 1] >> 2); - - + epmr = (LC3PLUS_EpModeRequest) ( dw0[2 * ncrc1 - 1] >> 2 ); + return epmr; } -FEC_STATIC LC3_INT16 fec_data_preproc(LC3_INT16 mode, LC3_INT16 epmr, LC3_UINT8 *iobuf, LC3_UINT8 *cw_buf, LC3_INT16 data_bytes, - LC3_INT16 slot_bytes, LC3_INT16 pc_split) +FEC_STATIC LC3_INT16 fec_data_preproc( LC3_INT16 mode, LC3_INT16 epmr, LC3_UINT8 *iobuf, LC3_UINT8 *cw_buf, LC3_INT16 data_bytes, LC3_INT16 slot_bytes, LC3_INT16 pc_split ) { - LC3_INT16 data_offset, n_crc1, n_crc2; - LC3_INT32 i, j; + LC3_INT16 data_offset, n_crc1, n_crc2; + LC3_INT32 i, j; - data_offset = 2*(slot_bytes - data_bytes); + data_offset = 2 * ( slot_bytes - data_bytes ); /* extract and reverse data*/ - j = 2*slot_bytes - 1; - for (i = 0; i < data_bytes; i++) + j = 2 * slot_bytes - 1; + for ( i = 0; i < data_bytes; i++ ) { cw_buf[j--] = iobuf[i] & 15; cw_buf[j--] = iobuf[i] >> 4; } /* add crc hashes */ - if (slot_bytes == 40) + if ( slot_bytes == 40 ) { n_crc1 = crc1_bytes_by_mode0[mode]; } @@ -454,7 +1180,7 @@ FEC_STATIC LC3_INT16 fec_data_preproc(LC3_INT16 mode, LC3_INT16 epmr, LC3_UINT8 n_crc1 = crc1_bytes_by_mode1[mode]; } - if (pc_split > 0 && mode > 1) + if ( pc_split > 0 && mode > 1 ) { n_crc2 = crc2_bytes_by_mode[mode]; } @@ -463,214 +1189,207 @@ FEC_STATIC LC3_INT16 fec_data_preproc(LC3_INT16 mode, LC3_INT16 epmr, LC3_UINT8 n_crc2 = 0; } - if (n_crc2) + if ( n_crc2 ) { - crc2(cw_buf + data_offset + 2 * data_bytes - pc_split, pc_split, cw_buf + data_offset - 2 * n_crc2, n_crc2, 0); + crc2( cw_buf + data_offset + 2 * data_bytes - pc_split, pc_split, cw_buf + data_offset - 2 * n_crc2, n_crc2, 0 ); } - if (n_crc1) + if ( n_crc1 ) { - crc1(cw_buf + data_offset, 2 * data_bytes - pc_split, epmr, cw_buf + data_offset - 2 * (n_crc1 + n_crc2), n_crc1, - 0); + crc1( cw_buf + data_offset, 2 * data_bytes - pc_split, epmr, cw_buf + data_offset - 2 * ( n_crc1 + n_crc2 ), n_crc1, + 0 ); } - data_offset -= 2* (n_crc1 + n_crc2); + data_offset -= 2 * ( n_crc1 + n_crc2 ); + + dw0_bitswap( cw_buf + data_offset, mode, slot_bytes ); - dw0_bitswap(cw_buf + data_offset, mode, slot_bytes); - - return data_offset; } -void fec_encoder(LC3_INT16 mode, LC3_INT16 epmr, LC3_UINT8 *iobuf, LC3_INT16 data_bytes, LC3_INT16 slot_bytes, LC3_INT16 n_pccw) +void fec_encoder( LC3_INT16 mode, LC3_INT16 epmr, LC3_UINT8 *iobuf, LC3_INT16 data_bytes, LC3_INT16 slot_bytes, LC3_INT16 n_pccw ) { - LC3_INT16 n_codewords, codeword_length, hd, redundancy_nibbles, cw_offset, dw_offset, pc_split; - LC3_INT32 i, j; + LC3_INT16 n_codewords, codeword_length, hd, redundancy_nibbles, cw_offset, dw_offset, pc_split; + LC3_INT32 i, j; LC3_UINT8 cw_buf[2 * FEC_SLOT_BYTES_MAX]; cw_offset = 0; dw_offset = 0; - pc_split = 0; + pc_split = 0; - n_codewords = get_n_codewords(slot_bytes); + n_codewords = get_n_codewords( slot_bytes ); /* some sanity checks */ { LC3_INT32 tmp = slot_bytes; - - assert((slot_bytes >= FEC_SLOT_BYTES_MIN && slot_bytes <= FEC_SLOT_BYTES_MAX) && - "fec_encoder: slot_bytes out of range"); - tmp -= mode == 1 ? 1 : n_codewords * (mode - 1); // reed solomon redundancy + + assert( ( slot_bytes >= FEC_SLOT_BYTES_MIN && slot_bytes <= FEC_SLOT_BYTES_MAX ) && + "fec_encoder: slot_bytes out of range" ); + tmp -= mode == 1 ? 1 : n_codewords * ( mode - 1 ); // reed solomon redundancy tmp -= slot_bytes == 40 ? crc1_bytes_by_mode0[mode] : crc1_bytes_by_mode1[mode]; // crc1 - tmp -= (n_pccw > 0) && (mode > 1) ? crc2_bytes_by_mode[mode] : 0; // crc2 - assert(data_bytes == tmp && "fec_encoder: inconsistent payload size"); - assert(n_codewords - n_pccw >= 6); + tmp -= ( n_pccw > 0 ) && ( mode > 1 ) ? crc2_bytes_by_mode[mode] : 0; // crc2 + assert( data_bytes == tmp && "fec_encoder: inconsistent payload size" ); + assert( n_codewords - n_pccw >= 6 ); } /* data preproc: re-ordering and hash extension */ - pc_split = fec_get_n_pc(mode, n_pccw, slot_bytes); + pc_split = fec_get_n_pc( mode, n_pccw, slot_bytes ); - dw_offset = fec_data_preproc(mode, epmr, iobuf, cw_buf, data_bytes, slot_bytes, pc_split); + dw_offset = fec_data_preproc( mode, epmr, iobuf, cw_buf, data_bytes, slot_bytes, pc_split ); /* encoding of first data word*/ - hd = hamming_distance_by_mode0[mode]; + hd = hamming_distance_by_mode0[mode]; redundancy_nibbles = hd - 1; - codeword_length = get_codeword_length(n_codewords, 2 * slot_bytes, 0); + codeword_length = get_codeword_length( n_codewords, 2 * slot_bytes, 0 ); - assert(codeword_length == (2 * slot_bytes - 1) / n_codewords + 1); + assert( codeword_length == ( 2 * slot_bytes - 1 ) / n_codewords + 1 ); - for (j = redundancy_nibbles; j < codeword_length; (j++, dw_offset++)) + for ( j = redundancy_nibbles; j < codeword_length; ( j++, dw_offset++ ) ) { cw_buf[j] = cw_buf[dw_offset]; } - rs16_enc(cw_buf, codeword_length, hd, mode, 1); + rs16_enc( cw_buf, codeword_length, hd, mode, 1 ); cw_offset += codeword_length; /* encoding of remaining data words */ - hd = hamming_distance_by_mode1[mode]; + hd = hamming_distance_by_mode1[mode]; redundancy_nibbles = hd - 1; - for (i = 1; i < n_codewords; i++) + for ( i = 1; i < n_codewords; i++ ) { - codeword_length = get_codeword_length(n_codewords, 2*slot_bytes, i); + codeword_length = get_codeword_length( n_codewords, 2 * slot_bytes, i ); - for (j = redundancy_nibbles; j < codeword_length; (j++, dw_offset++)) + for ( j = redundancy_nibbles; j < codeword_length; ( j++, dw_offset++ ) ) { cw_buf[cw_offset + j] = cw_buf[dw_offset]; } - rs16_enc(cw_buf + cw_offset, codeword_length, hd, mode, i < 6); + rs16_enc( cw_buf + cw_offset, codeword_length, hd, mode, i < 6 ); cw_offset += codeword_length; } - assert(cw_offset == 2 * slot_bytes && dw_offset == 2 * slot_bytes); + assert( cw_offset == 2 * slot_bytes && dw_offset == 2 * slot_bytes ); - fec_interleave_pack(iobuf, cw_buf, 2 * slot_bytes, n_codewords); - - + fec_interleave_pack( iobuf, cw_buf, 2 * slot_bytes, n_codewords ); } -FEC_STATIC void rs16_enc(LC3_UINT8 *iobuf, LC3_INT16 codeword_length, LC3_INT16 hamming_distance, LC3_INT16 fec_mode, - LC3_INT16 signal_mode) +FEC_STATIC void rs16_enc( LC3_UINT8 *iobuf, LC3_INT16 codeword_length, LC3_INT16 hamming_distance, LC3_INT16 fec_mode, LC3_INT16 signal_mode ) /* expects (data polynomial) * x^(hamming_distance - 1) in iobuf */ { - LC3_UINT8 const *gp; - LC3_UINT8 shift_buffer[RS16_CW_LEN_MAX + 1], lc; - LC3_INT32 i, j, deg_gp; + LC3_UINT8 const *gp; + LC3_UINT8 shift_buffer[RS16_CW_LEN_MAX + 1], lc; + LC3_INT32 i, j, deg_gp; - memset(shift_buffer, 0, sizeof(shift_buffer)); - gp = rs16_gp_by_hd[hamming_distance]; + memset( shift_buffer, 0, sizeof( shift_buffer ) ); + gp = rs16_gp_by_hd[hamming_distance]; deg_gp = hamming_distance - 1; - if (hamming_distance > 1) + if ( hamming_distance > 1 ) { - assert(codeword_length > deg_gp); + assert( codeword_length > deg_gp ); /* initialize redundancy part to zero */ - memset(iobuf, 0, deg_gp); + memset( iobuf, 0, deg_gp ); /* initialize shift_buffer */ - memmove(shift_buffer + 1, iobuf + codeword_length - deg_gp, deg_gp); + memmove( shift_buffer + 1, iobuf + codeword_length - deg_gp, deg_gp ); /* calculate remainder */ - for (i = codeword_length - deg_gp - 1; i >= 0; i--) + for ( i = codeword_length - deg_gp - 1; i >= 0; i-- ) { shift_buffer[0] = iobuf[i]; - lc = shift_buffer[deg_gp] << 4; + lc = shift_buffer[deg_gp] << 4; - for (j = deg_gp - 1; j >= 0; j--) + for ( j = deg_gp - 1; j >= 0; j-- ) { - shift_buffer[j + 1] = GF16_ADD(shift_buffer[j], GF16_MUL0(gp[j], lc)); + shift_buffer[j + 1] = GF16_ADD( shift_buffer[j], GF16_MUL0( gp[j], lc ) ); } } /* add remainder to shifted data polynomial */ - for (i = 0; i < deg_gp; i++) + for ( i = 0; i < deg_gp; i++ ) { iobuf[i] = shift_buffer[i + 1]; } /* add signaling polynomial */ - if (signal_mode) + if ( signal_mode ) { - assert(codeword_length > EP_SIG_POLY_DEG); - for (i = 0; i <= EP_SIG_POLY_DEG; i++) + assert( codeword_length > EP_SIG_POLY_DEG ); + for ( i = 0; i <= EP_SIG_POLY_DEG; i++ ) { - iobuf[i] = GF16_ADD(iobuf[i], sig_polys[fec_mode - 1][i]); + iobuf[i] = GF16_ADD( iobuf[i], sig_polys[fec_mode - 1][i] ); } } } - - } -FEC_STATIC void fec_interleave_pack(LC3_UINT8 *out, LC3_UINT8 *in, LC3_INT16 n_nibbles, LC3_INT16 n_codewords) +FEC_STATIC void fec_interleave_pack( LC3_UINT8 *out, LC3_UINT8 *in, LC3_INT16 n_nibbles, LC3_INT16 n_codewords ) { - LC3_INT16 out_offset, cw_offset, codeword_length; - LC3_INT32 i, j; + LC3_INT16 out_offset, cw_offset, codeword_length; + LC3_INT32 i, j; out_offset = 0; - cw_offset = 0; + cw_offset = 0; /* initialize output buffer to zero */ - memset(out, 0, n_nibbles >> 1); + memset( out, 0, n_nibbles >> 1 ); /* interleave and pack codewords */ - for (i = 0; i < n_codewords; i++) + for ( i = 0; i < n_codewords; i++ ) { - codeword_length = get_codeword_length(n_codewords, n_nibbles, i); + codeword_length = get_codeword_length( n_codewords, n_nibbles, i ); - for (j = 0; j < codeword_length; j++) + for ( j = 0; j < codeword_length; j++ ) { - out_offset = n_nibbles - 1 - j*n_codewords - i; - out[out_offset >> 1] |= in[cw_offset] << ((out_offset & 1) << 2); + out_offset = n_nibbles - 1 - j * n_codewords - i; + out[out_offset >> 1] |= in[cw_offset] << ( ( out_offset & 1 ) << 2 ); cw_offset = cw_offset + 1; } } - - assert(cw_offset == n_nibbles); + + assert( cw_offset == n_nibbles ); } /* Decoder */ -FEC_STATIC void fec_data_postproc(LC3_INT16 mode, LC3PLUS_EpModeRequest *epmr, LC3_UINT8 *obuf, LC3_INT16 data_bytes, LC3_UINT8 *cw_buf, - LC3_INT16 slot_bytes, LC3_INT16 pc_split, LC3_INT32 *bfi) +FEC_STATIC void fec_data_postproc( LC3_INT16 mode, LC3PLUS_EpModeRequest *epmr, LC3_UINT8 *obuf, LC3_INT16 data_bytes, LC3_UINT8 *cw_buf, LC3_INT16 slot_bytes, LC3_INT16 pc_split, LC3_INT32 *bfi ) { - LC3_INT16 i; - LC3_INT16 n_crc1, n_crc2; - LC3_INT16 cw_buf_len; - LC3PLUS_EpModeRequest tmp_epmr; + LC3_INT16 i; + LC3_INT16 n_crc1, n_crc2; + LC3_INT16 cw_buf_len; + LC3PLUS_EpModeRequest tmp_epmr; n_crc1 = crc1_bytes_by_mode1[mode]; - if (slot_bytes == 40) + if ( slot_bytes == 40 ) { n_crc1 = crc1_bytes_by_mode0[mode]; } n_crc2 = 0; - if (pc_split > 0) + if ( pc_split > 0 ) { n_crc2 = crc2_bytes_by_mode[mode]; } - assert(n_crc1 == (slot_bytes == 40 ? crc1_bytes_by_mode0[mode] : crc1_bytes_by_mode1[mode])); - assert(n_crc2 == ((pc_split > 0) && (mode > 1) ? crc2_bytes_by_mode[mode] : 0)); + assert( n_crc1 == ( slot_bytes == 40 ? crc1_bytes_by_mode0[mode] : crc1_bytes_by_mode1[mode] ) ); + assert( n_crc2 == ( ( pc_split > 0 ) && ( mode > 1 ) ? crc2_bytes_by_mode[mode] : 0 ) ); - cw_buf_len = 2 * (data_bytes + n_crc1 + n_crc2); + cw_buf_len = 2 * ( data_bytes + n_crc1 + n_crc2 ); - if ((mode - 1)) + if ( ( mode - 1 ) ) { /* reverse bit-swap */ - dw0_bitswap(cw_buf, mode, slot_bytes); - tmp_epmr = dw0_get_epmr(cw_buf, mode, slot_bytes); + dw0_bitswap( cw_buf, mode, slot_bytes ); + tmp_epmr = dw0_get_epmr( cw_buf, mode, slot_bytes ); - if (crc1(cw_buf + ((n_crc1 + n_crc2) << 1), ((data_bytes << 1) - pc_split), tmp_epmr, cw_buf, n_crc1, 1)) + if ( crc1( cw_buf + ( ( n_crc1 + n_crc2 ) << 1 ), ( ( data_bytes << 1 ) - pc_split ), tmp_epmr, cw_buf, n_crc1, 1 ) ) { *bfi = 1; - + return; } else @@ -679,112 +1398,109 @@ FEC_STATIC void fec_data_postproc(LC3_INT16 mode, LC3PLUS_EpModeRequest *epmr, L } } - if (pc_split > 0 && *bfi != 2) + if ( pc_split > 0 && *bfi != 2 ) { - if (crc2(cw_buf + (((data_bytes + (n_crc1 + n_crc2)) << 1) - pc_split), pc_split, - cw_buf + (n_crc1 << 1), n_crc2, 1)) + if ( crc2( cw_buf + ( ( ( data_bytes + ( n_crc1 + n_crc2 ) ) << 1 ) - pc_split ), pc_split, + cw_buf + ( n_crc1 << 1 ), n_crc2, 1 ) ) { *bfi = 2; } } - for (i = 0; i < data_bytes; i++) + for ( i = 0; i < data_bytes; i++ ) { - obuf[i] = (LC3_UINT8)(cw_buf[cw_buf_len - 2 * i - 1] | (cw_buf[cw_buf_len - 2 * i - 2] << 4)); + obuf[i] = (LC3_UINT8) ( cw_buf[cw_buf_len - 2 * i - 1] | ( cw_buf[cw_buf_len - 2 * i - 2] << 4 ) ); } - - } -LC3_INT32 fec_decoder(LC3_UINT8 *iobuf, LC3_INT16 slot_bytes, LC3_INT32 *data_bytes, LC3PLUS_EpModeRequest *epmr, LC3_INT16 ccc_flag, LC3_INT16 *n_pccw, - LC3_INT32 *bfi, LC3_INT16 *be_bp_left, LC3_INT16 *be_bp_right, LC3_INT16 *n_pc, LC3_INT16 *m_fec) +LC3_INT32 fec_decoder( LC3_UINT8 *iobuf, LC3_INT16 slot_bytes, LC3_INT32 *data_bytes, LC3PLUS_EpModeRequest *epmr, LC3_INT16 ccc_flag, LC3_INT16 *n_pccw, LC3_INT32 *bfi, LC3_INT16 *be_bp_left, LC3_INT16 *be_bp_right, LC3_INT16 *n_pc, LC3_INT16 *m_fec ) { - LC3_UINT8 cw_buf[2 * FEC_SLOT_BYTES_MAX]; - LC3_UINT8 array_of_trust[MAX_LEN]; - LC3_INT16 i, j; - LC3_INT16 cw_offset, dw_offset; - LC3_INT16 n_codewords, redundancy_nibbles, codeword_length; - LC3_INT16 mode, error_report; - LC3_INT16 n_crc; - LC3_INT16 first_bad_cw; - LC3_INT16 pc_split; - - UNUSED(n_crc); - - - if (*bfi == 1) - { - + LC3_UINT8 cw_buf[2 * FEC_SLOT_BYTES_MAX]; + LC3_UINT8 array_of_trust[MAX_LEN]; + LC3_INT16 i, j; + LC3_INT16 cw_offset, dw_offset; + LC3_INT16 n_codewords, redundancy_nibbles, codeword_length; + LC3_INT16 mode, error_report; + LC3_INT16 n_crc; + LC3_INT16 first_bad_cw; + LC3_INT16 pc_split; + + UNUSED( n_crc ); + + + if ( *bfi == 1 ) + { + return ERROR_REPORT_BEC_MASK; } - if (slot_bytes < FEC_SLOT_BYTES_MIN || slot_bytes > FEC_SLOT_BYTES_MAX) + if ( slot_bytes < FEC_SLOT_BYTES_MIN || slot_bytes > FEC_SLOT_BYTES_MAX ) { *bfi = 1; - + return ERROR_REPORT_BEC_MASK; } - if (ccc_flag == 0) + if ( ccc_flag == 0 ) { *be_bp_left = -1; *be_bp_right = -1; } - n_codewords = get_n_codewords(slot_bytes); + n_codewords = get_n_codewords( slot_bytes ); /* extract and de-interleave nibbles */ - fec_deinterleave_unpack(cw_buf, iobuf, 2 * slot_bytes, n_codewords); + fec_deinterleave_unpack( cw_buf, iobuf, 2 * slot_bytes, n_codewords ); /* mode detection and error correction */ - mode = rs16_detect_and_correct(cw_buf, 2 * slot_bytes, n_codewords, epmr, &error_report, bfi, array_of_trust, - ccc_flag, n_pccw); + mode = rs16_detect_and_correct( cw_buf, 2 * slot_bytes, n_codewords, epmr, &error_report, bfi, array_of_trust, + ccc_flag, n_pccw ); /* for normal slots the maximal number of bit errors is limited */ #ifndef APPLY_MAX_ERRORS - if (slot_bytes == 40 && mode > 0) + if ( slot_bytes == 40 && mode > 0 ) { - if ((error_report & ERROR_REPORT_BEC_MASK) > low_br_max_bit_errors_by_mode[mode]) - { - error_report &= ERROR_REPORT_BEC_MASK; + if ( ( error_report & ERROR_REPORT_BEC_MASK ) > low_br_max_bit_errors_by_mode[mode] ) + { + error_report &= ERROR_REPORT_BEC_MASK; mode = -1; *bfi = 1; } else { - if ((error_report & ERROR_REPORT_BEC_MASK) > low_br_max_bit_errors_by_mode[2]) + if ( ( error_report & ERROR_REPORT_BEC_MASK ) > low_br_max_bit_errors_by_mode[2] ) { error_report &= ~ERROR_REPORT_EP2_OK; } - if ((error_report & ERROR_REPORT_BEC_MASK) > low_br_max_bit_errors_by_mode[3]) + if ( ( error_report & ERROR_REPORT_BEC_MASK ) > low_br_max_bit_errors_by_mode[3] ) { error_report &= ~ERROR_REPORT_EP3_OK; } } } #endif - - if (*bfi == 1) + + if ( *bfi == 1 ) { *data_bytes = 0; - + return error_report; } /* initialization for decoding */ - *data_bytes = fec_get_data_size(mode, ccc_flag, slot_bytes); - pc_split = fec_get_n_pc(mode, *n_pccw, slot_bytes); - n_crc = get_total_crc_size(slot_bytes, mode, pc_split); + *data_bytes = fec_get_data_size( mode, ccc_flag, slot_bytes ); + pc_split = fec_get_n_pc( mode, *n_pccw, slot_bytes ); + n_crc = get_total_crc_size( slot_bytes, mode, pc_split ); /* decoding of first code word */ redundancy_nibbles = hamming_distance_by_mode0[mode] - 1; - codeword_length = get_codeword_length(n_codewords, slot_bytes + slot_bytes, 0); + codeword_length = get_codeword_length( n_codewords, slot_bytes + slot_bytes, 0 ); dw_offset = 0; cw_offset = 0; - for (j = redundancy_nibbles; j < codeword_length; j++) + for ( j = redundancy_nibbles; j < codeword_length; j++ ) { cw_buf[dw_offset++] = cw_buf[j]; } @@ -793,11 +1509,11 @@ LC3_INT32 fec_decoder(LC3_UINT8 *iobuf, LC3_INT16 slot_bytes, LC3_INT32 *data_by /* decoding of remaining code words */ redundancy_nibbles = hamming_distance_by_mode1[mode] - 1; - for (i = 1; i < n_codewords; i++) + for ( i = 1; i < n_codewords; i++ ) { - codeword_length = get_codeword_length(n_codewords, slot_bytes + slot_bytes, i); + codeword_length = get_codeword_length( n_codewords, slot_bytes + slot_bytes, i ); - for (j = redundancy_nibbles; j < codeword_length; j++) + for ( j = redundancy_nibbles; j < codeword_length; j++ ) { cw_buf[dw_offset++] = cw_buf[j + cw_offset]; } @@ -807,638 +1523,635 @@ LC3_INT32 fec_decoder(LC3_UINT8 *iobuf, LC3_INT16 slot_bytes, LC3_INT32 *data_by /* data postproc: hash validation and re-ordering */ - fec_data_postproc(mode, epmr, iobuf, *data_bytes, cw_buf, slot_bytes, pc_split, bfi); + fec_data_postproc( mode, epmr, iobuf, *data_bytes, cw_buf, slot_bytes, pc_split, bfi ); - if (*bfi == 1) + if ( *bfi == 1 ) { *data_bytes = 0; error_report &= ERROR_REPORT_BEC_MASK; - + return error_report; } - if (*bfi == 2) + if ( *bfi == 2 ) { - first_bad_cw = 0; + first_bad_cw = 0; array_of_trust[*n_pccw] = 0; - while (array_of_trust[first_bad_cw] != 0) + while ( array_of_trust[first_bad_cw] != 0 ) { first_bad_cw = first_bad_cw + 1; } - if (first_bad_cw == *n_pccw) + if ( first_bad_cw == *n_pccw ) { /* this is the case when CRC failed */ *be_bp_left = 0; } else { - *be_bp_left = 4*fec_get_n_pc(mode, first_bad_cw, slot_bytes); + *be_bp_left = 4 * fec_get_n_pc( mode, first_bad_cw, slot_bytes ); } - for (i = *n_pccw - 1; i >= 0; i--) + for ( i = *n_pccw - 1; i >= 0; i-- ) { - if (!array_of_trust[i]) + if ( !array_of_trust[i] ) { break; } } - if (i < 0) + if ( i < 0 ) { i = *n_pccw - 1; } - *be_bp_right = 4*fec_get_n_pc(mode, i + 1, slot_bytes) - 1; + *be_bp_right = 4 * fec_get_n_pc( mode, i + 1, slot_bytes ) - 1; } - if (ccc_flag == 0) + if ( ccc_flag == 0 ) { - *n_pc = pc_split; + *n_pc = pc_split; *m_fec = mode; } - + return error_report; } -FEC_STATIC void fec_deinterleave_unpack(LC3_UINT8 *out, LC3_UINT8 *in, LC3_INT16 n_nibbles, LC3_INT16 n_codewords) +FEC_STATIC void fec_deinterleave_unpack( LC3_UINT8 *out, LC3_UINT8 *in, LC3_INT16 n_nibbles, LC3_INT16 n_codewords ) { - LC3_INT16 in_offset, out_offset, codeword_length; - LC3_INT32 i, j; + LC3_INT16 in_offset, out_offset, codeword_length; + LC3_INT32 i, j; - in_offset = 0; + in_offset = 0; out_offset = 0; /* unpack nibbles in input buffer and deinterleave codewords */ - for (i = 0; i < n_codewords; i++) + for ( i = 0; i < n_codewords; i++ ) { - codeword_length = get_codeword_length(n_codewords, n_nibbles, i); - for (j = 0; j < codeword_length; (j++, out_offset++)) + codeword_length = get_codeword_length( n_codewords, n_nibbles, i ); + for ( j = 0; j < codeword_length; ( j++, out_offset++ ) ) { - in_offset = n_nibbles - 1 - j*n_codewords - i; - out[out_offset] = (in[in_offset >> 1] >> ((in_offset & 1) << 2)) & 15; + in_offset = n_nibbles - 1 - j * n_codewords - i; + out[out_offset] = ( in[in_offset >> 1] >> ( ( in_offset & 1 ) << 2 ) ) & 15; } } - - assert(out_offset == n_nibbles); + assert( out_offset == n_nibbles ); } -FEC_STATIC LC3PLUS_EpModeRequest fec_estimate_epmr_from_cw0(LC3_UINT8 *cw0, LC3_INT8 *t, LC3_UINT8 *syndromes, LC3_UINT8 *elp, LC3_INT8 *deg_elp, - LC3_UINT8 *err_pos, LC3_UINT8 *err_symb, LC3_INT16 n_codewords, LC3_INT16 n_symb) +FEC_STATIC LC3PLUS_EpModeRequest fec_estimate_epmr_from_cw0( LC3_UINT8 *cw0, LC3_INT8 *t, LC3_UINT8 *syndromes, LC3_UINT8 *elp, LC3_INT8 *deg_elp, LC3_UINT8 *err_pos, LC3_UINT8 *err_symb, LC3_INT16 n_codewords, LC3_INT16 n_symb ) { - LC3_INT32 epmr_lowest_risk_exp; - LC3_INT32 start, inc, i, n_candidates; - LC3_INT32 first_codeword_length; - LC3_INT32 mode_counter; - LC3PLUS_EpModeRequest epmr; - - epmr_lowest_risk_exp = 0; - first_codeword_length = get_codeword_length(n_codewords, n_symb, 0); - start = 2; - inc = 1; - n_candidates = 0; + LC3_INT32 epmr_lowest_risk_exp; + LC3_INT32 start, inc, i, n_candidates; + LC3_INT32 first_codeword_length; + LC3_INT32 mode_counter; + LC3PLUS_EpModeRequest epmr; + + epmr_lowest_risk_exp = 0; + first_codeword_length = get_codeword_length( n_codewords, n_symb, 0 ); + start = 2; + inc = 1; + n_candidates = 0; /* test if first code word decodes in mode 0 or 1 without error correction */ - if ((syndromes[SYNDROME_IDX(0, 0)] | syndromes[SYNDROME_IDX(0, 0) + 1]) == 0 || - (syndromes[SYNDROME_IDX(1, 0)] | syndromes[SYNDROME_IDX(1, 0) + 1]) == 0) + if ( ( syndromes[SYNDROME_IDX( 0, 0 )] | syndromes[SYNDROME_IDX( 0, 0 ) + 1] ) == 0 || + ( syndromes[SYNDROME_IDX( 1, 0 )] | syndromes[SYNDROME_IDX( 1, 0 ) + 1] ) == 0 ) { epmr_lowest_risk_exp = risk_table_f[1][0].exponent; } /* test if first code word decodes in mode 2 or 3 with lower risk */ - if (deg_elp[DEG_ELP_IDX(2, 0)] <= t[2]) + if ( deg_elp[DEG_ELP_IDX( 2, 0 )] <= t[2] ) { - if (risk_table_f[2][deg_elp[DEG_ELP_IDX(2, 0)]].exponent <= -8) + if ( risk_table_f[2][deg_elp[DEG_ELP_IDX( 2, 0 )]].exponent <= -8 ) { n_candidates++; start = 2; } } - if (deg_elp[DEG_ELP_IDX(3, 0)] <= t[3]) + if ( deg_elp[DEG_ELP_IDX( 3, 0 )] <= t[3] ) { - if (risk_table_f[3][deg_elp[DEG_ELP_IDX(3, 0)]].exponent <= -8) + if ( risk_table_f[3][deg_elp[DEG_ELP_IDX( 3, 0 )]].exponent <= -8 ) { n_candidates++; start = 3; } } - if (n_candidates > 1) + if ( n_candidates > 1 ) { /* decide on order if mode 2 and 3 are considered */ - if (simple_float_cmp(risk_table_f[2][deg_elp[DEG_ELP_IDX(2, 0)]], risk_table_f[3][deg_elp[DEG_ELP_IDX(3, 0)]]) < - 0) + if ( simple_float_cmp( risk_table_f[2][deg_elp[DEG_ELP_IDX( 2, 0 )]], risk_table_f[3][deg_elp[DEG_ELP_IDX( 3, 0 )]] ) < + 0 ) { start = 2; - inc = 1; + inc = 1; } else { start = 3; - inc = -1; + inc = -1; } } - for (mode_counter = start, i = 0; i < n_candidates; mode_counter += inc, i++) + for ( mode_counter = start, i = 0; i < n_candidates; mode_counter += inc, i++ ) { - if (risk_table_f[mode_counter][deg_elp[DEG_ELP_IDX(mode_counter, 0)]].exponent < epmr_lowest_risk_exp) + if ( risk_table_f[mode_counter][deg_elp[DEG_ELP_IDX( mode_counter, 0 )]].exponent < epmr_lowest_risk_exp ) { - if (!rs16_factorize_elp(err_pos + ERR_POS_IDX(mode_counter, 0), elp + ELP_IDX(mode_counter, 0), - deg_elp[DEG_ELP_IDX(mode_counter, 0)], first_codeword_length - 1)) + if ( !rs16_factorize_elp( err_pos + ERR_POS_IDX( mode_counter, 0 ), elp + ELP_IDX( mode_counter, 0 ), + deg_elp[DEG_ELP_IDX( mode_counter, 0 )], first_codeword_length - 1 ) ) { /* code word is decodable with error correction */ - epmr_lowest_risk_exp = risk_table_f[mode_counter][deg_elp[DEG_ELP_IDX(mode_counter, 0)]].exponent; + epmr_lowest_risk_exp = risk_table_f[mode_counter][deg_elp[DEG_ELP_IDX( mode_counter, 0 )]].exponent; - rs16_calculate_errors(err_symb + ERR_SYMB_IDX(mode_counter, 0), err_pos + ERR_POS_IDX(mode_counter, 0), - syndromes + SYNDROME_IDX(mode_counter, 0), deg_elp[DEG_ELP_IDX(mode_counter, 0)], - t[mode_counter]); + rs16_calculate_errors( err_symb + ERR_SYMB_IDX( mode_counter, 0 ), err_pos + ERR_POS_IDX( mode_counter, 0 ), + syndromes + SYNDROME_IDX( mode_counter, 0 ), deg_elp[DEG_ELP_IDX( mode_counter, 0 )], + t[mode_counter] ); - for (i = 0; i < deg_elp[DEG_ELP_IDX(mode_counter, 0)]; i++) + for ( i = 0; i < deg_elp[DEG_ELP_IDX( mode_counter, 0 )]; i++ ) { - cw0[err_pos[ERR_POS_IDX(mode_counter, 0) + i]] = GF16_ADD( - cw0[err_pos[ERR_POS_IDX(mode_counter, 0) + i]], err_symb[ERR_SYMB_IDX(mode_counter, 0) + i]); + cw0[err_pos[ERR_POS_IDX( mode_counter, 0 ) + i]] = GF16_ADD( + cw0[err_pos[ERR_POS_IDX( mode_counter, 0 ) + i]], err_symb[ERR_SYMB_IDX( mode_counter, 0 ) + i] ); } break; } } } - epmr = cw0_get_epmr(cw0, first_codeword_length - 1); + epmr = cw0_get_epmr( cw0, first_codeword_length - 1 ); - if (epmr_lowest_risk_exp > -16) + if ( epmr_lowest_risk_exp > -16 ) { epmr += 4; } - if (epmr_lowest_risk_exp > -8) + if ( epmr_lowest_risk_exp > -8 ) { epmr += 4; } - + return epmr; } -FEC_STATIC LC3_INT32 rs16_detect_and_correct(LC3_UINT8 *iobuf, LC3_INT32 n_symb, LC3_INT32 n_codewords, LC3PLUS_EpModeRequest *epmr, LC3_INT16 *error_report, - LC3_INT32 *bfi, LC3_UINT8 *array_of_trust, LC3_INT32 ccc_flag, LC3_INT16 *n_pccw) +FEC_STATIC LC3_INT32 rs16_detect_and_correct( LC3_UINT8 *iobuf, LC3_INT32 n_symb, LC3_INT32 n_codewords, LC3PLUS_EpModeRequest *epmr, LC3_INT16 *error_report, LC3_INT32 *bfi, LC3_UINT8 *array_of_trust, LC3_INT32 ccc_flag, LC3_INT16 *n_pccw ) { - LC3_INT16 mode_broken[4]; - LC3_INT16 error_report_ep_ok[4]; - LC3_INT16 i, cw_counter, mode_counter, cw_offset; - LC3_INT16 codeword_length; - LC3_INT16 mode; - LC3_INT16 mode_candidates[4]; - LC3_INT16 n_mode_candidates; - LC3_INT16 broken_cw, n_broken_cw; - LC3_INT16 j, idx_min; - LC3_INT16 n_pccw0; - simple_float val_min_f; - LC3_INT16 tmp; - LC3_INT16 epmr_position; - simple_float dec_risk_f[FEC_N_MODES]; - simple_float risk_min_f; - simple_float ep_risk_thresh; - LC3_INT32 epmr_dec_fail_increment; - LC3_UINT8 const *hamming_distance; - LC3_UINT8 syndromes[FEC_TOTAL_SYNDROME_SIZE]; - LC3_UINT8 elp[FEC_TOTAL_ELP_SIZE]; - LC3_UINT8 err_pos[FEC_TOTAL_ERR_POS_SIZE]; - LC3_UINT8 err_symb[FEC_TOTAL_ERROR_SIZE]; - LC3_INT8 t[FEC_N_MODES]; - LC3_INT8 deg_elp[FEC_TOTAL_DEG_ELP_SIZE]; - LC3_UINT8 blacklist[FEC_N_MODES]; - LC3_INT32 rop; - - void (*syndr_calc[3])(LC3_UINT8 *, LC3_UINT8 *, LC3_INT32); + LC3_INT16 mode_broken[4]; + LC3_INT16 error_report_ep_ok[4]; + LC3_INT16 i, cw_counter, mode_counter, cw_offset; + LC3_INT16 codeword_length; + LC3_INT16 mode; + LC3_INT16 mode_candidates[4]; + LC3_INT16 n_mode_candidates; + LC3_INT16 broken_cw, n_broken_cw; + LC3_INT16 j, idx_min; + LC3_INT16 n_pccw0; + simple_float val_min_f; + LC3_INT16 tmp; + LC3_INT16 epmr_position; + simple_float dec_risk_f[FEC_N_MODES]; + simple_float risk_min_f; + simple_float ep_risk_thresh; + LC3_INT32 epmr_dec_fail_increment; + LC3_UINT8 const *hamming_distance; + LC3_UINT8 syndromes[FEC_TOTAL_SYNDROME_SIZE]; + LC3_UINT8 elp[FEC_TOTAL_ELP_SIZE]; + LC3_UINT8 err_pos[FEC_TOTAL_ERR_POS_SIZE]; + LC3_UINT8 err_symb[FEC_TOTAL_ERROR_SIZE]; + LC3_INT8 t[FEC_N_MODES]; + LC3_INT8 deg_elp[FEC_TOTAL_DEG_ELP_SIZE]; + LC3_UINT8 blacklist[FEC_N_MODES]; + LC3_INT32 rop; + + void ( *syndr_calc[3] )( LC3_UINT8 *, LC3_UINT8 *, LC3_INT32 ); rop = 0; /* initialization */ - blacklist[0] = 0; - blacklist[1] = 0; - blacklist[2] = 0; - blacklist[3] = 0; - mode_broken[0] = 0; - mode_broken[1] = 0; - mode_broken[2] = 0; - mode_broken[3] = 0; + blacklist[0] = 0; + blacklist[1] = 0; + blacklist[2] = 0; + blacklist[3] = 0; + mode_broken[0] = 0; + mode_broken[1] = 0; + mode_broken[2] = 0; + mode_broken[3] = 0; error_report_ep_ok[0] = ERROR_REPORT_EP1_OK; error_report_ep_ok[1] = ERROR_REPORT_EP2_OK; error_report_ep_ok[2] = ERROR_REPORT_EP3_OK; error_report_ep_ok[3] = ERROR_REPORT_EP4_OK; - hamming_distance = &hamming_distance_by_mode0[1]; - mode = -1; - n_mode_candidates = 0; + hamming_distance = &hamming_distance_by_mode0[1]; + mode = -1; + n_mode_candidates = 0; risk_min_f.mantissa = SIMPLE_FLOAT_1_MANTISSA; risk_min_f.exponent = 0; - - if (n_symb <= 80) + + if ( n_symb <= 80 ) { - ep_risk_thresh.mantissa = EP_RISK_THRESH_NS_M; - ep_risk_thresh.exponent = EP_RISK_THRESH_NS_E; + ep_risk_thresh.mantissa = EP_RISK_THRESH_NS_M; + ep_risk_thresh.exponent = EP_RISK_THRESH_NS_E; } else { - ep_risk_thresh.mantissa = EP_RISK_THRESH_OS_M; - ep_risk_thresh.exponent = EP_RISK_THRESH_OS_E; + ep_risk_thresh.mantissa = EP_RISK_THRESH_OS_M; + ep_risk_thresh.exponent = EP_RISK_THRESH_OS_E; } - + syndr_calc[0] = &rs16_calculate_two_syndromes; syndr_calc[1] = &rs16_calculate_four_syndromes; syndr_calc[2] = &rs16_calculate_six_syndromes; - - for (i = 0; i < FEC_N_MODES; i++) + + for ( i = 0; i < FEC_N_MODES; i++ ) { - t[i] = (hamming_distance[i] -1)/2; + t[i] = ( hamming_distance[i] - 1 ) / 2; } - + *error_report = 0; - *bfi = 0; - + *bfi = 0; + /* mode detection (stage 1) */ - codeword_length = get_codeword_length(n_codewords, n_symb, 0); - + codeword_length = get_codeword_length( n_codewords, n_symb, 0 ); + epmr_position = codeword_length - 1; - - rs16_calculate_two_syndromes(syndromes + SYNDROME_IDX(0, 0), iobuf, codeword_length - 1); - - if ((syndromes[0 + SYNDROME_IDX(0, 0)] | syndromes[1 + SYNDROME_IDX(0, 0)]) == 0) - { - - /* data validation for fec mode 1 */ - *epmr = cw0_get_epmr(iobuf, epmr_position); - - dw0_bitswap(iobuf + 2, 1, n_symb / 2); - - if (!crc1(iobuf + 8, n_symb - 8, *epmr, iobuf + 2, 3, 1)) + + rs16_calculate_two_syndromes( syndromes + SYNDROME_IDX( 0, 0 ), iobuf, codeword_length - 1 ); + + if ( ( syndromes[0 + SYNDROME_IDX( 0, 0 )] | syndromes[1 + SYNDROME_IDX( 0, 0 )] ) == 0 ) { + + /* data validation for fec mode 1 */ + *epmr = cw0_get_epmr( iobuf, epmr_position ); + + dw0_bitswap( iobuf + 2, 1, n_symb / 2 ); + + if ( !crc1( iobuf + 8, n_symb - 8, *epmr, iobuf + 2, 3, 1 ) ) + { *error_report |= ERROR_REPORT_ALL_OK; - mode = 0; - - - rop = mode + 1; - goto CLEANUP; - } - else - { - /* reverse bit swap */ - dw0_bitswap(iobuf + 2, 1, n_symb / 2); - - *epmr += 4; - } + mode = 0; + + + rop = mode + 1; + goto CLEANUP; + } + else + { + /* reverse bit swap */ + dw0_bitswap( iobuf + 2, 1, n_symb / 2 ); + + *epmr += 4; + } } - + blacklist[0] = 1; - + /* mode detection (stage 2) */ - + /* calculate syndromes of code words 0 to 5 and modes 1 to 3 */ cw_offset = 0; - - for (cw_counter = 0; cw_counter < 6; cw_counter++) - { - codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); - - rs16_calculate_six_syndromes(syndromes + SYNDROME_IDX(1, cw_counter), iobuf + cw_offset, - codeword_length - 1); - - cw_offset += codeword_length; - - for (mode_counter = FEC_N_MODES - 1; mode_counter >= 1; mode_counter--) + + for ( cw_counter = 0; cw_counter < 6; cw_counter++ ) { - for (i = 0; i < hamming_distance[mode_counter] - 1; i++) + codeword_length = get_codeword_length( n_codewords, n_symb, cw_counter ); + + rs16_calculate_six_syndromes( syndromes + SYNDROME_IDX( 1, cw_counter ), iobuf + cw_offset, + codeword_length - 1 ); + + cw_offset += codeword_length; + + for ( mode_counter = FEC_N_MODES - 1; mode_counter >= 1; mode_counter-- ) { - syndromes[SYNDROME_IDX(mode_counter, cw_counter) + i] = GF16_ADD( - syndromes[SYNDROME_IDX(1, cw_counter) + i], sig_poly_syndr[mode_counter][i]); + for ( i = 0; i < hamming_distance[mode_counter] - 1; i++ ) + { + syndromes[SYNDROME_IDX( mode_counter, cw_counter ) + i] = GF16_ADD( + syndromes[SYNDROME_IDX( 1, cw_counter ) + i], sig_poly_syndr[mode_counter][i] ); + } } } - } /* check for valid code words */ - for (mode_counter = 1; mode_counter < FEC_N_MODES; mode_counter++) - { - n_broken_cw = 0; - for (cw_counter = 0; cw_counter < 6; cw_counter++) - { - broken_cw = 0; - for (i = 0; i < hamming_distance[mode_counter] - 1; i++) - { - broken_cw |= syndromes[SYNDROME_IDX(mode_counter, cw_counter) + i]; - } - if (broken_cw != 0) - { - n_broken_cw ++; - } - } - - if (n_broken_cw == 0) + for ( mode_counter = 1; mode_counter < FEC_N_MODES; mode_counter++ ) { - mode = mode_counter; - cw_offset = 0; - - *epmr = cw0_get_epmr(iobuf, epmr_position); - - for (cw_counter = 0; cw_counter < 6; cw_counter++) - { - codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); - for (i = 0; i <= EP_SIG_POLY_DEG; i++) + n_broken_cw = 0; + for ( cw_counter = 0; cw_counter < 6; cw_counter++ ) { - iobuf[cw_offset + i] = GF16_ADD(iobuf[cw_offset + i], sig_polys[mode][i]); - } - cw_offset += codeword_length; + broken_cw = 0; + for ( i = 0; i < hamming_distance[mode_counter] - 1; i++ ) + { + broken_cw |= syndromes[SYNDROME_IDX( mode_counter, cw_counter ) + i]; + } + if ( broken_cw != 0 ) + { + n_broken_cw++; + } } - } - } - - if (mode < 0) /* mode hasn't been detected so far -> errors occurred in transmission */ - { - /* calculate error locator polynomials for code words 0 to 5 */ - for (mode_counter = 1; mode_counter < FEC_N_MODES; mode_counter++) - { - for (cw_counter = 0; cw_counter < 6; cw_counter++) - { - deg_elp[DEG_ELP_IDX(mode_counter, cw_counter)] = rs16_calculate_elp( - elp + ELP_IDX(mode_counter, cw_counter), syndromes + SYNDROME_IDX(mode_counter, cw_counter), - t[mode_counter]); - if (deg_elp[DEG_ELP_IDX(mode_counter, cw_counter)] > t[mode_counter]) + + if ( n_broken_cw == 0 ) { - blacklist[mode_counter] = 1; - break; - } + mode = mode_counter; + cw_offset = 0; + + *epmr = cw0_get_epmr( iobuf, epmr_position ); + + for ( cw_counter = 0; cw_counter < 6; cw_counter++ ) + { + codeword_length = get_codeword_length( n_codewords, n_symb, cw_counter ); + for ( i = 0; i <= EP_SIG_POLY_DEG; i++ ) + { + iobuf[cw_offset + i] = GF16_ADD( iobuf[cw_offset + i], sig_polys[mode][i] ); + } + cw_offset += codeword_length; + } } } - - /* risk analysis for mode candidate selection */ - for (mode_counter = 1; mode_counter < FEC_N_MODES; mode_counter++) + + if ( mode < 0 ) /* mode hasn't been detected so far -> errors occurred in transmission */ { - dec_risk_f[mode_counter].mantissa = SIMPLE_FLOAT_1_MANTISSA; - dec_risk_f[mode_counter].exponent = 0; - - if (blacklist[mode_counter] == 0) - { - for (cw_counter = 0; cw_counter < 6; cw_counter++) + /* calculate error locator polynomials for code words 0 to 5 */ + for ( mode_counter = 1; mode_counter < FEC_N_MODES; mode_counter++ ) { - dec_risk_f[mode_counter] = simple_float_mul( - dec_risk_f[mode_counter], - risk_table_f[mode_counter][deg_elp[DEG_ELP_IDX(mode_counter, cw_counter)]]); - } - - if (simple_float_cmp(dec_risk_f[mode_counter], ep_risk_thresh) <= 0) - { - mode_candidates[n_mode_candidates++] = mode_counter; + for ( cw_counter = 0; cw_counter < 6; cw_counter++ ) + { + deg_elp[DEG_ELP_IDX( mode_counter, cw_counter )] = rs16_calculate_elp( + elp + ELP_IDX( mode_counter, cw_counter ), syndromes + SYNDROME_IDX( mode_counter, cw_counter ), + t[mode_counter] ); + if ( deg_elp[DEG_ELP_IDX( mode_counter, cw_counter )] > t[mode_counter] ) + { + blacklist[mode_counter] = 1; + break; + } + } } - - if (simple_float_cmp(dec_risk_f[mode_counter], risk_min_f) < 0) + + /* risk analysis for mode candidate selection */ + for ( mode_counter = 1; mode_counter < FEC_N_MODES; mode_counter++ ) { - risk_min_f = dec_risk_f[mode_counter]; - } + dec_risk_f[mode_counter].mantissa = SIMPLE_FLOAT_1_MANTISSA; + dec_risk_f[mode_counter].exponent = 0; + + if ( blacklist[mode_counter] == 0 ) + { + for ( cw_counter = 0; cw_counter < 6; cw_counter++ ) + { + dec_risk_f[mode_counter] = simple_float_mul( + dec_risk_f[mode_counter], + risk_table_f[mode_counter][deg_elp[DEG_ELP_IDX( mode_counter, cw_counter )]] ); + } + + if ( simple_float_cmp( dec_risk_f[mode_counter], ep_risk_thresh ) <= 0 ) + { + mode_candidates[n_mode_candidates++] = mode_counter; + } + + if ( simple_float_cmp( dec_risk_f[mode_counter], risk_min_f ) < 0 ) + { + risk_min_f = dec_risk_f[mode_counter]; + } + } } - } - assert(n_mode_candidates <= 4); // suppress false gcc warning when OPTIM=3 - - /* sort mode candidates by risk */ - for (i = 0; i < n_mode_candidates; i++) - { - idx_min = i; - val_min_f = dec_risk_f[mode_candidates[i]]; - - for (j = i + 1; j < n_mode_candidates; j++) - { - if (simple_float_cmp(dec_risk_f[mode_candidates[j]], val_min_f) < 0) + assert( n_mode_candidates <= 4 ); // suppress false gcc warning when OPTIM=3 + + /* sort mode candidates by risk */ + for ( i = 0; i < n_mode_candidates; i++ ) { - val_min_f = dec_risk_f[mode_candidates[j]]; - idx_min = j; - } - } - - if (idx_min > i) - { - tmp = mode_candidates[i]; - mode_candidates[i] = mode_candidates[idx_min]; - mode_candidates[idx_min] = tmp; + idx_min = i; + val_min_f = dec_risk_f[mode_candidates[i]]; + + for ( j = i + 1; j < n_mode_candidates; j++ ) + { + if ( simple_float_cmp( dec_risk_f[mode_candidates[j]], val_min_f ) < 0 ) + { + val_min_f = dec_risk_f[mode_candidates[j]]; + idx_min = j; + } + } + + if ( idx_min > i ) + { + tmp = mode_candidates[i]; + mode_candidates[i] = mode_candidates[idx_min]; + mode_candidates[idx_min] = tmp; + } } - } - - /* try out candidate modes */ - for (i = 0; i < n_mode_candidates; i++) - { - mode = mode_candidates[i]; - - for (cw_counter = 0; cw_counter < 6; cw_counter++) - { - codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); - - if (deg_elp[DEG_ELP_IDX(mode, cw_counter)]) + + /* try out candidate modes */ + for ( i = 0; i < n_mode_candidates; i++ ) { - if (rs16_factorize_elp(err_pos + ERR_POS_IDX(mode, cw_counter), elp + ELP_IDX(mode, cw_counter), - deg_elp[DEG_ELP_IDX(mode, cw_counter)], codeword_length - 1)) + mode = mode_candidates[i]; + + for ( cw_counter = 0; cw_counter < 6; cw_counter++ ) { - /* elp did not split into distinct linear factors or error position was out of range */ - mode = -1; - break; + codeword_length = get_codeword_length( n_codewords, n_symb, cw_counter ); + + if ( deg_elp[DEG_ELP_IDX( mode, cw_counter )] ) + { + if ( rs16_factorize_elp( err_pos + ERR_POS_IDX( mode, cw_counter ), elp + ELP_IDX( mode, cw_counter ), + deg_elp[DEG_ELP_IDX( mode, cw_counter )], codeword_length - 1 ) ) + { + /* elp did not split into distinct linear factors or error position was out of range */ + mode = -1; + break; + } + } + } + if ( mode > 0 ) + { + /* decodable mode with lowest risk has been found */ + break; } } - } - if (mode > 0) + + if ( mode < 0 ) { - /* decodable mode with lowest risk has been found */ - break; + /* no decodable mode has been found */ + *error_report = ERROR_REPORT_BEC_MASK; + *bfi = 1; + mode = -1; + + *epmr = fec_estimate_epmr_from_cw0( iobuf, t, syndromes, elp, deg_elp, err_pos, err_symb, n_codewords, + n_symb ); + + + rop = mode; + goto CLEANUP; } - } - - if (mode < 0) - { - /* no decodable mode has been found */ - *error_report = ERROR_REPORT_BEC_MASK; - *bfi = 1; - mode = -1; - - *epmr = fec_estimate_epmr_from_cw0(iobuf, t, syndromes, elp, deg_elp, err_pos, err_symb, n_codewords, - n_symb); - - - rop = mode; - goto CLEANUP; - } - - /* perform error correction */ - cw_offset = 0; - *error_report = 0; - for (cw_counter = 0; cw_counter < 6; cw_counter++) - { - codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); - - if (deg_elp[DEG_ELP_IDX(mode, cw_counter)]) - { - rs16_calculate_errors( - err_symb + ERR_SYMB_IDX(mode, cw_counter), err_pos + ERR_POS_IDX(mode, cw_counter), - syndromes + SYNDROME_IDX(mode, cw_counter), deg_elp[DEG_ELP_IDX(mode, cw_counter)], t[mode]); - - /* correct errors and sum up number of corrected bits */ - for (i = 0; i < deg_elp[DEG_ELP_IDX(mode, cw_counter)]; i++) + + /* perform error correction */ + cw_offset = 0; + *error_report = 0; + for ( cw_counter = 0; cw_counter < 6; cw_counter++ ) { - iobuf[err_pos[ERR_POS_IDX(mode, cw_counter) + i] + cw_offset] = - GF16_ADD(iobuf[err_pos[ERR_POS_IDX(mode, cw_counter) + i] + cw_offset], - err_symb[ERR_SYMB_IDX(mode, cw_counter) + i]); - *error_report += rs16_bit_count_table[err_symb[ERR_SYMB_IDX(mode, cw_counter) + i]]; - } + codeword_length = get_codeword_length( n_codewords, n_symb, cw_counter ); - for (i = 0; i < mode; i ++) + if ( deg_elp[DEG_ELP_IDX( mode, cw_counter )] ) + { + rs16_calculate_errors( + err_symb + ERR_SYMB_IDX( mode, cw_counter ), err_pos + ERR_POS_IDX( mode, cw_counter ), + syndromes + SYNDROME_IDX( mode, cw_counter ), deg_elp[DEG_ELP_IDX( mode, cw_counter )], t[mode] ); + + /* correct errors and sum up number of corrected bits */ + for ( i = 0; i < deg_elp[DEG_ELP_IDX( mode, cw_counter )]; i++ ) { - if(deg_elp[DEG_ELP_IDX(mode, cw_counter)] > i) + iobuf[err_pos[ERR_POS_IDX( mode, cw_counter ) + i] + cw_offset] = + GF16_ADD( iobuf[err_pos[ERR_POS_IDX( mode, cw_counter ) + i] + cw_offset], + err_symb[ERR_SYMB_IDX( mode, cw_counter ) + i] ); + *error_report += rs16_bit_count_table[err_symb[ERR_SYMB_IDX( mode, cw_counter ) + i]]; + } + + for ( i = 0; i < mode; i++ ) + { + if ( deg_elp[DEG_ELP_IDX( mode, cw_counter )] > i ) { mode_broken[i] = 1; } } + } + for ( i = 0; i <= EP_SIG_POLY_DEG; i++ ) + { + iobuf[cw_offset + i] = GF16_ADD( iobuf[cw_offset + i], sig_polys[mode][i] ); + } + cw_offset += codeword_length; } - - for (i = 0; i <= EP_SIG_POLY_DEG; i++) + + /* set epmr according to risk value of cw0 */ + epmr_dec_fail_increment = 8; + + if ( risk_table_f[mode][deg_elp[DEG_ELP_IDX( mode, 0 )]].exponent <= -8 ) { - iobuf[cw_offset + i] = GF16_ADD(iobuf[cw_offset + i], sig_polys[mode][i]); + epmr_dec_fail_increment -= 4; } - cw_offset += codeword_length; - } - - /* set epmr according to risk value of cw0 */ - epmr_dec_fail_increment = 8; - - if (risk_table_f[mode][deg_elp[DEG_ELP_IDX(mode, 0)]].exponent <= -8) - { - epmr_dec_fail_increment -= 4; - } - if (risk_table_f[mode][deg_elp[DEG_ELP_IDX(mode, 0)]].exponent <= -16) - { - epmr_dec_fail_increment -= 4; - } - - *epmr = (LC3PLUS_EpModeRequest)(cw0_get_epmr(iobuf, epmr_position) + epmr_dec_fail_increment); + if ( risk_table_f[mode][deg_elp[DEG_ELP_IDX( mode, 0 )]].exponent <= -16 ) + { + epmr_dec_fail_increment -= 4; + } + + *epmr = (LC3PLUS_EpModeRequest) ( cw0_get_epmr( iobuf, epmr_position ) + epmr_dec_fail_increment ); } - + /* mode has been successfully detected -> now check and try to correct remaining code words*/ - *n_pccw = fec_get_n_pccw(n_symb / 2, mode + 1, ccc_flag); - if (ccc_flag == 0) + *n_pccw = fec_get_n_pccw( n_symb / 2, mode + 1, ccc_flag ); + if ( ccc_flag == 0 ) { - n_pccw0 = fec_get_n_pccw(n_symb / 2, mode + 1, ccc_flag); - *n_pccw = n_pccw0; + n_pccw0 = fec_get_n_pccw( n_symb / 2, mode + 1, ccc_flag ); + *n_pccw = n_pccw0; } else { - n_pccw0 = 0; + n_pccw0 = 0; } - - for (cw_counter = 6; cw_counter < n_codewords; cw_counter++) + + for ( cw_counter = 6; cw_counter < n_codewords; cw_counter++ ) { - /* usual error correction scheme: syndromes -> elp's, errors, etc. */ - codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); - array_of_trust[n_codewords - 1 - cw_counter] = 1; - - syndr_calc[t[mode] - 1](syndromes, iobuf + cw_offset, codeword_length -1); - - deg_elp[0] = rs16_calculate_elp(elp, syndromes, t[mode]); - - for (i = 0; i < mode; i ++) + /* usual error correction scheme: syndromes -> elp's, errors, etc. */ + codeword_length = get_codeword_length( n_codewords, n_symb, cw_counter ); + array_of_trust[n_codewords - 1 - cw_counter] = 1; + + syndr_calc[t[mode] - 1]( syndromes, iobuf + cw_offset, codeword_length - 1 ); + + deg_elp[0] = rs16_calculate_elp( elp, syndromes, t[mode] ); + + for ( i = 0; i < mode; i++ ) { - if (deg_elp[0] > i) + if ( deg_elp[0] > i ) { mode_broken[i] = 1; } } - if (deg_elp[0] > t[mode]) - { - for (i = 0; i < 4; i ++) - { - mode_broken[i] = 1; - } - cw_offset += codeword_length; - if (cw_counter < n_codewords - n_pccw0) - { - *error_report = ERROR_REPORT_BEC_MASK; - mode = -1; - *bfi = 1; - break; - } - else + if ( deg_elp[0] > t[mode] ) { - *bfi = 2; - array_of_trust[n_codewords - 1 - cw_counter] = 0; - continue; - } - } - - if (deg_elp[0]) - { - if (rs16_factorize_elp(err_pos, elp, deg_elp[0], codeword_length - 1)) - { - cw_offset += codeword_length; - for (i = 0; i < 4; i ++) + for ( i = 0; i < 4; i++ ) { mode_broken[i] = 1; } - if (cw_counter < n_codewords - n_pccw0) + cw_offset += codeword_length; + if ( cw_counter < n_codewords - n_pccw0 ) { *error_report = ERROR_REPORT_BEC_MASK; mode = -1; *bfi = 1; - break; } else { - *bfi = 2; + *bfi = 2; array_of_trust[n_codewords - 1 - cw_counter] = 0; continue; } } - - rs16_calculate_errors(err_symb, err_pos, syndromes, deg_elp[0], t[mode]); - - /* correct errors and sum up number of corrected bits */ - for (i = 0; i < deg_elp[0]; i++) + + if ( deg_elp[0] ) { - iobuf[err_pos[i] + cw_offset] = GF16_ADD(iobuf[err_pos[i] + cw_offset], err_symb[i]); - *error_report += rs16_bit_count_table[err_symb[i]]; + if ( rs16_factorize_elp( err_pos, elp, deg_elp[0], codeword_length - 1 ) ) + { + cw_offset += codeword_length; + for ( i = 0; i < 4; i++ ) + { + mode_broken[i] = 1; + } + if ( cw_counter < n_codewords - n_pccw0 ) + { + *error_report = ERROR_REPORT_BEC_MASK; + mode = -1; + *bfi = 1; + + break; + } + else + { + *bfi = 2; + array_of_trust[n_codewords - 1 - cw_counter] = 0; + continue; + } + } + + rs16_calculate_errors( err_symb, err_pos, syndromes, deg_elp[0], t[mode] ); + + /* correct errors and sum up number of corrected bits */ + for ( i = 0; i < deg_elp[0]; i++ ) + { + iobuf[err_pos[i] + cw_offset] = GF16_ADD( iobuf[err_pos[i] + cw_offset], err_symb[i] ); + *error_report += rs16_bit_count_table[err_symb[i]]; + } + } + cw_offset += codeword_length; + if ( risk_table_f[mode][deg_elp[0]].exponent > -16 ) + { + array_of_trust[n_codewords - 1 - cw_counter] = 0; } } - cw_offset += codeword_length; - if (risk_table_f[mode][deg_elp[0]].exponent > -16) - { - array_of_trust[n_codewords - 1 - cw_counter] = 0; - } - } - + *error_report &= ERROR_REPORT_BEC_MASK; - for (i = 0; i < 4; i ++) + for ( i = 0; i < 4; i++ ) { - if (!mode_broken[i]) + if ( !mode_broken[i] ) { *error_report |= error_report_ep_ok[i]; } } - if (mode >= 0) + if ( mode >= 0 ) { rop = mode + 1; - } else { + } + else + { rop = -1; } - - + CLEANUP: return rop; } -FEC_STATIC void rs16_calculate_six_syndromes(LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg) +FEC_STATIC void rs16_calculate_six_syndromes( LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg ) { - LC3_INT32 i; - LC3_UINT8 buffer[15]; + LC3_INT32 i; + LC3_UINT8 buffer[15]; - assert(cw_poly_deg >= 12); + assert( cw_poly_deg >= 12 ); - for (i = 0; i <= cw_poly_deg; i++) + for ( i = 0; i <= cw_poly_deg; i++ ) { buffer[i] = cw[i]; } @@ -1450,121 +2163,119 @@ FEC_STATIC void rs16_calculate_six_syndromes(LC3_UINT8 *syndromes, LC3_UINT8 *cw syndromes[4] = buffer[0]; syndromes[5] = buffer[0]; - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[1], 32)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[1], 64)); - syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[1], 128)); - syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[1], 48)); - syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[1], 96)); - syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[1], 192)); - - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[2], 64)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[2], 48)); - syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[2], 192)); - syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[2], 80)); - syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[2], 112)); - syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[2], 240)); - - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[3], 128)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[3], 192)); - syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[3], 160)); - syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[3], 240)); - syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[3], 16)); - syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[3], 128)); - - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[4], 48)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[4], 80)); - syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[4], 240)); - syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[4], 32)); - syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[4], 96)); - syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[4], 160)); - - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[5], 96)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[5], 112)); - syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[5], 16)); - syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[5], 96)); - syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[5], 112)); - syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[5], 16)); - - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[6], 192)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[6], 240)); - syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[6], 128)); - syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[6], 160)); - syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[6], 16)); - syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[6], 192)); - - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[7], 176)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[7], 144)); - syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[7], 192)); - syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[7], 208)); - syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[7], 96)); - syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[7], 240)); - - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[8], 80)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[8], 32)); - syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[8], 160)); - syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[8], 64)); - syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[8], 112)); - syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[8], 128)); - - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[9], 160)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[9], 128)); - syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[9], 240)); - syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[9], 192)); - syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[9], 16)); - syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[9], 160)); - - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[10], 112)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[10], 96)); - syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[10], 16)); - syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[10], 112)); - syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[10], 96)); - syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[10], 16)); - - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[11], 224)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[11], 176)); - syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[11], 128)); - syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[11], 144)); - syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[11], 112)); - syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[11], 192)); - - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[12], 240)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[12], 160)); - syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[12], 192)); - syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[12], 128)); - syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[12], 16)); - syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[12], 240)); - - if (cw_poly_deg >= 13) - { - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[13], 208)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[13], 224)); - syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[13], 160)); - syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[13], 176)); - syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[13], 96)); - syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[13], 128)); - } - - if (cw_poly_deg >= 14) - { - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[14], 144)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[14], 208)); - syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[14], 240)); - syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[14], 224)); - syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[14], 112)); - syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[14], 160)); - } - - + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[1], 32 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[1], 64 ) ); + syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[1], 128 ) ); + syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[1], 48 ) ); + syndromes[4] = GF16_ADD( syndromes[4], GF16_MUL0( buffer[1], 96 ) ); + syndromes[5] = GF16_ADD( syndromes[5], GF16_MUL0( buffer[1], 192 ) ); + + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[2], 64 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[2], 48 ) ); + syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[2], 192 ) ); + syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[2], 80 ) ); + syndromes[4] = GF16_ADD( syndromes[4], GF16_MUL0( buffer[2], 112 ) ); + syndromes[5] = GF16_ADD( syndromes[5], GF16_MUL0( buffer[2], 240 ) ); + + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[3], 128 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[3], 192 ) ); + syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[3], 160 ) ); + syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[3], 240 ) ); + syndromes[4] = GF16_ADD( syndromes[4], GF16_MUL0( buffer[3], 16 ) ); + syndromes[5] = GF16_ADD( syndromes[5], GF16_MUL0( buffer[3], 128 ) ); + + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[4], 48 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[4], 80 ) ); + syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[4], 240 ) ); + syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[4], 32 ) ); + syndromes[4] = GF16_ADD( syndromes[4], GF16_MUL0( buffer[4], 96 ) ); + syndromes[5] = GF16_ADD( syndromes[5], GF16_MUL0( buffer[4], 160 ) ); + + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[5], 96 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[5], 112 ) ); + syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[5], 16 ) ); + syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[5], 96 ) ); + syndromes[4] = GF16_ADD( syndromes[4], GF16_MUL0( buffer[5], 112 ) ); + syndromes[5] = GF16_ADD( syndromes[5], GF16_MUL0( buffer[5], 16 ) ); + + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[6], 192 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[6], 240 ) ); + syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[6], 128 ) ); + syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[6], 160 ) ); + syndromes[4] = GF16_ADD( syndromes[4], GF16_MUL0( buffer[6], 16 ) ); + syndromes[5] = GF16_ADD( syndromes[5], GF16_MUL0( buffer[6], 192 ) ); + + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[7], 176 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[7], 144 ) ); + syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[7], 192 ) ); + syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[7], 208 ) ); + syndromes[4] = GF16_ADD( syndromes[4], GF16_MUL0( buffer[7], 96 ) ); + syndromes[5] = GF16_ADD( syndromes[5], GF16_MUL0( buffer[7], 240 ) ); + + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[8], 80 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[8], 32 ) ); + syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[8], 160 ) ); + syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[8], 64 ) ); + syndromes[4] = GF16_ADD( syndromes[4], GF16_MUL0( buffer[8], 112 ) ); + syndromes[5] = GF16_ADD( syndromes[5], GF16_MUL0( buffer[8], 128 ) ); + + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[9], 160 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[9], 128 ) ); + syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[9], 240 ) ); + syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[9], 192 ) ); + syndromes[4] = GF16_ADD( syndromes[4], GF16_MUL0( buffer[9], 16 ) ); + syndromes[5] = GF16_ADD( syndromes[5], GF16_MUL0( buffer[9], 160 ) ); + + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[10], 112 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[10], 96 ) ); + syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[10], 16 ) ); + syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[10], 112 ) ); + syndromes[4] = GF16_ADD( syndromes[4], GF16_MUL0( buffer[10], 96 ) ); + syndromes[5] = GF16_ADD( syndromes[5], GF16_MUL0( buffer[10], 16 ) ); + + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[11], 224 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[11], 176 ) ); + syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[11], 128 ) ); + syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[11], 144 ) ); + syndromes[4] = GF16_ADD( syndromes[4], GF16_MUL0( buffer[11], 112 ) ); + syndromes[5] = GF16_ADD( syndromes[5], GF16_MUL0( buffer[11], 192 ) ); + + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[12], 240 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[12], 160 ) ); + syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[12], 192 ) ); + syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[12], 128 ) ); + syndromes[4] = GF16_ADD( syndromes[4], GF16_MUL0( buffer[12], 16 ) ); + syndromes[5] = GF16_ADD( syndromes[5], GF16_MUL0( buffer[12], 240 ) ); + + if ( cw_poly_deg >= 13 ) + { + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[13], 208 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[13], 224 ) ); + syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[13], 160 ) ); + syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[13], 176 ) ); + syndromes[4] = GF16_ADD( syndromes[4], GF16_MUL0( buffer[13], 96 ) ); + syndromes[5] = GF16_ADD( syndromes[5], GF16_MUL0( buffer[13], 128 ) ); + } + + if ( cw_poly_deg >= 14 ) + { + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[14], 144 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[14], 208 ) ); + syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[14], 240 ) ); + syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[14], 224 ) ); + syndromes[4] = GF16_ADD( syndromes[4], GF16_MUL0( buffer[14], 112 ) ); + syndromes[5] = GF16_ADD( syndromes[5], GF16_MUL0( buffer[14], 160 ) ); + } } -FEC_STATIC void rs16_calculate_four_syndromes(LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg) +FEC_STATIC void rs16_calculate_four_syndromes( LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg ) { - LC3_INT32 i; - LC3_UINT8 buffer[15]; + LC3_INT32 i; + LC3_UINT8 buffer[15]; - assert(cw_poly_deg >= 12); + assert( cw_poly_deg >= 12 ); - for (i = 0; i <= cw_poly_deg; i++) + for ( i = 0; i <= cw_poly_deg; i++ ) { buffer[i] = cw[i]; } @@ -1574,93 +2285,91 @@ FEC_STATIC void rs16_calculate_four_syndromes(LC3_UINT8 *syndromes, LC3_UINT8 *c syndromes[2] = buffer[0]; syndromes[3] = buffer[0]; - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[1], 32)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[1], 64)); - syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[1], 128)); - syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[1], 48)); - - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[2], 64)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[2], 48)); - syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[2], 192)); - syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[2], 80)); - - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[3], 128)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[3], 192)); - syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[3], 160)); - syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[3], 240)); - - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[4], 48)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[4], 80)); - syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[4], 240)); - syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[4], 32)); - - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[5], 96)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[5], 112)); - syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[5], 16)); - syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[5], 96)); - - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[6], 192)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[6], 240)); - syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[6], 128)); - syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[6], 160)); - - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[7], 176)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[7], 144)); - syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[7], 192)); - syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[7], 208)); - - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[8], 80)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[8], 32)); - syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[8], 160)); - syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[8], 64)); - - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[9], 160)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[9], 128)); - syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[9], 240)); - syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[9], 192)); - - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[10], 112)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[10], 96)); - syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[10], 16)); - syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[10], 112)); - - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[11], 224)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[11], 176)); - syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[11], 128)); - syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[11], 144)); - - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[12], 240)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[12], 160)); - syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[12], 192)); - syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[12], 128)); - - if (cw_poly_deg >= 13) - { - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[13], 208)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[13], 224)); - syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[13], 160)); - syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[13], 176)); - } - - if (cw_poly_deg >= 14) - { - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[14], 144)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[14], 208)); - syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[14], 240)); - syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[14], 224)); + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[1], 32 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[1], 64 ) ); + syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[1], 128 ) ); + syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[1], 48 ) ); + + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[2], 64 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[2], 48 ) ); + syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[2], 192 ) ); + syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[2], 80 ) ); + + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[3], 128 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[3], 192 ) ); + syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[3], 160 ) ); + syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[3], 240 ) ); + + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[4], 48 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[4], 80 ) ); + syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[4], 240 ) ); + syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[4], 32 ) ); + + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[5], 96 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[5], 112 ) ); + syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[5], 16 ) ); + syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[5], 96 ) ); + + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[6], 192 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[6], 240 ) ); + syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[6], 128 ) ); + syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[6], 160 ) ); + + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[7], 176 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[7], 144 ) ); + syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[7], 192 ) ); + syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[7], 208 ) ); + + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[8], 80 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[8], 32 ) ); + syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[8], 160 ) ); + syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[8], 64 ) ); + + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[9], 160 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[9], 128 ) ); + syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[9], 240 ) ); + syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[9], 192 ) ); + + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[10], 112 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[10], 96 ) ); + syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[10], 16 ) ); + syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[10], 112 ) ); + + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[11], 224 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[11], 176 ) ); + syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[11], 128 ) ); + syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[11], 144 ) ); + + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[12], 240 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[12], 160 ) ); + syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[12], 192 ) ); + syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[12], 128 ) ); + + if ( cw_poly_deg >= 13 ) + { + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[13], 208 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[13], 224 ) ); + syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[13], 160 ) ); + syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[13], 176 ) ); + } + + if ( cw_poly_deg >= 14 ) + { + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[14], 144 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[14], 208 ) ); + syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[14], 240 ) ); + syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[14], 224 ) ); } - - } -FEC_STATIC void rs16_calculate_two_syndromes(LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg) +FEC_STATIC void rs16_calculate_two_syndromes( LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg ) { - LC3_INT32 i; - LC3_UINT8 buffer[15]; + LC3_INT32 i; + LC3_UINT8 buffer[15]; - assert(cw_poly_deg >= 12); + assert( cw_poly_deg >= 12 ); - for (i = 0; i <= cw_poly_deg; i++) + for ( i = 0; i <= cw_poly_deg; i++ ) { buffer[i] = cw[i]; } @@ -1668,662 +2377,659 @@ FEC_STATIC void rs16_calculate_two_syndromes(LC3_UINT8 *syndromes, LC3_UINT8 *cw syndromes[0] = buffer[0]; syndromes[1] = buffer[0]; - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[1], 32)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[1], 64)); + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[1], 32 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[1], 64 ) ); - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[2], 64)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[2], 48)); + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[2], 64 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[2], 48 ) ); - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[3], 128)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[3], 192)); + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[3], 128 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[3], 192 ) ); - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[4], 48)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[4], 80)); + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[4], 48 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[4], 80 ) ); - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[5], 96)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[5], 112)); + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[5], 96 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[5], 112 ) ); - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[6], 192)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[6], 240)); + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[6], 192 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[6], 240 ) ); - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[7], 176)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[7], 144)); + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[7], 176 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[7], 144 ) ); - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[8], 80)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[8], 32)); + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[8], 80 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[8], 32 ) ); - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[9], 160)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[9], 128)); + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[9], 160 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[9], 128 ) ); - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[10], 112)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[10], 96)); + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[10], 112 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[10], 96 ) ); - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[11], 224)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[11], 176)); + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[11], 224 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[11], 176 ) ); - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[12], 240)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[12], 160)); + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[12], 240 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[12], 160 ) ); - if (cw_poly_deg >= 13) + if ( cw_poly_deg >= 13 ) { - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[13], 208)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[13], 224)); + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[13], 208 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[13], 224 ) ); } - if (cw_poly_deg >= 14) + if ( cw_poly_deg >= 14 ) { - syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[14], 144)); - syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[14], 208)); + syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[14], 144 ) ); + syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[14], 208 ) ); } - - } -FEC_STATIC LC3_INT8 rs16_calculate_elp(LC3_UINT8 *elp, LC3_UINT8 *syndromes, LC3_INT16 t) +FEC_STATIC LC3_INT8 rs16_calculate_elp( LC3_UINT8 *elp, LC3_UINT8 *syndromes, LC3_INT16 t ) /* calculates error locator polynomial vie Petterson's algorithm */ { - LC3_INT8 ret; - LC3_UINT8 det, det_inv, aux, all_s, *s; - LC3_UINT8 s22, s33, s44, s13, s14, s15; - LC3_UINT8 s23, s24, s25, s34, s35; - LC3_UINT8 a, b, c, d, e, f; - - ret = 0; - all_s = 0; - s = syndromes; + LC3_INT8 ret; + LC3_UINT8 det, det_inv, aux, all_s, *s; + LC3_UINT8 s22, s33, s44, s13, s14, s15; + LC3_UINT8 s23, s24, s25, s34, s35; + LC3_UINT8 a, b, c, d, e, f; + + ret = 0; + all_s = 0; + s = syndromes; elp[0] = 1; - memset(elp + 1, 0, 3); + memset( elp + 1, 0, 3 ); - switch (t) - { - case 3: + switch ( t ) { - /* check for errors */ - all_s = s[0] | s[1] | s[2] | s[3] | s[4] | s[5]; - - if (all_s == 0) + case 3: { - break; - } + /* check for errors */ + all_s = s[0] | s[1] | s[2] | s[3] | s[4] | s[5]; + + if ( all_s == 0 ) + { + break; + } - /* assume 3 errors */ - s22 = GF16_MUL(s[1], s[1]); - s33 = GF16_MUL(s[2], s[2]); - s44 = GF16_MUL(s[3], s[3]); - s13 = GF16_MUL(s[0], s[2]); + /* assume 3 errors */ + s22 = GF16_MUL( s[1], s[1] ); + s33 = GF16_MUL( s[2], s[2] ); + s44 = GF16_MUL( s[3], s[3] ); + s13 = GF16_MUL( s[0], s[2] ); - det = GF16_ADD(GF16_ADD(GF16_MUL(s13, s[4]), GF16_MUL(s44, s[0])), - GF16_ADD(GF16_MUL(s22, s[4]), GF16_MUL(s33, s[2]))); + det = GF16_ADD( GF16_ADD( GF16_MUL( s13, s[4] ), GF16_MUL( s44, s[0] ) ), + GF16_ADD( GF16_MUL( s22, s[4] ), GF16_MUL( s33, s[2] ) ) ); - if (det) - { - det_inv = gf16_inv_table[det] << 4; + if ( det ) + { + det_inv = gf16_inv_table[det] << 4; - s14 = GF16_MUL(s[0], s[3]); - s15 = GF16_MUL(s[0], s[4]); + s14 = GF16_MUL( s[0], s[3] ); + s15 = GF16_MUL( s[0], s[4] ); - s23 = GF16_MUL(s[1], s[2]); - s24 = GF16_MUL(s[1], s[3]); - s25 = GF16_MUL(s[1], s[4]); + s23 = GF16_MUL( s[1], s[2] ); + s24 = GF16_MUL( s[1], s[3] ); + s25 = GF16_MUL( s[1], s[4] ); - s34 = GF16_MUL(s[2], s[3]); - s35 = GF16_MUL(s[2], s[4]); + s34 = GF16_MUL( s[2], s[3] ); + s35 = GF16_MUL( s[2], s[4] ); - a = GF16_ADD(s35, s44) << 4; - b = GF16_ADD(s15, s33) << 4; - c = GF16_ADD(s13, s22) << 4; - d = GF16_ADD(s34, s25) << 4; - e = GF16_ADD(s23, s14) << 4; - f = GF16_ADD(s24, s33) << 4; + a = GF16_ADD( s35, s44 ) << 4; + b = GF16_ADD( s15, s33 ) << 4; + c = GF16_ADD( s13, s22 ) << 4; + d = GF16_ADD( s34, s25 ) << 4; + e = GF16_ADD( s23, s14 ) << 4; + f = GF16_ADD( s24, s33 ) << 4; - aux = GF16_ADD(GF16_ADD(GF16_MUL0(a, s[3]), GF16_MUL0(d, s[4])), GF16_MUL0(f, s[5])); - elp[3] = GF16_MUL0(aux, det_inv); + aux = GF16_ADD( GF16_ADD( GF16_MUL0( a, s[3] ), GF16_MUL0( d, s[4] ) ), GF16_MUL0( f, s[5] ) ); + elp[3] = GF16_MUL0( aux, det_inv ); - aux = GF16_ADD(GF16_ADD(GF16_MUL0(d, s[3]), GF16_MUL0(b, s[4])), GF16_MUL0(e, s[5])); - elp[2] = GF16_MUL0(aux, det_inv); + aux = GF16_ADD( GF16_ADD( GF16_MUL0( d, s[3] ), GF16_MUL0( b, s[4] ) ), GF16_MUL0( e, s[5] ) ); + elp[2] = GF16_MUL0( aux, det_inv ); - aux = GF16_ADD(GF16_ADD(GF16_MUL0(f, s[3]), GF16_MUL0(e, s[4])), GF16_MUL0(c, s[5])); - elp[1] = GF16_MUL0(aux, det_inv); + aux = GF16_ADD( GF16_ADD( GF16_MUL0( f, s[3] ), GF16_MUL0( e, s[4] ) ), GF16_MUL0( c, s[5] ) ); + elp[1] = GF16_MUL0( aux, det_inv ); - if (elp[3] == 0) - { - ret = t+1; - } - else - { - ret = 3; + if ( elp[3] == 0 ) + { + ret = t + 1; + } + else + { + ret = 3; + } + break; } - break; - } - /* assume two errors */ - det = GF16_ADD(GF16_MUL(syndromes[0], syndromes[2]), GF16_MUL(syndromes[1], syndromes[1])); + /* assume two errors */ + det = GF16_ADD( GF16_MUL( syndromes[0], syndromes[2] ), GF16_MUL( syndromes[1], syndromes[1] ) ); - if (det) - { - det_inv = gf16_inv_table[det] << 4; + if ( det ) + { + det_inv = gf16_inv_table[det] << 4; - aux = GF16_ADD(GF16_MUL(syndromes[1], syndromes[2]), GF16_MUL(syndromes[0], syndromes[3])); - elp[1] = GF16_MUL0(aux, det_inv); + aux = GF16_ADD( GF16_MUL( syndromes[1], syndromes[2] ), GF16_MUL( syndromes[0], syndromes[3] ) ); + elp[1] = GF16_MUL0( aux, det_inv ); - aux = GF16_ADD(GF16_MUL(syndromes[2], syndromes[2]), GF16_MUL(syndromes[1], syndromes[3])); - elp[2] = GF16_MUL0(aux, det_inv); + aux = GF16_ADD( GF16_MUL( syndromes[2], syndromes[2] ), GF16_MUL( syndromes[1], syndromes[3] ) ); + elp[2] = GF16_MUL0( aux, det_inv ); - /* check remaining LSF relations */ - aux = GF16_ADD(GF16_ADD(GF16_MUL(elp[2], s[2]), GF16_MUL(elp[1], s[3])), s[4]) - | GF16_ADD(GF16_ADD(GF16_MUL(elp[2], s[3]), GF16_MUL(elp[1], s[4])), s[5]); + /* check remaining LSF relations */ + aux = GF16_ADD( GF16_ADD( GF16_MUL( elp[2], s[2] ), GF16_MUL( elp[1], s[3] ) ), s[4] ) | GF16_ADD( GF16_ADD( GF16_MUL( elp[2], s[3] ), GF16_MUL( elp[1], s[4] ) ), s[5] ); - aux |= elp[2] == 0; + aux |= elp[2] == 0; - if (aux != 0) - { - ret = t + 1; - } - else - { - ret = 2; + if ( aux != 0 ) + { + ret = t + 1; + } + else + { + ret = 2; + } + break; } - break; - } - /* assume one error */ - if (syndromes[0] != 0) - { - elp[1] = GF16_MUL(syndromes[1], gf16_inv_table[syndromes[0]]); + /* assume one error */ + if ( syndromes[0] != 0 ) + { + elp[1] = GF16_MUL( syndromes[1], gf16_inv_table[syndromes[0]] ); - /* check remaining LSF relations */ - aux = GF16_ADD(GF16_MUL(elp[1], s[1]), s[2]) - | GF16_ADD(GF16_MUL(elp[1], s[2]), s[3]) - | GF16_ADD(GF16_MUL(elp[1], s[3]), s[4]) - | GF16_ADD(GF16_MUL(elp[1], s[4]), s[5]); + /* check remaining LSF relations */ + aux = GF16_ADD( GF16_MUL( elp[1], s[1] ), s[2] ) | GF16_ADD( GF16_MUL( elp[1], s[2] ), s[3] ) | GF16_ADD( GF16_MUL( elp[1], s[3] ), s[4] ) | GF16_ADD( GF16_MUL( elp[1], s[4] ), s[5] ); - aux |= elp[1] == 0; + aux |= elp[1] == 0; - if (aux != 0) - { - ret = t + 1; - } - else - { - ret = 1; + if ( aux != 0 ) + { + ret = t + 1; + } + else + { + ret = 1; + } + break; } - break; - } - - ret = t + 1; - break; - } - case 2: - { - all_s = s[0] | s[1] | s[2] | s[3]; - if (all_s == 0) - { + ret = t + 1; break; } - - /* assume two errors */ - det = GF16_ADD(GF16_MUL(syndromes[0], syndromes[2]), GF16_MUL(syndromes[1], syndromes[1])); - - if (det) + case 2: { - det_inv = gf16_inv_table[det] << 4; - - aux = GF16_ADD(GF16_MUL(syndromes[1], syndromes[2]), GF16_MUL(syndromes[0], syndromes[3])); - elp[1] = GF16_MUL0(aux, det_inv); + all_s = s[0] | s[1] | s[2] | s[3]; - aux = GF16_ADD(GF16_MUL(syndromes[2], syndromes[2]), GF16_MUL(syndromes[1], syndromes[3])); - elp[2] = GF16_MUL0(aux, det_inv); - - if (elp[2] == 0) + if ( all_s == 0 ) { - ret = t + 1; + break; } - else + + /* assume two errors */ + det = GF16_ADD( GF16_MUL( syndromes[0], syndromes[2] ), GF16_MUL( syndromes[1], syndromes[1] ) ); + + if ( det ) { - ret = 2; - } - break; - } + det_inv = gf16_inv_table[det] << 4; - /* assume one error */ - if (syndromes[0] != 0) - { - elp[1] = GF16_MUL(syndromes[1], gf16_inv_table[syndromes[0]]); + aux = GF16_ADD( GF16_MUL( syndromes[1], syndromes[2] ), GF16_MUL( syndromes[0], syndromes[3] ) ); + elp[1] = GF16_MUL0( aux, det_inv ); - /* check remaining LSF relation */ - aux = GF16_ADD(GF16_MUL(elp[1], s[1]), s[2]) | GF16_ADD(GF16_MUL(elp[1], s[2]), s[3]); - aux |= elp[1] == 0; + aux = GF16_ADD( GF16_MUL( syndromes[2], syndromes[2] ), GF16_MUL( syndromes[1], syndromes[3] ) ); + elp[2] = GF16_MUL0( aux, det_inv ); - if (aux != 0) - { - ret = t + 1; + if ( elp[2] == 0 ) + { + ret = t + 1; + } + else + { + ret = 2; + } + break; } - else + + /* assume one error */ + if ( syndromes[0] != 0 ) { - ret = 1; - } - break; - } + elp[1] = GF16_MUL( syndromes[1], gf16_inv_table[syndromes[0]] ); - ret = t + 1; - break; - } - case 1: - { - all_s = s[0] | s[1]; + /* check remaining LSF relation */ + aux = GF16_ADD( GF16_MUL( elp[1], s[1] ), s[2] ) | GF16_ADD( GF16_MUL( elp[1], s[2] ), s[3] ); + aux |= elp[1] == 0; - if (all_s == 0) - { + if ( aux != 0 ) + { + ret = t + 1; + } + else + { + ret = 1; + } + break; + } + + ret = t + 1; break; } - - if (syndromes[0] != 0) + case 1: { - elp[1] = GF16_MUL(syndromes[1], gf16_inv_table[syndromes[0]]); - if (elp[1] == 0) + all_s = s[0] | s[1]; + + if ( all_s == 0 ) { - ret = t + 1; + break; } - else + + if ( syndromes[0] != 0 ) { - ret = 1; + elp[1] = GF16_MUL( syndromes[1], gf16_inv_table[syndromes[0]] ); + if ( elp[1] == 0 ) + { + ret = t + 1; + } + else + { + ret = 1; + } + break; } + + ret = t + 1; break; } - - ret = t + 1; - break; - } - default: assert(0 && "calculating elp of this degree not implemented"); + default: + assert( 0 && "calculating elp of this degree not implemented" ); } - + return ret; } -FEC_STATIC LC3_INT16 rs16_factorize_elp(LC3_UINT8 *err_pos, LC3_UINT8 *elp, LC3_INT16 deg_elp, LC3_INT16 max_pos) +FEC_STATIC LC3_INT16 rs16_factorize_elp( LC3_UINT8 *err_pos, LC3_UINT8 *elp, LC3_INT16 deg_elp, LC3_INT16 max_pos ) { - LC3_UINT8 beta, gamma; - LC3_INT16 zeros, err_pos0, err_pos1, err_pos2, ret; + LC3_UINT8 beta, gamma; + LC3_INT16 zeros, err_pos0, err_pos1, err_pos2, ret; - beta = 0; + beta = 0; gamma = 0; zeros = 0; - ret = 0; + ret = 0; - switch (deg_elp) + switch ( deg_elp ) { - case 0: break; + case 0: + break; - case 1: - err_pos0 = gf16_log_g[elp[1]]; - if (err_pos0 > max_pos) - { - ret = 1; + case 1: + err_pos0 = gf16_log_g[elp[1]]; + if ( err_pos0 > max_pos ) + { + ret = 1; + break; + } + + err_pos[0] = (LC3_UINT8) err_pos0; break; - } - err_pos[0] = (LC3_UINT8)err_pos0; - break; + case 2: + zeros = rs16_elp_deg2_table[elp[1] | ( elp[2] << 4 )]; + if ( zeros == 0 ) + { - case 2: - zeros = rs16_elp_deg2_table[elp[1] | (elp[2] << 4)]; - if (zeros == 0) - { - - return 1; - } + return 1; + } - err_pos0 = zeros & 15; - err_pos1 = (zeros >> 4) & 15; + err_pos0 = zeros & 15; + err_pos1 = ( zeros >> 4 ) & 15; - if (err_pos0 > max_pos || err_pos1 > max_pos) - { - ret = 1; + if ( err_pos0 > max_pos || err_pos1 > max_pos ) + { + ret = 1; + break; + } + + err_pos[0] = (LC3_UINT8) err_pos0; + err_pos[1] = (LC3_UINT8) err_pos1; break; - } - err_pos[0] = (LC3_UINT8)err_pos0; - err_pos[1] = (LC3_UINT8)err_pos1; - break; + case 3: + /* beta = a*a + b, gamma = a*b + c */ + beta = GF16_ADD( GF16_MUL( elp[1], elp[1] ), elp[2] ); + gamma = GF16_ADD( GF16_MUL( elp[1], elp[2] ), elp[3] ); + zeros = rs16_elp_deg3_table[beta | gamma << 4]; - case 3: - /* beta = a*a + b, gamma = a*b + c */ - beta = GF16_ADD(GF16_MUL(elp[1], elp[1]), elp[2]); - gamma = GF16_ADD(GF16_MUL(elp[1], elp[2]), elp[3]); - zeros = rs16_elp_deg3_table[beta | gamma << 4]; + if ( zeros == 0 ) + /* elp does not split over GF(16) or has multiple zeros */ + { + ret = 1; + break; + } - if (zeros == 0) - /* elp does not split over GF(16) or has multiple zeros */ - { - ret = 1; - break; - } + /* remove shift from zeros */ + err_pos0 = GF16_ADD( zeros & 15, elp[1] ); + err_pos1 = GF16_ADD( ( zeros >> 4 ) & 15, elp[1] ); + err_pos2 = GF16_ADD( ( zeros >> 8 ) & 15, elp[1] ); - /* remove shift from zeros */ - err_pos0 = GF16_ADD(zeros & 15, elp[1]); - err_pos1 = GF16_ADD((zeros >> 4) & 15, elp[1]); - err_pos2 = GF16_ADD((zeros >> 8) & 15, elp[1]); + if ( err_pos0 == 0 || err_pos1 == 0 || err_pos2 == 0 ) + { - if (err_pos0 == 0 || err_pos1 == 0 || err_pos2 == 0) - { - - return 1; - } + return 1; + } - err_pos0 = gf16_log_g[err_pos0]; - err_pos1 = gf16_log_g[err_pos1]; - err_pos2 = gf16_log_g[err_pos2]; + err_pos0 = gf16_log_g[err_pos0]; + err_pos1 = gf16_log_g[err_pos1]; + err_pos2 = gf16_log_g[err_pos2]; - if (err_pos0 > max_pos || err_pos1 > max_pos || err_pos2 > max_pos) - { - ret = 1; - break; - } + if ( err_pos0 > max_pos || err_pos1 > max_pos || err_pos2 > max_pos ) + { + ret = 1; + break; + } - err_pos[0] = (LC3_UINT8)err_pos0; - err_pos[1] = (LC3_UINT8)err_pos1; - err_pos[2] = (LC3_UINT8)err_pos2; + err_pos[0] = (LC3_UINT8) err_pos0; + err_pos[1] = (LC3_UINT8) err_pos1; + err_pos[2] = (LC3_UINT8) err_pos2; - break; + break; - default: assert(0 && "invalid degree in rs16_error_locator"); + default: + assert( 0 && "invalid degree in rs16_error_locator" ); } - + return ret; } -FEC_STATIC void rs16_calculate_errors(LC3_UINT8 *err_symb, LC3_UINT8 *err_pos, LC3_UINT8 *syndromes, LC3_INT8 deg_elp, LC3_INT8 t) +FEC_STATIC void rs16_calculate_errors( LC3_UINT8 *err_symb, LC3_UINT8 *err_pos, LC3_UINT8 *syndromes, LC3_INT8 deg_elp, LC3_INT8 t ) { - LC3_UINT8 det_inv; - LC3_UINT8 x0, x1, x2; - LC3_UINT8 x0sq, x1sq, x2sq; - LC3_UINT8 c0, c1, c2; - LC3_UINT8 s0, s1, s2; - LC3_UINT8 tmp; - - UNUSED(t); + LC3_UINT8 det_inv; + LC3_UINT8 x0, x1, x2; + LC3_UINT8 x0sq, x1sq, x2sq; + LC3_UINT8 c0, c1, c2; + LC3_UINT8 s0, s1, s2; + LC3_UINT8 tmp; + + UNUSED( t ); - assert(deg_elp <= t); + assert( deg_elp <= t ); - switch (deg_elp) + switch ( deg_elp ) { - case 0: break; + case 0: + break; - case 1: - err_symb[0] = GF16_MUL(gf16_g_pow[15 - err_pos[0]], syndromes[0]); + case 1: + err_symb[0] = GF16_MUL( gf16_g_pow[15 - err_pos[0]], syndromes[0] ); - break; + break; - case 2: - s0 = (LC3_UINT8) (syndromes[0] << 4); - s1 = (LC3_UINT8) (syndromes[1] << 4); + case 2: + s0 = (LC3_UINT8) ( syndromes[0] << 4 ); + s1 = (LC3_UINT8) ( syndromes[1] << 4 ); - x0 = gf16_g_pow[err_pos[0]]; - x1 = gf16_g_pow[err_pos[1]]; + x0 = gf16_g_pow[err_pos[0]]; + x1 = gf16_g_pow[err_pos[1]]; - x0sq = GF16_MUL(x0, x0); - x1sq = GF16_MUL(x1, x1); + x0sq = GF16_MUL( x0, x0 ); + x1sq = GF16_MUL( x1, x1 ); - tmp = GF16_ADD(GF16_MUL(x0sq, x1), GF16_MUL(x1sq, x0)); - det_inv = gf16_inv_table[tmp] << 4; + tmp = GF16_ADD( GF16_MUL( x0sq, x1 ), GF16_MUL( x1sq, x0 ) ); + det_inv = gf16_inv_table[tmp] << 4; - tmp = GF16_ADD(GF16_MUL0(x1sq, s0), GF16_MUL0(x1, s1)); - err_symb[0] = GF16_MUL0(tmp, det_inv); + tmp = GF16_ADD( GF16_MUL0( x1sq, s0 ), GF16_MUL0( x1, s1 ) ); + err_symb[0] = GF16_MUL0( tmp, det_inv ); - tmp = GF16_ADD(GF16_MUL0(x0sq, s0), GF16_MUL0(x0, s1)); - err_symb[1] = GF16_MUL0(tmp, det_inv); + tmp = GF16_ADD( GF16_MUL0( x0sq, s0 ), GF16_MUL0( x0, s1 ) ); + err_symb[1] = GF16_MUL0( tmp, det_inv ); - break; + break; - case 3: - s0 = syndromes[0] << 4; - s1 = syndromes[1] << 4; - s2 = syndromes[2] << 4; + case 3: + s0 = syndromes[0] << 4; + s1 = syndromes[1] << 4; + s2 = syndromes[2] << 4; - x0 = gf16_g_pow[err_pos[0]]; - x1 = gf16_g_pow[err_pos[1]]; - x2 = gf16_g_pow[err_pos[2]]; + x0 = gf16_g_pow[err_pos[0]]; + x1 = gf16_g_pow[err_pos[1]]; + x2 = gf16_g_pow[err_pos[2]]; - x0sq = GF16_MUL(x0, x0); - x1sq = GF16_MUL(x1, x1); - x2sq = GF16_MUL(x2, x2); + x0sq = GF16_MUL( x0, x0 ); + x1sq = GF16_MUL( x1, x1 ); + x2sq = GF16_MUL( x2, x2 ); - tmp = GF16_MUL(GF16_ADD(x1, x0), GF16_ADD(x2, x0)); - tmp = GF16_MUL(GF16_ADD(x2, x1), tmp); - det_inv = gf16_inv_table[tmp] << 4; + tmp = GF16_MUL( GF16_ADD( x1, x0 ), GF16_ADD( x2, x0 ) ); + tmp = GF16_MUL( GF16_ADD( x2, x1 ), tmp ); + det_inv = gf16_inv_table[tmp] << 4; - c0 = GF16_ADD(GF16_MUL(x1, x2sq), GF16_MUL(x2, x1sq)); - c1 = GF16_ADD(x2sq, x1sq); - c2 = GF16_ADD(x2, x1); + c0 = GF16_ADD( GF16_MUL( x1, x2sq ), GF16_MUL( x2, x1sq ) ); + c1 = GF16_ADD( x2sq, x1sq ); + c2 = GF16_ADD( x2, x1 ); - err_symb[0] = GF16_ADD(GF16_ADD(GF16_MUL0(c0, s0), GF16_MUL0(c1, s1)), GF16_MUL0(c2, s2)); + err_symb[0] = GF16_ADD( GF16_ADD( GF16_MUL0( c0, s0 ), GF16_MUL0( c1, s1 ) ), GF16_MUL0( c2, s2 ) ); - c0 = GF16_ADD(GF16_MUL(x0, x2sq), GF16_MUL(x2, x0sq)); - c1 = GF16_ADD(x2sq, x0sq); - c2 = GF16_ADD(x2, x0); + c0 = GF16_ADD( GF16_MUL( x0, x2sq ), GF16_MUL( x2, x0sq ) ); + c1 = GF16_ADD( x2sq, x0sq ); + c2 = GF16_ADD( x2, x0 ); - err_symb[1] = GF16_ADD(GF16_ADD(GF16_MUL0(c0, s0), GF16_MUL0(c1, s1)), GF16_MUL0(c2, s2)); + err_symb[1] = GF16_ADD( GF16_ADD( GF16_MUL0( c0, s0 ), GF16_MUL0( c1, s1 ) ), GF16_MUL0( c2, s2 ) ); - c0 = GF16_ADD(GF16_MUL(x0, x1sq), GF16_MUL(x1, x0sq)); - c1 = GF16_ADD(x1sq, x0sq); - c2 = GF16_ADD(x1, x0); + c0 = GF16_ADD( GF16_MUL( x0, x1sq ), GF16_MUL( x1, x0sq ) ); + c1 = GF16_ADD( x1sq, x0sq ); + c2 = GF16_ADD( x1, x0 ); - err_symb[2] = GF16_ADD(GF16_ADD(GF16_MUL0(c0, s0), GF16_MUL0(c1, s1)), GF16_MUL0(c2, s2)); + err_symb[2] = GF16_ADD( GF16_ADD( GF16_MUL0( c0, s0 ), GF16_MUL0( c1, s1 ) ), GF16_MUL0( c2, s2 ) ); - tmp = GF16_MUL0(err_symb[0], det_inv); - err_symb[0] = GF16_MUL(tmp, gf16_inv_table[x0]); + tmp = GF16_MUL0( err_symb[0], det_inv ); + err_symb[0] = GF16_MUL( tmp, gf16_inv_table[x0] ); - tmp = GF16_MUL0(err_symb[1], det_inv); - err_symb[1] = GF16_MUL(tmp, gf16_inv_table[x1]); + tmp = GF16_MUL0( err_symb[1], det_inv ); + err_symb[1] = GF16_MUL( tmp, gf16_inv_table[x1] ); - tmp = GF16_MUL0(err_symb[2], det_inv); - err_symb[2] = GF16_MUL(tmp, gf16_inv_table[x2]); + tmp = GF16_MUL0( err_symb[2], det_inv ); + err_symb[2] = GF16_MUL( tmp, gf16_inv_table[x2] ); - break; + break; - default: assert(0 && "method not implemented\n"); break; + default: + assert( 0 && "method not implemented\n" ); + break; } - - } /* hash functions for data validation */ /* hamming distance 4 */ -static const LC3_UINT32 crc14_mask[16] = {0, 17989, 35978, 51919, 71956, 89937, 103838, 119771, - 143912, 160877, 179874, 194791, 207676, 224633, 239542, 254451}; +static const LC3_UINT32 crc14_mask[16] = { 0, 17989, 35978, 51919, 71956, 89937, 103838, 119771, + 143912, 160877, 179874, 194791, 207676, 224633, 239542, 254451 }; /* hamming distance 4 */ -static const LC3_UINT32 crc22_mask[16] = {0, 4788009, 9576018, 14356859, 19152036, 23933837, 28713718, 33500639, - 33650273, 38304072, 43214899, 47867674, 52775621, 57427436, 62346391, 67001278}; +static const LC3_UINT32 crc22_mask[16] = { 0, 4788009, 9576018, 14356859, 19152036, 23933837, 28713718, 33500639, + 33650273, 38304072, 43214899, 47867674, 52775621, 57427436, 62346391, 67001278 }; -FEC_STATIC LC3_INT16 crc1(LC3_UINT8 *data, LC3_INT16 data_size, LC3_INT16 epmr, LC3_UINT8 *hash_val, LC3_INT16 hash_size, LC3_INT16 check) +FEC_STATIC LC3_INT16 crc1( LC3_UINT8 *data, LC3_INT16 data_size, LC3_INT16 epmr, LC3_UINT8 *hash_val, LC3_INT16 hash_size, LC3_INT16 check ) { - LC3_UINT32 const *mask; - LC3_INT32 shift, i, fail; - LC3_UINT32 rem; + LC3_UINT32 const *mask; + LC3_INT32 shift, i, fail; + LC3_UINT32 rem; fail = 0; - rem = 0; + rem = 0; - assert(hash_size > 0); + assert( hash_size > 0 ); - switch (hash_size) + switch ( hash_size ) { - case 2: - shift = 14; - mask = crc14_mask; - break; - case 3: - shift = 22; - mask = crc22_mask; - break; - default: - shift = 0; - mask = 0; - assert(0 && "crc hash size not implemented"); + case 2: + shift = 14; + mask = crc14_mask; + break; + case 3: + shift = 22; + mask = crc22_mask; + break; + default: + shift = 0; + mask = 0; + assert( 0 && "crc hash size not implemented" ); } /* data array contains 4-bit words */ - for (i = data_size - 1; i >= 0; i--) + for ( i = data_size - 1; i >= 0; i-- ) { - rem = (rem << 4) ^ data[i]; - rem ^= mask[(rem >> shift) & 15]; + rem = ( rem << 4 ) ^ data[i]; + rem ^= mask[( rem >> shift ) & 15]; } - rem = (rem << 4) ^ (epmr << 2); - rem ^= mask[(rem >> shift) & 15]; + rem = ( rem << 4 ) ^ ( epmr << 2 ); + rem ^= mask[( rem >> shift ) & 15]; - for (i = 0; i < 2 * hash_size - 1; i++) + for ( i = 0; i < 2 * hash_size - 1; i++ ) { rem <<= 4; - rem ^= mask[(rem >> shift) & 15]; + rem ^= mask[( rem >> shift ) & 15]; } - rem ^= ((LC3_UINT32) epmr) << shift; + rem ^= ( (LC3_UINT32) epmr ) << shift; - if (check) + if ( check ) { /* test hash value */ - for (i = 0; i < 2 * hash_size; i++) + for ( i = 0; i < 2 * hash_size; i++ ) { - fail |= hash_val[i] ^ ((rem >> (4*i)) & 15); + fail |= hash_val[i] ^ ( ( rem >> ( 4 * i ) ) & 15 ); } } else { /* write hash value */ - for (i = 0; i < 2 * hash_size; i++) + for ( i = 0; i < 2 * hash_size; i++ ) { - hash_val[i] = (LC3_UINT8) ((rem >> (4*i)) & 15); + hash_val[i] = (LC3_UINT8) ( ( rem >> ( 4 * i ) ) & 15 ); } } - + return fail; } /* hamming distance = 4 */ -static const LC3_UINT32 crc16_mask[16] = {0, 107243, 190269, 214486, 289937, 380538, 428972, 469319, - 579874, 621513, 671263, 761076, 832947, 857944, 938638, 1044581}; +static const LC3_UINT32 crc16_mask[16] = { 0, 107243, 190269, 214486, 289937, 380538, 428972, 469319, + 579874, 621513, 671263, 761076, 832947, 857944, 938638, 1044581 }; -FEC_STATIC LC3_INT16 crc2(LC3_UINT8 *data, LC3_INT16 data_size, LC3_UINT8 *hash_val, LC3_INT16 hash_size, LC3_INT16 check) +FEC_STATIC LC3_INT16 crc2( LC3_UINT8 *data, LC3_INT16 data_size, LC3_UINT8 *hash_val, LC3_INT16 hash_size, LC3_INT16 check ) { - LC3_UINT32 const *mask; - LC3_INT32 shift, i, fail; - LC3_UINT32 rem; + LC3_UINT32 const *mask; + LC3_INT32 shift, i, fail; + LC3_UINT32 rem; fail = 0; - rem = 0; + rem = 0; - assert(hash_size > 0); + assert( hash_size > 0 ); - switch (hash_size) + switch ( hash_size ) { - case 2: - shift = 16; - mask = crc16_mask; - break; - default: - shift = 0; - mask = 0; - assert(0 && "crc hash size not implemented"); + case 2: + shift = 16; + mask = crc16_mask; + break; + default: + shift = 0; + mask = 0; + assert( 0 && "crc hash size not implemented" ); } /* data array contains 4-bit words */ - for (i = data_size - 1; i >= 0; i--) + for ( i = data_size - 1; i >= 0; i-- ) { - rem = (rem << 4) ^ data[i]; - rem ^= mask[(rem >> shift) & 15]; + rem = ( rem << 4 ) ^ data[i]; + rem ^= mask[( rem >> shift ) & 15]; } - for (i = 0; i < 2 * hash_size; i++) + for ( i = 0; i < 2 * hash_size; i++ ) { rem <<= 4; - rem ^= mask[(rem >> shift) & 15]; + rem ^= mask[( rem >> shift ) & 15]; } - if (check) + if ( check ) { /* test hash value */ - for (i = 0; i < 2 * hash_size; i++) + for ( i = 0; i < 2 * hash_size; i++ ) { - fail |= hash_val[i] ^ ((rem >> (4*i)) & 15); + fail |= hash_val[i] ^ ( ( rem >> ( 4 * i ) ) & 15 ); } } else { /* write hash value */ - for (i = 0; i < 2 * hash_size; i++) + for ( i = 0; i < 2 * hash_size; i++ ) { - hash_val[i] = (LC3_UINT8) ((rem >> (4*i)) & 15); + hash_val[i] = (LC3_UINT8) ( ( rem >> ( 4 * i ) ) & 15 ); } } - + return fail; } /* simple float implementation */ -FEC_STATIC simple_float simple_float_mul(simple_float op1, simple_float op2) +FEC_STATIC simple_float simple_float_mul( simple_float op1, simple_float op2 ) { - simple_float rop; - LC3_INT32 aux; - - aux = (op1.mantissa * op2.mantissa) >> 14; + simple_float rop; + LC3_INT32 aux; + + aux = ( op1.mantissa * op2.mantissa ) >> 14; rop.exponent = op1.exponent + op2.exponent; - if (aux & 32768L) + if ( aux & 32768L ) { - aux >>= 1; - rop.exponent ++; + aux >>= 1; + rop.exponent++; } rop.mantissa = (LC3_INT16) aux; - + return rop; } /* Auxiliary */ -FEC_STATIC LC3_INT16 simple_float_cmp(simple_float op1, simple_float op2) +FEC_STATIC LC3_INT16 simple_float_cmp( simple_float op1, simple_float op2 ) /* returns 1 if op1 > op2, 0 if op1 = op2, and -1 if op1 < op2 */ { - LC3_INT16 rval; - LC3_INT16 mdiff; - LC3_INT16 ediff; + LC3_INT16 rval; + LC3_INT16 mdiff; + LC3_INT16 ediff; rval = 0; ediff = op1.exponent - op2.exponent; mdiff = (LC3_INT16) op1.mantissa - (LC3_INT16) op2.mantissa; - if (ediff == 0) + if ( ediff == 0 ) { - if (mdiff > 0) + if ( mdiff > 0 ) { rval = 1; } - if (mdiff < 0) + if ( mdiff < 0 ) { rval = -1; } } else { - if (ediff > 0) + if ( ediff > 0 ) { rval = 1; } - if (ediff < 0) + if ( ediff < 0 ) { rval = -1; } } - + return rval; } - diff --git a/lib_lc3plus/apply_global_gain.c b/lib_lc3plus/apply_global_gain.c index c67432e2c3..2f7a3d880b 100644 --- a/lib_lc3plus/apply_global_gain.c +++ b/lib_lc3plus/apply_global_gain.c @@ -1,21 +1,21 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -void processApplyGlobalGain_fl(LC3_FLOAT x[], LC3_INT xLen, LC3_INT global_gain_idx, LC3_INT global_gain_off) +void processApplyGlobalGain_fl( LC3_FLOAT x[], LC3_INT xLen, LC3_INT global_gain_idx, LC3_INT global_gain_off ) { LC3_FLOAT gg = 0; - gg = LC3_POW(10, (LC3_FLOAT)(global_gain_idx + global_gain_off) / 28); + gg = LC3_POW( 10, (LC3_FLOAT) ( global_gain_idx + global_gain_off ) / 28 ); - mult_const(x, gg, xLen); + mult_const( x, gg, xLen ); } diff --git a/lib_lc3plus/ari_codec.c b/lib_lc3plus/ari_codec.c index 80c75fcf0c..818c62021b 100644 --- a/lib_lc3plus/ari_codec.c +++ b/lib_lc3plus/ari_codec.c @@ -1,284 +1,310 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -static void ac_shift_fl(Encoder_State_fl* st); -static void ac_encode_fl(Encoder_State_fl* st, LC3_INT sym_freq, LC3_INT cum_freq); -static void tns_order_freq_enc(LC3_INT enable_lpc_weighting, LC3_INT order, LC3_INT* symfreq, LC3_INT* cumfreq); -static void tns_coef_freq_enc(LC3_INT k, LC3_INT idx, LC3_INT* symfreq, LC3_INT* cumfreq); -static void ac_freq_fl(LC3_INT pki, LC3_INT s, LC3_INT* symfreq, LC3_INT* cumfreq); -static void ac_finalize_fl(Encoder_State_fl* st); -static void write_uint_forward_fl(Encoder_State_fl* st, LC3_INT val, LC3_INT numbits); -static void ari_enc_init(Encoder_State_fl* st, LC3_UINT8* bytes, LC3_INT* bp_side, LC3_INT* mask_side); -static LC3_INT sign(LC3_INT x); -static void read_bit_fl(LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* bit, LC3_INT *bp, Decoder_State_fl* st_fl, LC3_INT from_left); -static void ac_dec_init_fl(LC3_UINT8* ptr, LC3_INT* bp, Decoder_State_fl* st_fl, LC3_INT from_left, LC3_INT mask_side, LC3_INT *bp_side); -static void tns_order_freq(LC3_INT enable_lpc_weighting, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym); -static void tns_coef_freq(LC3_INT k, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym); -static LC3_INT ac_decode_fl(Decoder_State_fl* st, LC3_INT* sym_freq, LC3_INT* cum_freq, LC3_INT num_sym, LC3_UINT8* ptr, LC3_INT* bp, LC3_INT from_left, LC3_INT mask_side, LC3_INT *bp_side); -static void ac_freq(LC3_INT pki, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym); -static void findNonZero(LC3_INT* in, LC3_INT* out, LC3_INT len, LC3_INT* outLen); -static void pc_check_bytes(LC3_INT32* bp, Decoder_State_fl* st_fl, LC3_INT32 from_left, LC3_INT32 mask_side, LC3_INT32 *bp_side); -static void calculate_nfseed(LC3_INT *x, LC3_INT L_spec, LC3_INT *nf_seed); - -void calculate_nfseed(LC3_INT *x, LC3_INT L_spec, LC3_INT *nf_seed) +static void ac_shift_fl( Encoder_State_fl *st ); +static void ac_encode_fl( Encoder_State_fl *st, LC3_INT sym_freq, LC3_INT cum_freq ); +static void tns_order_freq_enc( LC3_INT enable_lpc_weighting, LC3_INT order, LC3_INT *symfreq, LC3_INT *cumfreq ); +static void tns_coef_freq_enc( LC3_INT k, LC3_INT idx, LC3_INT *symfreq, LC3_INT *cumfreq ); +static void ac_freq_fl( LC3_INT pki, LC3_INT s, LC3_INT *symfreq, LC3_INT *cumfreq ); +static void ac_finalize_fl( Encoder_State_fl *st ); +static void write_uint_forward_fl( Encoder_State_fl *st, LC3_INT val, LC3_INT numbits ); +static void ari_enc_init( Encoder_State_fl *st, LC3_UINT8 *bytes, LC3_INT *bp_side, LC3_INT *mask_side ); +static LC3_INT sign( LC3_INT x ); +static void read_bit_fl( LC3_UINT8 *ptr, LC3_INT *mask_side, LC3_INT *bp_side, LC3_INT *bit, LC3_INT *bp, Decoder_State_fl *st_fl, LC3_INT from_left ); +static void ac_dec_init_fl( LC3_UINT8 *ptr, LC3_INT *bp, Decoder_State_fl *st_fl, LC3_INT from_left, LC3_INT mask_side, LC3_INT *bp_side ); +static void tns_order_freq( LC3_INT enable_lpc_weighting, LC3_INT *symfreq, LC3_INT *cumfreq, LC3_INT *numsym ); +static void tns_coef_freq( LC3_INT k, LC3_INT *symfreq, LC3_INT *cumfreq, LC3_INT *numsym ); +static LC3_INT ac_decode_fl( Decoder_State_fl *st, LC3_INT *sym_freq, LC3_INT *cum_freq, LC3_INT num_sym, LC3_UINT8 *ptr, LC3_INT *bp, LC3_INT from_left, LC3_INT mask_side, LC3_INT *bp_side ); +static void ac_freq( LC3_INT pki, LC3_INT *symfreq, LC3_INT *cumfreq, LC3_INT *numsym ); +static void findNonZero( LC3_INT *in, LC3_INT *out, LC3_INT len, LC3_INT *outLen ); +static void pc_check_bytes( LC3_INT32 *bp, Decoder_State_fl *st_fl, LC3_INT32 from_left, LC3_INT32 mask_side, LC3_INT32 *bp_side ); +static void calculate_nfseed( LC3_INT *x, LC3_INT L_spec, LC3_INT *nf_seed ); + +void calculate_nfseed( LC3_INT *x, LC3_INT L_spec, LC3_INT *nf_seed ) { LC3_INT k = 0; - + *nf_seed = 0; - - for (k = 0; k < L_spec; k++) { - *nf_seed = *nf_seed + (abs(x[k]) & 32767) * k; + + for ( k = 0; k < L_spec; k++ ) + { + *nf_seed = *nf_seed + ( abs( x[k] ) & 32767 ) * k; } *nf_seed = *nf_seed & 65535; - if (*nf_seed >= 32768) { + if ( *nf_seed >= 32768 ) + { *nf_seed = *nf_seed - 65536; } } -static void pc_check_bytes(LC3_INT32* bp, Decoder_State_fl* st_fl, LC3_INT32 from_left, LC3_INT32 mask_side, LC3_INT32 *bp_side) +static void pc_check_bytes( LC3_INT32 *bp, Decoder_State_fl *st_fl, LC3_INT32 from_left, LC3_INT32 mask_side, LC3_INT32 *bp_side ) { LC3_INT32 bp_local, bp_side_local, offset; - - if (st_fl->pc_bytes > 0) + + if ( st_fl->pc_bytes > 0 ) { - if (!from_left && mask_side != 1) + if ( !from_left && mask_side != 1 ) { return; } - if (st_fl->pc_c_bp_side > 0 && *bp_side < 0) + if ( st_fl->pc_c_bp_side > 0 && *bp_side < 0 ) { - assert(mask_side == 1); - assert(st_fl->pc_b_right != -1); + assert( mask_side == 1 ); + assert( st_fl->pc_b_right != -1 ); *bp_side = st_fl->pc_b_right; return; } bp_local = *bp; bp_side_local = *bp_side; - - if (from_left) + + if ( from_left ) { - if (mask_side == 1) + if ( mask_side == 1 ) { bp_side_local = bp_side_local + 1; } - } else { + } + else + { bp_local = bp_local - 1; } - - if (st_fl->pc_b_right == -1) + + if ( st_fl->pc_b_right == -1 ) { offset = -1; - if (!st_fl->pc_enc) + if ( !st_fl->pc_enc ) { offset = offset + st_fl->pc_bytes; } - - if ((bp_side_local + offset - bp_local) == st_fl->pc_bytes) + + if ( ( bp_side_local + offset - bp_local ) == st_fl->pc_bytes ) { st_fl->pc_b_left = bp_local + 1; st_fl->pc_b_right = bp_side_local - 1; - - if (st_fl->pc_enc) + + if ( st_fl->pc_enc ) { st_fl->pc_return = 1; return; } } } - - if (!st_fl->pc_enc && st_fl->pc_b_right > -1) + + if ( !st_fl->pc_enc && st_fl->pc_b_right > -1 ) { - if (from_left && *bp == st_fl->pc_b_left) + if ( from_left && *bp == st_fl->pc_b_left ) { *bp = 0; st_fl->pc_c_bp = 1; } - - if (!from_left && bp_side_local == st_fl->pc_b_right) + + if ( !from_left && bp_side_local == st_fl->pc_b_right ) { *bp_side = st_fl->pc_bytes - 1; st_fl->pc_c_bp_side = 1; } - - if (st_fl->pc_bfi == 2) + + if ( st_fl->pc_bfi == 2 ) { - - if ((st_fl->pc_c_bp && (*bp + 1) >= st_fl->pc_be_bp_left) || (st_fl->pc_c_bp_side && (*bp_side + 1) <= st_fl->pc_be_bp_right)) + + if ( ( st_fl->pc_c_bp && ( *bp + 1 ) >= st_fl->pc_be_bp_left ) || ( st_fl->pc_c_bp_side && ( *bp_side + 1 ) <= st_fl->pc_be_bp_right ) ) { st_fl->pc_bbi = 2; - } else if ((st_fl->pc_c_bp && *bp >= 0) || (st_fl->pc_c_bp_side && *bp_side <= (st_fl->pc_bytes - 1))) + } + else if ( ( st_fl->pc_c_bp && *bp >= 0 ) || ( st_fl->pc_c_bp_side && *bp_side <= ( st_fl->pc_bytes - 1 ) ) ) { st_fl->pc_bbi = 1; } } - } + } } - + return; } -void ac_dec_init_fl(LC3_UINT8* ptr, LC3_INT* bp, Decoder_State_fl* st_fl, LC3_INT from_left, LC3_INT mask_side, LC3_INT *bp_side) +void ac_dec_init_fl( LC3_UINT8 *ptr, LC3_INT *bp, Decoder_State_fl *st_fl, LC3_INT from_left, LC3_INT mask_side, LC3_INT *bp_side ) { LC3_INT i = 0; - if (!st_fl->pc_enc) + if ( !st_fl->pc_enc ) { *bp = *bp + st_fl->pc_bytes; } st_fl->ac_low_fl = 0; - st_fl->ac_range_fl = (LC3_UINT32)pow(2, 24) - (LC3_UINT32)1; - for (i = 0; i < 3; i++) { - pc_check_bytes(bp, st_fl, from_left, mask_side, bp_side); - - st_fl->ac_low_fl = (st_fl->ac_low_fl << 8) + (LC3_UINT32)ptr[*bp]; - *bp = *bp + 1; + st_fl->ac_range_fl = (LC3_UINT32) pow( 2, 24 ) - (LC3_UINT32) 1; + for ( i = 0; i < 3; i++ ) + { + pc_check_bytes( bp, st_fl, from_left, mask_side, bp_side ); + + st_fl->ac_low_fl = ( st_fl->ac_low_fl << 8 ) + (LC3_UINT32) ptr[*bp]; + *bp = *bp + 1; } st_fl->BER_detect = 0; } -void tns_order_freq(LC3_INT enable_lpc_weighting, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym) +void tns_order_freq( LC3_INT enable_lpc_weighting, LC3_INT *symfreq, LC3_INT *cumfreq, LC3_INT *numsym ) { LC3_INT i = 0, j = 0; *numsym = 8; j = 0; - for (i = 1; i < 9; i++) { + for ( i = 1; i < 9; i++ ) + { symfreq[j] = ari_tns_order_cf[enable_lpc_weighting][i]; j++; } - for (i = 0; i < *numsym; i++) { + for ( i = 0; i < *numsym; i++ ) + { symfreq[i] -= ari_tns_order_cf[enable_lpc_weighting][i]; } - for (i = 0; i < *numsym; i++) { + for ( i = 0; i < *numsym; i++ ) + { cumfreq[i] = ari_tns_order_cf[enable_lpc_weighting][i]; } } /* Returns val */ -LC3_INT ac_decode_fl(Decoder_State_fl* st, LC3_INT* sym_freq, LC3_INT* cum_freq, LC3_INT num_sym, LC3_UINT8* ptr, LC3_INT* bp, LC3_INT from_left, LC3_INT mask_side, LC3_INT *bp_side) +LC3_INT ac_decode_fl( Decoder_State_fl *st, LC3_INT *sym_freq, LC3_INT *cum_freq, LC3_INT num_sym, LC3_UINT8 *ptr, LC3_INT *bp, LC3_INT from_left, LC3_INT mask_side, LC3_INT *bp_side ) { LC3_INT val = 0, tmp = 0; - + tmp = st->ac_range_fl >> 10; - if (st->ac_low_fl >= (LC3_UINT32)(tmp << 10)) { + if ( st->ac_low_fl >= (LC3_UINT32) ( tmp << 10 ) ) + { st->BER_detect = 1; } val = num_sym - 1; - while (st->ac_low_fl < (LC3_UINT32)(tmp * cum_freq[val])) { + while ( st->ac_low_fl < (LC3_UINT32) ( tmp * cum_freq[val] ) ) + { val--; } - st->ac_low_fl = st->ac_low_fl - tmp * cum_freq[val]; + st->ac_low_fl = st->ac_low_fl - tmp * cum_freq[val]; st->ac_range_fl = tmp * sym_freq[val]; - while (st->ac_range_fl < pow(2, 16)) { - st->ac_low_fl = st->ac_low_fl << 8; - st->ac_low_fl = ((LC3_INT)st->ac_low_fl) & ((LC3_INT)(pow(2, 24) - 1)); - - pc_check_bytes(bp, st, from_left, mask_side, bp_side); - - st->ac_low_fl = st->ac_low_fl + ptr[*bp]; - *bp = *bp + 1; + while ( st->ac_range_fl < pow( 2, 16 ) ) + { + st->ac_low_fl = st->ac_low_fl << 8; + st->ac_low_fl = ( (LC3_INT) st->ac_low_fl ) & ( (LC3_INT) ( pow( 2, 24 ) - 1 ) ); + + pc_check_bytes( bp, st, from_left, mask_side, bp_side ); + + st->ac_low_fl = st->ac_low_fl + ptr[*bp]; + *bp = *bp + 1; st->ac_range_fl = st->ac_range_fl << 8; } return val; } -void tns_coef_freq(LC3_INT k, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym) +void tns_coef_freq( LC3_INT k, LC3_INT *symfreq, LC3_INT *cumfreq, LC3_INT *numsym ) { LC3_INT i = 0, j = 0; *numsym = 18 - 1; j = 0; - for (i = 1; i <= *numsym; i++) { + for ( i = 1; i <= *numsym; i++ ) + { symfreq[j] = ari_tns_freq_cf[k][i]; j++; } - for (i = 0; i < *numsym; i++) { + for ( i = 0; i < *numsym; i++ ) + { symfreq[i] -= ari_tns_freq_cf[k][i]; } - for (i = 0; i < *numsym; i++) { + for ( i = 0; i < *numsym; i++ ) + { cumfreq[i] = ari_tns_freq_cf[k][i]; } } -void ac_freq(LC3_INT pki, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym) +void ac_freq( LC3_INT pki, LC3_INT *symfreq, LC3_INT *cumfreq, LC3_INT *numsym ) { LC3_INT i = 0, j = 0; *numsym = 18 - 1; j = 0; - for (i = 1; i <= *numsym; i++) { + for ( i = 1; i <= *numsym; i++ ) + { symfreq[j] = ari_spec_cumfreq_fl[pki][i]; j++; } - for (i = 0; i < *numsym; i++) { + for ( i = 0; i < *numsym; i++ ) + { symfreq[i] -= ari_spec_cumfreq_fl[pki][i]; } - for (i = 0; i < *numsym; i++) { + for ( i = 0; i < *numsym; i++ ) + { cumfreq[i] = ari_spec_cumfreq_fl[pki][i]; } } -void read_bit_fl(LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* bit, LC3_INT *bp, Decoder_State_fl* st_fl, LC3_INT from_left) +void read_bit_fl( LC3_UINT8 *ptr, LC3_INT *mask_side, LC3_INT *bp_side, LC3_INT *bit, LC3_INT *bp, Decoder_State_fl *st_fl, LC3_INT from_left ) { *bit = 0; - - UNUSED(bp); - UNUSED(st_fl); - UNUSED(from_left); - if (ptr[*bp_side] & *mask_side) { + UNUSED( bp ); + UNUSED( st_fl ); + UNUSED( from_left ); + + if ( ptr[*bp_side] & *mask_side ) + { *bit = 1; - } else { + } + else + { *bit = 0; } - if (*mask_side == 128) { + if ( *mask_side == 128 ) + { *mask_side = 1; - *bp_side = *bp_side - 1; - } else { + *bp_side = *bp_side - 1; + } + else + { *mask_side = *mask_side * 2; } } -void findNonZero(LC3_INT* in, LC3_INT* out, LC3_INT len, LC3_INT* outLen) +void findNonZero( LC3_INT *in, LC3_INT *out, LC3_INT len, LC3_INT *outLen ) { LC3_INT i = 0, j = 0; - for (i = 0; i < len; i++) { - if (in[i] != 0) { + for ( i = 0; i < len; i++ ) + { + if ( in[i] != 0 ) + { out[j] = i; j++; } @@ -287,119 +313,119 @@ void findNonZero(LC3_INT* in, LC3_INT* out, LC3_INT len, LC3_INT* outLen) *outLen = j; } -void processAriDecoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side, LC3_INT L_spec, LC3_INT fs_idx, LC3_INT enable_lpc_weighting, - LC3_INT tns_numfilters, LC3_INT lsbMode, LC3_INT lastnz, LC3_INT* bfi, LC3_INT* tns_order, LC3_INT fac_ns_idx, - LC3_INT gg_idx, uint8_t * resBits, LC3_INT* x, LC3_INT* nf_seed, LC3_INT* tns_idx, LC3_INT* zero_frame, LC3_INT numbytes, - LC3_INT* nbits_residual, LC3_INT* residualPresent, LC3_INT frame_dms, - LC3_INT32 n_pc, LC3_INT32 be_bp_left, LC3_INT32 be_bp_right, LC3_INT32 enc, LC3_INT32 *b_left, LC3_INT32 *spec_inv_idx, - LC3_INT hrmode -) +void processAriDecoder_fl( LC3_UINT8 *bytes, LC3_INT bp_side, LC3_INT mask_side, LC3_INT L_spec, LC3_INT fs_idx, LC3_INT enable_lpc_weighting, LC3_INT tns_numfilters, LC3_INT lsbMode, LC3_INT lastnz, LC3_INT *bfi, LC3_INT *tns_order, LC3_INT fac_ns_idx, LC3_INT gg_idx, uint8_t *resBits, LC3_INT *x, LC3_INT *nf_seed, LC3_INT *tns_idx, LC3_INT *zero_frame, LC3_INT numbytes, LC3_INT *nbits_residual, LC3_INT *residualPresent, LC3_INT frame_dms, LC3_INT32 n_pc, LC3_INT32 be_bp_left, LC3_INT32 be_bp_right, LC3_INT32 enc, LC3_INT32 *b_left, LC3_INT32 *spec_inv_idx, LC3_INT hrmode ) { Decoder_State_fl st; - LC3_INT a = 0, b = 0, t = 0, bp = 0; - LC3_INT c = 0; - LC3_INT nbits_side = 0, extra_bits = 0; - LC3_UINT8* ptr = NULL; - LC3_INT n = 0, k = 0, lev = 0; - LC3_INT max_lev = 0, tmp = 0; - LC3_INT sym_freq[MAX_LEN] = {0}, cum_freq[MAX_LEN] = {0}, numsym = 0, bit = 0, lev1 = 0, pki = 0, sym = 0, - save_lev[MAX_LEN] = {0}, idx_len = 0, total_bits = 0, nbits_ari = 0, idx[MAX_LEN] = {0}, rateFlag = 0; + LC3_INT a = 0, b = 0, t = 0, bp = 0; + LC3_INT c = 0; + LC3_INT nbits_side = 0, extra_bits = 0; + LC3_UINT8 *ptr = NULL; + LC3_INT n = 0, k = 0, lev = 0; + LC3_INT max_lev = 0, tmp = 0; + LC3_INT sym_freq[MAX_LEN] = { 0 }, cum_freq[MAX_LEN] = { 0 }, numsym = 0, bit = 0, lev1 = 0, pki = 0, sym = 0, + save_lev[MAX_LEN] = { 0 }, idx_len = 0, total_bits = 0, nbits_ari = 0, idx[MAX_LEN] = { 0 }, rateFlag = 0; total_bits = 8 * numbytes; - - memset(&st, 0, sizeof(st)); - - - st.pc_bytes = (n_pc + 1) >> 1; + + memset( &st, 0, sizeof( st ) ); + + + st.pc_bytes = ( n_pc + 1 ) >> 1; st.pc_b_left = numbytes + 1; st.pc_b_right = -1; st.pc_enc = enc; st.pc_bfi = *bfi; - st.pc_be_bp_left = floor(be_bp_left / 8); - st.pc_be_bp_right = floor(be_bp_right / 8) - 1; + st.pc_be_bp_left = floor( be_bp_left / 8 ); + st.pc_be_bp_right = floor( be_bp_right / 8 ) - 1; *spec_inv_idx = L_spec + 1; - assert(st.pc_be_bp_right < st.pc_bytes || st.pc_bytes == 0); + assert( st.pc_be_bp_right < st.pc_bytes || st.pc_bytes == 0 ); /* Rate flag */ - if (fs_idx != 5) + if ( fs_idx != 5 ) { - if (total_bits > (160 + fs_idx * 160)) { + if ( total_bits > ( 160 + fs_idx * 160 ) ) + { rateFlag = 512; } } /* Init */ - c = 0; - t = 0; + c = 0; + t = 0; bp = 0; - + *b_left = -1; ptr = bytes; /* Start Decoding */ - ac_dec_init_fl(ptr, &bp, &st, 1, mask_side, &bp_side); - + ac_dec_init_fl( ptr, &bp, &st, 1, mask_side, &bp_side ); + /* Decode TNS data */ tmp = MAXLAG; - if (frame_dms == 25) + if ( frame_dms == 25 ) { tmp /= 2; } - if (frame_dms == 50) + if ( frame_dms == 50 ) { tmp /= 2; } /* Decode TNS data */ - for (n = 0; n < tns_numfilters; n++) { - - if (tns_order[n] > 0) { - tns_order_freq(enable_lpc_weighting, sym_freq, cum_freq, &numsym); - - tns_order[n] = ac_decode_fl(&st, sym_freq, cum_freq, numsym, ptr, &bp, 1, mask_side, &bp_side); - - if (st.pc_return) + for ( n = 0; n < tns_numfilters; n++ ) + { + + if ( tns_order[n] > 0 ) + { + tns_order_freq( enable_lpc_weighting, sym_freq, cum_freq, &numsym ); + + tns_order[n] = ac_decode_fl( &st, sym_freq, cum_freq, numsym, ptr, &bp, 1, mask_side, &bp_side ); + + if ( st.pc_return ) { *b_left = st.pc_b_left; return; } - + tns_order[n] = tns_order[n] + 1; - - if (tns_order[n] > tmp) + + if ( tns_order[n] > tmp ) { st.BER_detect = 1; } - - if (st.pc_bbi == 1) + + if ( st.pc_bbi == 1 ) { spec_inv_idx = 0; - } else if (st.pc_bbi == 2) + } + else if ( st.pc_bbi == 2 ) { st.BER_detect = 1; } - for (k = 0; k < tns_order[n]; k++) { - if (bp_side < bp) + for ( k = 0; k < tns_order[n]; k++ ) + { + if ( bp_side < bp ) { *bfi = 1; return; } - - tns_coef_freq(k, sym_freq, cum_freq, &numsym); - tns_idx[n * 8 + k] = ac_decode_fl(&st, sym_freq, cum_freq, numsym, ptr, &bp, 1, mask_side, &bp_side); - - if (st.pc_return) + + tns_coef_freq( k, sym_freq, cum_freq, &numsym ); + tns_idx[n * 8 + k] = ac_decode_fl( &st, sym_freq, cum_freq, numsym, ptr, &bp, 1, mask_side, &bp_side ); + + if ( st.pc_return ) { *b_left = st.pc_b_left; return; } - - if (st.pc_bbi == 1) + + if ( st.pc_bbi == 1 ) { spec_inv_idx = 0; - } else if (st.pc_bbi == 2) + } + else if ( st.pc_bbi == 2 ) { st.BER_detect = 1; } @@ -407,196 +433,216 @@ void processAriDecoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side, } } - if (st.BER_detect > 0) { + if ( st.BER_detect > 0 ) + { *bfi = 1; return; } /* Spectral data */ - for (k = 0; k < lastnz; k = k + 2) { + for ( k = 0; k < lastnz; k = k + 2 ) + { /* Context */ t = c + rateFlag; - if (k > L_spec / 2) { + if ( k > L_spec / 2 ) + { t = t + 256; } /* Decode amplitude */ - x[k] = 0; + x[k] = 0; x[k + 1] = 0; - if (hrmode == 1) { + if ( hrmode == 1 ) + { max_lev = 13 + 8; - } else { + } + else + { max_lev = 13; } - for (lev = 0; lev <= max_lev; lev++) { - lev1 = MIN(lev, 3); - pki = ari_spec_lookup_fl[t + lev1 * 1024]; - ac_freq(pki, sym_freq, cum_freq, &numsym); - sym = ac_decode_fl(&st, sym_freq, cum_freq, numsym, ptr, &bp, 1, mask_side, &bp_side); + for ( lev = 0; lev <= max_lev; lev++ ) + { + lev1 = MIN( lev, 3 ); + pki = ari_spec_lookup_fl[t + lev1 * 1024]; + ac_freq( pki, sym_freq, cum_freq, &numsym ); + sym = ac_decode_fl( &st, sym_freq, cum_freq, numsym, ptr, &bp, 1, mask_side, &bp_side ); - if (st.pc_return) - { - *b_left = st.pc_b_left; - return; - } - - if (st.pc_bbi == 1) - { - *spec_inv_idx = MIN(*spec_inv_idx, k); - } else if (st.pc_bbi == 2) - { - *spec_inv_idx = k; - x[k] = 0; - x[k + 1] = 0; - calculate_nfseed(x, k, nf_seed); - return; - } + if ( st.pc_return ) + { + *b_left = st.pc_b_left; + return; + } + + if ( st.pc_bbi == 1 ) + { + *spec_inv_idx = MIN( *spec_inv_idx, k ); + } + else if ( st.pc_bbi == 2 ) + { + *spec_inv_idx = k; + x[k] = 0; + x[k + 1] = 0; + calculate_nfseed( x, k, nf_seed ); + return; + } - if (sym < 16) { + if ( sym < 16 ) + { break; } - if (lsbMode == 0 || lev > 0) { - pc_check_bytes(&bp, &st, 0, mask_side, &bp_side); - read_bit_fl(ptr, &mask_side, &bp_side, &bit, &bp, &st, 0); + if ( lsbMode == 0 || lev > 0 ) + { + pc_check_bytes( &bp, &st, 0, mask_side, &bp_side ); + read_bit_fl( ptr, &mask_side, &bp_side, &bit, &bp, &st, 0 ); - if (st.pc_return) + if ( st.pc_return ) { *b_left = st.pc_b_left; return; } - - if (st.pc_bbi == 2) + + if ( st.pc_bbi == 2 ) { *spec_inv_idx = k; x[k] = 0; x[k + 1] = 0; - calculate_nfseed(x, k, nf_seed); + calculate_nfseed( x, k, nf_seed ); return; } - - x[k] = x[k] + (bit << lev); - pc_check_bytes(&bp, &st, 0, mask_side, &bp_side); - read_bit_fl(ptr, &mask_side, &bp_side, &bit, &bp, &st, 0); - if (st.pc_return) + x[k] = x[k] + ( bit << lev ); + pc_check_bytes( &bp, &st, 0, mask_side, &bp_side ); + read_bit_fl( ptr, &mask_side, &bp_side, &bit, &bp, &st, 0 ); + + if ( st.pc_return ) { *b_left = st.pc_b_left; return; } - - if (st.pc_bbi == 2) + + if ( st.pc_bbi == 2 ) { *spec_inv_idx = k; x[k] = 0; x[k + 1] = 0; - calculate_nfseed(x, k, nf_seed); + calculate_nfseed( x, k, nf_seed ); return; } - x[k + 1] = x[k + 1] + (bit << lev); + x[k + 1] = x[k + 1] + ( bit << lev ); } } - - if ((lev - 1) == 13 && sym == 16) + + if ( ( lev - 1 ) == 13 && sym == 16 ) { st.BER_detect = 1; } - - if (hrmode == 0) { - lev = MIN(lev, 13); + + if ( hrmode == 0 ) + { + lev = MIN( lev, 13 ); } - if (lsbMode == 1) { + if ( lsbMode == 1 ) + { save_lev[k] = lev; } a = sym & 3; b = sym >> 2; - x[k] = x[k] + (a << lev); - x[k + 1] = x[k + 1] + (b << lev); + x[k] = x[k] + ( a << lev ); + x[k + 1] = x[k + 1] + ( b << lev ); /* Decode signs */ - if (x[k] > 0) { - pc_check_bytes(&bp, &st, 0, mask_side, &bp_side); - read_bit_fl(ptr, &mask_side, &bp_side, &bit, &bp, &st, 0); - - if (st.pc_return) + if ( x[k] > 0 ) + { + pc_check_bytes( &bp, &st, 0, mask_side, &bp_side ); + read_bit_fl( ptr, &mask_side, &bp_side, &bit, &bp, &st, 0 ); + + if ( st.pc_return ) { *b_left = st.pc_b_left; return; } - - if (st.pc_bbi == 2) + + if ( st.pc_bbi == 2 ) { *spec_inv_idx = k; x[k] = 0; x[k + 1] = 0; - calculate_nfseed(x, k, nf_seed); + calculate_nfseed( x, k, nf_seed ); return; } - if (bit == 1) { + if ( bit == 1 ) + { x[k] = -x[k]; } } - if (x[k + 1] > 0) { - pc_check_bytes(&bp, &st, 0, mask_side, &bp_side); - read_bit_fl(ptr, &mask_side, &bp_side, &bit, &bp, &st, 0); - - if (st.pc_return) + if ( x[k + 1] > 0 ) + { + pc_check_bytes( &bp, &st, 0, mask_side, &bp_side ); + read_bit_fl( ptr, &mask_side, &bp_side, &bit, &bp, &st, 0 ); + + if ( st.pc_return ) { *b_left = st.pc_b_left; return; } - - if (st.pc_bbi == 2) + + if ( st.pc_bbi == 2 ) { *spec_inv_idx = k + 1; x[k + 1] = 0; - calculate_nfseed(x, k, nf_seed); + calculate_nfseed( x, k, nf_seed ); return; } - - if (bit == 1) { + + if ( bit == 1 ) + { x[k + 1] = -x[k + 1]; } } /* Context */ - lev1 = MIN(lev, 3); - if (lev1 <= 1) { - t = 1 + (a + b) * (lev1 + 1); - } else { + lev1 = MIN( lev, 3 ); + if ( lev1 <= 1 ) + { + t = 1 + ( a + b ) * ( lev1 + 1 ); + } + else + { t = 12 + lev1; } - c = (c & 15) * 16 + t; + c = ( c & 15 ) * 16 + t; - if (((bp - bp_side) > 3 && (st.pc_c_bp == st.pc_c_bp_side))) { + if ( ( ( bp - bp_side ) > 3 && ( st.pc_c_bp == st.pc_c_bp_side ) ) ) + { - if ((0 < *spec_inv_idx) && (*spec_inv_idx < (L_spec + 1))) + if ( ( 0 < *spec_inv_idx ) && ( *spec_inv_idx < ( L_spec + 1 ) ) ) { *bfi = 2; - calculate_nfseed(x, k, nf_seed); - return; + calculate_nfseed( x, k, nf_seed ); + return; } *bfi = 1; return; } - - if (st.BER_detect > 0) + + if ( st.BER_detect > 0 ) { - if ((0 < *spec_inv_idx) && (*spec_inv_idx < (L_spec + 1))) + if ( ( 0 < *spec_inv_idx ) && ( *spec_inv_idx < ( L_spec + 1 ) ) ) { *bfi = 2; - calculate_nfseed(x, k, nf_seed); + calculate_nfseed( x, k, nf_seed ); return; } @@ -606,189 +652,220 @@ void processAriDecoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side, } /* Residual bits */ - nbits_side = total_bits - (8 * bp_side + 8 - (31 - clz_func(mask_side))); - nbits_ari = (bp - 3) * 8; - extra_bits = 25 - (31 - clz_func(st.ac_range_fl)); + nbits_side = total_bits - ( 8 * bp_side + 8 - ( 31 - clz_func( mask_side ) ) ); + nbits_ari = ( bp - 3 ) * 8; + extra_bits = 25 - ( 31 - clz_func( st.ac_range_fl ) ); - if (enc == 0) + if ( enc == 0 ) { - if (st.pc_c_bp == 0) + if ( st.pc_c_bp == 0 ) { - nbits_ari = (bp - st.pc_bytes - 3) * 8; - } else { - nbits_ari = (bp + st.pc_b_left - st.pc_bytes - 3) * 8; + nbits_ari = ( bp - st.pc_bytes - 3 ) * 8; } - - if (st.pc_c_bp_side != 0) + else { - nbits_side = total_bits - 8 * (st.pc_b_left) + 8 * (st.pc_bytes - bp_side) - (8 - LC3_LOGTWO(mask_side)); + nbits_ari = ( bp + st.pc_b_left - st.pc_bytes - 3 ) * 8; + } + + if ( st.pc_c_bp_side != 0 ) + { + nbits_side = total_bits - 8 * ( st.pc_b_left ) + 8 * ( st.pc_bytes - bp_side ) - ( 8 - LC3_LOGTWO( mask_side ) ); } } - - *nbits_residual = total_bits - (nbits_side + nbits_ari + extra_bits); - if (*nbits_residual < 0) { - if ((0 < *spec_inv_idx) && (*spec_inv_idx < (L_spec + 1))) + *nbits_residual = total_bits - ( nbits_side + nbits_ari + extra_bits ); + + if ( *nbits_residual < 0 ) + { + if ( ( 0 < *spec_inv_idx ) && ( *spec_inv_idx < ( L_spec + 1 ) ) ) { *bfi = 2; - calculate_nfseed(x, k, nf_seed); + calculate_nfseed( x, k, nf_seed ); return; } - + *bfi = 1; return; } - if (lsbMode == 0) { - findNonZero(x, idx, L_spec, &idx_len); - if (hrmode) + if ( lsbMode == 0 ) + { + findNonZero( x, idx, L_spec, &idx_len ); + if ( hrmode ) { idx_len *= EXT_RES_ITER_MAX; } - *nbits_residual = MIN(*nbits_residual, idx_len); + *nbits_residual = MIN( *nbits_residual, idx_len ); *residualPresent = 1; - memset(resBits, 0, MAX_RESBITS_LEN); + memset( resBits, 0, MAX_RESBITS_LEN ); - for (k = 0; k < *nbits_residual; k++) { - pc_check_bytes(&bp, &st, 0, mask_side, &bp_side); - read_bit_fl(ptr, &mask_side, &bp_side, &tmp, &bp, &st, 0); - - if (st.pc_return) + for ( k = 0; k < *nbits_residual; k++ ) + { + pc_check_bytes( &bp, &st, 0, mask_side, &bp_side ); + read_bit_fl( ptr, &mask_side, &bp_side, &tmp, &bp, &st, 0 ); + + if ( st.pc_return ) { - *b_left = st.pc_b_left; + *b_left = st.pc_b_left; return; } - - if (st.pc_bbi == 2) + + if ( st.pc_bbi == 2 ) { *bfi = 0; - memset(resBits, 0, sizeof(uint8_t) * (*nbits_residual)); - calculate_nfseed(x, k, nf_seed); + memset( resBits, 0, sizeof( uint8_t ) * ( *nbits_residual ) ); + calculate_nfseed( x, k, nf_seed ); return; } - - resBits[k >> 3] |= tmp << (k & 7); + + resBits[k >> 3] |= tmp << ( k & 7 ); } - } else { - for (k = 0; k < lastnz; k = k + 2) { - if (save_lev[k] > 0) { - if (*nbits_residual == 0) { + } + else + { + for ( k = 0; k < lastnz; k = k + 2 ) + { + if ( save_lev[k] > 0 ) + { + if ( *nbits_residual == 0 ) + { break; } - pc_check_bytes(&bp, &st, 0, mask_side, &bp_side); - read_bit_fl(ptr, &mask_side, &bp_side, &bit, &bp, &st, 0); - - if (st.pc_return) + pc_check_bytes( &bp, &st, 0, mask_side, &bp_side ); + read_bit_fl( ptr, &mask_side, &bp_side, &bit, &bp, &st, 0 ); + + if ( st.pc_return ) { *b_left = st.pc_b_left; return; } - if (st.pc_bbi == 2) + if ( st.pc_bbi == 2 ) { *bfi = 0; - memset(resBits, 0, sizeof(LC3_INT32) * (*nbits_residual)); - calculate_nfseed(x, k, nf_seed); + memset( resBits, 0, sizeof( LC3_INT32 ) * ( *nbits_residual ) ); + calculate_nfseed( x, k, nf_seed ); return; } - + *nbits_residual = *nbits_residual - 1; - if (bit == 1) { - if (x[k] > 0) { + if ( bit == 1 ) + { + if ( x[k] > 0 ) + { x[k] = x[k] + 1; - } else if (x[k] < 0) { + } + else if ( x[k] < 0 ) + { x[k] = x[k] - 1; - } else { - if (*nbits_residual == 0) { + } + else + { + if ( *nbits_residual == 0 ) + { break; } - pc_check_bytes(&bp, &st, 0, mask_side, &bp_side); - read_bit_fl(ptr, &mask_side, &bp_side, &bit, &bp, &st, 0); - - if (st.pc_return) + pc_check_bytes( &bp, &st, 0, mask_side, &bp_side ); + read_bit_fl( ptr, &mask_side, &bp_side, &bit, &bp, &st, 0 ); + + if ( st.pc_return ) { *b_left = st.pc_b_left; return; } - if (st.pc_bbi == 2) + if ( st.pc_bbi == 2 ) { *bfi = 0; - memset(resBits, 0, sizeof(LC3_INT32) * (*nbits_residual)); - calculate_nfseed(x, k, nf_seed); + memset( resBits, 0, sizeof( LC3_INT32 ) * ( *nbits_residual ) ); + calculate_nfseed( x, k, nf_seed ); return; } - + *nbits_residual = *nbits_residual - 1; - if (bit == 0) { + if ( bit == 0 ) + { x[k] = 1; - } else { + } + else + { x[k] = -1; } } } - if (*nbits_residual == 0) { + if ( *nbits_residual == 0 ) + { break; } - pc_check_bytes(&bp, &st, 0, mask_side, &bp_side); - read_bit_fl(ptr, &mask_side, &bp_side, &bit, &bp, &st, 0); - - if (st.pc_return) + pc_check_bytes( &bp, &st, 0, mask_side, &bp_side ); + read_bit_fl( ptr, &mask_side, &bp_side, &bit, &bp, &st, 0 ); + + if ( st.pc_return ) { *b_left = st.pc_b_left; return; } - if (st.pc_bbi == 2) + if ( st.pc_bbi == 2 ) { *bfi = 0; - memset(resBits, 0, sizeof(LC3_INT32) * (*nbits_residual)); - calculate_nfseed(x, k, nf_seed); + memset( resBits, 0, sizeof( LC3_INT32 ) * ( *nbits_residual ) ); + calculate_nfseed( x, k, nf_seed ); return; } - + *nbits_residual = *nbits_residual - 1; - if (bit == 1) { - if (x[k + 1] > 0) { + if ( bit == 1 ) + { + if ( x[k + 1] > 0 ) + { x[k + 1] = x[k + 1] + 1; - } else if (x[k + 1] < 0) { + } + else if ( x[k + 1] < 0 ) + { x[k + 1] = x[k + 1] - 1; - } else { - if (*nbits_residual == 0) { + } + else + { + if ( *nbits_residual == 0 ) + { break; } - pc_check_bytes(&bp, &st, 0, mask_side, &bp_side); - read_bit_fl(ptr, &mask_side, &bp_side, &bit, &bp, &st, 0); - - if (st.pc_return) + pc_check_bytes( &bp, &st, 0, mask_side, &bp_side ); + read_bit_fl( ptr, &mask_side, &bp_side, &bit, &bp, &st, 0 ); + + if ( st.pc_return ) { *b_left = st.pc_b_left; return; } - if (st.pc_bbi == 2) + if ( st.pc_bbi == 2 ) { *bfi = 0; - memset(resBits, 0, sizeof(LC3_INT32) * (*nbits_residual)); - calculate_nfseed(x, k, nf_seed); + memset( resBits, 0, sizeof( LC3_INT32 ) * ( *nbits_residual ) ); + calculate_nfseed( x, k, nf_seed ); return; } - + *nbits_residual = *nbits_residual - 1; - if (bit == 0) { + if ( bit == 0 ) + { x[k + 1] = 1; - } else { + } + else + { x[k + 1] = -1; } } @@ -798,119 +875,132 @@ void processAriDecoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side, } /* Noise-filling seed */ - calculate_nfseed(x, L_spec, nf_seed); + calculate_nfseed( x, L_spec, nf_seed ); /* Zero frame flag */ - if (lastnz == 2 && x[0] == 0 && x[1] == 0 && gg_idx == 0 && fac_ns_idx == 7) { + if ( lastnz == 2 && x[0] == 0 && x[1] == 0 && gg_idx == 0 && fac_ns_idx == 7 ) + { *zero_frame = 1; - } else { + } + else + { *zero_frame = 0; } - - if (enc) + + if ( enc ) { - if (st.pc_bytes > 0) + if ( st.pc_bytes > 0 ) { - if (st.pc_b_left > numbytes) + if ( st.pc_b_left > numbytes ) { *b_left = bp_side - st.pc_bytes; } } } - - if ((*bfi == 2) && (*spec_inv_idx == (L_spec + 1))) + + if ( ( *bfi == 2 ) && ( *spec_inv_idx == ( L_spec + 1 ) ) ) { *bfi = 0; } - + *spec_inv_idx = *spec_inv_idx - 1; } -void ac_encode_fl(Encoder_State_fl* st, LC3_INT sym_freq, LC3_INT cum_freq) +void ac_encode_fl( Encoder_State_fl *st, LC3_INT sym_freq, LC3_INT cum_freq ) { LC3_INT r = 0; - r = st->range >> 10; + r = st->range >> 10; st->low = st->low + r * cum_freq; - if ((st->low >> 24) == 1) { + if ( ( st->low >> 24 ) == 1 ) + { st->carry = 1; } - st->low = (st->low) & ((LC3_INT)pow(2, 24) - 1); + st->low = ( st->low ) & ( (LC3_INT) pow( 2, 24 ) - 1 ); st->range = r * sym_freq; - while (st->range < (LC3_INT)pow(2, 16)) { + while ( st->range < (LC3_INT) pow( 2, 16 ) ) + { st->range = st->range << 8; - ac_shift_fl(st); + ac_shift_fl( st ); } } -void ac_shift_fl(Encoder_State_fl* st) +void ac_shift_fl( Encoder_State_fl *st ) { - if (st->low < 16711680 || st->carry == 1) { - if (st->cache >= 0) { + if ( st->low < 16711680 || st->carry == 1 ) + { + if ( st->cache >= 0 ) + { st->ptr[st->bp] = st->cache + st->carry; - st->bp = st->bp + 1; + st->bp = st->bp + 1; } - while (st->carry_count > 0) { - st->ptr[st->bp] = (st->carry + 255) & 255; - st->bp = st->bp + 1; + while ( st->carry_count > 0 ) + { + st->ptr[st->bp] = ( st->carry + 255 ) & 255; + st->bp = st->bp + 1; st->carry_count = st->carry_count - 1; } st->cache = st->low >> 16; st->carry = 0; - } else { + } + else + { st->carry_count = st->carry_count + 1; } st->low = st->low << 8; - st->low = (st->low) & ((LC3_INT)pow(2, 24) - 1); + st->low = ( st->low ) & ( (LC3_INT) pow( 2, 24 ) - 1 ); } -void tns_order_freq_enc(LC3_INT enable_lpc_weighting, LC3_INT order, LC3_INT* symfreq, LC3_INT* cumfreq) +void tns_order_freq_enc( LC3_INT enable_lpc_weighting, LC3_INT order, LC3_INT *symfreq, LC3_INT *cumfreq ) { *symfreq = tns_freq_cf[enable_lpc_weighting][order] - tns_freq_cf[enable_lpc_weighting][order - 1]; *cumfreq = tns_freq_cf[enable_lpc_weighting][order - 1]; } -void tns_coef_freq_enc(LC3_INT k, LC3_INT idx, LC3_INT* symfreq, LC3_INT* cumfreq) +void tns_coef_freq_enc( LC3_INT k, LC3_INT idx, LC3_INT *symfreq, LC3_INT *cumfreq ) { *symfreq = tns_cf[k][idx + 1] - tns_cf[k][idx]; *cumfreq = tns_cf[k][idx]; } -void ac_freq_fl(LC3_INT pki, LC3_INT s, LC3_INT* symfreq, LC3_INT* cumfreq) +void ac_freq_fl( LC3_INT pki, LC3_INT s, LC3_INT *symfreq, LC3_INT *cumfreq ) { *symfreq = ari_spec_cumfreq_fl[pki][s + 1] - ari_spec_cumfreq_fl[pki][s]; *cumfreq = ari_spec_cumfreq_fl[pki][s]; } -void ac_finalize_fl(Encoder_State_fl* st) +void ac_finalize_fl( Encoder_State_fl *st ) { LC3_INT bits = 0, mask = 0, val = 0, over1 = 0, high = 0, over2 = 0, c = 0, b = 0; - bits = 24 - floor(LC3_LOGTWO(st->range)); - mask = ((LC3_INT)pow(2, 24) - 1) >> bits; - val = st->low + mask; + bits = 24 - floor( LC3_LOGTWO( st->range ) ); + mask = ( (LC3_INT) pow( 2, 24 ) - 1 ) >> bits; + val = st->low + mask; over1 = val >> 24; - val = (val) & ((LC3_INT)pow(2, 24) - 1); - high = st->low + st->range; + val = ( val ) & ( (LC3_INT) pow( 2, 24 ) - 1 ); + high = st->low + st->range; over2 = high >> 24; - high = high & ((LC3_INT)pow(2, 24) - 1); - val = val & (((LC3_INT)pow(2, 24) - 1) - mask); + high = high & ( (LC3_INT) pow( 2, 24 ) - 1 ); + val = val & ( ( (LC3_INT) pow( 2, 24 ) - 1 ) - mask ); - if (over1 == over2) { - if (val + mask >= high) { + if ( over1 == over2 ) + { + if ( val + mask >= high ) + { bits = bits + 1; mask = mask >> 1; - val = ((st->low + mask) & ((LC3_INT)pow(2, 24) - 1)) & (((LC3_INT)pow(2, 24) - 1) - mask); + val = ( ( st->low + mask ) & ( (LC3_INT) pow( 2, 24 ) - 1 ) ) & ( ( (LC3_INT) pow( 2, 24 ) - 1 ) - mask ); } - if (val < st->low) { + if ( val < st->low ) + { st->carry = 1; } } @@ -919,44 +1009,57 @@ void ac_finalize_fl(Encoder_State_fl* st) b = bits; - if (bits > 8) { - for (; b >= 1; b = b - 8) { - ac_shift_fl(st); + if ( bits > 8 ) + { + for ( ; b >= 1; b = b - 8 ) + { + ac_shift_fl( st ); } - } else { - ac_shift_fl(st); + } + else + { + ac_shift_fl( st ); } bits = b; - if (bits < 0) { + if ( bits < 0 ) + { bits += 8; } - if (st->carry_count > 0) { + if ( st->carry_count > 0 ) + { st->ptr[st->bp] = st->cache; - st->bp = st->bp + 1; + st->bp = st->bp + 1; - for (c = st->carry_count; c >= 2; c--) { + for ( c = st->carry_count; c >= 2; c-- ) + { st->ptr[st->bp] = 255; - st->bp = st->bp + 1; + st->bp = st->bp + 1; } - write_uint_forward_fl(st, 255 << (bits - 8), bits); - } else { - write_uint_forward_fl(st, st->cache, bits); + write_uint_forward_fl( st, 255 << ( bits - 8 ), bits ); + } + else + { + write_uint_forward_fl( st, st->cache, bits ); } } -void write_uint_forward_fl(Encoder_State_fl* st, LC3_INT val, LC3_INT numbits) +void write_uint_forward_fl( Encoder_State_fl *st, LC3_INT val, LC3_INT numbits ) { LC3_INT k = 0, bit = 0, mask = 128; - for (k = 0; k < numbits; k++) { + for ( k = 0; k < numbits; k++ ) + { bit = val & mask; - if (bit == 0) { - st->ptr[st->bp] = st->ptr[st->bp] & (255 - mask); - } else { + if ( bit == 0 ) + { + st->ptr[st->bp] = st->ptr[st->bp] & ( 255 - mask ); + } + else + { st->ptr[st->bp] = st->ptr[st->bp] | mask; } @@ -964,159 +1067,176 @@ void write_uint_forward_fl(Encoder_State_fl* st, LC3_INT val, LC3_INT numbits) } } -void ari_enc_init(Encoder_State_fl* st, LC3_UINT8* bytes, LC3_INT* bp_side, LC3_INT* mask_side) +void ari_enc_init( Encoder_State_fl *st, LC3_UINT8 *bytes, LC3_INT *bp_side, LC3_INT *mask_side ) { - st->ptr = bytes; - st->bp_side = bp_side; - st->mask_side = mask_side; - st->bp = 0; - st->low = 0; - st->range = (LC3_INT)pow(2, 24) - 1; - st->cache = -1; - st->carry = 0; + st->ptr = bytes; + st->bp_side = bp_side; + st->mask_side = mask_side; + st->bp = 0; + st->low = 0; + st->range = (LC3_INT) pow( 2, 24 ) - 1; + st->cache = -1; + st->carry = 0; st->carry_count = 0; } -LC3_INT sign(LC3_INT x) +LC3_INT sign( LC3_INT x ) { - if (x > 0) + if ( x > 0 ) return 1; - if (x < 0) + if ( x < 0 ) return -1; return 0; } -void processAriEncoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side, LC3_INT* x, LC3_INT* tns_order, LC3_INT tns_numfilters, - LC3_INT* tns_idx, LC3_INT lastnz, LC3_INT* codingdata, uint8_t* res_bits, LC3_INT resBitsLen, LC3_INT lsbMode, - LC3_INT nbbits, LC3_INT enable_lpc_weighting) +void processAriEncoder_fl( LC3_UINT8 *bytes, LC3_INT bp_side, LC3_INT mask_side, LC3_INT *x, LC3_INT *tns_order, LC3_INT tns_numfilters, LC3_INT *tns_idx, LC3_INT lastnz, LC3_INT *codingdata, uint8_t *res_bits, LC3_INT resBitsLen, LC3_INT lsbMode, LC3_INT nbbits, LC3_INT enable_lpc_weighting ) { - LC3_INT total_bits = 0, cumfreq = 0, symfreq = 0, k = 0, i = 0, j = 0, lev = 0, lev1 = 0; - LC3_INT bit1 = 0, bit2 = 0, lsb1 = 0, lsb2 = 0, a = 0, b = 0, bit = 0, pki = 0, nbits_side = 0; - LC3_INT nbits_residual_enc = 0, nbits_ari = 0, lsbs[MAX_LEN] = {0}, lsbsLen = 0; + LC3_INT total_bits = 0, cumfreq = 0, symfreq = 0, k = 0, i = 0, j = 0, lev = 0, lev1 = 0; + LC3_INT bit1 = 0, bit2 = 0, lsb1 = 0, lsb2 = 0, a = 0, b = 0, bit = 0, pki = 0, nbits_side = 0; + LC3_INT nbits_residual_enc = 0, nbits_ari = 0, lsbs[MAX_LEN] = { 0 }, lsbsLen = 0; Encoder_State_fl st; - ari_enc_init(&st, bytes, &bp_side, &mask_side); + ari_enc_init( &st, bytes, &bp_side, &mask_side ); total_bits = nbbits; /* TNS data */ - for (i = 0; i < tns_numfilters; i++) { - if (tns_order[i] > 0) { - tns_order_freq_enc(enable_lpc_weighting, tns_order[i], &symfreq, &cumfreq); - ac_encode_fl(&st, symfreq, cumfreq); - - for (j = 0; j < tns_order[i]; j++) { - tns_coef_freq_enc(j, tns_idx[i * 8 + j], &symfreq, &cumfreq); - ac_encode_fl(&st, symfreq, cumfreq); + for ( i = 0; i < tns_numfilters; i++ ) + { + if ( tns_order[i] > 0 ) + { + tns_order_freq_enc( enable_lpc_weighting, tns_order[i], &symfreq, &cumfreq ); + ac_encode_fl( &st, symfreq, cumfreq ); + + for ( j = 0; j < tns_order[i]; j++ ) + { + tns_coef_freq_enc( j, tns_idx[i * 8 + j], &symfreq, &cumfreq ); + ac_encode_fl( &st, symfreq, cumfreq ); } } } /* Spectral data */ - for (k = 0; k < lastnz; k = k + 2) { - for (lev = 0; lev < codingdata[1]; lev++) { - lev1 = MIN(lev, 3); - pki = ari_spec_lookup_fl[codingdata[0] + lev1 * 1024]; - ac_freq_fl(pki, 16, &symfreq, &cumfreq); + for ( k = 0; k < lastnz; k = k + 2 ) + { + for ( lev = 0; lev < codingdata[1]; lev++ ) + { + lev1 = MIN( lev, 3 ); + pki = ari_spec_lookup_fl[codingdata[0] + lev1 * 1024]; + ac_freq_fl( pki, 16, &symfreq, &cumfreq ); - ac_encode_fl(&st, symfreq, cumfreq); - bit1 = (abs(x[k]) >> lev) & 1; - bit2 = (abs(x[k + 1]) >> lev) & 1; + ac_encode_fl( &st, symfreq, cumfreq ); + bit1 = ( abs( x[k] ) >> lev ) & 1; + bit2 = ( abs( x[k + 1] ) >> lev ) & 1; - if (lsbMode == 1 && lev == 0) { + if ( lsbMode == 1 && lev == 0 ) + { lsb1 = bit1; lsb2 = bit2; - } else { - write_bit_backward_fl(st.ptr, st.bp_side, st.mask_side, bit1); - write_bit_backward_fl(st.ptr, st.bp_side, st.mask_side, bit2); + } + else + { + write_bit_backward_fl( st.ptr, st.bp_side, st.mask_side, bit1 ); + write_bit_backward_fl( st.ptr, st.bp_side, st.mask_side, bit2 ); } } - lev1 = MIN(MAX(codingdata[1], 0), 3); - pki = ari_spec_lookup_fl[codingdata[0] + lev1 * 1024]; + lev1 = MIN( MAX( codingdata[1], 0 ), 3 ); + pki = ari_spec_lookup_fl[codingdata[0] + lev1 * 1024]; - ac_freq_fl(pki, codingdata[2], &symfreq, &cumfreq); - ac_encode_fl(&st, symfreq, cumfreq); + ac_freq_fl( pki, codingdata[2], &symfreq, &cumfreq ); + ac_encode_fl( &st, symfreq, cumfreq ); - a = abs(x[k]); - b = abs(x[k + 1]); + a = abs( x[k] ); + b = abs( x[k + 1] ); - if (lsbMode == 1 && codingdata[1] > 0) { - a = a >> 1; + if ( lsbMode == 1 && codingdata[1] > 0 ) + { + a = a >> 1; lsbs[lsbsLen] = lsb1; lsbsLen++; - if (a == 0 && x[k] != 0) { - bit = MAX(0, -sign(x[k])); + if ( a == 0 && x[k] != 0 ) + { + bit = MAX( 0, -sign( x[k] ) ); lsbs[lsbsLen] = bit; lsbsLen++; } - b = b >> 1; + b = b >> 1; lsbs[lsbsLen] = lsb2; lsbsLen++; - if (b == 0 && x[k + 1] != 0) { - bit = MAX(0, -sign(x[k + 1])); + if ( b == 0 && x[k + 1] != 0 ) + { + bit = MAX( 0, -sign( x[k + 1] ) ); lsbs[lsbsLen] = bit; lsbsLen++; } } - if (a != 0) { - bit = MAX(0, -sign(x[k])); - write_bit_backward_fl(st.ptr, st.bp_side, st.mask_side, bit); + if ( a != 0 ) + { + bit = MAX( 0, -sign( x[k] ) ); + write_bit_backward_fl( st.ptr, st.bp_side, st.mask_side, bit ); } - if (b != 0) { - bit = MAX(0, -sign(x[k + 1])); - write_bit_backward_fl(st.ptr, st.bp_side, st.mask_side, bit); + if ( b != 0 ) + { + bit = MAX( 0, -sign( x[k + 1] ) ); + write_bit_backward_fl( st.ptr, st.bp_side, st.mask_side, bit ); } codingdata += 3; } /* Residual bits */ - nbits_side = total_bits - (8 * (*(st.bp_side) + 1) + 8 - LC3_LOGTWO(*(st.mask_side))); - nbits_ari = (st.bp + 1) * 8 + 25 - floor(LC3_LOGTWO(st.range)); + nbits_side = total_bits - ( 8 * ( *( st.bp_side ) + 1 ) + 8 - LC3_LOGTWO( *( st.mask_side ) ) ); + nbits_ari = ( st.bp + 1 ) * 8 + 25 - floor( LC3_LOGTWO( st.range ) ); - if (st.cache >= 0) { + if ( st.cache >= 0 ) + { nbits_ari = nbits_ari + 8; } - if (st.carry_count > 0) { + if ( st.carry_count > 0 ) + { nbits_ari = nbits_ari + st.carry_count * 8; } - nbits_residual_enc = MAX(total_bits - (nbits_side + nbits_ari), 0); + nbits_residual_enc = MAX( total_bits - ( nbits_side + nbits_ari ), 0 ); /* the max operation avoids in very rare cases, that - * nbits_residual_enc becomes negative; having overwritten - * the last bit(s) of the side information is in this case - * assumed to be not critical, since no spectral data bits - * were written */ - - if (lsbMode == 0) { - nbits_residual_enc = MIN(nbits_residual_enc, resBitsLen); - for (k = 0; k < nbits_residual_enc; k++) { - if (res_bits[k >> 3] & (1 << (k & 7))) + * nbits_residual_enc becomes negative; having overwritten + * the last bit(s) of the side information is in this case + * assumed to be not critical, since no spectral data bits + * were written */ + + if ( lsbMode == 0 ) + { + nbits_residual_enc = MIN( nbits_residual_enc, resBitsLen ); + for ( k = 0; k < nbits_residual_enc; k++ ) + { + if ( res_bits[k >> 3] & ( 1 << ( k & 7 ) ) ) { - write_bit_backward_fl(st.ptr, st.bp_side, st.mask_side, 1); + write_bit_backward_fl( st.ptr, st.bp_side, st.mask_side, 1 ); } else { - write_bit_backward_fl(st.ptr, st.bp_side, st.mask_side, 0); + write_bit_backward_fl( st.ptr, st.bp_side, st.mask_side, 0 ); } } - } else { - nbits_residual_enc = MIN(nbits_residual_enc, lsbsLen); + } + else + { + nbits_residual_enc = MIN( nbits_residual_enc, lsbsLen ); - for (k = 0; k < nbits_residual_enc; k++) { - write_bit_backward_fl(st.ptr, st.bp_side, st.mask_side, lsbs[k]); + for ( k = 0; k < nbits_residual_enc; k++ ) + { + write_bit_backward_fl( st.ptr, st.bp_side, st.mask_side, lsbs[k] ); } } - ac_finalize_fl(&st); + ac_finalize_fl( &st ); } - diff --git a/lib_lc3plus/attack_detector.c b/lib_lc3plus/attack_detector.c index c9f7c0a94c..56dd248519 100644 --- a/lib_lc3plus/attack_detector.c +++ b/lib_lc3plus/attack_detector.c @@ -1,21 +1,20 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -void attack_detector_fl(LC3_FLOAT* in, LC3_INT frame_size, LC3_INT fs, LC3_INT* lastAttackPosition, LC3_FLOAT* accNrg, LC3_INT* attackFlag, - LC3_FLOAT* attdec_filter_mem, LC3_INT attackHandlingOn, LC3_INT attdec_nblocks, LC3_INT attdec_hangover_threshold) +void attack_detector_fl( LC3_FLOAT *in, LC3_INT frame_size, LC3_INT fs, LC3_INT *lastAttackPosition, LC3_FLOAT *accNrg, LC3_INT *attackFlag, LC3_FLOAT *attdec_filter_mem, LC3_INT attackHandlingOn, LC3_INT attdec_nblocks, LC3_INT attdec_hangover_threshold ) { - LC3_FLOAT f_sig[160] = {0}, block_nrg[4] = {0}, sum = 0, tmpEne = 0, *ptr = NULL, tmp[162] = {0}; - LC3_INT i = 0, j = 0, attackPosition = 0; + LC3_FLOAT f_sig[160] = { 0 }, block_nrg[4] = { 0 }, sum = 0, tmpEne = 0, *ptr = NULL, tmp[162] = { 0 }; + LC3_INT i = 0, j = 0, attackPosition = 0; LC3_FLOAT mval = 0; LC3_INT frame_size_16k = attdec_nblocks * 40; @@ -23,80 +22,97 @@ void attack_detector_fl(LC3_FLOAT* in, LC3_INT frame_size, LC3_INT fs, LC3_INT* ptr = &tmp[2]; - - if (attackHandlingOn) { + if ( attackHandlingOn ) + { /* Decimate 96, 48 and 32 kHz signals to 16 kHz */ - if (fs == 96000) { - for (i = 0; i < frame_size;) { + if ( fs == 96000 ) + { + for ( i = 0; i < frame_size; ) + { ptr[j] = in[i] + in[i + 1] + in[i + 2] + in[i + 3] + in[i + 4] + in[i + 5]; - i = i + 6; + i = i + 6; j++; } mval = 1e-5; - } else if (fs == 48000) { + } + else if ( fs == 48000 ) + { j = 0; - for (i = 0; i < frame_size;) { - ptr[j] = (in[i] + in[i + 1] + in[i + 2]); - i = i + 3; + for ( i = 0; i < frame_size; ) + { + ptr[j] = ( in[i] + in[i + 1] + in[i + 2] ); + i = i + 3; j++; } - } else if (fs == 32000) { + } + else if ( fs == 32000 ) + { j = 0; - for (i = 0; i < frame_size;) { - ptr[j] = (in[i] + in[i + 1]); - i = i + 2; + for ( i = 0; i < frame_size; ) + { + ptr[j] = ( in[i] + in[i + 1] ); + i = i + 2; j++; } - } else if (fs == 24000) { + } + else if ( fs == 24000 ) + { j = 0; - for (i = 0; i < frame_size;) { - ptr[j] = (in[i] + (in[i + 1] + in[i + 2]) / 2.0); - i = i + 3; + for ( i = 0; i < frame_size; ) + { + ptr[j] = ( in[i] + ( in[i + 1] + in[i + 2] ) / 2.0 ); + i = i + 3; j++; } } /* Filter */ - ptr[-2] = (LC3_FLOAT)attdec_filter_mem[0]; - ptr[-1] = (LC3_FLOAT)attdec_filter_mem[1]; + ptr[-2] = (LC3_FLOAT) attdec_filter_mem[0]; + ptr[-1] = (LC3_FLOAT) attdec_filter_mem[1]; attdec_filter_mem[0] = ptr[frame_size_16k - 2]; attdec_filter_mem[1] = ptr[frame_size_16k - 1]; - for (i = 159; i >= 0; i--) { + for ( i = 159; i >= 0; i-- ) + { tmpEne = 0; tmpEne += ptr[i] * 0.375; - tmpEne += ptr[i - 1] * (-0.5); - tmpEne += ptr[i - 2] * (0.125); + tmpEne += ptr[i - 1] * ( -0.5 ); + tmpEne += ptr[i - 2] * ( 0.125 ); f_sig[i] = tmpEne; } - for (i = 0; i < attdec_nblocks; i++) { + for ( i = 0; i < attdec_nblocks; i++ ) + { sum = 0; - for (j = 0; j < 40; j++) { + for ( j = 0; j < 40; j++ ) + { sum += f_sig[j + i * 40] * f_sig[j + i * 40]; } block_nrg[i] = sum; } - *attackFlag = 0; + *attackFlag = 0; attackPosition = -1; - for (i = 0; i < attdec_nblocks; i++) { + for ( i = 0; i < attdec_nblocks; i++ ) + { tmpEne = block_nrg[i] / 8.5; - if (tmpEne > MAX(*accNrg, mval)) { - *attackFlag = 1; + if ( tmpEne > MAX( *accNrg, mval ) ) + { + *attackFlag = 1; attackPosition = i + 1; } - *accNrg = MAX(block_nrg[i], 0.25 * (*accNrg)); + *accNrg = MAX( block_nrg[i], 0.25 * ( *accNrg ) ); } - if (*lastAttackPosition > attdec_hangover_threshold) { + if ( *lastAttackPosition > attdec_hangover_threshold ) + { *attackFlag = 1; } diff --git a/lib_lc3plus/clib.h b/lib_lc3plus/clib.h index bd70927808..163da2baae 100644 --- a/lib_lc3plus/clib.h +++ b/lib_lc3plus/clib.h @@ -1,12 +1,12 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #ifndef CLIB_H #define CLIB_H diff --git a/lib_lc3plus/constants.c b/lib_lc3plus/constants.c index 8189761a04..d2dc0bb822 100644 --- a/lib_lc3plus/constants.c +++ b/lib_lc3plus/constants.c @@ -1,65 +1,114 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" /* DCT */ -#define ENTRY_DCT2_1 {0.353553, 0.000000} -#define ENTRY_DCT2_2 {0.351851, -0.034654} -#define ENTRY_DCT2_3 {0.346760, -0.068975} -#define ENTRY_DCT2_4 {0.338329, -0.102631} -#define ENTRY_DCT2_5 {0.326641, -0.135299} -#define ENTRY_DCT2_6 {0.311806, -0.166664} -#define ENTRY_DCT2_7 {0.293969, -0.196424} -#define ENTRY_DCT2_8 {0.273300, -0.224292} -#define ENTRY_DCT2_9 {0.250000, -0.250000} -#define ENTRY_DCT2_10 {0.224292, -0.273300} -#define ENTRY_DCT2_11 {0.196424, -0.293969} -#define ENTRY_DCT2_12 {0.166664, -0.311806} -#define ENTRY_DCT2_13 {0.135299, -0.326641} -#define ENTRY_DCT2_14 {0.102631, -0.338329} -#define ENTRY_DCT2_15 {0.068975, -0.346760} -#define ENTRY_DCT2_16 {0.034654, -0.351851} +#define ENTRY_DCT2_1 \ + { \ + 0.353553, 0.000000 \ + } +#define ENTRY_DCT2_2 \ + { \ + 0.351851, -0.034654 \ + } +#define ENTRY_DCT2_3 \ + { \ + 0.346760, -0.068975 \ + } +#define ENTRY_DCT2_4 \ + { \ + 0.338329, -0.102631 \ + } +#define ENTRY_DCT2_5 \ + { \ + 0.326641, -0.135299 \ + } +#define ENTRY_DCT2_6 \ + { \ + 0.311806, -0.166664 \ + } +#define ENTRY_DCT2_7 \ + { \ + 0.293969, -0.196424 \ + } +#define ENTRY_DCT2_8 \ + { \ + 0.273300, -0.224292 \ + } +#define ENTRY_DCT2_9 \ + { \ + 0.250000, -0.250000 \ + } +#define ENTRY_DCT2_10 \ + { \ + 0.224292, -0.273300 \ + } +#define ENTRY_DCT2_11 \ + { \ + 0.196424, -0.293969 \ + } +#define ENTRY_DCT2_12 \ + { \ + 0.166664, -0.311806 \ + } +#define ENTRY_DCT2_13 \ + { \ + 0.135299, -0.326641 \ + } +#define ENTRY_DCT2_14 \ + { \ + 0.102631, -0.338329 \ + } +#define ENTRY_DCT2_15 \ + { \ + 0.068975, -0.346760 \ + } +#define ENTRY_DCT2_16 \ + { \ + 0.034654, -0.351851 \ + } const Complex dct2_16[16] = { -ENTRY_DCT2_1, -ENTRY_DCT2_2, -ENTRY_DCT2_3, -ENTRY_DCT2_4, -ENTRY_DCT2_5, -ENTRY_DCT2_6, -ENTRY_DCT2_7, -ENTRY_DCT2_8, -ENTRY_DCT2_9, -ENTRY_DCT2_10, -ENTRY_DCT2_11, -ENTRY_DCT2_12, -ENTRY_DCT2_13, -ENTRY_DCT2_14, -ENTRY_DCT2_15, -ENTRY_DCT2_16 -}; - -const LC3_INT ari_tns_order_cf[2][9] = {{0, 3, 12, 35, 89, 200, 390, 658, 1024}, - {0, 14, 56, 156, 313, 494, 672, 839, 1024}}; + ENTRY_DCT2_1, + ENTRY_DCT2_2, + ENTRY_DCT2_3, + ENTRY_DCT2_4, + ENTRY_DCT2_5, + ENTRY_DCT2_6, + ENTRY_DCT2_7, + ENTRY_DCT2_8, + ENTRY_DCT2_9, + ENTRY_DCT2_10, + ENTRY_DCT2_11, + ENTRY_DCT2_12, + ENTRY_DCT2_13, + ENTRY_DCT2_14, + ENTRY_DCT2_15, + ENTRY_DCT2_16 +}; + +const LC3_INT ari_tns_order_cf[2][9] = { { 0, 3, 12, 35, 89, 200, 390, 658, 1024 }, + { 0, 14, 56, 156, 313, 494, 672, 839, 1024 } }; const LC3_INT ari_tns_freq_cf[8][18] = { - {0, 1, 6, 21, 52, 106, 192, 289, 409, 568, 720, 831, 935, 994, 1016, 1022, 1023, 1024}, - {0, 1, 2, 3, 4, 17, 60, 154, 293, 466, 626, 780, 911, 989, 1016, 1022, 1023, 1024}, - {0, 1, 2, 3, 4, 13, 56, 162, 361, 578, 788, 929, 1003, 1020, 1021, 1022, 1023, 1024}, - {0, 1, 2, 3, 4, 6, 17, 66, 270, 555, 852, 972, 1011, 1020, 1021, 1022, 1023, 1024}, - {0, 1, 2, 3, 4, 5, 12, 54, 295, 636, 950, 1008, 1017, 1020, 1021, 1022, 1023, 1024}, - {0, 1, 2, 3, 4, 5, 6, 19, 224, 590, 967, 1014, 1019, 1020, 1021, 1022, 1023, 1024}, - {0, 1, 2, 3, 4, 5, 6, 19, 300, 630, 1001, 1018, 1019, 1020, 1021, 1022, 1023, 1024}, - {0, 1, 2, 3, 4, 5, 6, 11, 308, 309, 991, 1017, 1019, 1020, 1021, 1022, 1023, 1024}}; + { 0, 1, 6, 21, 52, 106, 192, 289, 409, 568, 720, 831, 935, 994, 1016, 1022, 1023, 1024 }, + { 0, 1, 2, 3, 4, 17, 60, 154, 293, 466, 626, 780, 911, 989, 1016, 1022, 1023, 1024 }, + { 0, 1, 2, 3, 4, 13, 56, 162, 361, 578, 788, 929, 1003, 1020, 1021, 1022, 1023, 1024 }, + { 0, 1, 2, 3, 4, 6, 17, 66, 270, 555, 852, 972, 1011, 1020, 1021, 1022, 1023, 1024 }, + { 0, 1, 2, 3, 4, 5, 12, 54, 295, 636, 950, 1008, 1017, 1020, 1021, 1022, 1023, 1024 }, + { 0, 1, 2, 3, 4, 5, 6, 19, 224, 590, 967, 1014, 1019, 1020, 1021, 1022, 1023, 1024 }, + { 0, 1, 2, 3, 4, 5, 6, 19, 300, 630, 1001, 1018, 1019, 1020, 1021, 1022, 1023, 1024 }, + { 0, 1, 2, 3, 4, 5, 6, 11, 308, 309, 991, 1017, 1019, 1020, 1021, 1022, 1023, 1024 } +}; const LC3_INT ari_spec_lookup_fl[4096] = { 0x01, 0x27, 0x07, 0x19, 0x16, 0x16, 0x1C, 0x16, 0x16, 0x16, 0x16, 0x1C, 0x1C, 0x1C, 0x22, 0x1F, 0x1F, 0x28, 0x2B, @@ -277,723 +326,736 @@ const LC3_INT ari_spec_lookup_fl[4096] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; const LC3_INT ari_spec_cumfreq_fl[64][18] = { - {0, 1, 2, 177, 225, 226, 227, 336, 372, 543, 652, 699, 719, 768, 804, 824, 834, 1024}, - {0, 18, 44, 61, 71, 98, 135, 159, 175, 197, 229, 251, 265, 282, 308, 328, 341, 1024}, - {0, 71, 163, 212, 237, 318, 420, 481, 514, 556, 613, 652, 675, 697, 727, 749, 764, 1024}, - {0, 160, 290, 336, 354, 475, 598, 653, 677, 722, 777, 808, 823, 842, 866, 881, 890, 1024}, - {0, 71, 144, 177, 195, 266, 342, 385, 411, 445, 489, 519, 539, 559, 586, 607, 622, 1024}, - {0, 48, 108, 140, 159, 217, 285, 327, 354, 385, 427, 457, 478, 497, 524, 545, 561, 1024}, - {0, 138, 247, 290, 308, 419, 531, 584, 609, 655, 710, 742, 759, 780, 807, 825, 836, 1024}, - {0, 16, 40, 62, 79, 103, 139, 170, 195, 215, 245, 270, 290, 305, 327, 346, 362, 1024}, - {0, 579, 729, 741, 743, 897, 970, 980, 982, 996, 1007, 1010, 1011, 1014, 1017, 1018, 1019, 1024}, - {0, 398, 582, 607, 612, 788, 902, 925, 931, 956, 979, 987, 990, 996, 1002, 1005, 1007, 1024}, - {0, 13, 34, 52, 63, 83, 112, 134, 149, 163, 183, 199, 211, 221, 235, 247, 257, 1024}, - {0, 281, 464, 501, 510, 681, 820, 857, 867, 902, 938, 953, 959, 968, 978, 984, 987, 1024}, - {0, 198, 362, 408, 421, 575, 722, 773, 789, 832, 881, 905, 915, 928, 944, 954, 959, 1024}, - {0, 1, 2, 95, 139, 140, 141, 213, 251, 337, 407, 450, 475, 515, 551, 576, 592, 1024}, - {0, 133, 274, 338, 366, 483, 605, 664, 691, 730, 778, 807, 822, 837, 857, 870, 878, 1024}, - {0, 128, 253, 302, 320, 443, 577, 636, 659, 708, 767, 799, 814, 833, 857, 872, 881, 1024}, - {0, 1, 2, 25, 42, 43, 44, 67, 85, 105, 126, 144, 159, 174, 191, 205, 217, 1024}, - {0, 70, 166, 229, 267, 356, 468, 533, 569, 606, 653, 685, 705, 722, 745, 762, 774, 1024}, - {0, 55, 130, 175, 200, 268, 358, 416, 449, 488, 542, 581, 606, 628, 659, 683, 699, 1024}, - {0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 1024}, - {0, 34, 85, 123, 147, 196, 265, 317, 352, 386, 433, 470, 497, 518, 549, 574, 593, 1024}, - {0, 30, 73, 105, 127, 170, 229, 274, 305, 335, 377, 411, 436, 455, 483, 506, 524, 1024}, - {0, 9, 24, 38, 51, 65, 87, 108, 126, 139, 159, 177, 193, 204, 221, 236, 250, 1024}, - {0, 30, 74, 105, 125, 166, 224, 266, 294, 322, 361, 391, 413, 431, 457, 478, 494, 1024}, - {0, 15, 38, 58, 73, 95, 128, 156, 178, 196, 222, 245, 263, 276, 296, 314, 329, 1024}, - {0, 11, 28, 44, 57, 74, 100, 123, 142, 157, 179, 199, 216, 228, 246, 262, 276, 1024}, - {0, 448, 619, 639, 643, 821, 926, 944, 948, 971, 991, 998, 1000, 1005, 1010, 1012, 1013, 1024}, - {0, 332, 520, 549, 555, 741, 874, 903, 910, 940, 970, 981, 985, 991, 998, 1002, 1004, 1024}, - {0, 8, 21, 34, 45, 58, 78, 96, 112, 124, 141, 157, 170, 180, 194, 207, 219, 1024}, - {0, 239, 415, 457, 468, 631, 776, 820, 833, 872, 914, 933, 940, 951, 964, 971, 975, 1024}, - {0, 165, 310, 359, 375, 513, 652, 707, 727, 774, 828, 856, 868, 884, 904, 916, 923, 1024}, - {0, 3, 8, 13, 18, 23, 30, 37, 44, 48, 55, 62, 68, 72, 78, 84, 90, 1024}, - {0, 115, 237, 289, 311, 422, 547, 608, 635, 680, 737, 771, 788, 807, 832, 849, 859, 1024}, - {0, 107, 221, 272, 293, 399, 521, 582, 610, 656, 714, 749, 767, 787, 813, 831, 842, 1024}, - {0, 6, 16, 26, 35, 45, 60, 75, 89, 98, 112, 125, 137, 145, 157, 168, 178, 1024}, - {0, 72, 160, 210, 236, 320, 422, 482, 514, 555, 608, 644, 665, 685, 712, 732, 745, 1024}, - {0, 45, 108, 153, 183, 244, 327, 385, 421, 455, 502, 536, 559, 578, 605, 626, 641, 1024}, - {0, 1, 2, 9, 16, 17, 18, 26, 34, 40, 48, 55, 62, 68, 75, 82, 88, 1024}, - {0, 29, 73, 108, 132, 174, 236, 284, 318, 348, 391, 426, 452, 471, 500, 524, 543, 1024}, - {0, 20, 51, 76, 93, 123, 166, 200, 225, 247, 279, 305, 326, 342, 365, 385, 401, 1024}, - {0, 742, 845, 850, 851, 959, 997, 1001, 1002, 1009, 1014, 1016, 1017, 1019, 1020, 1021, 1022, 1024}, - {0, 42, 94, 121, 137, 186, 244, 280, 303, 330, 366, 392, 410, 427, 451, 470, 484, 1024}, - {0, 13, 33, 51, 66, 85, 114, 140, 161, 178, 203, 225, 243, 256, 275, 292, 307, 1024}, - {0, 501, 670, 689, 693, 848, 936, 952, 956, 975, 991, 997, 999, 1004, 1008, 1010, 1011, 1024}, - {0, 445, 581, 603, 609, 767, 865, 888, 895, 926, 954, 964, 968, 977, 986, 991, 993, 1024}, - {0, 285, 442, 479, 489, 650, 779, 818, 830, 870, 912, 930, 937, 949, 963, 971, 975, 1024}, - {0, 349, 528, 561, 569, 731, 852, 883, 892, 923, 953, 965, 970, 978, 987, 992, 994, 1024}, - {0, 199, 355, 402, 417, 563, 700, 750, 767, 811, 860, 884, 894, 909, 926, 936, 942, 1024}, - {0, 141, 275, 325, 343, 471, 606, 664, 686, 734, 791, 822, 836, 854, 877, 891, 899, 1024}, - {0, 243, 437, 493, 510, 649, 775, 820, 836, 869, 905, 923, 931, 941, 953, 960, 964, 1024}, - {0, 91, 197, 248, 271, 370, 487, 550, 580, 625, 684, 721, 741, 761, 788, 807, 819, 1024}, - {0, 107, 201, 242, 262, 354, 451, 503, 531, 573, 626, 660, 680, 701, 730, 751, 765, 1024}, - {0, 168, 339, 407, 432, 553, 676, 731, 755, 789, 830, 854, 866, 879, 895, 906, 912, 1024}, - {0, 67, 147, 191, 214, 290, 384, 441, 472, 513, 567, 604, 627, 648, 678, 700, 715, 1024}, - {0, 46, 109, 148, 171, 229, 307, 359, 391, 427, 476, 513, 537, 558, 588, 612, 629, 1024}, - {0, 848, 918, 920, 921, 996, 1012, 1013, 1014, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024}, - {0, 36, 88, 123, 145, 193, 260, 308, 340, 372, 417, 452, 476, 496, 525, 548, 565, 1024}, - {0, 24, 61, 90, 110, 145, 196, 237, 266, 292, 330, 361, 385, 403, 430, 453, 471, 1024}, - {0, 85, 182, 230, 253, 344, 454, 515, 545, 590, 648, 685, 706, 727, 756, 776, 789, 1024}, - {0, 22, 55, 82, 102, 135, 183, 222, 252, 278, 315, 345, 368, 385, 410, 431, 448, 1024}, - {0, 1, 2, 56, 89, 90, 91, 140, 172, 221, 268, 303, 328, 358, 388, 412, 430, 1024}, - {0, 45, 109, 152, 177, 239, 320, 376, 411, 448, 499, 537, 563, 585, 616, 640, 658, 1024}, - {0, 247, 395, 433, 445, 599, 729, 771, 785, 829, 875, 896, 905, 920, 937, 946, 951, 1024}, - {0, 231, 367, 408, 423, 557, 676, 723, 742, 786, 835, 860, 872, 889, 909, 921, 928, 1024}}; + { 0, 1, 2, 177, 225, 226, 227, 336, 372, 543, 652, 699, 719, 768, 804, 824, 834, 1024 }, + { 0, 18, 44, 61, 71, 98, 135, 159, 175, 197, 229, 251, 265, 282, 308, 328, 341, 1024 }, + { 0, 71, 163, 212, 237, 318, 420, 481, 514, 556, 613, 652, 675, 697, 727, 749, 764, 1024 }, + { 0, 160, 290, 336, 354, 475, 598, 653, 677, 722, 777, 808, 823, 842, 866, 881, 890, 1024 }, + { 0, 71, 144, 177, 195, 266, 342, 385, 411, 445, 489, 519, 539, 559, 586, 607, 622, 1024 }, + { 0, 48, 108, 140, 159, 217, 285, 327, 354, 385, 427, 457, 478, 497, 524, 545, 561, 1024 }, + { 0, 138, 247, 290, 308, 419, 531, 584, 609, 655, 710, 742, 759, 780, 807, 825, 836, 1024 }, + { 0, 16, 40, 62, 79, 103, 139, 170, 195, 215, 245, 270, 290, 305, 327, 346, 362, 1024 }, + { 0, 579, 729, 741, 743, 897, 970, 980, 982, 996, 1007, 1010, 1011, 1014, 1017, 1018, 1019, 1024 }, + { 0, 398, 582, 607, 612, 788, 902, 925, 931, 956, 979, 987, 990, 996, 1002, 1005, 1007, 1024 }, + { 0, 13, 34, 52, 63, 83, 112, 134, 149, 163, 183, 199, 211, 221, 235, 247, 257, 1024 }, + { 0, 281, 464, 501, 510, 681, 820, 857, 867, 902, 938, 953, 959, 968, 978, 984, 987, 1024 }, + { 0, 198, 362, 408, 421, 575, 722, 773, 789, 832, 881, 905, 915, 928, 944, 954, 959, 1024 }, + { 0, 1, 2, 95, 139, 140, 141, 213, 251, 337, 407, 450, 475, 515, 551, 576, 592, 1024 }, + { 0, 133, 274, 338, 366, 483, 605, 664, 691, 730, 778, 807, 822, 837, 857, 870, 878, 1024 }, + { 0, 128, 253, 302, 320, 443, 577, 636, 659, 708, 767, 799, 814, 833, 857, 872, 881, 1024 }, + { 0, 1, 2, 25, 42, 43, 44, 67, 85, 105, 126, 144, 159, 174, 191, 205, 217, 1024 }, + { 0, 70, 166, 229, 267, 356, 468, 533, 569, 606, 653, 685, 705, 722, 745, 762, 774, 1024 }, + { 0, 55, 130, 175, 200, 268, 358, 416, 449, 488, 542, 581, 606, 628, 659, 683, 699, 1024 }, + { 0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 1024 }, + { 0, 34, 85, 123, 147, 196, 265, 317, 352, 386, 433, 470, 497, 518, 549, 574, 593, 1024 }, + { 0, 30, 73, 105, 127, 170, 229, 274, 305, 335, 377, 411, 436, 455, 483, 506, 524, 1024 }, + { 0, 9, 24, 38, 51, 65, 87, 108, 126, 139, 159, 177, 193, 204, 221, 236, 250, 1024 }, + { 0, 30, 74, 105, 125, 166, 224, 266, 294, 322, 361, 391, 413, 431, 457, 478, 494, 1024 }, + { 0, 15, 38, 58, 73, 95, 128, 156, 178, 196, 222, 245, 263, 276, 296, 314, 329, 1024 }, + { 0, 11, 28, 44, 57, 74, 100, 123, 142, 157, 179, 199, 216, 228, 246, 262, 276, 1024 }, + { 0, 448, 619, 639, 643, 821, 926, 944, 948, 971, 991, 998, 1000, 1005, 1010, 1012, 1013, 1024 }, + { 0, 332, 520, 549, 555, 741, 874, 903, 910, 940, 970, 981, 985, 991, 998, 1002, 1004, 1024 }, + { 0, 8, 21, 34, 45, 58, 78, 96, 112, 124, 141, 157, 170, 180, 194, 207, 219, 1024 }, + { 0, 239, 415, 457, 468, 631, 776, 820, 833, 872, 914, 933, 940, 951, 964, 971, 975, 1024 }, + { 0, 165, 310, 359, 375, 513, 652, 707, 727, 774, 828, 856, 868, 884, 904, 916, 923, 1024 }, + { 0, 3, 8, 13, 18, 23, 30, 37, 44, 48, 55, 62, 68, 72, 78, 84, 90, 1024 }, + { 0, 115, 237, 289, 311, 422, 547, 608, 635, 680, 737, 771, 788, 807, 832, 849, 859, 1024 }, + { 0, 107, 221, 272, 293, 399, 521, 582, 610, 656, 714, 749, 767, 787, 813, 831, 842, 1024 }, + { 0, 6, 16, 26, 35, 45, 60, 75, 89, 98, 112, 125, 137, 145, 157, 168, 178, 1024 }, + { 0, 72, 160, 210, 236, 320, 422, 482, 514, 555, 608, 644, 665, 685, 712, 732, 745, 1024 }, + { 0, 45, 108, 153, 183, 244, 327, 385, 421, 455, 502, 536, 559, 578, 605, 626, 641, 1024 }, + { 0, 1, 2, 9, 16, 17, 18, 26, 34, 40, 48, 55, 62, 68, 75, 82, 88, 1024 }, + { 0, 29, 73, 108, 132, 174, 236, 284, 318, 348, 391, 426, 452, 471, 500, 524, 543, 1024 }, + { 0, 20, 51, 76, 93, 123, 166, 200, 225, 247, 279, 305, 326, 342, 365, 385, 401, 1024 }, + { 0, 742, 845, 850, 851, 959, 997, 1001, 1002, 1009, 1014, 1016, 1017, 1019, 1020, 1021, 1022, 1024 }, + { 0, 42, 94, 121, 137, 186, 244, 280, 303, 330, 366, 392, 410, 427, 451, 470, 484, 1024 }, + { 0, 13, 33, 51, 66, 85, 114, 140, 161, 178, 203, 225, 243, 256, 275, 292, 307, 1024 }, + { 0, 501, 670, 689, 693, 848, 936, 952, 956, 975, 991, 997, 999, 1004, 1008, 1010, 1011, 1024 }, + { 0, 445, 581, 603, 609, 767, 865, 888, 895, 926, 954, 964, 968, 977, 986, 991, 993, 1024 }, + { 0, 285, 442, 479, 489, 650, 779, 818, 830, 870, 912, 930, 937, 949, 963, 971, 975, 1024 }, + { 0, 349, 528, 561, 569, 731, 852, 883, 892, 923, 953, 965, 970, 978, 987, 992, 994, 1024 }, + { 0, 199, 355, 402, 417, 563, 700, 750, 767, 811, 860, 884, 894, 909, 926, 936, 942, 1024 }, + { 0, 141, 275, 325, 343, 471, 606, 664, 686, 734, 791, 822, 836, 854, 877, 891, 899, 1024 }, + { 0, 243, 437, 493, 510, 649, 775, 820, 836, 869, 905, 923, 931, 941, 953, 960, 964, 1024 }, + { 0, 91, 197, 248, 271, 370, 487, 550, 580, 625, 684, 721, 741, 761, 788, 807, 819, 1024 }, + { 0, 107, 201, 242, 262, 354, 451, 503, 531, 573, 626, 660, 680, 701, 730, 751, 765, 1024 }, + { 0, 168, 339, 407, 432, 553, 676, 731, 755, 789, 830, 854, 866, 879, 895, 906, 912, 1024 }, + { 0, 67, 147, 191, 214, 290, 384, 441, 472, 513, 567, 604, 627, 648, 678, 700, 715, 1024 }, + { 0, 46, 109, 148, 171, 229, 307, 359, 391, 427, 476, 513, 537, 558, 588, 612, 629, 1024 }, + { 0, 848, 918, 920, 921, 996, 1012, 1013, 1014, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024 }, + { 0, 36, 88, 123, 145, 193, 260, 308, 340, 372, 417, 452, 476, 496, 525, 548, 565, 1024 }, + { 0, 24, 61, 90, 110, 145, 196, 237, 266, 292, 330, 361, 385, 403, 430, 453, 471, 1024 }, + { 0, 85, 182, 230, 253, 344, 454, 515, 545, 590, 648, 685, 706, 727, 756, 776, 789, 1024 }, + { 0, 22, 55, 82, 102, 135, 183, 222, 252, 278, 315, 345, 368, 385, 410, 431, 448, 1024 }, + { 0, 1, 2, 56, 89, 90, 91, 140, 172, 221, 268, 303, 328, 358, 388, 412, 430, 1024 }, + { 0, 45, 109, 152, 177, 239, 320, 376, 411, 448, 499, 537, 563, 585, 616, 640, 658, 1024 }, + { 0, 247, 395, 433, 445, 599, 729, 771, 785, 829, 875, 896, 905, 920, 937, 946, 951, 1024 }, + { 0, 231, 367, 408, 423, 557, 676, 723, 742, 786, 835, 860, 872, 889, 909, 921, 928, 1024 } +}; const LC3_INT ari_spec_bits_fl[64][17] = { - {20480, 20480, 5220, 9042, 20480, 20480, 6619, 9892, 5289, 6619, 9105, 11629, 8982, 9892, 11629, 13677, 4977}, - {11940, 10854, 12109, 13677, 10742, 9812, 11090, 12288, 11348, 10240, 11348, 12683, 12109, 10854, 11629, 12902, - 1197}, - {7886, 7120, 8982, 10970, 7496, 6815, 8334, 10150, 9437, 8535, 9656, 11216, 11348, 10431, 11348, 12479, 4051}, - {5485, 6099, 9168, 11940, 6311, 6262, 8640, 11090, 9233, 8640, 10334, 12479, 11781, 11090, 12479, 13988, 6009}, - {7886, 7804, 10150, 11940, 7886, 7685, 9368, 10854, 10061, 9300, 10431, 11629, 11629, 10742, 11485, 12479, 2763}, - {9042, 8383, 10240, 11781, 8483, 8013, 9437, 10742, 10334, 9437, 10431, 11485, 11781, 10742, 11485, 12288, 2346}, - {5922, 6619, 9368, 11940, 6566, 6539, 8750, 10970, 9168, 8640, 10240, 12109, 11485, 10742, 11940, 13396, 5009}, - {12288, 11090, 11348, 12109, 11090, 9892, 10334, 10970, 11629, 10431, 10970, 11629, 12479, 11348, 11781, 12288, - 1289}, - {1685, 5676, 13138, 18432, 5598, 7804, 13677, 18432, 12683, 13396, 17234, 20480, 17234, 17234, 20480, 20480, 15725}, - {2793, 5072, 10970, 15725, 5204, 6487, 11216, 15186, 10970, 11216, 14336, 17234, 15186, 15186, 17234, 18432, 12109}, - {12902, 11485, 11940, 13396, 11629, 10531, 11348, 12479, 12683, 11629, 12288, 13138, 13677, 12683, 13138, 13677, - 854}, - {3821, 5088, 9812, 13988, 5289, 5901, 9812, 13677, 9976, 9892, 12479, 15186, 13988, 13677, 15186, 17234, 9812}, - {4856, 5412, 9168, 12902, 5598, 5736, 8863, 12288, 9368, 8982, 11090, 13677, 12902, 12288, 13677, 15725, 8147}, - {20480, 20480, 7088, 9300, 20480, 20480, 7844, 9733, 7320, 7928, 9368, 10970, 9581, 9892, 10970, 12288, 2550}, - {6031, 5859, 8192, 10635, 6410, 6286, 8433, 10742, 9656, 9042, 10531, 12479, 12479, 11629, 12902, 14336, 5756}, - {6144, 6215, 8982, 11940, 6262, 6009, 8433, 11216, 8982, 8433, 10240, 12479, 11781, 11090, 12479, 13988, 5817}, - {20480, 20480, 11216, 12109, 20480, 20480, 11216, 11940, 11629, 11485, 11940, 12479, 12479, 12109, 12683, 13138, - 704}, - {7928, 6994, 8239, 9733, 7218, 6539, 8147, 9892, 9812, 9105, 10240, 11629, 12109, 11216, 12109, 13138, 4167}, - {8640, 7724, 9233, 10970, 8013, 7185, 8483, 10150, 9656, 8694, 9656, 10970, 11348, 10334, 11090, 12288, 3391}, - {20480, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, - 91}, - {10061, 8863, 9733, 11090, 8982, 7970, 8806, 9976, 10061, 9105, 9812, 10742, 11485, 10334, 10970, 11781, 2557}, - {10431, 9368, 10240, 11348, 9368, 8433, 9233, 10334, 10431, 9437, 10061, 10970, 11781, 10635, 11216, 11940, 2119}, - {13988, 12479, 12683, 12902, 12683, 11348, 11485, 11940, 12902, 11629, 11940, 12288, 13396, 12109, 12479, 12683, - 828}, - {10431, 9300, 10334, 11629, 9508, 8483, 9437, 10635, 10635, 9656, 10431, 11348, 11940, 10854, 11485, 12288, 1946}, - {12479, 11216, 11629, 12479, 11348, 10150, 10635, 11348, 11940, 10854, 11216, 11940, 12902, 11629, 11940, 12479, - 1146}, - {13396, 12109, 12288, 12902, 12109, 10854, 11216, 11781, 12479, 11348, 11629, 12109, 13138, 11940, 12288, 12683, - 928}, - {2443, 5289, 11629, 16384, 5170, 6730, 11940, 16384, 11216, 11629, 14731, 18432, 15725, 15725, 18432, 20480, 13396}, - {3328, 5009, 10531, 15186, 5040, 6031, 10531, 14731, 10431, 10431, 13396, 16384, 15186, 14731, 16384, 18432, 11629}, - {14336, 12902, 12902, 13396, 12902, 11629, 11940, 12288, 13138, 12109, 12288, 12902, 13677, 12683, 12902, 13138, - 711}, - {4300, 5204, 9437, 13396, 5430, 5776, 9300, 12902, 9656, 9437, 11781, 14731, 13396, 12902, 14731, 16384, 8982}, - {5394, 5776, 8982, 12288, 5922, 5901, 8640, 11629, 9105, 8694, 10635, 13138, 12288, 11629, 13138, 14731, 6844}, - {17234, 15725, 15725, 15725, 15725, 14731, 14731, 14731, 16384, 14731, 14731, 15186, 16384, 15186, 15186, 15186, - 272}, - {6461, 6286, 8806, 11348, 6566, 6215, 8334, 10742, 9233, 8535, 10061, 12109, 11781, 10970, 12109, 13677, 5394}, - {6674, 6487, 8863, 11485, 6702, 6286, 8334, 10635, 9168, 8483, 9976, 11940, 11629, 10854, 11940, 13396, 5105}, - {15186, 13677, 13677, 13988, 13677, 12479, 12479, 12683, 13988, 12683, 12902, 13138, 14336, 13138, 13396, 13677, - 565}, - {7844, 7252, 8922, 10854, 7389, 6815, 8383, 10240, 9508, 8750, 9892, 11485, 11629, 10742, 11629, 12902, 3842}, - {9233, 8239, 9233, 10431, 8334, 7424, 8483, 9892, 10061, 9105, 10061, 11216, 11781, 10742, 11485, 12479, 2906}, - {20480, 20480, 14731, 14731, 20480, 20480, 14336, 14336, 15186, 14336, 14731, 14731, 15186, 14731, 14731, 15186, - 266}, - {10531, 9300, 9976, 11090, 9437, 8286, 9042, 10061, 10431, 9368, 9976, 10854, 11781, 10531, 11090, 11781, 2233}, - {11629, 10334, 10970, 12109, 10431, 9368, 10061, 10970, 11348, 10240, 10854, 11485, 12288, 11216, 11629, 12288, - 1469}, - {952, 6787, 15725, 20480, 6646, 9733, 16384, 20480, 14731, 15725, 18432, 20480, 18432, 20480, 20480, 20480, 18432}, - {9437, 8806, 10742, 12288, 8982, 8483, 9892, 11216, 10742, 9892, 10854, 11940, 12109, 11090, 11781, 12683, 1891}, - {12902, 11629, 11940, 12479, 11781, 10531, 10854, 11485, 12109, 10970, 11348, 11940, 12902, 11781, 12109, 12479, - 1054}, - {2113, 5323, 11781, 16384, 5579, 7252, 12288, 16384, 11781, 12288, 15186, 18432, 15725, 16384, 18432, 20480, 12902}, - {2463, 5965, 11348, 15186, 5522, 6934, 11216, 14731, 10334, 10635, 13677, 16384, 13988, 13988, 15725, 18432, 10334}, - {3779, 5541, 9812, 13677, 5467, 6122, 9656, 13138, 9581, 9437, 11940, 14731, 13138, 12683, 14336, 16384, 8982}, - {3181, 5154, 10150, 14336, 5448, 6311, 10334, 13988, 10334, 10431, 13138, 15725, 14336, 13988, 15725, 18432, 10431}, - {4841, 5560, 9105, 12479, 5756, 5944, 8922, 12109, 9300, 8982, 11090, 13677, 12479, 12109, 13677, 15186, 7460}, - {5859, 6009, 8922, 11940, 6144, 5987, 8483, 11348, 9042, 8535, 10334, 12683, 11940, 11216, 12683, 14336, 6215}, - {4250, 4916, 8587, 12109, 5901, 6191, 9233, 12288, 10150, 9892, 11940, 14336, 13677, 13138, 14731, 16384, 8383}, - {7153, 6702, 8863, 11216, 6904, 6410, 8239, 10431, 9233, 8433, 9812, 11629, 11629, 10742, 11781, 13138, 4753}, - {6674, 7057, 9508, 11629, 7120, 6964, 8806, 10635, 9437, 8750, 10061, 11629, 11485, 10531, 11485, 12683, 4062}, - {5341, 5289, 8013, 10970, 6311, 6262, 8640, 11090, 10061, 9508, 11090, 13138, 12902, 12288, 13396, 15186, 6539}, - {8057, 7533, 9300, 11216, 7685, 7057, 8535, 10334, 9508, 8694, 9812, 11216, 11485, 10431, 11348, 12479, 3541}, - {9168, 8239, 9656, 11216, 8483, 7608, 8806, 10240, 9892, 8982, 9812, 11090, 11485, 10431, 11090, 12109, 2815}, - {558, 7928, 18432, 20480, 7724, 12288, 20480, 20480, 18432, 20480, 20480, 20480, 20480, 20480, 20480, 20480, 20480}, - {9892, 8806, 9976, 11348, 9042, 8057, 9042, 10240, 10240, 9233, 9976, 11090, 11629, 10531, 11216, 12109, 2371}, - {11090, 9812, 10531, 11629, 9976, 8863, 9508, 10531, 10854, 9733, 10334, 11090, 11940, 10742, 11216, 11940, 1821}, - {7354, 6964, 9042, 11216, 7153, 6592, 8334, 10431, 9233, 8483, 9812, 11485, 11485, 10531, 11629, 12902, 4349}, - {11348, 10150, 10742, 11629, 10150, 9042, 9656, 10431, 10854, 9812, 10431, 11216, 12109, 10970, 11485, 12109, 1700}, - {20480, 20480, 8694, 10150, 20480, 20480, 8982, 10240, 8982, 9105, 9976, 10970, 10431, 10431, 11090, 11940, 1610}, - {9233, 8192, 9368, 10970, 8286, 7496, 8587, 9976, 9812, 8863, 9733, 10854, 11348, 10334, 11090, 11940, 3040}, - {4202, 5716, 9733, 13138, 5598, 6099, 9437, 12683, 9300, 9168, 11485, 13988, 12479, 12109, 13988, 15725, 7804}, - {4400, 5965, 9508, 12479, 6009, 6360, 9105, 11781, 9300, 8982, 10970, 13138, 12109, 11629, 13138, 14731, 6994}}; + { 20480, 20480, 5220, 9042, 20480, 20480, 6619, 9892, 5289, 6619, 9105, 11629, 8982, 9892, 11629, 13677, 4977 }, + { 11940, 10854, 12109, 13677, 10742, 9812, 11090, 12288, 11348, 10240, 11348, 12683, 12109, 10854, 11629, 12902, + 1197 }, + { 7886, 7120, 8982, 10970, 7496, 6815, 8334, 10150, 9437, 8535, 9656, 11216, 11348, 10431, 11348, 12479, 4051 }, + { 5485, 6099, 9168, 11940, 6311, 6262, 8640, 11090, 9233, 8640, 10334, 12479, 11781, 11090, 12479, 13988, 6009 }, + { 7886, 7804, 10150, 11940, 7886, 7685, 9368, 10854, 10061, 9300, 10431, 11629, 11629, 10742, 11485, 12479, 2763 }, + { 9042, 8383, 10240, 11781, 8483, 8013, 9437, 10742, 10334, 9437, 10431, 11485, 11781, 10742, 11485, 12288, 2346 }, + { 5922, 6619, 9368, 11940, 6566, 6539, 8750, 10970, 9168, 8640, 10240, 12109, 11485, 10742, 11940, 13396, 5009 }, + { 12288, 11090, 11348, 12109, 11090, 9892, 10334, 10970, 11629, 10431, 10970, 11629, 12479, 11348, 11781, 12288, + 1289 }, + { 1685, 5676, 13138, 18432, 5598, 7804, 13677, 18432, 12683, 13396, 17234, 20480, 17234, 17234, 20480, 20480, 15725 }, + { 2793, 5072, 10970, 15725, 5204, 6487, 11216, 15186, 10970, 11216, 14336, 17234, 15186, 15186, 17234, 18432, 12109 }, + { 12902, 11485, 11940, 13396, 11629, 10531, 11348, 12479, 12683, 11629, 12288, 13138, 13677, 12683, 13138, 13677, + 854 }, + { 3821, 5088, 9812, 13988, 5289, 5901, 9812, 13677, 9976, 9892, 12479, 15186, 13988, 13677, 15186, 17234, 9812 }, + { 4856, 5412, 9168, 12902, 5598, 5736, 8863, 12288, 9368, 8982, 11090, 13677, 12902, 12288, 13677, 15725, 8147 }, + { 20480, 20480, 7088, 9300, 20480, 20480, 7844, 9733, 7320, 7928, 9368, 10970, 9581, 9892, 10970, 12288, 2550 }, + { 6031, 5859, 8192, 10635, 6410, 6286, 8433, 10742, 9656, 9042, 10531, 12479, 12479, 11629, 12902, 14336, 5756 }, + { 6144, 6215, 8982, 11940, 6262, 6009, 8433, 11216, 8982, 8433, 10240, 12479, 11781, 11090, 12479, 13988, 5817 }, + { 20480, 20480, 11216, 12109, 20480, 20480, 11216, 11940, 11629, 11485, 11940, 12479, 12479, 12109, 12683, 13138, + 704 }, + { 7928, 6994, 8239, 9733, 7218, 6539, 8147, 9892, 9812, 9105, 10240, 11629, 12109, 11216, 12109, 13138, 4167 }, + { 8640, 7724, 9233, 10970, 8013, 7185, 8483, 10150, 9656, 8694, 9656, 10970, 11348, 10334, 11090, 12288, 3391 }, + { 20480, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, + 91 }, + { 10061, 8863, 9733, 11090, 8982, 7970, 8806, 9976, 10061, 9105, 9812, 10742, 11485, 10334, 10970, 11781, 2557 }, + { 10431, 9368, 10240, 11348, 9368, 8433, 9233, 10334, 10431, 9437, 10061, 10970, 11781, 10635, 11216, 11940, 2119 }, + { 13988, 12479, 12683, 12902, 12683, 11348, 11485, 11940, 12902, 11629, 11940, 12288, 13396, 12109, 12479, 12683, + 828 }, + { 10431, 9300, 10334, 11629, 9508, 8483, 9437, 10635, 10635, 9656, 10431, 11348, 11940, 10854, 11485, 12288, 1946 }, + { 12479, 11216, 11629, 12479, 11348, 10150, 10635, 11348, 11940, 10854, 11216, 11940, 12902, 11629, 11940, 12479, + 1146 }, + { 13396, 12109, 12288, 12902, 12109, 10854, 11216, 11781, 12479, 11348, 11629, 12109, 13138, 11940, 12288, 12683, + 928 }, + { 2443, 5289, 11629, 16384, 5170, 6730, 11940, 16384, 11216, 11629, 14731, 18432, 15725, 15725, 18432, 20480, 13396 }, + { 3328, 5009, 10531, 15186, 5040, 6031, 10531, 14731, 10431, 10431, 13396, 16384, 15186, 14731, 16384, 18432, 11629 }, + { 14336, 12902, 12902, 13396, 12902, 11629, 11940, 12288, 13138, 12109, 12288, 12902, 13677, 12683, 12902, 13138, + 711 }, + { 4300, 5204, 9437, 13396, 5430, 5776, 9300, 12902, 9656, 9437, 11781, 14731, 13396, 12902, 14731, 16384, 8982 }, + { 5394, 5776, 8982, 12288, 5922, 5901, 8640, 11629, 9105, 8694, 10635, 13138, 12288, 11629, 13138, 14731, 6844 }, + { 17234, 15725, 15725, 15725, 15725, 14731, 14731, 14731, 16384, 14731, 14731, 15186, 16384, 15186, 15186, 15186, + 272 }, + { 6461, 6286, 8806, 11348, 6566, 6215, 8334, 10742, 9233, 8535, 10061, 12109, 11781, 10970, 12109, 13677, 5394 }, + { 6674, 6487, 8863, 11485, 6702, 6286, 8334, 10635, 9168, 8483, 9976, 11940, 11629, 10854, 11940, 13396, 5105 }, + { 15186, 13677, 13677, 13988, 13677, 12479, 12479, 12683, 13988, 12683, 12902, 13138, 14336, 13138, 13396, 13677, + 565 }, + { 7844, 7252, 8922, 10854, 7389, 6815, 8383, 10240, 9508, 8750, 9892, 11485, 11629, 10742, 11629, 12902, 3842 }, + { 9233, 8239, 9233, 10431, 8334, 7424, 8483, 9892, 10061, 9105, 10061, 11216, 11781, 10742, 11485, 12479, 2906 }, + { 20480, 20480, 14731, 14731, 20480, 20480, 14336, 14336, 15186, 14336, 14731, 14731, 15186, 14731, 14731, 15186, + 266 }, + { 10531, 9300, 9976, 11090, 9437, 8286, 9042, 10061, 10431, 9368, 9976, 10854, 11781, 10531, 11090, 11781, 2233 }, + { 11629, 10334, 10970, 12109, 10431, 9368, 10061, 10970, 11348, 10240, 10854, 11485, 12288, 11216, 11629, 12288, + 1469 }, + { 952, 6787, 15725, 20480, 6646, 9733, 16384, 20480, 14731, 15725, 18432, 20480, 18432, 20480, 20480, 20480, 18432 }, + { 9437, 8806, 10742, 12288, 8982, 8483, 9892, 11216, 10742, 9892, 10854, 11940, 12109, 11090, 11781, 12683, 1891 }, + { 12902, 11629, 11940, 12479, 11781, 10531, 10854, 11485, 12109, 10970, 11348, 11940, 12902, 11781, 12109, 12479, + 1054 }, + { 2113, 5323, 11781, 16384, 5579, 7252, 12288, 16384, 11781, 12288, 15186, 18432, 15725, 16384, 18432, 20480, 12902 }, + { 2463, 5965, 11348, 15186, 5522, 6934, 11216, 14731, 10334, 10635, 13677, 16384, 13988, 13988, 15725, 18432, 10334 }, + { 3779, 5541, 9812, 13677, 5467, 6122, 9656, 13138, 9581, 9437, 11940, 14731, 13138, 12683, 14336, 16384, 8982 }, + { 3181, 5154, 10150, 14336, 5448, 6311, 10334, 13988, 10334, 10431, 13138, 15725, 14336, 13988, 15725, 18432, 10431 }, + { 4841, 5560, 9105, 12479, 5756, 5944, 8922, 12109, 9300, 8982, 11090, 13677, 12479, 12109, 13677, 15186, 7460 }, + { 5859, 6009, 8922, 11940, 6144, 5987, 8483, 11348, 9042, 8535, 10334, 12683, 11940, 11216, 12683, 14336, 6215 }, + { 4250, 4916, 8587, 12109, 5901, 6191, 9233, 12288, 10150, 9892, 11940, 14336, 13677, 13138, 14731, 16384, 8383 }, + { 7153, 6702, 8863, 11216, 6904, 6410, 8239, 10431, 9233, 8433, 9812, 11629, 11629, 10742, 11781, 13138, 4753 }, + { 6674, 7057, 9508, 11629, 7120, 6964, 8806, 10635, 9437, 8750, 10061, 11629, 11485, 10531, 11485, 12683, 4062 }, + { 5341, 5289, 8013, 10970, 6311, 6262, 8640, 11090, 10061, 9508, 11090, 13138, 12902, 12288, 13396, 15186, 6539 }, + { 8057, 7533, 9300, 11216, 7685, 7057, 8535, 10334, 9508, 8694, 9812, 11216, 11485, 10431, 11348, 12479, 3541 }, + { 9168, 8239, 9656, 11216, 8483, 7608, 8806, 10240, 9892, 8982, 9812, 11090, 11485, 10431, 11090, 12109, 2815 }, + { 558, 7928, 18432, 20480, 7724, 12288, 20480, 20480, 18432, 20480, 20480, 20480, 20480, 20480, 20480, 20480, 20480 }, + { 9892, 8806, 9976, 11348, 9042, 8057, 9042, 10240, 10240, 9233, 9976, 11090, 11629, 10531, 11216, 12109, 2371 }, + { 11090, 9812, 10531, 11629, 9976, 8863, 9508, 10531, 10854, 9733, 10334, 11090, 11940, 10742, 11216, 11940, 1821 }, + { 7354, 6964, 9042, 11216, 7153, 6592, 8334, 10431, 9233, 8483, 9812, 11485, 11485, 10531, 11629, 12902, 4349 }, + { 11348, 10150, 10742, 11629, 10150, 9042, 9656, 10431, 10854, 9812, 10431, 11216, 12109, 10970, 11485, 12109, 1700 }, + { 20480, 20480, 8694, 10150, 20480, 20480, 8982, 10240, 8982, 9105, 9976, 10970, 10431, 10431, 11090, 11940, 1610 }, + { 9233, 8192, 9368, 10970, 8286, 7496, 8587, 9976, 9812, 8863, 9733, 10854, 11348, 10334, 11090, 11940, 3040 }, + { 4202, 5716, 9733, 13138, 5598, 6099, 9437, 12683, 9300, 9168, 11485, 13988, 12479, 12109, 13988, 15725, 7804 }, + { 4400, 5965, 9508, 12479, 6009, 6360, 9105, 11781, 9300, 8982, 10970, 13138, 12109, 11629, 13138, 14731, 6994 } +}; const LC3_FLOAT sns_LFCB[8][32] = { - {2.26283365592678, 2.94516479191376, -2.18610707009979, 0.693688236528920, -1.29752132315296, 0.914652037830672, - -2.51428812578962, -0.922188404812385, 0.790322288369266, 1.44775580178724, 0.793354526417474, 2.72425347385034, - -0.530830198375400, 1.68728410845006, -2.95183272801858, 0.101878342785628, 2.68254575498426, 4.82697923680403, - 0.0878419936470335, 1.39102308204326, 0.384585893889182, 1.93227399441719, 0.175080462899884, -1.18817020250556, - 2.53322203327061, 3.99889837485606, 0.507902593186381, 3.16856825107569, 1.89414766731764, 0.948880604517188, - -1.88026757045628, 0.246375746277129}, - {0.813311269061339, 2.41143317956679, -1.97152135675228, 0.955609857158220, -0.740369057177853, - 1.74293043435257, -2.89175271384373, 0.632495141440552, 0.628401261876199, 2.72399951674952, - 0.0143931185523454, 2.95947572404824, -0.212690682812164, 2.43614509237656, -1.59393496773345, - 0.589857324228917, 1.32738010899420, 3.11947804492488, -0.569586840238501, 1.98146479199466, - -0.160588785536510, 3.01030180412057, -0.750522832248985, 0.366792873662636, 2.11274642695908, - 4.07901751451956, 1.58838449789527, 3.25853458159407, 1.25108694609232, 2.13239439249982, - -1.26431072758705, 0.955621773393099}, - {-0.530193494871436, 0.960455106400727, -1.78718619681006, 0.575230787038733, -0.345372483642106, - 1.90906626859986, -2.00450666759434, 1.08736431254641, 0.393117923540450, 2.31083268737528, - -0.567834844729679, 1.84953559268461, 0.00576613628377097, 2.33019429078225, -0.109918772878022, - 0.619047646793466, 0.130185273804048, 1.39513671385178, -1.14506015668811, 1.11265796388770, - -0.539366809557710, 3.06543893826204, -1.03943893342231, 1.30957830409096, 1.26288411502064, - 2.82285661102496, 1.72899023869209, 2.42230591328599, 0.590451210720628, 2.72345350344278, - 0.311424976968699, 1.52046776741766}, - {-1.35664835903442, -0.443226488076917, -1.91865895685577, -0.114603419462889, -0.313285696247940, - 1.54408483842665, -0.750912273903127, 0.608628624535820, 0.480007710866901, 0.935051269566529, - -0.654760467916745, 0.563284922322364, 0.424871484383745, 1.77983777835091, 0.388609072919257, - 1.26731313851796, -0.338533088511347, 0.250295315918722, -1.66968488172598, -0.220107509420743, - -0.529309078789857, 2.50110160870008, -1.13577508937648, 1.68330687280491, 0.761513512430427, - 1.72607212849580, 1.00692230241726, 1.79446077643261, 0.608358583293714, 2.76986076866588, - 1.83670210306430, 1.97647400419457}, - {-1.59952176563196, -1.22913612425590, -1.79399121836596, -0.646050637436029, -0.402977242824477, - 1.09344960761455, 0.441202104904691, 0.131174567547348, 0.447815138050143, -0.274743911383688, - -0.479458998475743, 0.139917088125072, 0.473128952158668, 1.44411295390082, 0.512932649517584, - 2.41961047769804, -0.368219235899667, -0.393613839379793, -1.84534417603682, -0.774965611552366, - 0.190433547437932, 1.93089592978934, -1.04197903837494, 1.25100924225127, 0.522117937976170, - 0.647144377348619, 0.377121231816382, 1.52177910653089, 0.878171010011082, 2.54286973254946, - 2.25634191839874, 1.94043867177462}, - {-1.44098768430095, -1.55590039118170, -1.35738404257288, -0.952351370449625, -0.372020853465227, - 0.647479549518278, 1.20190987601009, -0.296149157743752, 0.209734214552234, -0.902077696828602, - -0.173894661902889, 0.359641093366222, 0.858894199321281, 1.51995177009730, 0.628112597063497, - 2.25174252572187, -0.191689946715961, -0.643458173054701, -1.56468027328802, -0.594063874149117, - 2.56062918106522, 0.572153810961837, -0.0152060098993382, 0.942375751628615, 0.118680069757121, - -0.331148521217238, 0.476370766899498, 1.17196706537602, 1.11912510950950, 2.02046263825019, - 2.04818998463474, 2.23375847282686}, - {-1.14381648305821, -1.49688655952376, -0.705444279353869, -1.07405247226150, -0.0783414177323738, - 0.0361790752449642, 1.32742857257290, -0.207013516525629, 0.00656691996428021, -0.940681511945404, - 0.0680162705515438, 0.689461354774589, 1.19111160854435, 1.47199393750425, 0.822621796430634, - 0.526537030991201, -0.154782377153908, -0.642570736856943, -1.11746759076420, 0.136937680628923, - 2.81896398245248, -0.811741794081091, 2.07048391716707, 0.826250483374133, -0.452346827507370, - -0.884042570848749, 1.08754740372170, 0.489394596980695, 1.01857661550342, 0.830045859400910, - 2.19526837458568, 1.98835977758407}, - {-0.755203767909064, -1.11689986501469, -0.0478172944777711, -0.758087707094905, 0.0970441303992295, - -0.297092807178889, 1.22049081140984, 0.134924916642080, -0.0861242342061857, -0.633697038974310, - 0.295125948369794, 0.639790176833105, 0.996189669638358, 0.977682473891761, 0.875891424655081, - -0.396591513227999, -0.234207177774392, -0.723193223444072, -0.533981663366786, 0.818242891264338, - 0.656670875696161, -1.17641810861903, 3.42948918081689, 0.439952741120956, -0.700352426161103, - -1.12697340645478, 1.08756266099221, -0.0622795715718769, 0.620453891011724, -0.0275569173888263, - 2.02659613836619, 1.27232672554701}}; + { 2.26283365592678, 2.94516479191376, -2.18610707009979, 0.693688236528920, -1.29752132315296, 0.914652037830672, + -2.51428812578962, -0.922188404812385, 0.790322288369266, 1.44775580178724, 0.793354526417474, 2.72425347385034, + -0.530830198375400, 1.68728410845006, -2.95183272801858, 0.101878342785628, 2.68254575498426, 4.82697923680403, + 0.0878419936470335, 1.39102308204326, 0.384585893889182, 1.93227399441719, 0.175080462899884, -1.18817020250556, + 2.53322203327061, 3.99889837485606, 0.507902593186381, 3.16856825107569, 1.89414766731764, 0.948880604517188, + -1.88026757045628, 0.246375746277129 }, + { 0.813311269061339, 2.41143317956679, -1.97152135675228, 0.955609857158220, -0.740369057177853, + 1.74293043435257, -2.89175271384373, 0.632495141440552, 0.628401261876199, 2.72399951674952, + 0.0143931185523454, 2.95947572404824, -0.212690682812164, 2.43614509237656, -1.59393496773345, + 0.589857324228917, 1.32738010899420, 3.11947804492488, -0.569586840238501, 1.98146479199466, + -0.160588785536510, 3.01030180412057, -0.750522832248985, 0.366792873662636, 2.11274642695908, + 4.07901751451956, 1.58838449789527, 3.25853458159407, 1.25108694609232, 2.13239439249982, + -1.26431072758705, 0.955621773393099 }, + { -0.530193494871436, 0.960455106400727, -1.78718619681006, 0.575230787038733, -0.345372483642106, + 1.90906626859986, -2.00450666759434, 1.08736431254641, 0.393117923540450, 2.31083268737528, + -0.567834844729679, 1.84953559268461, 0.00576613628377097, 2.33019429078225, -0.109918772878022, + 0.619047646793466, 0.130185273804048, 1.39513671385178, -1.14506015668811, 1.11265796388770, + -0.539366809557710, 3.06543893826204, -1.03943893342231, 1.30957830409096, 1.26288411502064, + 2.82285661102496, 1.72899023869209, 2.42230591328599, 0.590451210720628, 2.72345350344278, + 0.311424976968699, 1.52046776741766 }, + { -1.35664835903442, -0.443226488076917, -1.91865895685577, -0.114603419462889, -0.313285696247940, + 1.54408483842665, -0.750912273903127, 0.608628624535820, 0.480007710866901, 0.935051269566529, + -0.654760467916745, 0.563284922322364, 0.424871484383745, 1.77983777835091, 0.388609072919257, + 1.26731313851796, -0.338533088511347, 0.250295315918722, -1.66968488172598, -0.220107509420743, + -0.529309078789857, 2.50110160870008, -1.13577508937648, 1.68330687280491, 0.761513512430427, + 1.72607212849580, 1.00692230241726, 1.79446077643261, 0.608358583293714, 2.76986076866588, + 1.83670210306430, 1.97647400419457 }, + { -1.59952176563196, -1.22913612425590, -1.79399121836596, -0.646050637436029, -0.402977242824477, + 1.09344960761455, 0.441202104904691, 0.131174567547348, 0.447815138050143, -0.274743911383688, + -0.479458998475743, 0.139917088125072, 0.473128952158668, 1.44411295390082, 0.512932649517584, + 2.41961047769804, -0.368219235899667, -0.393613839379793, -1.84534417603682, -0.774965611552366, + 0.190433547437932, 1.93089592978934, -1.04197903837494, 1.25100924225127, 0.522117937976170, + 0.647144377348619, 0.377121231816382, 1.52177910653089, 0.878171010011082, 2.54286973254946, + 2.25634191839874, 1.94043867177462 }, + { -1.44098768430095, -1.55590039118170, -1.35738404257288, -0.952351370449625, -0.372020853465227, + 0.647479549518278, 1.20190987601009, -0.296149157743752, 0.209734214552234, -0.902077696828602, + -0.173894661902889, 0.359641093366222, 0.858894199321281, 1.51995177009730, 0.628112597063497, + 2.25174252572187, -0.191689946715961, -0.643458173054701, -1.56468027328802, -0.594063874149117, + 2.56062918106522, 0.572153810961837, -0.0152060098993382, 0.942375751628615, 0.118680069757121, + -0.331148521217238, 0.476370766899498, 1.17196706537602, 1.11912510950950, 2.02046263825019, + 2.04818998463474, 2.23375847282686 }, + { -1.14381648305821, -1.49688655952376, -0.705444279353869, -1.07405247226150, -0.0783414177323738, + 0.0361790752449642, 1.32742857257290, -0.207013516525629, 0.00656691996428021, -0.940681511945404, + 0.0680162705515438, 0.689461354774589, 1.19111160854435, 1.47199393750425, 0.822621796430634, + 0.526537030991201, -0.154782377153908, -0.642570736856943, -1.11746759076420, 0.136937680628923, + 2.81896398245248, -0.811741794081091, 2.07048391716707, 0.826250483374133, -0.452346827507370, + -0.884042570848749, 1.08754740372170, 0.489394596980695, 1.01857661550342, 0.830045859400910, + 2.19526837458568, 1.98835977758407 }, + { -0.755203767909064, -1.11689986501469, -0.0478172944777711, -0.758087707094905, 0.0970441303992295, + -0.297092807178889, 1.22049081140984, 0.134924916642080, -0.0861242342061857, -0.633697038974310, + 0.295125948369794, 0.639790176833105, 0.996189669638358, 0.977682473891761, 0.875891424655081, + -0.396591513227999, -0.234207177774392, -0.723193223444072, -0.533981663366786, 0.818242891264338, + 0.656670875696161, -1.17641810861903, 3.42948918081689, 0.439952741120956, -0.700352426161103, + -1.12697340645478, 1.08756266099221, -0.0622795715718769, 0.620453891011724, -0.0275569173888263, + 2.02659613836619, 1.27232672554701 } +}; const LC3_FLOAT sns_HFCB[8][32] = { - {0.232028419124465, -1.29503936673618, 0.139285716045803, -0.316513102185725, 0.879518405226496, - -0.296701922455375, 0.340981100469697, -1.41229759077597, -0.228839511827379, -1.07148628544449, - -0.590988511188051, -0.848434098836164, 1.14069145562382, -0.376283237967464, 0.665004120598402, - -0.826265953982679, 1.41008326832173, 0.361386817574348, 0.437469239330329, 0.648100318996503, - 1.11919833091304, 0.141847497087176, 0.504046955390252, -0.501076050479357, 3.74970982709642, - -1.15258990980549, 1.02827246422140, 0.128831971707817, 1.34033030334757, 2.13843105419313, - 0.564830487355396, -0.422460547586087}, - {-1.00890270604455, -1.79929965384339, -0.258185126171752, -0.477747657209805, 0.298340096007189, - -0.975004919174553, 0.268899788946055, -1.48522119349852, -0.333719069784662, -1.41767015456261, - -0.0711737758537628, -0.583226810708889, 0.964016892398293, 0.0425675462096105, 1.09790764690795, - -0.671181232766603, 0.754441907835468, -0.0219991705427826, 0.305440419605961, 0.682299133640680, - 1.23465532536005, -0.110660070633151, 0.826982162959097, -0.325678006081417, 1.52342611847045, - -1.10800885906241, 1.09770519389828, 0.689439395264878, 1.38996825067789, 4.24711267303104, - 1.59184977958743, 0.326149625049801}, - {-2.14223502789471, -1.88703147531519, -0.650804572670110, -0.551162075879755, -0.915386396405710, - -1.35857500246993, 0.0563335684828033, -1.18603579834700, -0.809321359324656, -1.54891762265441, - 0.345719522947313, 0.0900423688142873, 0.381461205984798, 0.516547696592306, 1.38342667112079, - -0.228495592779472, -1.30550584958631, -0.579368833633824, -0.00738786566478374, 0.253247464332976, - 0.589170238085318, -0.282824592543629, 1.11981236291828, 0.0280798194947077, -0.457715661897855, - -0.562615116512472, 0.768645545764776, 1.12346905009575, 1.04467921708883, 2.89734109830439, - 2.39771699015146, 1.39171313342261}, - {-2.37533813570664, -1.80991659687332, -1.06815731781969, -0.484788283381197, -2.20645974739762, - -0.983721105837444, 0.0499114046826685, -0.625001634441352, -1.63587876923797, -1.45296062475530, - 0.300549460996251, 0.845025007556886, -0.482849340608998, 0.251716881864630, 1.34327358628285, - 0.518980852551937, -1.87133711350971, -0.879427960941070, -0.495649854710252, 0.0735842143788469, - -1.37192459653166, -0.00659813474614194, 1.17914044332734, 0.262054554763133, -0.798711008243192, - -0.220562123765675, 0.206081977740766, 1.30934523106594, 0.635822746244367, 0.932730658026815, - 3.03697343600704, 2.23146614636474}, - {-2.23041933049655, -1.76340038479206, -1.61928741524302, -0.238388394455814, -2.74142180959951, - -0.652956939100809, -0.0954130727414369, 0.153902497468304, -1.88486397330982, -1.03182970062270, - -1.11865218295857, 1.06572384501716, -1.81632721260589, -0.216179967524303, 0.822978836855922, - 1.36721896340278, -1.24008685156305, -0.850685023408119, -0.806651271118393, 0.314216709389010, - -2.37095707241577, 0.285929279627216, 1.07987429197260, 0.360590806085767, -0.386819329309100, - -0.349842880336644, -0.342805735091998, 1.35511964713935, -0.274733755518482, -0.292822249729810, - 2.66424350337151, 2.61179442169688}, - {-2.17595881223696, -1.83418428467950, -2.18762566441756, -0.143024507285504, -2.86139074276891, - -0.989986992921811, -0.760166146083885, 0.576386497810755, -1.64496691316356, -0.690642640272584, - -2.44089151148049, 0.737582999377756, -2.80279512728555, -0.534074091124504, 0.215876798515679, - 2.18023038253092, -1.26712924866274, -0.779397050155816, -1.22431891984401, 0.234729880923679, - -2.00779782682360, 0.0460445529952971, 0.697536239067500, 0.635623722053700, -0.375901062231203, - -0.753432770250495, -0.754939404625340, 1.42311381470799, -1.54923372430695, -0.810404296853182, - 1.39304485032606, 2.66540340196570}, - {-2.29065913541000, -1.80480980687405, -2.63757586939054, 0.0683186673649074, -2.88841597105271, - -1.61467224598900, -2.32758120177007, 0.795092603798871, -1.40515778046612, -0.428843804532171, - -2.22854732450735, 0.256590452459912, -3.23385724833864, -0.640786096262196, -0.404925753080293, - 2.53596092750107, -2.03670813003907, -0.732182927291826, -1.70157770043181, 0.144600134479837, - -1.66688540224395, -0.602596415577886, -0.912548817371081, 0.959012467178154, -0.657836899930538, - -0.988596593396384, -1.04196177632000, 1.15706449190905, -2.44239710278007, -0.788868098756483, - 0.403834023595745, 2.40103554105707}, - {-2.53286397979846, -1.73679545317401, -2.97897749575096, 0.0883061717288066, -2.95182608262521, - -2.40712302385116, -3.77155485385656, 0.596564632144913, -1.46666471326146, -0.494960215408874, - -1.89509228210853, -0.491963359762378, -3.45908714491473, -0.869745032374135, -1.07025605870523, - 2.20121098860036, -2.89685162242381, -0.888348514821255, -2.24491913755611, -0.0682120178880174, - -1.92631846258406, -2.26568728632575, -3.57684747062773, 1.30745156688653, -1.28163964243603, - -1.28790471791471, -1.50335652955529, 0.406319437516838, -3.02457606944550, -0.935353148761338, - -0.656270971328114, 1.75920379670881}}; - -const LC3_INT pvq_enc_A[16][11] = {{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, - {0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19}, - {0, 1, 5, 13, 25, 41, 61, 85, 113, 145, 181}, - {0, 1, 7, 25, 63, 129, 231, 377, 575, 833, 1159}, - {0, 1, 9, 41, 129, 321, 681, 1289, 2241, 3649, 5641}, - {0, 1, 11, 61, 231, 681, 1683, 3653, 7183, 13073, 22363}, - {0, 1, 13, 85, 377, 1289, 3653, 8989, 19825, 40081, 75517}, - {0, 1, 15, 113, 575, 2241, 7183, 19825, 48639, 108545, 224143}, - {0, 1, 17, 145, 833, 3649, 13073, 40081, 108545, 265729, 598417}, - {0, 1, 19, 181, 1159, 5641, 22363, 75517, 224143, 598417, 1462563}, - {0, 1, 21, 221, 1561, 8361, 36365, 134245, 433905, 1256465, 3317445}, - {0, 1, 23, 265, 2047, 11969, 56695, 227305, 795455, 2485825, 7059735}, - {0, 1, 25, 313, 2625, 16641, 85305, 369305, 1392065, 4673345, 14218905}, - {0, 1, 27, 365, 3303, 22569, 124515, 579125, 2340495, 8405905, 27298155}, - {0, 1, 29, 421, 4089, 29961, 177045, 880685, 3800305, 14546705, 50250765}, - {0, 1, 31, 481, 4991, 39041, 246047, 1303777, 5984767, 24331777, 89129247}}; - -const LC3_FLOAT lp_scale_factors[6] = {1, 1, 0.6666666666666666, .5, 0.3333333333333333, 0.16666666666666666}; + { 0.232028419124465, -1.29503936673618, 0.139285716045803, -0.316513102185725, 0.879518405226496, + -0.296701922455375, 0.340981100469697, -1.41229759077597, -0.228839511827379, -1.07148628544449, + -0.590988511188051, -0.848434098836164, 1.14069145562382, -0.376283237967464, 0.665004120598402, + -0.826265953982679, 1.41008326832173, 0.361386817574348, 0.437469239330329, 0.648100318996503, + 1.11919833091304, 0.141847497087176, 0.504046955390252, -0.501076050479357, 3.74970982709642, + -1.15258990980549, 1.02827246422140, 0.128831971707817, 1.34033030334757, 2.13843105419313, + 0.564830487355396, -0.422460547586087 }, + { -1.00890270604455, -1.79929965384339, -0.258185126171752, -0.477747657209805, 0.298340096007189, + -0.975004919174553, 0.268899788946055, -1.48522119349852, -0.333719069784662, -1.41767015456261, + -0.0711737758537628, -0.583226810708889, 0.964016892398293, 0.0425675462096105, 1.09790764690795, + -0.671181232766603, 0.754441907835468, -0.0219991705427826, 0.305440419605961, 0.682299133640680, + 1.23465532536005, -0.110660070633151, 0.826982162959097, -0.325678006081417, 1.52342611847045, + -1.10800885906241, 1.09770519389828, 0.689439395264878, 1.38996825067789, 4.24711267303104, + 1.59184977958743, 0.326149625049801 }, + { -2.14223502789471, -1.88703147531519, -0.650804572670110, -0.551162075879755, -0.915386396405710, + -1.35857500246993, 0.0563335684828033, -1.18603579834700, -0.809321359324656, -1.54891762265441, + 0.345719522947313, 0.0900423688142873, 0.381461205984798, 0.516547696592306, 1.38342667112079, + -0.228495592779472, -1.30550584958631, -0.579368833633824, -0.00738786566478374, 0.253247464332976, + 0.589170238085318, -0.282824592543629, 1.11981236291828, 0.0280798194947077, -0.457715661897855, + -0.562615116512472, 0.768645545764776, 1.12346905009575, 1.04467921708883, 2.89734109830439, + 2.39771699015146, 1.39171313342261 }, + { -2.37533813570664, -1.80991659687332, -1.06815731781969, -0.484788283381197, -2.20645974739762, + -0.983721105837444, 0.0499114046826685, -0.625001634441352, -1.63587876923797, -1.45296062475530, + 0.300549460996251, 0.845025007556886, -0.482849340608998, 0.251716881864630, 1.34327358628285, + 0.518980852551937, -1.87133711350971, -0.879427960941070, -0.495649854710252, 0.0735842143788469, + -1.37192459653166, -0.00659813474614194, 1.17914044332734, 0.262054554763133, -0.798711008243192, + -0.220562123765675, 0.206081977740766, 1.30934523106594, 0.635822746244367, 0.932730658026815, + 3.03697343600704, 2.23146614636474 }, + { -2.23041933049655, -1.76340038479206, -1.61928741524302, -0.238388394455814, -2.74142180959951, + -0.652956939100809, -0.0954130727414369, 0.153902497468304, -1.88486397330982, -1.03182970062270, + -1.11865218295857, 1.06572384501716, -1.81632721260589, -0.216179967524303, 0.822978836855922, + 1.36721896340278, -1.24008685156305, -0.850685023408119, -0.806651271118393, 0.314216709389010, + -2.37095707241577, 0.285929279627216, 1.07987429197260, 0.360590806085767, -0.386819329309100, + -0.349842880336644, -0.342805735091998, 1.35511964713935, -0.274733755518482, -0.292822249729810, + 2.66424350337151, 2.61179442169688 }, + { -2.17595881223696, -1.83418428467950, -2.18762566441756, -0.143024507285504, -2.86139074276891, + -0.989986992921811, -0.760166146083885, 0.576386497810755, -1.64496691316356, -0.690642640272584, + -2.44089151148049, 0.737582999377756, -2.80279512728555, -0.534074091124504, 0.215876798515679, + 2.18023038253092, -1.26712924866274, -0.779397050155816, -1.22431891984401, 0.234729880923679, + -2.00779782682360, 0.0460445529952971, 0.697536239067500, 0.635623722053700, -0.375901062231203, + -0.753432770250495, -0.754939404625340, 1.42311381470799, -1.54923372430695, -0.810404296853182, + 1.39304485032606, 2.66540340196570 }, + { -2.29065913541000, -1.80480980687405, -2.63757586939054, 0.0683186673649074, -2.88841597105271, + -1.61467224598900, -2.32758120177007, 0.795092603798871, -1.40515778046612, -0.428843804532171, + -2.22854732450735, 0.256590452459912, -3.23385724833864, -0.640786096262196, -0.404925753080293, + 2.53596092750107, -2.03670813003907, -0.732182927291826, -1.70157770043181, 0.144600134479837, + -1.66688540224395, -0.602596415577886, -0.912548817371081, 0.959012467178154, -0.657836899930538, + -0.988596593396384, -1.04196177632000, 1.15706449190905, -2.44239710278007, -0.788868098756483, + 0.403834023595745, 2.40103554105707 }, + { -2.53286397979846, -1.73679545317401, -2.97897749575096, 0.0883061717288066, -2.95182608262521, + -2.40712302385116, -3.77155485385656, 0.596564632144913, -1.46666471326146, -0.494960215408874, + -1.89509228210853, -0.491963359762378, -3.45908714491473, -0.869745032374135, -1.07025605870523, + 2.20121098860036, -2.89685162242381, -0.888348514821255, -2.24491913755611, -0.0682120178880174, + -1.92631846258406, -2.26568728632575, -3.57684747062773, 1.30745156688653, -1.28163964243603, + -1.28790471791471, -1.50335652955529, 0.406319437516838, -3.02457606944550, -0.935353148761338, + -0.656270971328114, 1.75920379670881 } +}; + +const LC3_INT pvq_enc_A[16][11] = { { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, + { 0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19 }, + { 0, 1, 5, 13, 25, 41, 61, 85, 113, 145, 181 }, + { 0, 1, 7, 25, 63, 129, 231, 377, 575, 833, 1159 }, + { 0, 1, 9, 41, 129, 321, 681, 1289, 2241, 3649, 5641 }, + { 0, 1, 11, 61, 231, 681, 1683, 3653, 7183, 13073, 22363 }, + { 0, 1, 13, 85, 377, 1289, 3653, 8989, 19825, 40081, 75517 }, + { 0, 1, 15, 113, 575, 2241, 7183, 19825, 48639, 108545, 224143 }, + { 0, 1, 17, 145, 833, 3649, 13073, 40081, 108545, 265729, 598417 }, + { 0, 1, 19, 181, 1159, 5641, 22363, 75517, 224143, 598417, 1462563 }, + { 0, 1, 21, 221, 1561, 8361, 36365, 134245, 433905, 1256465, 3317445 }, + { 0, 1, 23, 265, 2047, 11969, 56695, 227305, 795455, 2485825, 7059735 }, + { 0, 1, 25, 313, 2625, 16641, 85305, 369305, 1392065, 4673345, 14218905 }, + { 0, 1, 27, 365, 3303, 22569, 124515, 579125, 2340495, 8405905, 27298155 }, + { 0, 1, 29, 421, 4089, 29961, 177045, 880685, 3800305, 14546705, 50250765 }, + { 0, 1, 31, 481, 4991, 39041, 246047, 1303777, 5984767, 24331777, 89129247 } }; + +const LC3_FLOAT lp_scale_factors[6] = { 1, 1, 0.6666666666666666, .5, 0.3333333333333333, 0.16666666666666666 }; /* 12.8 kHz resampler */ -const LC3_FLOAT highpass50_filt_b[3] = {0.9827947082978771, -1.965589416595754, 0.9827947082978771}; -const LC3_FLOAT highpass50_filt_a[3] = {1, -1.9652933726226904, 0.9658854605688177}; +const LC3_FLOAT highpass50_filt_b[3] = { 0.9827947082978771, -1.965589416595754, 0.9827947082978771 }; +const LC3_FLOAT highpass50_filt_a[3] = { 1, -1.9652933726226904, 0.9658854605688177 }; const LC3_INT32 resamp_params[][4] = { - {24, 5, 0, 15}, - {12, 10, 1, 3}, - {8, 15, 1, 7}, - {6, 20, 2, 3}, - {4, 30, 3, 3}, - {2, 60, 7, 1} + { 24, 5, 0, 15 }, + { 12, 10, 1, 3 }, + { 8, 15, 1, 7 }, + { 6, 20, 2, 3 }, + { 4, 30, 3, 3 }, + { 2, 60, 7, 1 } }; -const LC3_FLOAT lp_filter_8[240] = {0.0065408750, 0.0127360141, -0.0320970677, -0.1382038444, 0.8005587459, -0.1382038444, -0.0320970677, 0.0127360141, 0.0065408750, 0.0000000000, 0.0064595463, 0.0084537705, -0.0391003005, -0.1198658869, 0.7945935130, -0.1519452035, -0.0230523963, 0.0167804975, 0.0063002659, -0.0002451667, 0.0060938913, 0.0041435249, -0.0439039879, -0.0980933905, 0.7768620253, -0.1600013375, -0.0122310519, 0.0203715712, 0.0057131811, -0.0005356151, 0.0054914863, 0.0000000000, -0.0464562289, -0.0740769655, 0.7478516698, -0.1614013463, 0.0000000000, 0.0232978407, 0.0047708568, -0.0008596397, 0.0047065411, -0.0038048958, -0.0468063876, -0.0489920303, 0.7083564401, -0.1553338468, 0.0131809860, 0.0253629088, 0.0034824028, -0.0012012133, 0.0037965439, -0.0071282135, -0.0450960808, -0.0239577144, 0.6594504118, -0.1411849856, 0.0267735831, 0.0263961889, 0.0018761361, -0.0015404741, 0.0028190494, -0.0098603060, -0.0415467210, -0.0000000000, 0.6024519205, -0.1185704023, 0.0401797108, 0.0262632743, -0.0000000000, -0.0018545259, 0.0018287648, -0.0119272992, -0.0364444591, 0.0219798349, 0.5388799906, -0.0873604342, 0.0527642742, 0.0248753466, -0.0020790326, -0.0021185349, 0.0008750616, -0.0132916924, -0.0301232301, 0.0412303619, 0.4704038501, -0.0476967618, 0.0638811216, 0.0221970305, -0.0042766319, -0.0023070835, 0.0000000000, -0.0139512215, -0.0229468606, 0.0571681485, 0.3987891078, 0.0000000000, 0.0729012638, 0.0182522610, -0.0064938627, -0.0023957258, -0.0007630716, -0.0139361415, -0.0152910165, 0.0693885013, 0.3258404732, 0.0550325289, 0.0792422444, 0.0131276902, -0.0086209681, -0.0023626641, -0.0013903243, -0.0133052040, -0.0075258445, 0.0776687115, 0.2533447146, 0.1164389849, 0.0823974460, 0.0069732964, -0.0105420630, -0.0021904600, -0.0018676731, -0.0121405739, -0.0000000000, 0.0819641128, 0.1830149740, 0.1830149740, 0.0819641128, -0.0000000000, -0.0121405739, -0.0018676731, -0.0021904600, -0.0105420630, 0.0069732964, 0.0823974460, 0.1164389849, 0.2533447146, 0.0776687115, -0.0075258445, -0.0133052040, -0.0013903243, -0.0023626641, -0.0086209681, 0.0131276902, 0.0792422444, 0.0550325289, 0.3258404732, 0.0693885013, -0.0152910165, -0.0139361415, -0.0007630716, -0.0023957258, -0.0064938627, 0.0182522610, 0.0729012638, 0.0000000000, 0.3987891078, 0.0571681485, -0.0229468606, -0.0139512215, 0.0000000000, -0.0023070835, -0.0042766319, 0.0221970305, 0.0638811216, -0.0476967618, 0.4704038501, 0.0412303619, -0.0301232301, -0.0132916924, 0.0008750616, -0.0021185349, -0.0020790326, 0.0248753466, 0.0527642742, -0.0873604342, 0.5388799906, 0.0219798349, -0.0364444591, -0.0119272992, 0.0018287648, -0.0018545259, -0.0000000000, 0.0262632743, 0.0401797108, -0.1185704023, 0.6024519205, -0.0000000000, -0.0415467210, -0.0098603060, 0.0028190494, -0.0015404741, 0.0018761361, 0.0263961889, 0.0267735831, -0.1411849856, 0.6594504118, -0.0239577144, -0.0450960808, -0.0071282135, 0.0037965439, -0.0012012133, 0.0034824028, 0.0253629088, 0.0131809860, -0.1553338468, 0.7083564401, -0.0489920303, -0.0468063876, -0.0038048958, 0.0047065411, -0.0008596397, 0.0047708568, 0.0232978407, 0.0000000000, -0.1614013463, 0.7478516698, -0.0740769655, -0.0464562289, 0.0000000000, 0.0054914863, -0.0005356151, 0.0057131811, 0.0203715712, -0.0122310519, -0.1600013375, 0.7768620253, -0.0980933905, -0.0439039879, 0.0041435249, 0.0060938913, -0.0002451667, 0.0063002659, 0.0167804975, -0.0230523963, -0.1519452035, 0.7945935130, -0.1198658869, -0.0391003005, 0.0084537705, 0.0064595463}; +const LC3_FLOAT lp_filter_8[240] = { 0.0065408750, 0.0127360141, -0.0320970677, -0.1382038444, 0.8005587459, -0.1382038444, -0.0320970677, 0.0127360141, 0.0065408750, 0.0000000000, 0.0064595463, 0.0084537705, -0.0391003005, -0.1198658869, 0.7945935130, -0.1519452035, -0.0230523963, 0.0167804975, 0.0063002659, -0.0002451667, 0.0060938913, 0.0041435249, -0.0439039879, -0.0980933905, 0.7768620253, -0.1600013375, -0.0122310519, 0.0203715712, 0.0057131811, -0.0005356151, 0.0054914863, 0.0000000000, -0.0464562289, -0.0740769655, 0.7478516698, -0.1614013463, 0.0000000000, 0.0232978407, 0.0047708568, -0.0008596397, 0.0047065411, -0.0038048958, -0.0468063876, -0.0489920303, 0.7083564401, -0.1553338468, 0.0131809860, 0.0253629088, 0.0034824028, -0.0012012133, 0.0037965439, -0.0071282135, -0.0450960808, -0.0239577144, 0.6594504118, -0.1411849856, 0.0267735831, 0.0263961889, 0.0018761361, -0.0015404741, 0.0028190494, -0.0098603060, -0.0415467210, -0.0000000000, 0.6024519205, -0.1185704023, 0.0401797108, 0.0262632743, -0.0000000000, -0.0018545259, 0.0018287648, -0.0119272992, -0.0364444591, 0.0219798349, 0.5388799906, -0.0873604342, 0.0527642742, 0.0248753466, -0.0020790326, -0.0021185349, 0.0008750616, -0.0132916924, -0.0301232301, 0.0412303619, 0.4704038501, -0.0476967618, 0.0638811216, 0.0221970305, -0.0042766319, -0.0023070835, 0.0000000000, -0.0139512215, -0.0229468606, 0.0571681485, 0.3987891078, 0.0000000000, 0.0729012638, 0.0182522610, -0.0064938627, -0.0023957258, -0.0007630716, -0.0139361415, -0.0152910165, 0.0693885013, 0.3258404732, 0.0550325289, 0.0792422444, 0.0131276902, -0.0086209681, -0.0023626641, -0.0013903243, -0.0133052040, -0.0075258445, 0.0776687115, 0.2533447146, 0.1164389849, 0.0823974460, 0.0069732964, -0.0105420630, -0.0021904600, -0.0018676731, -0.0121405739, -0.0000000000, 0.0819641128, 0.1830149740, 0.1830149740, 0.0819641128, -0.0000000000, -0.0121405739, -0.0018676731, -0.0021904600, -0.0105420630, 0.0069732964, 0.0823974460, 0.1164389849, 0.2533447146, 0.0776687115, -0.0075258445, -0.0133052040, -0.0013903243, -0.0023626641, -0.0086209681, 0.0131276902, 0.0792422444, 0.0550325289, 0.3258404732, 0.0693885013, -0.0152910165, -0.0139361415, -0.0007630716, -0.0023957258, -0.0064938627, 0.0182522610, 0.0729012638, 0.0000000000, 0.3987891078, 0.0571681485, -0.0229468606, -0.0139512215, 0.0000000000, -0.0023070835, -0.0042766319, 0.0221970305, 0.0638811216, -0.0476967618, 0.4704038501, 0.0412303619, -0.0301232301, -0.0132916924, 0.0008750616, -0.0021185349, -0.0020790326, 0.0248753466, 0.0527642742, -0.0873604342, 0.5388799906, 0.0219798349, -0.0364444591, -0.0119272992, 0.0018287648, -0.0018545259, -0.0000000000, 0.0262632743, 0.0401797108, -0.1185704023, 0.6024519205, -0.0000000000, -0.0415467210, -0.0098603060, 0.0028190494, -0.0015404741, 0.0018761361, 0.0263961889, 0.0267735831, -0.1411849856, 0.6594504118, -0.0239577144, -0.0450960808, -0.0071282135, 0.0037965439, -0.0012012133, 0.0034824028, 0.0253629088, 0.0131809860, -0.1553338468, 0.7083564401, -0.0489920303, -0.0468063876, -0.0038048958, 0.0047065411, -0.0008596397, 0.0047708568, 0.0232978407, 0.0000000000, -0.1614013463, 0.7478516698, -0.0740769655, -0.0464562289, 0.0000000000, 0.0054914863, -0.0005356151, 0.0057131811, 0.0203715712, -0.0122310519, -0.1600013375, 0.7768620253, -0.0980933905, -0.0439039879, 0.0041435249, 0.0060938913, -0.0002451667, 0.0063002659, 0.0167804975, -0.0230523963, -0.1519452035, 0.7945935130, -0.1198658869, -0.0391003005, 0.0084537705, 0.0064595463 }; const LC3_FLOAT lp_filter_16[240] = { --0.0018676731, 0.0065408750, -0.0121405739, 0.0127360141, -0.0000000000, -0.0320970677, 0.0819641128, -0.1382038444, 0.1830149740, 0.8005587459, 0.1830149740, -0.1382038444, 0.0819641128, -0.0320970677, -0.0000000000, 0.0127360141, -0.0121405739, 0.0065408750, -0.0018676731, 0.0000000000, -0.0021904600, 0.0064595463, -0.0105420630, 0.0084537705, 0.0069732964, -0.0391003005, 0.0823974460, -0.1198658869, 0.1164389849, 0.7945935130, 0.2533447146, -0.1519452035, 0.0776687115, -0.0230523963, -0.0075258445, 0.0167804975, -0.0133052040, 0.0063002659, -0.0013903243, -0.0002451667, -0.0023626641, 0.0060938913, -0.0086209681, 0.0041435249, 0.0131276902, -0.0439039879, 0.0792422444, -0.0980933905, 0.0550325289, 0.7768620253, 0.3258404732, -0.1600013375, 0.0693885013, -0.0122310519, -0.0152910165, 0.0203715712, -0.0139361415, 0.0057131811, -0.0007630716, -0.0005356151, -0.0023957258, 0.0054914863, -0.0064938627, 0.0000000000, 0.0182522610, -0.0464562289, 0.0729012638, -0.0740769655, 0.0000000000, 0.7478516698, 0.3987891078, -0.1614013463, 0.0571681485, 0.0000000000, -0.0229468606, 0.0232978407, -0.0139512215, 0.0047708568, 0.0000000000, -0.0008596397, -0.0023070835, 0.0047065411, -0.0042766319, -0.0038048958, 0.0221970305, -0.0468063876, 0.0638811216, -0.0489920303, -0.0476967618, 0.7083564401, 0.4704038501, -0.1553338468, 0.0412303619, 0.0131809860, -0.0301232301, 0.0253629088, -0.0132916924, 0.0034824028, 0.0008750616, -0.0012012133, -0.0021185349, 0.0037965439, -0.0020790326, -0.0071282135, 0.0248753466, -0.0450960808, 0.0527642742, -0.0239577144, -0.0873604342, 0.6594504118, 0.5388799906, -0.1411849856, 0.0219798349, 0.0267735831, -0.0364444591, 0.0263961889, -0.0119272992, 0.0018761361, 0.0018287648, -0.0015404741, -0.0018545259, 0.0028190494, -0.0000000000, -0.0098603060, 0.0262632743, -0.0415467210, 0.0401797108, -0.0000000000, -0.1185704023, 0.6024519205, 0.6024519205, -0.1185704023, -0.0000000000, 0.0401797108, -0.0415467210, 0.0262632743, -0.0098603060, -0.0000000000, 0.0028190494, -0.0018545259, -0.0015404741, 0.0018287648, 0.0018761361, -0.0119272992, 0.0263961889, -0.0364444591, 0.0267735831, 0.0219798349, -0.1411849856, 0.5388799906, 0.6594504118, -0.0873604342, -0.0239577144, 0.0527642742, -0.0450960808, 0.0248753466, -0.0071282135, -0.0020790326, 0.0037965439, -0.0021185349, -0.0012012133, 0.0008750616, 0.0034824028, -0.0132916924, 0.0253629088, -0.0301232301, 0.0131809860, 0.0412303619, -0.1553338468, 0.4704038501, 0.7083564401, -0.0476967618, -0.0489920303, 0.0638811216, -0.0468063876, 0.0221970305, -0.0038048958, -0.0042766319, 0.0047065411, -0.0023070835, -0.0008596397, 0.0000000000, 0.0047708568, -0.0139512215, 0.0232978407, -0.0229468606, 0.0000000000, 0.0571681485, -0.1614013463, 0.3987891078, 0.7478516698, 0.0000000000, -0.0740769655, 0.0729012638, -0.0464562289, 0.0182522610, 0.0000000000, -0.0064938627, 0.0054914863, -0.0023957258, -0.0005356151, -0.0007630716, 0.0057131811, -0.0139361415, 0.0203715712, -0.0152910165, -0.0122310519, 0.0693885013, -0.1600013375, 0.3258404732, 0.7768620253, 0.0550325289, -0.0980933905, 0.0792422444, -0.0439039879, 0.0131276902, 0.0041435249, -0.0086209681, 0.0060938913, -0.0023626641, -0.0002451667, -0.0013903243, 0.0063002659, -0.0133052040, 0.0167804975, -0.0075258445, -0.0230523963, 0.0776687115, -0.1519452035, 0.2533447146, 0.7945935130, 0.1164389849, -0.1198658869, 0.0823974460, -0.0391003005, 0.0069732964, 0.0084537705, -0.0105420630, 0.0064595463, -0.0021904600 + -0.0018676731, 0.0065408750, -0.0121405739, 0.0127360141, -0.0000000000, -0.0320970677, 0.0819641128, -0.1382038444, 0.1830149740, 0.8005587459, 0.1830149740, -0.1382038444, 0.0819641128, -0.0320970677, -0.0000000000, 0.0127360141, -0.0121405739, 0.0065408750, -0.0018676731, 0.0000000000, -0.0021904600, 0.0064595463, -0.0105420630, 0.0084537705, 0.0069732964, -0.0391003005, 0.0823974460, -0.1198658869, 0.1164389849, 0.7945935130, 0.2533447146, -0.1519452035, 0.0776687115, -0.0230523963, -0.0075258445, 0.0167804975, -0.0133052040, 0.0063002659, -0.0013903243, -0.0002451667, -0.0023626641, 0.0060938913, -0.0086209681, 0.0041435249, 0.0131276902, -0.0439039879, 0.0792422444, -0.0980933905, 0.0550325289, 0.7768620253, 0.3258404732, -0.1600013375, 0.0693885013, -0.0122310519, -0.0152910165, 0.0203715712, -0.0139361415, 0.0057131811, -0.0007630716, -0.0005356151, -0.0023957258, 0.0054914863, -0.0064938627, 0.0000000000, 0.0182522610, -0.0464562289, 0.0729012638, -0.0740769655, 0.0000000000, 0.7478516698, 0.3987891078, -0.1614013463, 0.0571681485, 0.0000000000, -0.0229468606, 0.0232978407, -0.0139512215, 0.0047708568, 0.0000000000, -0.0008596397, -0.0023070835, 0.0047065411, -0.0042766319, -0.0038048958, 0.0221970305, -0.0468063876, 0.0638811216, -0.0489920303, -0.0476967618, 0.7083564401, 0.4704038501, -0.1553338468, 0.0412303619, 0.0131809860, -0.0301232301, 0.0253629088, -0.0132916924, 0.0034824028, 0.0008750616, -0.0012012133, -0.0021185349, 0.0037965439, -0.0020790326, -0.0071282135, 0.0248753466, -0.0450960808, 0.0527642742, -0.0239577144, -0.0873604342, 0.6594504118, 0.5388799906, -0.1411849856, 0.0219798349, 0.0267735831, -0.0364444591, 0.0263961889, -0.0119272992, 0.0018761361, 0.0018287648, -0.0015404741, -0.0018545259, 0.0028190494, -0.0000000000, -0.0098603060, 0.0262632743, -0.0415467210, 0.0401797108, -0.0000000000, -0.1185704023, 0.6024519205, 0.6024519205, -0.1185704023, -0.0000000000, 0.0401797108, -0.0415467210, 0.0262632743, -0.0098603060, -0.0000000000, 0.0028190494, -0.0018545259, -0.0015404741, 0.0018287648, 0.0018761361, -0.0119272992, 0.0263961889, -0.0364444591, 0.0267735831, 0.0219798349, -0.1411849856, 0.5388799906, 0.6594504118, -0.0873604342, -0.0239577144, 0.0527642742, -0.0450960808, 0.0248753466, -0.0071282135, -0.0020790326, 0.0037965439, -0.0021185349, -0.0012012133, 0.0008750616, 0.0034824028, -0.0132916924, 0.0253629088, -0.0301232301, 0.0131809860, 0.0412303619, -0.1553338468, 0.4704038501, 0.7083564401, -0.0476967618, -0.0489920303, 0.0638811216, -0.0468063876, 0.0221970305, -0.0038048958, -0.0042766319, 0.0047065411, -0.0023070835, -0.0008596397, 0.0000000000, 0.0047708568, -0.0139512215, 0.0232978407, -0.0229468606, 0.0000000000, 0.0571681485, -0.1614013463, 0.3987891078, 0.7478516698, 0.0000000000, -0.0740769655, 0.0729012638, -0.0464562289, 0.0182522610, 0.0000000000, -0.0064938627, 0.0054914863, -0.0023957258, -0.0005356151, -0.0007630716, 0.0057131811, -0.0139361415, 0.0203715712, -0.0152910165, -0.0122310519, 0.0693885013, -0.1600013375, 0.3258404732, 0.7768620253, 0.0550325289, -0.0980933905, 0.0792422444, -0.0439039879, 0.0131276902, 0.0041435249, -0.0086209681, 0.0060938913, -0.0023626641, -0.0002451667, -0.0013903243, 0.0063002659, -0.0133052040, 0.0167804975, -0.0075258445, -0.0230523963, 0.0776687115, -0.1519452035, 0.2533447146, 0.7945935130, 0.1164389849, -0.1198658869, 0.0823974460, -0.0391003005, 0.0069732964, 0.0084537705, -0.0105420630, 0.0064595463, -0.0021904600 }; const LC3_FLOAT lp_filter_24[240] = { --0.0015380557, 0.0005833744, 0.0043605831, -0.0028510878, -0.0088611282, 0.0084906761, 0.0147980200, -0.0200821534, -0.0213980451, 0.0425874144, 0.0274869073, -0.0921358988, -0.0317978412, 0.3136025667, 0.5337058306, 0.3136025667, -0.0317978412, -0.0921358988, 0.0274869073, 0.0425874144, -0.0213980451, -0.0200821534, 0.0147980200, 0.0084906761, -0.0088611282, -0.0028510878, 0.0043605831, 0.0005833744, -0.0015380557, 0.0000000000, -0.0014123565, 0.0000000000, 0.0043063643, -0.0013860217, -0.0093008140, 0.0056358469, 0.0165835638, -0.0152979074, -0.0260668676, 0.0351761840, 0.0381121002, -0.0799105912, -0.0582402907, 0.2658593953, 0.5297290087, 0.3592533171, 0.0000000000, -0.1012968048, 0.0146532226, 0.0486008413, -0.0153682642, -0.0242963061, 0.0121681746, 0.0111869983, -0.0079515325, -0.0043292418, 0.0042001773, 0.0012191766, -0.0015971506, -0.0001634445, -0.0012363506, -0.0005087144, 0.0040625944, -0.0000000000, -0.0092907613, 0.0027623500, 0.0175088495, -0.0101940110, -0.0292693246, 0.0267864745, 0.0462590009, -0.0653955936, -0.0790469348, 0.2172269821, 0.5179080367, 0.4016346335, 0.0366883539, -0.1066675633, -0.0000000000, 0.0528281629, -0.0081540346, -0.0276978146, 0.0087517938, 0.0135810468, -0.0065735374, -0.0057473122, 0.0038087873, 0.0018793662, -0.0015751094, -0.0003570767, -0.0010269828, -0.0009268829, 0.0036609909, 0.0012507574, -0.0088701360, 0.0000000000, 0.0175974593, -0.0050172298, -0.0309708193, 0.0178490561, 0.0517791398, -0.0493846424, -0.0941233262, 0.1688964665, 0.4985677898, 0.4396336079, 0.0776259899, -0.1076008976, -0.0159718096, 0.0549316332, 0.0000000000, -0.0300640538, 0.0046488643, 0.0155318938, -0.0047521424, -0.0070280419, 0.0031805711, 0.0025310293, -0.0014603067, -0.0005730931, -0.0008008089, -0.0012451154, 0.0031376940, 0.0023216018, -0.0080937156, -0.0025365972, 0.0169086065, -0.0000000000, -0.0312042590, 0.0087873237, 0.0546427406, -0.0326613523, -0.1035559028, 0.1220099851, 0.4722376168, 0.4722376168, 0.1220099851, -0.1035559028, -0.0326613523, 0.0546427406, 0.0087873237, -0.0312042590, -0.0000000000, 0.0169086065, -0.0025365972, -0.0080937156, 0.0023216018, 0.0031376940, -0.0012451154, -0.0008008089, -0.0005730931, -0.0014603067, 0.0025310293, 0.0031805711, -0.0070280419, -0.0047521424, 0.0155318938, 0.0046488643, -0.0300640538, 0.0000000000, 0.0549316332, -0.0159718096, -0.1076008976, 0.0776259899, 0.4396336079, 0.4985677898, 0.1688964665, -0.0941233262, -0.0493846424, 0.0517791398, 0.0178490561, -0.0309708193, -0.0050172298, 0.0175974593, 0.0000000000, -0.0088701360, 0.0012507574, 0.0036609909, -0.0009268829, -0.0010269828, -0.0003570767, -0.0015751094, 0.0018793662, 0.0038087873, -0.0057473122, -0.0065735374, 0.0135810468, 0.0087517938, -0.0276978146, -0.0081540346, 0.0528281629, -0.0000000000, -0.1066675633, 0.0366883539, 0.4016346335, 0.5179080367, 0.2172269821, -0.0790469348, -0.0653955936, 0.0462590009, 0.0267864745, -0.0292693246, -0.0101940110, 0.0175088495, 0.0027623500, -0.0092907613, -0.0000000000, 0.0040625944, -0.0005087144, -0.0012363506, -0.0001634445, -0.0015971506, 0.0012191766, 0.0042001773, -0.0043292418, -0.0079515325, 0.0111869983, 0.0121681746, -0.0242963061, -0.0153682642, 0.0486008413, 0.0146532226, -0.1012968048, 0.0000000000, 0.3592533171, 0.5297290087, 0.2658593953, -0.0582402907, -0.0799105912, 0.0381121002, 0.0351761840, -0.0260668676, -0.0152979074, 0.0165835638, 0.0056358469, -0.0093008140, -0.0013860217, 0.0043063643, 0.0000000000, -0.0014123565 + -0.0015380557, 0.0005833744, 0.0043605831, -0.0028510878, -0.0088611282, 0.0084906761, 0.0147980200, -0.0200821534, -0.0213980451, 0.0425874144, 0.0274869073, -0.0921358988, -0.0317978412, 0.3136025667, 0.5337058306, 0.3136025667, -0.0317978412, -0.0921358988, 0.0274869073, 0.0425874144, -0.0213980451, -0.0200821534, 0.0147980200, 0.0084906761, -0.0088611282, -0.0028510878, 0.0043605831, 0.0005833744, -0.0015380557, 0.0000000000, -0.0014123565, 0.0000000000, 0.0043063643, -0.0013860217, -0.0093008140, 0.0056358469, 0.0165835638, -0.0152979074, -0.0260668676, 0.0351761840, 0.0381121002, -0.0799105912, -0.0582402907, 0.2658593953, 0.5297290087, 0.3592533171, 0.0000000000, -0.1012968048, 0.0146532226, 0.0486008413, -0.0153682642, -0.0242963061, 0.0121681746, 0.0111869983, -0.0079515325, -0.0043292418, 0.0042001773, 0.0012191766, -0.0015971506, -0.0001634445, -0.0012363506, -0.0005087144, 0.0040625944, -0.0000000000, -0.0092907613, 0.0027623500, 0.0175088495, -0.0101940110, -0.0292693246, 0.0267864745, 0.0462590009, -0.0653955936, -0.0790469348, 0.2172269821, 0.5179080367, 0.4016346335, 0.0366883539, -0.1066675633, -0.0000000000, 0.0528281629, -0.0081540346, -0.0276978146, 0.0087517938, 0.0135810468, -0.0065735374, -0.0057473122, 0.0038087873, 0.0018793662, -0.0015751094, -0.0003570767, -0.0010269828, -0.0009268829, 0.0036609909, 0.0012507574, -0.0088701360, 0.0000000000, 0.0175974593, -0.0050172298, -0.0309708193, 0.0178490561, 0.0517791398, -0.0493846424, -0.0941233262, 0.1688964665, 0.4985677898, 0.4396336079, 0.0776259899, -0.1076008976, -0.0159718096, 0.0549316332, 0.0000000000, -0.0300640538, 0.0046488643, 0.0155318938, -0.0047521424, -0.0070280419, 0.0031805711, 0.0025310293, -0.0014603067, -0.0005730931, -0.0008008089, -0.0012451154, 0.0031376940, 0.0023216018, -0.0080937156, -0.0025365972, 0.0169086065, -0.0000000000, -0.0312042590, 0.0087873237, 0.0546427406, -0.0326613523, -0.1035559028, 0.1220099851, 0.4722376168, 0.4722376168, 0.1220099851, -0.1035559028, -0.0326613523, 0.0546427406, 0.0087873237, -0.0312042590, -0.0000000000, 0.0169086065, -0.0025365972, -0.0080937156, 0.0023216018, 0.0031376940, -0.0012451154, -0.0008008089, -0.0005730931, -0.0014603067, 0.0025310293, 0.0031805711, -0.0070280419, -0.0047521424, 0.0155318938, 0.0046488643, -0.0300640538, 0.0000000000, 0.0549316332, -0.0159718096, -0.1076008976, 0.0776259899, 0.4396336079, 0.4985677898, 0.1688964665, -0.0941233262, -0.0493846424, 0.0517791398, 0.0178490561, -0.0309708193, -0.0050172298, 0.0175974593, 0.0000000000, -0.0088701360, 0.0012507574, 0.0036609909, -0.0009268829, -0.0010269828, -0.0003570767, -0.0015751094, 0.0018793662, 0.0038087873, -0.0057473122, -0.0065735374, 0.0135810468, 0.0087517938, -0.0276978146, -0.0081540346, 0.0528281629, -0.0000000000, -0.1066675633, 0.0366883539, 0.4016346335, 0.5179080367, 0.2172269821, -0.0790469348, -0.0653955936, 0.0462590009, 0.0267864745, -0.0292693246, -0.0101940110, 0.0175088495, 0.0027623500, -0.0092907613, -0.0000000000, 0.0040625944, -0.0005087144, -0.0012363506, -0.0001634445, -0.0015971506, 0.0012191766, 0.0042001773, -0.0043292418, -0.0079515325, 0.0111869983, 0.0121681746, -0.0242963061, -0.0153682642, 0.0486008413, 0.0146532226, -0.1012968048, 0.0000000000, 0.3592533171, 0.5297290087, 0.2658593953, -0.0582402907, -0.0799105912, 0.0381121002, 0.0351761840, -0.0260668676, -0.0152979074, 0.0165835638, 0.0056358469, -0.0093008140, -0.0013860217, 0.0043063643, 0.0000000000, -0.0014123565 }; const LC3_FLOAT lp_filter_32[240] = { --0.0009272629, -0.0009338366, 0.0014095247, 0.0032704375, -0.0000000000, -0.0060702870, -0.0049301530, 0.0063680070, 0.0131316371, -0.0000000000, -0.0207733605, -0.0160485338, 0.0200898554, 0.0409820564, -0.0000000000, -0.0691019222, -0.0592852011, 0.0915074870, 0.3012259603, 0.4002793729, 0.3012259603, 0.0915074870, -0.0592852011, -0.0691019222, -0.0000000000, 0.0409820564, 0.0200898554, -0.0160485338, -0.0207733605, -0.0000000000, 0.0131316371, 0.0063680070, -0.0049301530, -0.0060702870, -0.0000000000, 0.0032704375, 0.0014095247, -0.0009338366, -0.0009272629, 0.0000000000, -0.0007702371, -0.0010952300, 0.0009143824, 0.0032297731, 0.0009380680, -0.0052710315, -0.0059636496, 0.0042268853, 0.0131980944, 0.0034866482, -0.0182222296, -0.0195501503, 0.0133867916, 0.0411987230, 0.0109899174, -0.0599329434, -0.0705924928, 0.0582194924, 0.2694399953, 0.3972967565, 0.3297252059, 0.1266723573, -0.0436802171, -0.0759726018, -0.0119788572, 0.0388343558, 0.0263821371, -0.0115261981, -0.0225480404, -0.0037629222, 0.0124376733, 0.0083902488, -0.0035641068, -0.0066526020, -0.0010395163, 0.0031501330, 0.0018982720, -0.0006951622, -0.0010592674, -0.0001225834, -0.0006006067, -0.0011813320, 0.0004375308, 0.0030469457, 0.0017412014, -0.0043104840, -0.0066458462, 0.0020717625, 0.0126814544, 0.0065638451, -0.0150616150, -0.0219519939, 0.0065904930, 0.0396211222, 0.0206151810, -0.0490466952, -0.0776669234, 0.0275162645, 0.2352019250, 0.3884310126, 0.3541782200, 0.1629202366, -0.0238483809, -0.0800006688, -0.0244960152, 0.0346942507, 0.0319405608, -0.0061155260, -0.0234031938, -0.0076455083, 0.0110985152, 0.0101857856, -0.0019024479, -0.0069680708, -0.0021383159, 0.0028565906, 0.0023532705, -0.0003815358, -0.0011535417, -0.0002678075, -0.0004298199, -0.0011978629, 0.0000000000, 0.0027457431, 0.0023854284, -0.0032469314, -0.0069756107, 0.0000000000, 0.0116489204, 0.0091261305, -0.0114734303, -0.0232281145, 0.0000000000, 0.0364506319, 0.0285840742, -0.0370384827, -0.0807006732, 0.0000000000, 0.1993945539, 0.3739258349, 0.3739258349, 0.1993945539, 0.0000000000, -0.0807006732, -0.0370384827, 0.0285840742, 0.0364506319, 0.0000000000, -0.0232281145, -0.0114734303, 0.0091261305, 0.0116489204, 0.0000000000, -0.0069756107, -0.0032469314, 0.0023854284, 0.0027457431, 0.0000000000, -0.0011978629, -0.0004298199, -0.0002678075, -0.0011535417, -0.0003815358, 0.0023532705, 0.0028565906, -0.0021383159, -0.0069680708, -0.0019024479, 0.0101857856, 0.0110985152, -0.0076455083, -0.0234031938, -0.0061155260, 0.0319405608, 0.0346942507, -0.0244960152, -0.0800006688, -0.0238483809, 0.1629202366, 0.3541782200, 0.3884310126, 0.2352019250, 0.0275162645, -0.0776669234, -0.0490466952, 0.0206151810, 0.0396211222, 0.0065904930, -0.0219519939, -0.0150616150, 0.0065638451, 0.0126814544, 0.0020717625, -0.0066458462, -0.0043104840, 0.0017412014, 0.0030469457, 0.0004375308, -0.0011813320, -0.0006006067, -0.0001225834, -0.0010592674, -0.0006951622, 0.0018982720, 0.0031501330, -0.0010395163, -0.0066526020, -0.0035641068, 0.0083902488, 0.0124376733, -0.0037629222, -0.0225480404, -0.0115261981, 0.0263821371, 0.0388343558, -0.0119788572, -0.0759726018, -0.0436802171, 0.1266723573, 0.3297252059, 0.3972967565, 0.2694399953, 0.0582194924, -0.0705924928, -0.0599329434, 0.0109899174, 0.0411987230, 0.0133867916, -0.0195501503, -0.0182222296, 0.0034866482, 0.0131980944, 0.0042268853, -0.0059636496, -0.0052710315, 0.0009380680, 0.0032297731, 0.0009143824, -0.0010952300, -0.0007702371 + -0.0009272629, -0.0009338366, 0.0014095247, 0.0032704375, -0.0000000000, -0.0060702870, -0.0049301530, 0.0063680070, 0.0131316371, -0.0000000000, -0.0207733605, -0.0160485338, 0.0200898554, 0.0409820564, -0.0000000000, -0.0691019222, -0.0592852011, 0.0915074870, 0.3012259603, 0.4002793729, 0.3012259603, 0.0915074870, -0.0592852011, -0.0691019222, -0.0000000000, 0.0409820564, 0.0200898554, -0.0160485338, -0.0207733605, -0.0000000000, 0.0131316371, 0.0063680070, -0.0049301530, -0.0060702870, -0.0000000000, 0.0032704375, 0.0014095247, -0.0009338366, -0.0009272629, 0.0000000000, -0.0007702371, -0.0010952300, 0.0009143824, 0.0032297731, 0.0009380680, -0.0052710315, -0.0059636496, 0.0042268853, 0.0131980944, 0.0034866482, -0.0182222296, -0.0195501503, 0.0133867916, 0.0411987230, 0.0109899174, -0.0599329434, -0.0705924928, 0.0582194924, 0.2694399953, 0.3972967565, 0.3297252059, 0.1266723573, -0.0436802171, -0.0759726018, -0.0119788572, 0.0388343558, 0.0263821371, -0.0115261981, -0.0225480404, -0.0037629222, 0.0124376733, 0.0083902488, -0.0035641068, -0.0066526020, -0.0010395163, 0.0031501330, 0.0018982720, -0.0006951622, -0.0010592674, -0.0001225834, -0.0006006067, -0.0011813320, 0.0004375308, 0.0030469457, 0.0017412014, -0.0043104840, -0.0066458462, 0.0020717625, 0.0126814544, 0.0065638451, -0.0150616150, -0.0219519939, 0.0065904930, 0.0396211222, 0.0206151810, -0.0490466952, -0.0776669234, 0.0275162645, 0.2352019250, 0.3884310126, 0.3541782200, 0.1629202366, -0.0238483809, -0.0800006688, -0.0244960152, 0.0346942507, 0.0319405608, -0.0061155260, -0.0234031938, -0.0076455083, 0.0110985152, 0.0101857856, -0.0019024479, -0.0069680708, -0.0021383159, 0.0028565906, 0.0023532705, -0.0003815358, -0.0011535417, -0.0002678075, -0.0004298199, -0.0011978629, 0.0000000000, 0.0027457431, 0.0023854284, -0.0032469314, -0.0069756107, 0.0000000000, 0.0116489204, 0.0091261305, -0.0114734303, -0.0232281145, 0.0000000000, 0.0364506319, 0.0285840742, -0.0370384827, -0.0807006732, 0.0000000000, 0.1993945539, 0.3739258349, 0.3739258349, 0.1993945539, 0.0000000000, -0.0807006732, -0.0370384827, 0.0285840742, 0.0364506319, 0.0000000000, -0.0232281145, -0.0114734303, 0.0091261305, 0.0116489204, 0.0000000000, -0.0069756107, -0.0032469314, 0.0023854284, 0.0027457431, 0.0000000000, -0.0011978629, -0.0004298199, -0.0002678075, -0.0011535417, -0.0003815358, 0.0023532705, 0.0028565906, -0.0021383159, -0.0069680708, -0.0019024479, 0.0101857856, 0.0110985152, -0.0076455083, -0.0234031938, -0.0061155260, 0.0319405608, 0.0346942507, -0.0244960152, -0.0800006688, -0.0238483809, 0.1629202366, 0.3541782200, 0.3884310126, 0.2352019250, 0.0275162645, -0.0776669234, -0.0490466952, 0.0206151810, 0.0396211222, 0.0065904930, -0.0219519939, -0.0150616150, 0.0065638451, 0.0126814544, 0.0020717625, -0.0066458462, -0.0043104840, 0.0017412014, 0.0030469457, 0.0004375308, -0.0011813320, -0.0006006067, -0.0001225834, -0.0010592674, -0.0006951622, 0.0018982720, 0.0031501330, -0.0010395163, -0.0066526020, -0.0035641068, 0.0083902488, 0.0124376733, -0.0037629222, -0.0225480404, -0.0115261981, 0.0263821371, 0.0388343558, -0.0119788572, -0.0759726018, -0.0436802171, 0.1266723573, 0.3297252059, 0.3972967565, 0.2694399953, 0.0582194924, -0.0705924928, -0.0599329434, 0.0109899174, 0.0411987230, 0.0133867916, -0.0195501503, -0.0182222296, 0.0034866482, 0.0131980944, 0.0042268853, -0.0059636496, -0.0052710315, 0.0009380680, 0.0032297731, 0.0009143824, -0.0010952300, -0.0007702371 }; const LC3_FLOAT lp_filter_48[240] = { --0.0004004044, -0.0007690279, -0.0006225577, 0.0002916872, 0.0015688470, 0.0021802916, 0.0011608009, -0.0014255439, -0.0040468578, -0.0044305641, -0.0012682986, 0.0042453380, 0.0084543033, 0.0073990100, -0.0000000000, -0.0100410767, -0.0156021295, -0.0106990226, 0.0043936619, 0.0212937072, 0.0273213703, 0.0137434537, -0.0163306762, -0.0460679494, -0.0517779514, -0.0158989206, 0.0610049926, 0.1568012834, 0.2361188084, 0.2668529153, 0.2361188084, 0.1568012834, 0.0610049926, -0.0158989206, -0.0517779514, -0.0460679494, -0.0163306762, 0.0137434537, 0.0273213703, 0.0212937072, 0.0043936619, -0.0106990226, -0.0156021295, -0.0100410767, -0.0000000000, 0.0073990100, 0.0084543033, 0.0042453380, -0.0012682986, -0.0044305641, -0.0040468578, -0.0014255439, 0.0011608009, 0.0021802916, 0.0015688470, 0.0002916872, -0.0006225577, -0.0007690279, -0.0004004044, 0.0000000000, -0.0002865466, -0.0007061783, -0.0007301533, 0.0000000000, 0.0012655146, 0.0021531822, 0.0015902856, -0.0006930109, -0.0035140209, -0.0046504070, -0.0023760712, 0.0028179234, 0.0077659469, 0.0082917819, 0.0023244321, -0.0076489537, -0.0150320269, -0.0130334338, 0.0000000000, 0.0175880920, 0.0274658166, 0.0190560501, -0.0079859048, -0.0399552956, -0.0538004488, -0.0291201454, 0.0388129950, 0.1329296976, 0.2198168039, 0.2648645043, 0.2492838949, 0.1796266586, 0.0844482332, 0.0000000000, -0.0470616631, -0.0506484024, -0.0246923212, 0.0073266113, 0.0258895699, 0.0243004207, 0.0089245280, -0.0076841321, -0.0154854096, -0.0121481530, -0.0025086149, 0.0060840873, 0.0087987296, 0.0055934992, 0.0000000000, -0.0039757662, -0.0044350680, -0.0021646209, 0.0006253787, 0.0021000886, 0.0018304954, 0.0006095883, -0.0004634415, -0.0007985753, -0.0005134914, -0.0000817222, -0.0001785384, -0.0006181753, -0.0007875547, -0.0002543572, 0.0009396831, 0.0020312972, 0.0019043937, -0.0000000000, -0.0028736561, -0.0046453807, -0.0032867687, 0.0013811750, 0.0067905234, 0.0087544248, 0.0043758969, -0.0050970055, -0.0138489073, -0.0146346623, -0.0040770173, 0.0133932373, 0.0264140815, 0.0231295004, -0.0000000000, -0.0326977968, -0.0533337817, -0.0395234674, 0.0183441769, 0.1086134911, 0.2008173168, 0.2589540184, 0.2589540184, 0.2008173168, 0.1086134911, 0.0183441769, -0.0395234674, -0.0533337817, -0.0326977968, -0.0000000000, 0.0231295004, 0.0264140815, 0.0133932373, -0.0040770173, -0.0146346623, -0.0138489073, -0.0050970055, 0.0043758969, 0.0087544248, 0.0067905234, 0.0013811750, -0.0032867687, -0.0046453807, -0.0028736561, -0.0000000000, 0.0019043937, 0.0020312972, 0.0009396831, -0.0002543572, -0.0007875547, -0.0006181753, -0.0001785384, -0.0000817222, -0.0005134914, -0.0007985753, -0.0004634415, 0.0006095883, 0.0018304954, 0.0021000886, 0.0006253787, -0.0021646209, -0.0044350680, -0.0039757662, 0.0000000000, 0.0055934992, 0.0087987296, 0.0060840873, -0.0025086149, -0.0121481530, -0.0154854096, -0.0076841321, 0.0089245280, 0.0243004207, 0.0258895699, 0.0073266113, -0.0246923212, -0.0506484024, -0.0470616631, 0.0000000000, 0.0844482332, 0.1796266586, 0.2492838949, 0.2648645043, 0.2198168039, 0.1329296976, 0.0388129950, -0.0291201454, -0.0538004488, -0.0399552956, -0.0079859048, 0.0190560501, 0.0274658166, 0.0175880920, 0.0000000000, -0.0130334338, -0.0150320269, -0.0076489537, 0.0023244321, 0.0082917819, 0.0077659469, 0.0028179234, -0.0023760712, -0.0046504070, -0.0035140209, -0.0006930109, 0.0015902856, 0.0021531822, 0.0012655146, 0.0000000000, -0.0007301533, -0.0007061783, -0.0002865466 + -0.0004004044, -0.0007690279, -0.0006225577, 0.0002916872, 0.0015688470, 0.0021802916, 0.0011608009, -0.0014255439, -0.0040468578, -0.0044305641, -0.0012682986, 0.0042453380, 0.0084543033, 0.0073990100, -0.0000000000, -0.0100410767, -0.0156021295, -0.0106990226, 0.0043936619, 0.0212937072, 0.0273213703, 0.0137434537, -0.0163306762, -0.0460679494, -0.0517779514, -0.0158989206, 0.0610049926, 0.1568012834, 0.2361188084, 0.2668529153, 0.2361188084, 0.1568012834, 0.0610049926, -0.0158989206, -0.0517779514, -0.0460679494, -0.0163306762, 0.0137434537, 0.0273213703, 0.0212937072, 0.0043936619, -0.0106990226, -0.0156021295, -0.0100410767, -0.0000000000, 0.0073990100, 0.0084543033, 0.0042453380, -0.0012682986, -0.0044305641, -0.0040468578, -0.0014255439, 0.0011608009, 0.0021802916, 0.0015688470, 0.0002916872, -0.0006225577, -0.0007690279, -0.0004004044, 0.0000000000, -0.0002865466, -0.0007061783, -0.0007301533, 0.0000000000, 0.0012655146, 0.0021531822, 0.0015902856, -0.0006930109, -0.0035140209, -0.0046504070, -0.0023760712, 0.0028179234, 0.0077659469, 0.0082917819, 0.0023244321, -0.0076489537, -0.0150320269, -0.0130334338, 0.0000000000, 0.0175880920, 0.0274658166, 0.0190560501, -0.0079859048, -0.0399552956, -0.0538004488, -0.0291201454, 0.0388129950, 0.1329296976, 0.2198168039, 0.2648645043, 0.2492838949, 0.1796266586, 0.0844482332, 0.0000000000, -0.0470616631, -0.0506484024, -0.0246923212, 0.0073266113, 0.0258895699, 0.0243004207, 0.0089245280, -0.0076841321, -0.0154854096, -0.0121481530, -0.0025086149, 0.0060840873, 0.0087987296, 0.0055934992, 0.0000000000, -0.0039757662, -0.0044350680, -0.0021646209, 0.0006253787, 0.0021000886, 0.0018304954, 0.0006095883, -0.0004634415, -0.0007985753, -0.0005134914, -0.0000817222, -0.0001785384, -0.0006181753, -0.0007875547, -0.0002543572, 0.0009396831, 0.0020312972, 0.0019043937, -0.0000000000, -0.0028736561, -0.0046453807, -0.0032867687, 0.0013811750, 0.0067905234, 0.0087544248, 0.0043758969, -0.0050970055, -0.0138489073, -0.0146346623, -0.0040770173, 0.0133932373, 0.0264140815, 0.0231295004, -0.0000000000, -0.0326977968, -0.0533337817, -0.0395234674, 0.0183441769, 0.1086134911, 0.2008173168, 0.2589540184, 0.2589540184, 0.2008173168, 0.1086134911, 0.0183441769, -0.0395234674, -0.0533337817, -0.0326977968, -0.0000000000, 0.0231295004, 0.0264140815, 0.0133932373, -0.0040770173, -0.0146346623, -0.0138489073, -0.0050970055, 0.0043758969, 0.0087544248, 0.0067905234, 0.0013811750, -0.0032867687, -0.0046453807, -0.0028736561, -0.0000000000, 0.0019043937, 0.0020312972, 0.0009396831, -0.0002543572, -0.0007875547, -0.0006181753, -0.0001785384, -0.0000817222, -0.0005134914, -0.0007985753, -0.0004634415, 0.0006095883, 0.0018304954, 0.0021000886, 0.0006253787, -0.0021646209, -0.0044350680, -0.0039757662, 0.0000000000, 0.0055934992, 0.0087987296, 0.0060840873, -0.0025086149, -0.0121481530, -0.0154854096, -0.0076841321, 0.0089245280, 0.0243004207, 0.0258895699, 0.0073266113, -0.0246923212, -0.0506484024, -0.0470616631, 0.0000000000, 0.0844482332, 0.1796266586, 0.2492838949, 0.2648645043, 0.2198168039, 0.1329296976, 0.0388129950, -0.0291201454, -0.0538004488, -0.0399552956, -0.0079859048, 0.0190560501, 0.0274658166, 0.0175880920, 0.0000000000, -0.0130334338, -0.0150320269, -0.0076489537, 0.0023244321, 0.0082917819, 0.0077659469, 0.0028179234, -0.0023760712, -0.0046504070, -0.0035140209, -0.0006930109, 0.0015902856, 0.0021531822, 0.0012655146, 0.0000000000, -0.0007301533, -0.0007061783, -0.0002865466 }; const LC3_FLOAT lp_filter_96[240] = { --0.0000892692, -0.0002002022, -0.0003090877, -0.0003845139, -0.0003937774, -0.0003112789, -0.0001271786, 0.0001458436, 0.0004698416, 0.0007844235, 0.0010156486, 0.0010901458, 0.0009521968, 0.0005804005, -0.0000000000, -0.0007127720, -0.0014368281, -0.0020234289, -0.0023226903, -0.0022152821, -0.0016433843, -0.0006341493, 0.0006905875, 0.0021226690, 0.0033952617, 0.0042271516, 0.0043772124, 0.0036995050, 0.0021879484, -0.0000000000, -0.0025485028, -0.0050205383, -0.0069244537, -0.0078010648, -0.0073173312, -0.0053495113, -0.0020385087, 0.0021968309, 0.0066966186, 0.0106468536, 0.0132070407, 0.0136606852, 0.0115647502, 0.0068717268, -0.0000000000, -0.0081653381, -0.0163488984, -0.0230339747, -0.0266668908, -0.0258889757, -0.0197617337, -0.0079494603, 0.0091720885, 0.0305024963, 0.0543067455, 0.0784006417, 0.1004086584, 0.1180594042, 0.1294770092, 0.1334264576, 0.1294770092, 0.1180594042, 0.1004086584, 0.0784006417, 0.0543067455, 0.0305024963, 0.0091720885, -0.0079494603, -0.0197617337, -0.0258889757, -0.0266668908, -0.0230339747, -0.0163488984, -0.0081653381, -0.0000000000, 0.0068717268, 0.0115647502, 0.0136606852, 0.0132070407, 0.0106468536, 0.0066966186, 0.0021968309, -0.0020385087, -0.0053495113, -0.0073173312, -0.0078010648, -0.0069244537, -0.0050205383, -0.0025485028, -0.0000000000, 0.0021879484, 0.0036995050, 0.0043772124, 0.0042271516, 0.0033952617, 0.0021226690, 0.0006905875, -0.0006341493, -0.0016433843, -0.0022152821, -0.0023226903, -0.0020234289, -0.0014368281, -0.0007127720, -0.0000000000, 0.0005804005, 0.0009521968, 0.0010901458, 0.0010156486, 0.0007844235, 0.0004698416, 0.0001458436, -0.0001271786, -0.0003112789, -0.0003937774, -0.0003845139, -0.0003090877, -0.0002002022, -0.0000892692, 0.0000000000, -0.0000408611, -0.0001432733, -0.0002567457, -0.0003530891, -0.0003992876, -0.0003650767, -0.0002317207, 0.0000000000, 0.0003047941, 0.0006327573, 0.0009152477, 0.0010765911, 0.0010500443, 0.0007951428, 0.0003126893, -0.0003465054, -0.0010823105, -0.0017570105, -0.0022175340, -0.0023252035, -0.0019878831, -0.0011880356, 0.0000000000, 0.0014089617, 0.0027967496, 0.0038829735, 0.0043993648, 0.0041458909, 0.0030420437, 0.0011622161, -0.0012543075, -0.0038244769, -0.0060740765, -0.0075160135, -0.0077427048, -0.0065167169, -0.0038420660, 0.0000000000, 0.0044622640, 0.0087940460, 0.0121502103, 0.0137329083, 0.0129447849, 0.0095280251, 0.0036633057, -0.0039929524, -0.0123461606, -0.0199776478, -0.0253242012, -0.0269002244, -0.0235308316, -0.0145600727, 0.0000000000, 0.0194064975, 0.0422241166, 0.0664648488, 0.0898133293, 0.1099084020, 0.1246419474, 0.1324322522, 0.1324322522, 0.1246419474, 0.1099084020, 0.0898133293, 0.0664648488, 0.0422241166, 0.0194064975, 0.0000000000, -0.0145600727, -0.0235308316, -0.0269002244, -0.0253242012, -0.0199776478, -0.0123461606, -0.0039929524, 0.0036633057, 0.0095280251, 0.0129447849, 0.0137329083, 0.0121502103, 0.0087940460, 0.0044622640, 0.0000000000, -0.0038420660, -0.0065167169, -0.0077427048, -0.0075160135, -0.0060740765, -0.0038244769, -0.0012543075, 0.0011622161, 0.0030420437, 0.0041458909, 0.0043993648, 0.0038829735, 0.0027967496, 0.0014089617, 0.0000000000, -0.0011880356, -0.0019878831, -0.0023252035, -0.0022175340, -0.0017570105, -0.0010823105, -0.0003465054, 0.0003126893, 0.0007951428, 0.0010500443, 0.0010765911, 0.0009152477, 0.0006327573, 0.0003047941, 0.0000000000, -0.0002317207, -0.0003650767, -0.0003992876, -0.0003530891, -0.0002567457, -0.0001432733, -0.0000408611 + -0.0000892692, -0.0002002022, -0.0003090877, -0.0003845139, -0.0003937774, -0.0003112789, -0.0001271786, 0.0001458436, 0.0004698416, 0.0007844235, 0.0010156486, 0.0010901458, 0.0009521968, 0.0005804005, -0.0000000000, -0.0007127720, -0.0014368281, -0.0020234289, -0.0023226903, -0.0022152821, -0.0016433843, -0.0006341493, 0.0006905875, 0.0021226690, 0.0033952617, 0.0042271516, 0.0043772124, 0.0036995050, 0.0021879484, -0.0000000000, -0.0025485028, -0.0050205383, -0.0069244537, -0.0078010648, -0.0073173312, -0.0053495113, -0.0020385087, 0.0021968309, 0.0066966186, 0.0106468536, 0.0132070407, 0.0136606852, 0.0115647502, 0.0068717268, -0.0000000000, -0.0081653381, -0.0163488984, -0.0230339747, -0.0266668908, -0.0258889757, -0.0197617337, -0.0079494603, 0.0091720885, 0.0305024963, 0.0543067455, 0.0784006417, 0.1004086584, 0.1180594042, 0.1294770092, 0.1334264576, 0.1294770092, 0.1180594042, 0.1004086584, 0.0784006417, 0.0543067455, 0.0305024963, 0.0091720885, -0.0079494603, -0.0197617337, -0.0258889757, -0.0266668908, -0.0230339747, -0.0163488984, -0.0081653381, -0.0000000000, 0.0068717268, 0.0115647502, 0.0136606852, 0.0132070407, 0.0106468536, 0.0066966186, 0.0021968309, -0.0020385087, -0.0053495113, -0.0073173312, -0.0078010648, -0.0069244537, -0.0050205383, -0.0025485028, -0.0000000000, 0.0021879484, 0.0036995050, 0.0043772124, 0.0042271516, 0.0033952617, 0.0021226690, 0.0006905875, -0.0006341493, -0.0016433843, -0.0022152821, -0.0023226903, -0.0020234289, -0.0014368281, -0.0007127720, -0.0000000000, 0.0005804005, 0.0009521968, 0.0010901458, 0.0010156486, 0.0007844235, 0.0004698416, 0.0001458436, -0.0001271786, -0.0003112789, -0.0003937774, -0.0003845139, -0.0003090877, -0.0002002022, -0.0000892692, 0.0000000000, -0.0000408611, -0.0001432733, -0.0002567457, -0.0003530891, -0.0003992876, -0.0003650767, -0.0002317207, 0.0000000000, 0.0003047941, 0.0006327573, 0.0009152477, 0.0010765911, 0.0010500443, 0.0007951428, 0.0003126893, -0.0003465054, -0.0010823105, -0.0017570105, -0.0022175340, -0.0023252035, -0.0019878831, -0.0011880356, 0.0000000000, 0.0014089617, 0.0027967496, 0.0038829735, 0.0043993648, 0.0041458909, 0.0030420437, 0.0011622161, -0.0012543075, -0.0038244769, -0.0060740765, -0.0075160135, -0.0077427048, -0.0065167169, -0.0038420660, 0.0000000000, 0.0044622640, 0.0087940460, 0.0121502103, 0.0137329083, 0.0129447849, 0.0095280251, 0.0036633057, -0.0039929524, -0.0123461606, -0.0199776478, -0.0253242012, -0.0269002244, -0.0235308316, -0.0145600727, 0.0000000000, 0.0194064975, 0.0422241166, 0.0664648488, 0.0898133293, 0.1099084020, 0.1246419474, 0.1324322522, 0.1324322522, 0.1246419474, 0.1099084020, 0.0898133293, 0.0664648488, 0.0422241166, 0.0194064975, 0.0000000000, -0.0145600727, -0.0235308316, -0.0269002244, -0.0253242012, -0.0199776478, -0.0123461606, -0.0039929524, 0.0036633057, 0.0095280251, 0.0129447849, 0.0137329083, 0.0121502103, 0.0087940460, 0.0044622640, 0.0000000000, -0.0038420660, -0.0065167169, -0.0077427048, -0.0075160135, -0.0060740765, -0.0038244769, -0.0012543075, 0.0011622161, 0.0030420437, 0.0041458909, 0.0043993648, 0.0038829735, 0.0027967496, 0.0014089617, 0.0000000000, -0.0011880356, -0.0019878831, -0.0023252035, -0.0022175340, -0.0017570105, -0.0010823105, -0.0003465054, 0.0003126893, 0.0007951428, 0.0010500443, 0.0010765911, 0.0009152477, 0.0006327573, 0.0003047941, 0.0000000000, -0.0002317207, -0.0003650767, -0.0003992876, -0.0003530891, -0.0002567457, -0.0001432733, -0.0000408611 }; -const LC3_FLOAT *lp_filter[] = {lp_filter_8, lp_filter_16, lp_filter_24, lp_filter_32, lp_filter_48, lp_filter_96}; +const LC3_FLOAT *lp_filter[] = { lp_filter_8, lp_filter_16, lp_filter_24, lp_filter_32, lp_filter_48, lp_filter_96 }; -const LC3_INT up_fac[6] = {24, 12, 8, 6, 4, 2}; +const LC3_INT up_fac[6] = { 24, 12, 8, 6, 4, 2 }; /* TNS */ const LC3_INT huff_bits_tns[8][17] = { - {20480, 15725, 12479, 10334, 8694, 7320, 6964, 6335, 5504, 5637, 6566, 6758, 8433, 11348, 15186, 20480, 20480}, - {20480, 20480, 20480, 20480, 12902, 9368, 7057, 5901, 5254, 5485, 5598, 6076, 7608, 10742, 15186, 20480, 20480}, - {20480, 20480, 20480, 20480, 13988, 9368, 6702, 4841, 4585, 4682, 5859, 7764, 12109, 20480, 20480, 20480, 20480}, - {20480, 20480, 20480, 20480, 18432, 13396, 8982, 4767, 3779, 3658, 6335, 9656, 13988, 20480, 20480, 20480, 20480}, - {20480, 20480, 20480, 20480, 20480, 14731, 9437, 4275, 3249, 3493, 8483, 13988, 17234, 20480, 20480, 20480, 20480}, - {20480, 20480, 20480, 20480, 20480, 20480, 12902, 4753, 3040, 2953, 9105, 15725, 20480, 20480, 20480, 20480, 20480}, - {20480, 20480, 20480, 20480, 20480, 20480, 12902, 3821, 3346, 3000, 12109, 20480, 20480, 20480, 20480, 20480, - 20480}, - {20480, 20480, 20480, 20480, 20480, 20480, 15725, 3658, 20480, 1201, 10854, 18432, 20480, 20480, 20480, 20480, - 20480}}; - -const LC3_INT order1_tns[8] = {17234, 13988, 11216, 8694, 6566, 4977, 3961, 3040}; -const LC3_INT order2_tns[8] = {12683, 9437, 6874, 5541, 5121, 5170, 5359, 5056}; - -const LC3_FLOAT lagw_tns[9] = {1, - 0.998028026020383, - 0.992135405511397, - 0.982391584470799, - 0.968910791191297, - 0.951849807369274, - 0.931404933402306, - 0.907808229996959, - 0.881323136669471}; + { 20480, 15725, 12479, 10334, 8694, 7320, 6964, 6335, 5504, 5637, 6566, 6758, 8433, 11348, 15186, 20480, 20480 }, + { 20480, 20480, 20480, 20480, 12902, 9368, 7057, 5901, 5254, 5485, 5598, 6076, 7608, 10742, 15186, 20480, 20480 }, + { 20480, 20480, 20480, 20480, 13988, 9368, 6702, 4841, 4585, 4682, 5859, 7764, 12109, 20480, 20480, 20480, 20480 }, + { 20480, 20480, 20480, 20480, 18432, 13396, 8982, 4767, 3779, 3658, 6335, 9656, 13988, 20480, 20480, 20480, 20480 }, + { 20480, 20480, 20480, 20480, 20480, 14731, 9437, 4275, 3249, 3493, 8483, 13988, 17234, 20480, 20480, 20480, 20480 }, + { 20480, 20480, 20480, 20480, 20480, 20480, 12902, 4753, 3040, 2953, 9105, 15725, 20480, 20480, 20480, 20480, 20480 }, + { 20480, 20480, 20480, 20480, 20480, 20480, 12902, 3821, 3346, 3000, 12109, 20480, 20480, 20480, 20480, 20480, + 20480 }, + { 20480, 20480, 20480, 20480, 20480, 20480, 15725, 3658, 20480, 1201, 10854, 18432, 20480, 20480, 20480, 20480, + 20480 } +}; + +const LC3_INT order1_tns[8] = { 17234, 13988, 11216, 8694, 6566, 4977, 3961, 3040 }; +const LC3_INT order2_tns[8] = { 12683, 9437, 6874, 5541, 5121, 5170, 5359, 5056 }; + +const LC3_FLOAT lagw_tns[9] = { 1, + 0.998028026020383, + 0.992135405511397, + 0.982391584470799, + 0.968910791191297, + 0.951849807369274, + 0.931404933402306, + 0.907808229996959, + 0.881323136669471 }; const LC3_FLOAT quants_pts_tns[17] = { -0.995727539062500, -0.961822509765625, -0.895172119140625, - -0.798004150390625, -0.673706054687500, -0.526428222656250, - -0.361236572265625, -0.183746337890625, 0.000000000000000, - 0.183746337890625, 0.361236572265625, 0.526428222656250, - 0.673706054687500, 0.798004150390625, 0.895172119140625, - 0.961822509765625, 0.995727539062500}; - -const LC3_FLOAT quants_thr_tns[18] = {-1, - -0.982973099683902, - -0.932472229404356, - -0.850217135729614, - -0.739008917220659, - -0.602634636379256, - -0.445738355776538, - -0.273662990072083, - -0.0922683594633020, - 0.0922683594633020, - 0.273662990072083, - 0.445738355776538, - 0.602634636379256, - 0.739008917220659, - 0.850217135729614, - 0.932472229404356, - 0.982973099683902, - 1}; + -0.798004150390625, -0.673706054687500, -0.526428222656250, + -0.361236572265625, -0.183746337890625, 0.000000000000000, + 0.183746337890625, 0.361236572265625, 0.526428222656250, + 0.673706054687500, 0.798004150390625, 0.895172119140625, + 0.961822509765625, 0.995727539062500 }; + +const LC3_FLOAT quants_thr_tns[18] = { -1, + -0.982973099683902, + -0.932472229404356, + -0.850217135729614, + -0.739008917220659, + -0.602634636379256, + -0.445738355776538, + -0.273662990072083, + -0.0922683594633020, + 0.0922683594633020, + 0.273662990072083, + 0.445738355776538, + 0.602634636379256, + 0.739008917220659, + 0.850217135729614, + 0.932472229404356, + 0.982973099683902, + 1 }; /* SNS */ -const LC3_FLOAT sns_vq_far_adj_gains_fl[8] = {1.05859375000000, 1.23706054687500, 1.43920898437500, 1.98950195312500, - 2.49877929687500, 3.13110351562500, 4.11816406250000, 4.85400390625000}; +const LC3_FLOAT sns_vq_far_adj_gains_fl[8] = { 1.05859375000000, 1.23706054687500, 1.43920898437500, 1.98950195312500, + 2.49877929687500, 3.13110351562500, 4.11816406250000, 4.85400390625000 }; -const LC3_FLOAT sns_vq_near_adj_gains_fl[4] = {1.73315429687500, 2.22949218750000, 2.74731445312500, 3.61523437500000}; +const LC3_FLOAT sns_vq_near_adj_gains_fl[4] = { 1.73315429687500, 2.22949218750000, 2.74731445312500, 3.61523437500000 }; -const LC3_FLOAT sns_vq_reg_lf_adj_gains_fl[4] = {1.52465820312500, 3.67260742187500, 4.36059570312500, - 5.13037109375000}; +const LC3_FLOAT sns_vq_reg_lf_adj_gains_fl[4] = { 1.52465820312500, 3.67260742187500, 4.36059570312500, + 5.13037109375000 }; -const LC3_FLOAT q_g_sns[6] = {2.17651367187500, 2.94287109375000, 1.52465820312500, - 3.67260742187500, 4.36059570312500, 5.13037109375000}; +const LC3_FLOAT q_g_sns[6] = { 2.17651367187500, 2.94287109375000, 1.52465820312500, + 3.67260742187500, 4.36059570312500, 5.13037109375000 }; -const LC3_FLOAT sns_vq_reg_adj_gains_fl[2] = {2.17651367187500, 2.94287109375000}; +const LC3_FLOAT sns_vq_reg_adj_gains_fl[2] = { 2.17651367187500, 2.94287109375000 }; /* First element in each row is multiplied with norm2 = 1 / sqrt(2) */ const LC3_FLOAT idct_lookup[M][M] = { - {0.707106781186547, 0.995184726672197, 0.980785280403230, 0.956940335732209, 0.923879532511287, 0.881921264348355, 0.831469612302545, 0.773010453362737, 0.707106781186548, 0.634393284163646, 0.555570233019602, 0.471396736825998, 0.382683432365090, 0.290284677254462, 0.195090322016128, 0.0980171403295608}, - {0.707106781186547, 0.956940335732209, 0.831469612302545, 0.634393284163646, 0.382683432365090, 0.0980171403295608, -0.195090322016128, -0.471396736825998, -0.707106781186548, -0.881921264348355, -0.980785280403230, -0.995184726672197, -0.923879532511287, -0.773010453362737, -0.555570233019602, -0.290284677254462}, - {0.707106781186547, 0.881921264348355, 0.555570233019602, 0.0980171403295608, -0.382683432365090, -0.773010453362737, -0.980785280403230, -0.956940335732209, -0.707106781186548, -0.290284677254462, 0.195090322016128, 0.634393284163646, 0.923879532511287, 0.995184726672197, 0.831469612302546, 0.471396736825998}, - {0.707106781186547, 0.773010453362737, 0.195090322016128, -0.471396736825998, -0.923879532511287, -0.956940335732209, -0.555570233019602, 0.0980171403295601, 0.707106781186547, 0.995184726672197, 0.831469612302546, 0.290284677254463, -0.382683432365090, -0.881921264348355, -0.980785280403231, -0.634393284163645}, - {0.707106781186547, 0.634393284163646, -0.195090322016128, -0.881921264348355, -0.923879532511287, -0.290284677254462, 0.555570233019602, 0.995184726672197, 0.707106781186548, -0.0980171403295600, -0.831469612302545, -0.956940335732209, -0.382683432365091, 0.471396736825997, 0.980785280403230, 0.773010453362738}, - {0.707106781186547, 0.471396736825998, -0.555570233019602, -0.995184726672197, -0.382683432365090, 0.634393284163645, 0.980785280403231, 0.290284677254463, -0.707106781186547, -0.956940335732209, -0.195090322016130, 0.773010453362736, 0.923879532511287, 0.0980171403295626, -0.831469612302544, -0.881921264348356}, - {0.707106781186547, 0.290284677254462, -0.831469612302545, -0.773010453362737, 0.382683432365090, 0.995184726672197, 0.195090322016128, -0.881921264348356, -0.707106781186547, 0.471396736825997, 0.980785280403230, 0.0980171403295591, -0.923879532511287, -0.634393284163646, 0.555570233019604, 0.956940335732208}, - {0.707106781186547, 0.0980171403295608, -0.980785280403230, -0.290284677254463, 0.923879532511287, 0.471396736825998, -0.831469612302544, -0.634393284163647, 0.707106781186547, 0.773010453362738, -0.555570233019602, -0.881921264348356, 0.382683432365086, 0.956940335732209, -0.195090322016125, -0.995184726672197}, - {0.707106781186547, -0.0980171403295607, -0.980785280403230, 0.290284677254463, 0.923879532511287, -0.471396736825998, -0.831469612302545, 0.634393284163646, 0.707106781186547, -0.773010453362737, -0.555570233019603, 0.881921264348356, 0.382683432365088, -0.956940335732209, -0.195090322016127, 0.995184726672197}, - {0.707106781186547, -0.290284677254462, -0.831469612302546, 0.773010453362737, 0.382683432365090, -0.995184726672197, 0.195090322016127, 0.881921264348356, -0.707106781186547, -0.471396736825998, 0.980785280403230, -0.0980171403295577, -0.923879532511288, 0.634393284163644, 0.555570233019606, -0.956940335732208}, - {0.707106781186547, -0.471396736825998, -0.555570233019602, 0.995184726672197, -0.382683432365090, -0.634393284163645, 0.980785280403230, -0.290284677254463, -0.707106781186547, 0.956940335732209, -0.195090322016129, -0.773010453362737, 0.923879532511287, -0.0980171403295610, -0.831469612302545, 0.881921264348355}, - {0.707106781186547, -0.634393284163645, -0.195090322016129, 0.881921264348355, -0.923879532511286, 0.290284677254461, 0.555570233019603, -0.995184726672197, 0.707106781186547, 0.0980171403295628, -0.831469612302547, 0.956940335732208, -0.382683432365089, -0.471396736825999, 0.980785280403231, -0.773010453362733}, - {0.707106781186547, -0.773010453362737, 0.195090322016128, 0.471396736825998, -0.923879532511287, 0.956940335732209, -0.555570233019602, -0.0980171403295592, 0.707106781186548, -0.995184726672197, 0.831469612302546, -0.290284677254462, -0.382683432365091, 0.881921264348355, -0.980785280403231, 0.634393284163644}, - {0.707106781186547, -0.881921264348355, 0.555570233019602, -0.0980171403295600, -0.382683432365091, 0.773010453362738, -0.980785280403231, 0.956940335732208, -0.707106781186546, 0.290284677254462, 0.195090322016130, -0.634393284163649, 0.923879532511288, -0.995184726672197, 0.831469612302542, -0.471396736825993}, - {0.707106781186547, -0.956940335732209, 0.831469612302545, -0.634393284163645, 0.382683432365090, -0.0980171403295615, -0.195090322016130, 0.471396736825998, -0.707106781186548, 0.881921264348355, -0.980785280403230, 0.995184726672197, -0.923879532511285, 0.773010453362735, -0.555570233019601, 0.290284677254462}, - {0.707106781186547, -0.995184726672197, 0.980785280403230, -0.956940335732209, 0.923879532511286, -0.881921264348355, 0.831469612302544, -0.773010453362736, 0.707106781186546, -0.634393284163644, 0.555570233019601, -0.471396736825994, 0.382683432365086, -0.290284677254458, 0.195090322016124, -0.0980171403295567} + { 0.707106781186547, 0.995184726672197, 0.980785280403230, 0.956940335732209, 0.923879532511287, 0.881921264348355, 0.831469612302545, 0.773010453362737, 0.707106781186548, 0.634393284163646, 0.555570233019602, 0.471396736825998, 0.382683432365090, 0.290284677254462, 0.195090322016128, 0.0980171403295608 }, + { 0.707106781186547, 0.956940335732209, 0.831469612302545, 0.634393284163646, 0.382683432365090, 0.0980171403295608, -0.195090322016128, -0.471396736825998, -0.707106781186548, -0.881921264348355, -0.980785280403230, -0.995184726672197, -0.923879532511287, -0.773010453362737, -0.555570233019602, -0.290284677254462 }, + { 0.707106781186547, 0.881921264348355, 0.555570233019602, 0.0980171403295608, -0.382683432365090, -0.773010453362737, -0.980785280403230, -0.956940335732209, -0.707106781186548, -0.290284677254462, 0.195090322016128, 0.634393284163646, 0.923879532511287, 0.995184726672197, 0.831469612302546, 0.471396736825998 }, + { 0.707106781186547, 0.773010453362737, 0.195090322016128, -0.471396736825998, -0.923879532511287, -0.956940335732209, -0.555570233019602, 0.0980171403295601, 0.707106781186547, 0.995184726672197, 0.831469612302546, 0.290284677254463, -0.382683432365090, -0.881921264348355, -0.980785280403231, -0.634393284163645 }, + { 0.707106781186547, 0.634393284163646, -0.195090322016128, -0.881921264348355, -0.923879532511287, -0.290284677254462, 0.555570233019602, 0.995184726672197, 0.707106781186548, -0.0980171403295600, -0.831469612302545, -0.956940335732209, -0.382683432365091, 0.471396736825997, 0.980785280403230, 0.773010453362738 }, + { 0.707106781186547, 0.471396736825998, -0.555570233019602, -0.995184726672197, -0.382683432365090, 0.634393284163645, 0.980785280403231, 0.290284677254463, -0.707106781186547, -0.956940335732209, -0.195090322016130, 0.773010453362736, 0.923879532511287, 0.0980171403295626, -0.831469612302544, -0.881921264348356 }, + { 0.707106781186547, 0.290284677254462, -0.831469612302545, -0.773010453362737, 0.382683432365090, 0.995184726672197, 0.195090322016128, -0.881921264348356, -0.707106781186547, 0.471396736825997, 0.980785280403230, 0.0980171403295591, -0.923879532511287, -0.634393284163646, 0.555570233019604, 0.956940335732208 }, + { 0.707106781186547, 0.0980171403295608, -0.980785280403230, -0.290284677254463, 0.923879532511287, 0.471396736825998, -0.831469612302544, -0.634393284163647, 0.707106781186547, 0.773010453362738, -0.555570233019602, -0.881921264348356, 0.382683432365086, 0.956940335732209, -0.195090322016125, -0.995184726672197 }, + { 0.707106781186547, -0.0980171403295607, -0.980785280403230, 0.290284677254463, 0.923879532511287, -0.471396736825998, -0.831469612302545, 0.634393284163646, 0.707106781186547, -0.773010453362737, -0.555570233019603, 0.881921264348356, 0.382683432365088, -0.956940335732209, -0.195090322016127, 0.995184726672197 }, + { 0.707106781186547, -0.290284677254462, -0.831469612302546, 0.773010453362737, 0.382683432365090, -0.995184726672197, 0.195090322016127, 0.881921264348356, -0.707106781186547, -0.471396736825998, 0.980785280403230, -0.0980171403295577, -0.923879532511288, 0.634393284163644, 0.555570233019606, -0.956940335732208 }, + { 0.707106781186547, -0.471396736825998, -0.555570233019602, 0.995184726672197, -0.382683432365090, -0.634393284163645, 0.980785280403230, -0.290284677254463, -0.707106781186547, 0.956940335732209, -0.195090322016129, -0.773010453362737, 0.923879532511287, -0.0980171403295610, -0.831469612302545, 0.881921264348355 }, + { 0.707106781186547, -0.634393284163645, -0.195090322016129, 0.881921264348355, -0.923879532511286, 0.290284677254461, 0.555570233019603, -0.995184726672197, 0.707106781186547, 0.0980171403295628, -0.831469612302547, 0.956940335732208, -0.382683432365089, -0.471396736825999, 0.980785280403231, -0.773010453362733 }, + { 0.707106781186547, -0.773010453362737, 0.195090322016128, 0.471396736825998, -0.923879532511287, 0.956940335732209, -0.555570233019602, -0.0980171403295592, 0.707106781186548, -0.995184726672197, 0.831469612302546, -0.290284677254462, -0.382683432365091, 0.881921264348355, -0.980785280403231, 0.634393284163644 }, + { 0.707106781186547, -0.881921264348355, 0.555570233019602, -0.0980171403295600, -0.382683432365091, 0.773010453362738, -0.980785280403231, 0.956940335732208, -0.707106781186546, 0.290284677254462, 0.195090322016130, -0.634393284163649, 0.923879532511288, -0.995184726672197, 0.831469612302542, -0.471396736825993 }, + { 0.707106781186547, -0.956940335732209, 0.831469612302545, -0.634393284163645, 0.382683432365090, -0.0980171403295615, -0.195090322016130, 0.471396736825998, -0.707106781186548, 0.881921264348355, -0.980785280403230, 0.995184726672197, -0.923879532511285, 0.773010453362735, -0.555570233019601, 0.290284677254462 }, + { 0.707106781186547, -0.995184726672197, 0.980785280403230, -0.956940335732209, 0.923879532511286, -0.881921264348355, 0.831469612302544, -0.773010453362736, 0.707106781186546, -0.634393284163644, 0.555570233019601, -0.471396736825994, 0.382683432365086, -0.290284677254458, 0.195090322016124, -0.0980171403295567 } }; const LC3_FLOAT sns_dec_gains[4][8] = { - {2.17651367187500, 2.94287109375000, 0, 0, 0, 0, 0, 0}, - {1.52465820312500, 3.67260742187500, 4.36059570312500, 5.13037109375000, 0, 0, 0, 0}, - {1.73315429687500, 2.22949218750000, 2.74731445312500, 3.61523437500000, 0, 0, 0, 0}, - {1.05859375000000, 1.23706054687500, 1.43920898437500, 1.98950195312500, 2.49877929687500, 3.13110351562500, - 4.11816406250000, 4.85400390625000}}; + { 2.17651367187500, 2.94287109375000, 0, 0, 0, 0, 0, 0 }, + { 1.52465820312500, 3.67260742187500, 4.36059570312500, 5.13037109375000, 0, 0, 0, 0 }, + { 1.73315429687500, 2.22949218750000, 2.74731445312500, 3.61523437500000, 0, 0, 0, 0 }, + { 1.05859375000000, 1.23706054687500, 1.43920898437500, 1.98950195312500, 2.49877929687500, 3.13110351562500, + 4.11816406250000, 4.85400390625000 } +}; /* Global Gain */ -const LC3_INT gg_p1[6] = {80, 230, 380, 530, 680, 830}; -const LC3_INT gg_p2[6] = {500, 1025, 1550, 2075, 2600, 3125}; -const LC3_INT gg_p3[6] = {850, 1700, 2550, 3400, 4250, 5100}; +const LC3_INT gg_p1[6] = { 80, 230, 380, 530, 680, 830 }; +const LC3_INT gg_p2[6] = { 500, 1025, 1550, 2075, 2600, 3125 }; +const LC3_INT gg_p3[6] = { 850, 1700, 2550, 3400, 4250, 5100 }; -const LC3_FLOAT gg_c[6] = {0.00575396825396825, 0.00500524109014675, 0.00473646723646723, - 0.00459816612729234, 0.00451388888888889, 0.004457153231663}; -const LC3_FLOAT gg_d[6] = {1310.34482758621, 3241.36125654450, 5267.66917293233, - 7326.39296187684, 9400.00000000000, 11481.67006109979}; +const LC3_FLOAT gg_c[6] = { 0.00575396825396825, 0.00500524109014675, 0.00473646723646723, + 0.00459816612729234, 0.00451388888888889, 0.004457153231663 }; +const LC3_FLOAT gg_d[6] = { 1310.34482758621, 3241.36125654450, 5267.66917293233, + 7326.39296187684, 9400.00000000000, 11481.67006109979 }; /* Olpa */ -const LC3_FLOAT olpa_down2[5] = {0.1236796411180537, 0.2353512128364889, 0.2819382920909148, 0.2353512128364889, - 0.1236796411180537}; - -const LC3_FLOAT olpa_acw[98] = {1.0, - 0.994845360824742, - 0.989690721649485, - 0.984536082474227, - 0.979381443298969, - 0.974226804123711, - 0.969072164948454, - 0.963917525773196, - 0.958762886597938, - 0.953608247422680, - 0.948453608247423, - 0.943298969072165, - 0.938144329896907, - 0.932989690721650, - 0.927835051546392, - 0.922680412371134, - 0.917525773195876, - 0.912371134020619, - 0.907216494845361, - 0.902061855670103, - 0.896907216494845, - 0.891752577319588, - 0.886597938144330, - 0.881443298969072, - 0.876288659793814, - 0.871134020618557, - 0.865979381443299, - 0.860824742268041, - 0.855670103092784, - 0.850515463917526, - 0.845360824742268, - 0.840206185567010, - 0.835051546391753, - 0.829896907216495, - 0.824742268041237, - 0.819587628865979, - 0.814432989690722, - 0.809278350515464, - 0.804123711340206, - 0.798969072164949, - 0.793814432989691, - 0.788659793814433, - 0.783505154639175, - 0.778350515463918, - 0.773195876288660, - 0.768041237113402, - 0.762886597938144, - 0.757731958762887, - 0.752577319587629, - 0.747422680412371, - 0.742268041237113, - 0.737113402061856, - 0.731958762886598, - 0.726804123711340, - 0.721649484536083, - 0.716494845360825, - 0.711340206185567, - 0.706185567010309, - 0.701030927835052, - 0.695876288659794, - 0.690721649484536, - 0.685567010309278, - 0.680412371134021, - 0.675257731958763, - 0.670103092783505, - 0.664948453608247, - 0.659793814432990, - 0.654639175257732, - 0.649484536082474, - 0.644329896907216, - 0.639175257731959, - 0.634020618556701, - 0.628865979381443, - 0.623711340206186, - 0.618556701030928, - 0.613402061855670, - 0.608247422680412, - 0.603092783505155, - 0.597938144329897, - 0.592783505154639, - 0.587628865979382, - 0.582474226804124, - 0.577319587628866, - 0.572164948453608, - 0.567010309278351, - 0.561855670103093, - 0.556701030927835, - 0.551546391752577, - 0.546391752577320, - 0.541237113402062, - 0.536082474226804, - 0.530927835051546, - 0.525773195876289, - 0.520618556701031, - 0.515463917525773, - 0.510309278350515, - 0.505154639175258, - 0.500000000000000}; +const LC3_FLOAT olpa_down2[5] = { 0.1236796411180537, 0.2353512128364889, 0.2819382920909148, 0.2353512128364889, + 0.1236796411180537 }; + +const LC3_FLOAT olpa_acw[98] = { 1.0, + 0.994845360824742, + 0.989690721649485, + 0.984536082474227, + 0.979381443298969, + 0.974226804123711, + 0.969072164948454, + 0.963917525773196, + 0.958762886597938, + 0.953608247422680, + 0.948453608247423, + 0.943298969072165, + 0.938144329896907, + 0.932989690721650, + 0.927835051546392, + 0.922680412371134, + 0.917525773195876, + 0.912371134020619, + 0.907216494845361, + 0.902061855670103, + 0.896907216494845, + 0.891752577319588, + 0.886597938144330, + 0.881443298969072, + 0.876288659793814, + 0.871134020618557, + 0.865979381443299, + 0.860824742268041, + 0.855670103092784, + 0.850515463917526, + 0.845360824742268, + 0.840206185567010, + 0.835051546391753, + 0.829896907216495, + 0.824742268041237, + 0.819587628865979, + 0.814432989690722, + 0.809278350515464, + 0.804123711340206, + 0.798969072164949, + 0.793814432989691, + 0.788659793814433, + 0.783505154639175, + 0.778350515463918, + 0.773195876288660, + 0.768041237113402, + 0.762886597938144, + 0.757731958762887, + 0.752577319587629, + 0.747422680412371, + 0.742268041237113, + 0.737113402061856, + 0.731958762886598, + 0.726804123711340, + 0.721649484536083, + 0.716494845360825, + 0.711340206185567, + 0.706185567010309, + 0.701030927835052, + 0.695876288659794, + 0.690721649484536, + 0.685567010309278, + 0.680412371134021, + 0.675257731958763, + 0.670103092783505, + 0.664948453608247, + 0.659793814432990, + 0.654639175257732, + 0.649484536082474, + 0.644329896907216, + 0.639175257731959, + 0.634020618556701, + 0.628865979381443, + 0.623711340206186, + 0.618556701030928, + 0.613402061855670, + 0.608247422680412, + 0.603092783505155, + 0.597938144329897, + 0.592783505154639, + 0.587628865979382, + 0.582474226804124, + 0.577319587628866, + 0.572164948453608, + 0.567010309278351, + 0.561855670103093, + 0.556701030927835, + 0.551546391752577, + 0.546391752577320, + 0.541237113402062, + 0.536082474226804, + 0.530927835051546, + 0.525773195876289, + 0.520618556701031, + 0.515463917525773, + 0.510309278350515, + 0.505154639175258, + 0.500000000000000 }; /* LTPF */ -const LC3_FLOAT conf_tilt_filter_16[4][3] = {{6.023618207009578e-01, 4.197609261363617e-01, -1.883424527883687e-02}, - {5.994768582584314e-01, 4.197609261363620e-01, -1.594928283631041e-02}, - {5.967764663733787e-01, 4.197609261363617e-01, -1.324889095125780e-02}, - {5.942410120098895e-01, 4.197609261363618e-01, -1.071343658776831e-02}}; - -const LC3_FLOAT conf_tilt_filter_24[4][5] = {{3.989695588963494e-01, 5.142508607708275e-01, 1.004382966157454e-01, - -1.278893956818042e-02, -1.572280075461383e-03}, - {3.948634911286333e-01, 5.123819208048688e-01, 1.043194926386267e-01, - -1.091999960222166e-02, -1.347408330627317e-03}, - {3.909844475885914e-01, 5.106053522688359e-01, 1.079832524685944e-01, - -9.143431066188848e-03, -1.132124620551895e-03}, - {3.873093888199928e-01, 5.089122083363975e-01, 1.114517380217371e-01, - -7.450287133750717e-03, -9.255514050963111e-04}}; +const LC3_FLOAT conf_tilt_filter_16[4][3] = { { 6.023618207009578e-01, 4.197609261363617e-01, -1.883424527883687e-02 }, + { 5.994768582584314e-01, 4.197609261363620e-01, -1.594928283631041e-02 }, + { 5.967764663733787e-01, 4.197609261363617e-01, -1.324889095125780e-02 }, + { 5.942410120098895e-01, 4.197609261363618e-01, -1.071343658776831e-02 } }; + +const LC3_FLOAT conf_tilt_filter_24[4][5] = { { 3.989695588963494e-01, 5.142508607708275e-01, 1.004382966157454e-01, + -1.278893956818042e-02, -1.572280075461383e-03 }, + { 3.948634911286333e-01, 5.123819208048688e-01, 1.043194926386267e-01, + -1.091999960222166e-02, -1.347408330627317e-03 }, + { 3.909844475885914e-01, 5.106053522688359e-01, 1.079832524685944e-01, + -9.143431066188848e-03, -1.132124620551895e-03 }, + { 3.873093888199928e-01, 5.089122083363975e-01, 1.114517380217371e-01, + -7.450287133750717e-03, -9.255514050963111e-04 } }; const LC3_FLOAT conf_tilt_filter_32[4][7] = { - {2.982379446702096e-01, 4.652809203721290e-01, 2.105997428614279e-01, 3.766780380806063e-02, -1.015696155796564e-02, - -2.535880996101096e-03, -3.182946168719958e-04}, - {2.943834154510240e-01, 4.619294002718798e-01, 2.129465770091844e-01, 4.066175002688857e-02, -8.693272297010050e-03, - -2.178307114679820e-03, -2.742888063983188e-04}, - {2.907439213122688e-01, 4.587461910960279e-01, 2.151456974108970e-01, 4.350104772529774e-02, -7.295495347716925e-03, - -1.834395637237086e-03, -2.316920186482416e-04}, - {2.872975852589158e-01, 4.557148886861379e-01, 2.172126950911401e-01, 4.620088878229615e-02, -5.957463802125952e-03, - -1.502934284345198e-03, -1.903851911308866e-04}}; + { 2.982379446702096e-01, 4.652809203721290e-01, 2.105997428614279e-01, 3.766780380806063e-02, -1.015696155796564e-02, + -2.535880996101096e-03, -3.182946168719958e-04 }, + { 2.943834154510240e-01, 4.619294002718798e-01, 2.129465770091844e-01, 4.066175002688857e-02, -8.693272297010050e-03, + -2.178307114679820e-03, -2.742888063983188e-04 }, + { 2.907439213122688e-01, 4.587461910960279e-01, 2.151456974108970e-01, 4.350104772529774e-02, -7.295495347716925e-03, + -1.834395637237086e-03, -2.316920186482416e-04 }, + { 2.872975852589158e-01, 4.557148886861379e-01, 2.172126950911401e-01, 4.620088878229615e-02, -5.957463802125952e-03, + -1.502934284345198e-03, -1.903851911308866e-04 } +}; const LC3_FLOAT conf_tilt_filter_48[4][11] = { - {1.981363739883217e-01, 3.524494903964904e-01, 2.513695269649414e-01, 1.424146237314458e-01, 5.704731023952599e-02, - 9.293366241586384e-03, -7.226025368953745e-03, -3.172679890356356e-03, -1.121835963567014e-03, - -2.902957238400140e-04, -4.270815593769240e-05}, - {1.950709426598375e-01, 3.484660408341632e-01, 2.509988459466574e-01, 1.441167412482088e-01, 5.928947317677285e-02, - 1.108923827452231e-02, -6.192908108653504e-03, -2.726705509251737e-03, -9.667125826217151e-04, - -2.508100923165204e-04, -3.699938766131869e-05}, - {1.921810055196015e-01, 3.446945561091513e-01, 2.506220094626024e-01, 1.457102447664837e-01, 6.141132133664525e-02, - 1.279941396562798e-02, -5.203721087886321e-03, -2.297324511109085e-03, -8.165608133217555e-04, - -2.123855748277408e-04, -3.141271330981649e-05}, - {1.894485314175868e-01, 3.411139251108252e-01, 2.502406876894361e-01, 1.472065631098081e-01, 6.342477229539051e-02, - 1.443203434150312e-02, -4.254449144657098e-03, -1.883081472613493e-03, -6.709619060722140e-04, - -1.749363341966872e-04, -2.593864735284285e-05}}; + { 1.981363739883217e-01, 3.524494903964904e-01, 2.513695269649414e-01, 1.424146237314458e-01, 5.704731023952599e-02, + 9.293366241586384e-03, -7.226025368953745e-03, -3.172679890356356e-03, -1.121835963567014e-03, + -2.902957238400140e-04, -4.270815593769240e-05 }, + { 1.950709426598375e-01, 3.484660408341632e-01, 2.509988459466574e-01, 1.441167412482088e-01, 5.928947317677285e-02, + 1.108923827452231e-02, -6.192908108653504e-03, -2.726705509251737e-03, -9.667125826217151e-04, + -2.508100923165204e-04, -3.699938766131869e-05 }, + { 1.921810055196015e-01, 3.446945561091513e-01, 2.506220094626024e-01, 1.457102447664837e-01, 6.141132133664525e-02, + 1.279941396562798e-02, -5.203721087886321e-03, -2.297324511109085e-03, -8.165608133217555e-04, + -2.123855748277408e-04, -3.141271330981649e-05 }, + { 1.894485314175868e-01, 3.411139251108252e-01, 2.502406876894361e-01, 1.472065631098081e-01, 6.342477229539051e-02, + 1.443203434150312e-02, -4.254449144657098e-03, -1.883081472613493e-03, -6.709619060722140e-04, + -1.749363341966872e-04, -2.593864735284285e-05 } +}; const LC3_FLOAT conf_inter_filter_16[4][4] = { - {2.098804630681809e-01, 5.835275754221211e-01, 2.098804630681809e-01, 0.000000000000000e+00}, - {1.069991860896389e-01, 5.500750019177116e-01, 3.356906254147840e-01, 6.698858366939680e-03}, - {3.967114782344967e-02, 4.592209296082350e-01, 4.592209296082350e-01, 3.967114782344967e-02}, - {6.698858366939680e-03, 3.356906254147840e-01, 5.500750019177116e-01, 1.069991860896389e-01}}; - -const LC3_FLOAT conf_inter_filter_24[4][6] = {{6.322231627323796e-02, 2.507309606013235e-01, 3.713909428901578e-01, - 2.507309606013235e-01, 6.322231627323796e-02, 0.000000000000000e+00}, - {3.459272174099855e-02, 1.986515602645028e-01, 3.626411726581452e-01, - 2.986750548992179e-01, 1.013092873505928e-01, 4.263543712369752e-03}, - {1.535746784963907e-02, 1.474344878058222e-01, 3.374259553990717e-01, - 3.374259553990717e-01, 1.474344878058222e-01, 1.535746784963907e-02}, - {4.263543712369752e-03, 1.013092873505928e-01, 2.986750548992179e-01, - 3.626411726581452e-01, 1.986515602645028e-01, 3.459272174099855e-02}}; + { 2.098804630681809e-01, 5.835275754221211e-01, 2.098804630681809e-01, 0.000000000000000e+00 }, + { 1.069991860896389e-01, 5.500750019177116e-01, 3.356906254147840e-01, 6.698858366939680e-03 }, + { 3.967114782344967e-02, 4.592209296082350e-01, 4.592209296082350e-01, 3.967114782344967e-02 }, + { 6.698858366939680e-03, 3.356906254147840e-01, 5.500750019177116e-01, 1.069991860896389e-01 } +}; + +const LC3_FLOAT conf_inter_filter_24[4][6] = { { 6.322231627323796e-02, 2.507309606013235e-01, 3.713909428901578e-01, + 2.507309606013235e-01, 6.322231627323796e-02, 0.000000000000000e+00 }, + { 3.459272174099855e-02, 1.986515602645028e-01, 3.626411726581452e-01, + 2.986750548992179e-01, 1.013092873505928e-01, 4.263543712369752e-03 }, + { 1.535746784963907e-02, 1.474344878058222e-01, 3.374259553990717e-01, + 3.374259553990717e-01, 1.474344878058222e-01, 1.535746784963907e-02 }, + { 4.263543712369752e-03, 1.013092873505928e-01, 2.986750548992179e-01, + 3.626411726581452e-01, 1.986515602645028e-01, 3.459272174099855e-02 } }; const LC3_FLOAT conf_inter_filter_32[4][8] = { - {2.900401878228730e-02, 1.129857420560927e-01, 2.212024028097570e-01, 2.723909472446145e-01, 2.212024028097570e-01, - 1.129857420560927e-01, 2.900401878228730e-02, 0.000000000000000e+00}, - {1.703153418385261e-02, 8.722503785537784e-02, 1.961407762232199e-01, 2.689237982237257e-01, 2.424999102756389e-01, - 1.405773364650031e-01, 4.474877169485788e-02, 3.127030243100724e-03}, - {8.563673748488349e-03, 6.426222944493845e-02, 1.687676705918012e-01, 2.587445937795505e-01, 2.587445937795505e-01, - 1.687676705918012e-01, 6.426222944493845e-02, 8.563673748488349e-03}, - {3.127030243100724e-03, 4.474877169485788e-02, 1.405773364650031e-01, 2.424999102756389e-01, 2.689237982237257e-01, - 1.961407762232199e-01, 8.722503785537784e-02, 1.703153418385261e-02}}; + { 2.900401878228730e-02, 1.129857420560927e-01, 2.212024028097570e-01, 2.723909472446145e-01, 2.212024028097570e-01, + 1.129857420560927e-01, 2.900401878228730e-02, 0.000000000000000e+00 }, + { 1.703153418385261e-02, 8.722503785537784e-02, 1.961407762232199e-01, 2.689237982237257e-01, 2.424999102756389e-01, + 1.405773364650031e-01, 4.474877169485788e-02, 3.127030243100724e-03 }, + { 8.563673748488349e-03, 6.426222944493845e-02, 1.687676705918012e-01, 2.587445937795505e-01, 2.587445937795505e-01, + 1.687676705918012e-01, 6.426222944493845e-02, 8.563673748488349e-03 }, + { 3.127030243100724e-03, 4.474877169485788e-02, 1.405773364650031e-01, 2.424999102756389e-01, 2.689237982237257e-01, + 1.961407762232199e-01, 8.722503785537784e-02, 1.703153418385261e-02 } +}; const LC3_FLOAT conf_inter_filter_48[4][12] = { - {1.082359386659387e-02, 3.608969221303979e-02, 7.676401468099964e-02, 1.241530577501703e-01, 1.627596438300696e-01, - 1.776771417779109e-01, 1.627596438300696e-01, 1.241530577501703e-01, 7.676401468099964e-02, 3.608969221303979e-02, - 1.082359386659387e-02, 0.000000000000000e+00}, - {7.041404930459358e-03, 2.819702319820420e-02, 6.547044935127551e-02, 1.124647986743299e-01, 1.548418956489015e-01, - 1.767122381341857e-01, 1.691507213057663e-01, 1.352901577989766e-01, 8.851425011427483e-02, 4.499353848562444e-02, - 1.557613714732002e-02, 2.039721956502016e-03}, - {4.146998467444788e-03, 2.135757310741917e-02, 5.482735584552816e-02, 1.004971444643720e-01, 1.456060342830002e-01, - 1.738439838565869e-01, 1.738439838565869e-01, 1.456060342830002e-01, 1.004971444643720e-01, 5.482735584552816e-02, - 2.135757310741917e-02, 4.146998467444788e-03}, - {2.039721956502016e-03, 1.557613714732002e-02, 4.499353848562444e-02, 8.851425011427483e-02, 1.352901577989766e-01, - 1.691507213057663e-01, 1.767122381341857e-01, 1.548418956489015e-01, 1.124647986743299e-01, 6.547044935127551e-02, - 2.819702319820420e-02, 7.041404930459358e-03}}; - -const LC3_FLOAT inter4_1[33] = {0, - -2.874561161519444e-03, - -3.001251025861499e-03, - +2.745471654059321e-03, - +1.535727698935322e-02, - +2.868234046665657e-02, - +2.950385026557377e-02, - +4.598334491135473e-03, - -4.729632459043440e-02, - -1.058359163062837e-01, - -1.303050213607112e-01, - -7.544046357555201e-02, - +8.357885725250529e-02, - +3.301825710764459e-01, - +6.032970076366158e-01, - +8.174886856243178e-01, - +8.986382851273982e-01, - +8.174886856243178e-01, - +6.032970076366158e-01, - +3.301825710764459e-01, - +8.357885725250529e-02, - -7.544046357555201e-02, - -1.303050213607112e-01, - -1.058359163062837e-01, - -4.729632459043440e-02, - +4.598334491135473e-03, - +2.950385026557377e-02, - +2.868234046665657e-02, - +1.535727698935322e-02, - +2.745471654059321e-03, - -3.001251025861499e-03, - -2.874561161519444e-03, - 0}; + { 1.082359386659387e-02, 3.608969221303979e-02, 7.676401468099964e-02, 1.241530577501703e-01, 1.627596438300696e-01, + 1.776771417779109e-01, 1.627596438300696e-01, 1.241530577501703e-01, 7.676401468099964e-02, 3.608969221303979e-02, + 1.082359386659387e-02, 0.000000000000000e+00 }, + { 7.041404930459358e-03, 2.819702319820420e-02, 6.547044935127551e-02, 1.124647986743299e-01, 1.548418956489015e-01, + 1.767122381341857e-01, 1.691507213057663e-01, 1.352901577989766e-01, 8.851425011427483e-02, 4.499353848562444e-02, + 1.557613714732002e-02, 2.039721956502016e-03 }, + { 4.146998467444788e-03, 2.135757310741917e-02, 5.482735584552816e-02, 1.004971444643720e-01, 1.456060342830002e-01, + 1.738439838565869e-01, 1.738439838565869e-01, 1.456060342830002e-01, 1.004971444643720e-01, 5.482735584552816e-02, + 2.135757310741917e-02, 4.146998467444788e-03 }, + { 2.039721956502016e-03, 1.557613714732002e-02, 4.499353848562444e-02, 8.851425011427483e-02, 1.352901577989766e-01, + 1.691507213057663e-01, 1.767122381341857e-01, 1.548418956489015e-01, 1.124647986743299e-01, 6.547044935127551e-02, + 2.819702319820420e-02, 7.041404930459358e-03 } +}; + +const LC3_FLOAT inter4_1[33] = { 0, + -2.874561161519444e-03, + -3.001251025861499e-03, + +2.745471654059321e-03, + +1.535727698935322e-02, + +2.868234046665657e-02, + +2.950385026557377e-02, + +4.598334491135473e-03, + -4.729632459043440e-02, + -1.058359163062837e-01, + -1.303050213607112e-01, + -7.544046357555201e-02, + +8.357885725250529e-02, + +3.301825710764459e-01, + +6.032970076366158e-01, + +8.174886856243178e-01, + +8.986382851273982e-01, + +8.174886856243178e-01, + +6.032970076366158e-01, + +3.301825710764459e-01, + +8.357885725250529e-02, + -7.544046357555201e-02, + -1.303050213607112e-01, + -1.058359163062837e-01, + -4.729632459043440e-02, + +4.598334491135473e-03, + +2.950385026557377e-02, + +2.868234046665657e-02, + +1.535727698935322e-02, + +2.745471654059321e-03, + -3.001251025861499e-03, + -2.874561161519444e-03, + 0 }; const LC3_FLOAT enc_inter_filter[4][4] = { - {+2.098804630681809e-01, +5.835275754221211e-01, +2.098804630681809e-01, 0}, - {+1.069991860896389e-01, +5.500750019177116e-01, +3.356906254147840e-01, +6.698858366939680e-03}, - {+3.967114782344967e-02, +4.592209296082350e-01, +4.592209296082350e-01, +3.967114782344967e-02}, - {+6.698858366939680e-03, +3.356906254147840e-01, +5.500750019177116e-01, +1.069991860896389e-01}}; + { +2.098804630681809e-01, +5.835275754221211e-01, +2.098804630681809e-01, 0 }, + { +1.069991860896389e-01, +5.500750019177116e-01, +3.356906254147840e-01, +6.698858366939680e-03 }, + { +3.967114782344967e-02, +4.592209296082350e-01, +4.592209296082350e-01, +3.967114782344967e-02 }, + { +6.698858366939680e-03, +3.356906254147840e-01, +5.500750019177116e-01, +1.069991860896389e-01 } +}; /* Bandwidth Detector */ -const LC3_INT threshold_quiet[4] = {20, 10, 10, 10}; -const LC3_INT threshold_brickwall[4] = {15, 23, 20, 20}; -const LC3_INT brickwall_dist[4] = {4, 4, 3, 1}; -const LC3_INT BW_warp_idx_start_16k[4] = {53, 0, 0, 0}; -const LC3_INT BW_warp_idx_stop_16k[4] = {63, 0, 0, 0}; -const LC3_INT BW_warp_idx_start_24k[4] = {47, 59, 0, 0}; -const LC3_INT BW_warp_idx_stop_24k[4] = {56, 63, 0, 0}; -const LC3_INT BW_warp_idx_start_32k[4] = {44, 54, 60, 0}; -const LC3_INT BW_warp_idx_stop_32k[4] = {52, 59, 63, 0}; -const LC3_INT BW_warp_idx_start_48k[4] = {41, 51, 57, 61}; -const LC3_INT BW_warp_idx_stop_48k[4] = {49, 55, 60, 63}; -const LC3_INT* BW_warp_idx_start_all[4] = {BW_warp_idx_start_16k, BW_warp_idx_start_24k, BW_warp_idx_start_32k, - BW_warp_idx_start_48k}; -const LC3_INT* BW_warp_idx_stop_all[4] = {BW_warp_idx_stop_16k, BW_warp_idx_stop_24k, BW_warp_idx_stop_32k, - BW_warp_idx_stop_48k}; - -const LC3_INT BW_warp_idx_start_16k_2_5ms[4] = {24, 0, 0, 0}; -const LC3_INT BW_warp_idx_stop_16k_2_5ms[4] = {34, 0, 0, 0}; -const LC3_INT BW_warp_idx_start_24k_2_5ms[4] = {24, 35, 0, 0}; -const LC3_INT BW_warp_idx_stop_24k_2_5ms[4] = {32, 39, 0, 0}; -const LC3_INT BW_warp_idx_start_32k_2_5ms[4] = {24, 33, 39, 0}; -const LC3_INT BW_warp_idx_stop_32k_2_5ms[4] = {31, 38, 42, 0}; -const LC3_INT BW_warp_idx_start_48k_2_5ms[4] = {22, 31, 37, 41}; -const LC3_INT BW_warp_idx_stop_48k_2_5ms[4] = {29, 35, 40, 43}; - -const LC3_INT* BW_warp_idx_start_all_2_5ms[4] = {BW_warp_idx_start_16k_2_5ms, BW_warp_idx_start_24k_2_5ms, - BW_warp_idx_start_32k_2_5ms, BW_warp_idx_start_48k_2_5ms}; -const LC3_INT* BW_warp_idx_stop_all_2_5ms[4] = {BW_warp_idx_stop_16k_2_5ms, BW_warp_idx_stop_24k_2_5ms, - BW_warp_idx_stop_32k_2_5ms, BW_warp_idx_stop_48k_2_5ms}; - -const LC3_INT bands_number_2_5ms_HR[6] = {20, 35, 40, 43, 45, 49}; - -const LC3_INT bands_number_2_5ms[5] = {20, 35, 40, 43, 44}; - - -const LC3_INT BW_warp_idx_start_16k_5ms[4] = {39, 0, 0, 0}; -const LC3_INT BW_warp_idx_stop_16k_5ms[4] = {49, 0, 0, 0}; -const LC3_INT BW_warp_idx_start_24k_5ms[4] = {35, 47, 0, 0}; -const LC3_INT BW_warp_idx_stop_24k_5ms[4] = {44, 51, 0, 0}; -const LC3_INT BW_warp_idx_start_32k_5ms[4] = {34, 44, 50, 0}; -const LC3_INT BW_warp_idx_stop_32k_5ms[4] = {42, 49, 53, 0}; -const LC3_INT BW_warp_idx_start_48k_5ms[4] = {32, 42, 48, 52}; -const LC3_INT BW_warp_idx_stop_48k_5ms[4] = {40, 46, 51, 54}; - -const LC3_INT* BW_warp_idx_start_all_5ms[4] = {BW_warp_idx_start_16k_5ms, BW_warp_idx_start_24k_5ms, - BW_warp_idx_start_32k_5ms, BW_warp_idx_start_48k_5ms}; -const LC3_INT* BW_warp_idx_stop_all_5ms[4] = {BW_warp_idx_stop_16k_5ms, BW_warp_idx_stop_24k_5ms, - BW_warp_idx_stop_32k_5ms, BW_warp_idx_stop_48k_5ms}; - -const LC3_INT bands_number_5ms[6] = {39, 50, 52, 54, 55, 58}; - - -const LC3_INT BW_cutoff_bin_all[MAX_BW_BANDS_NUMBER] = {80, 160, 240, 320, 400, 400}; -const LC3_INT BW_cutoff_bits_all[MAX_BW_BANDS_NUMBER] = {0, 1, 2, 2, 3, 0}; - -const LC3_INT BW_cutoff_bin_all_5ms[MAX_BW_BANDS_NUMBER] = {40, 80, 120, 160, 200, 200}; -const LC3_INT BW_cutoff_bin_all_2_5ms[MAX_BW_BANDS_NUMBER] = {20, 40, 60, 80, 100, 100}; +const LC3_INT threshold_quiet[4] = { 20, 10, 10, 10 }; +const LC3_INT threshold_brickwall[4] = { 15, 23, 20, 20 }; +const LC3_INT brickwall_dist[4] = { 4, 4, 3, 1 }; +const LC3_INT BW_warp_idx_start_16k[4] = { 53, 0, 0, 0 }; +const LC3_INT BW_warp_idx_stop_16k[4] = { 63, 0, 0, 0 }; +const LC3_INT BW_warp_idx_start_24k[4] = { 47, 59, 0, 0 }; +const LC3_INT BW_warp_idx_stop_24k[4] = { 56, 63, 0, 0 }; +const LC3_INT BW_warp_idx_start_32k[4] = { 44, 54, 60, 0 }; +const LC3_INT BW_warp_idx_stop_32k[4] = { 52, 59, 63, 0 }; +const LC3_INT BW_warp_idx_start_48k[4] = { 41, 51, 57, 61 }; +const LC3_INT BW_warp_idx_stop_48k[4] = { 49, 55, 60, 63 }; +const LC3_INT *BW_warp_idx_start_all[4] = { BW_warp_idx_start_16k, BW_warp_idx_start_24k, BW_warp_idx_start_32k, + BW_warp_idx_start_48k }; +const LC3_INT *BW_warp_idx_stop_all[4] = { BW_warp_idx_stop_16k, BW_warp_idx_stop_24k, BW_warp_idx_stop_32k, + BW_warp_idx_stop_48k }; + +const LC3_INT BW_warp_idx_start_16k_2_5ms[4] = { 24, 0, 0, 0 }; +const LC3_INT BW_warp_idx_stop_16k_2_5ms[4] = { 34, 0, 0, 0 }; +const LC3_INT BW_warp_idx_start_24k_2_5ms[4] = { 24, 35, 0, 0 }; +const LC3_INT BW_warp_idx_stop_24k_2_5ms[4] = { 32, 39, 0, 0 }; +const LC3_INT BW_warp_idx_start_32k_2_5ms[4] = { 24, 33, 39, 0 }; +const LC3_INT BW_warp_idx_stop_32k_2_5ms[4] = { 31, 38, 42, 0 }; +const LC3_INT BW_warp_idx_start_48k_2_5ms[4] = { 22, 31, 37, 41 }; +const LC3_INT BW_warp_idx_stop_48k_2_5ms[4] = { 29, 35, 40, 43 }; + +const LC3_INT *BW_warp_idx_start_all_2_5ms[4] = { BW_warp_idx_start_16k_2_5ms, BW_warp_idx_start_24k_2_5ms, + BW_warp_idx_start_32k_2_5ms, BW_warp_idx_start_48k_2_5ms }; +const LC3_INT *BW_warp_idx_stop_all_2_5ms[4] = { BW_warp_idx_stop_16k_2_5ms, BW_warp_idx_stop_24k_2_5ms, + BW_warp_idx_stop_32k_2_5ms, BW_warp_idx_stop_48k_2_5ms }; + +const LC3_INT bands_number_2_5ms_HR[6] = { 20, 35, 40, 43, 45, 49 }; + +const LC3_INT bands_number_2_5ms[5] = { 20, 35, 40, 43, 44 }; + + +const LC3_INT BW_warp_idx_start_16k_5ms[4] = { 39, 0, 0, 0 }; +const LC3_INT BW_warp_idx_stop_16k_5ms[4] = { 49, 0, 0, 0 }; +const LC3_INT BW_warp_idx_start_24k_5ms[4] = { 35, 47, 0, 0 }; +const LC3_INT BW_warp_idx_stop_24k_5ms[4] = { 44, 51, 0, 0 }; +const LC3_INT BW_warp_idx_start_32k_5ms[4] = { 34, 44, 50, 0 }; +const LC3_INT BW_warp_idx_stop_32k_5ms[4] = { 42, 49, 53, 0 }; +const LC3_INT BW_warp_idx_start_48k_5ms[4] = { 32, 42, 48, 52 }; +const LC3_INT BW_warp_idx_stop_48k_5ms[4] = { 40, 46, 51, 54 }; + +const LC3_INT *BW_warp_idx_start_all_5ms[4] = { BW_warp_idx_start_16k_5ms, BW_warp_idx_start_24k_5ms, + BW_warp_idx_start_32k_5ms, BW_warp_idx_start_48k_5ms }; +const LC3_INT *BW_warp_idx_stop_all_5ms[4] = { BW_warp_idx_stop_16k_5ms, BW_warp_idx_stop_24k_5ms, + BW_warp_idx_stop_32k_5ms, BW_warp_idx_stop_48k_5ms }; + +const LC3_INT bands_number_5ms[6] = { 39, 50, 52, 54, 55, 58 }; + + +const LC3_INT BW_cutoff_bin_all[MAX_BW_BANDS_NUMBER] = { 80, 160, 240, 320, 400, 400 }; +const LC3_INT BW_cutoff_bits_all[MAX_BW_BANDS_NUMBER] = { 0, 1, 2, 2, 3, 0 }; + +const LC3_INT BW_cutoff_bin_all_5ms[MAX_BW_BANDS_NUMBER] = { 40, 80, 120, 160, 200, 200 }; +const LC3_INT BW_cutoff_bin_all_2_5ms[MAX_BW_BANDS_NUMBER] = { 20, 40, 60, 80, 100, 100 }; /* Arithmetic coding */ -const LC3_INT tns_cf[8][18] = {{0, 1, 6, 21, 52, 106, 192, 289, 409, 568, 720, 831, 935, 994, 1016, 1022, 1023, 1024}, - {0, 1, 2, 3, 4, 17, 60, 154, 293, 466, 626, 780, 911, 989, 1016, 1022, 1023, 1024}, - {0, 1, 2, 3, 4, 13, 56, 162, 361, 578, 788, 929, 1003, 1020, 1021, 1022, 1023, 1024}, - {0, 1, 2, 3, 4, 6, 17, 66, 270, 555, 852, 972, 1011, 1020, 1021, 1022, 1023, 1024}, - {0, 1, 2, 3, 4, 5, 12, 54, 295, 636, 950, 1008, 1017, 1020, 1021, 1022, 1023, 1024}, - {0, 1, 2, 3, 4, 5, 6, 19, 224, 590, 967, 1014, 1019, 1020, 1021, 1022, 1023, 1024}, - {0, 1, 2, 3, 4, 5, 6, 19, 300, 630, 1001, 1018, 1019, 1020, 1021, 1022, 1023, 1024}, - {0, 1, 2, 3, 4, 5, 6, 11, 308, 309, 991, 1017, 1019, 1020, 1021, 1022, 1023, 1024}}; +const LC3_INT tns_cf[8][18] = { { 0, 1, 6, 21, 52, 106, 192, 289, 409, 568, 720, 831, 935, 994, 1016, 1022, 1023, 1024 }, + { 0, 1, 2, 3, 4, 17, 60, 154, 293, 466, 626, 780, 911, 989, 1016, 1022, 1023, 1024 }, + { 0, 1, 2, 3, 4, 13, 56, 162, 361, 578, 788, 929, 1003, 1020, 1021, 1022, 1023, 1024 }, + { 0, 1, 2, 3, 4, 6, 17, 66, 270, 555, 852, 972, 1011, 1020, 1021, 1022, 1023, 1024 }, + { 0, 1, 2, 3, 4, 5, 12, 54, 295, 636, 950, 1008, 1017, 1020, 1021, 1022, 1023, 1024 }, + { 0, 1, 2, 3, 4, 5, 6, 19, 224, 590, 967, 1014, 1019, 1020, 1021, 1022, 1023, 1024 }, + { 0, 1, 2, 3, 4, 5, 6, 19, 300, 630, 1001, 1018, 1019, 1020, 1021, 1022, 1023, 1024 }, + { 0, 1, 2, 3, 4, 5, 6, 11, 308, 309, 991, 1017, 1019, 1020, 1021, 1022, 1023, 1024 } }; -const LC3_INT tns_freq_cf[2][9] = {{0, 3, 12, 35, 89, 200, 390, 658, 1024}, {0, 14, 56, 156, 313, 494, 672, 839, 1024}}; +const LC3_INT tns_freq_cf[2][9] = { { 0, 3, 12, 35, 89, 200, 390, 658, 1024 }, { 0, 14, 56, 156, 313, 494, 672, 839, 1024 } }; /* MDCT Windows */ @@ -1006,7 +1068,8 @@ const LC3_FLOAT MDCT_WINDOW_80_2_5ms[40] = { 9.999772999978698e-01, 9.996266599807562e-01, 9.980987183772584e-01, 9.937180643904148e-01, 9.839026370225886e-01, 9.654056798094166e-01, 9.348747871791264e-01, 8.895849967038094e-01, 8.281382099997300e-01, 7.509434386216048e-01, 6.603665285212146e-01, 5.605239559005871e-01, 4.567696724165073e-01, 3.549776504187033e-01, 2.607525136824537e-01, - 1.787053464784875e-01, 1.119125037883055e-01, 6.163560962361236e-02, 2.732289618100209e-02, 6.737914289329320e-03}; + 1.787053464784875e-01, 1.119125037883055e-01, 6.163560962361236e-02, 2.732289618100209e-02, 6.737914289329320e-03 +}; const LC3_FLOAT MDCT_WINDOW_160_2_5ms[80] = { 4.764416154578566e-03, 1.204636278996989e-02, 2.226396539371650e-02, 3.580223111285056e-02, 5.299054649961241e-02, @@ -1024,7 +1087,8 @@ const LC3_FLOAT MDCT_WINDOW_160_2_5ms[80] = { 6.841360194558924e-01, 6.363019156559162e-01, 5.864570980113353e-01, 5.352743274612082e-01, 4.834713159013930e-01, 4.317862022264749e-01, 3.809524578920635e-01, 3.316743228466244e-01, 2.846038181323611e-01, 2.403202823615340e-01, 1.993132407013812e-01, 1.619692437449073e-01, 1.285631180041137e-01, 9.925385917916330e-02, 7.408518398076024e-02, - 5.299054649961241e-02, 3.580223111285056e-02, 2.226396539371650e-02, 1.204636278996989e-02, 4.764416154578566e-03}; + 5.299054649961241e-02, 3.580223111285056e-02, 2.226396539371650e-02, 1.204636278996989e-02, 4.764416154578566e-03 +}; const LC3_FLOAT MDCT_WINDOW_240_2_5ms[120] = { 3.890134207235998e-03, 8.202595078385781e-03, 1.370235555340779e-02, 2.052968531182845e-02, 2.880307728389693e-02, @@ -1050,7 +1114,8 @@ const LC3_FLOAT MDCT_WINDOW_240_2_5ms[120] = { 3.562772881250116e-01, 3.238754496100354e-01, 2.924999908279060e-01, 2.623227204239969e-01, 2.334981807379911e-01, 2.061617274373514e-01, 1.804279808512455e-01, 1.563896708020576e-01, 1.341168883357315e-01, 1.136567491769230e-01, 9.503346510857243e-02, 7.824881086160715e-02, 6.328296540190831e-02, 5.009569719921809e-02, 3.862785141889536e-02, - 2.880307728389693e-02, 2.052968531182845e-02, 1.370235555340779e-02, 8.202595078385781e-03, 3.890134207235998e-03}; + 2.880307728389693e-02, 2.052968531182845e-02, 1.370235555340779e-02, 8.202595078385781e-03, 3.890134207235998e-03 +}; const LC3_FLOAT MDCT_WINDOW_320_2_5ms[160] = { 3.368958353152859e-03, 6.455557414799749e-03, 1.014308076237845e-02, 1.452126850237346e-02, 1.965076732239952e-02, @@ -1084,7 +1149,8 @@ const LC3_FLOAT MDCT_WINDOW_320_2_5ms[160] = { 2.095824125414741e-01, 1.899744548998832e-01, 1.713020663983868e-01, 1.535996228917228e-01, 1.368942751980506e-01, 1.212058930254449e-01, 1.065470811378728e-01, 9.292326595333501e-02, 8.033284980531531e-02, 6.876742903793599e-02, 5.821207082124419e-02, 4.864564178753818e-02, 4.004117865352276e-02, 3.236628529621430e-02, 2.558352795411825e-02, - 1.965076732239952e-02, 1.452126850237346e-02, 1.014308076237845e-02, 6.455557414799749e-03, 3.368958353152859e-03}; + 1.965076732239952e-02, 1.452126850237346e-02, 1.014308076237845e-02, 6.455557414799749e-03, 3.368958353152859e-03 +}; const LC3_FLOAT MDCT_WINDOW_480_2_5ms[240] = { 2.750746382614873e-03, 4.775245154322467e-03, 6.991265476184880e-03, 9.470118155887091e-03, 1.224415763156159e-02, @@ -1134,7 +1200,8 @@ const LC3_FLOAT MDCT_WINDOW_480_2_5ms[240] = { 9.966673316465058e-02, 9.081309669365416e-02, 8.241826576309315e-02, 7.447973421347953e-02, 6.699369195627566e-02, 5.995506493224793e-02, 5.335755875796826e-02, 4.719370517091751e-02, 4.145491000214293e-02, 3.613150075407039e-02, 3.121277069249126e-02, 2.668701415521377e-02, 2.254154337372088e-02, 1.876266772162453e-02, 1.533559472880042e-02, - 1.224415763156159e-02, 9.470118155887091e-03, 6.991265476184880e-03, 4.775245154322467e-03, 2.750746382614873e-03}; + 1.224415763156159e-02, 9.470118155887091e-03, 6.991265476184880e-03, 4.775245154322467e-03, 2.750746382614873e-03 +}; const LC3_FLOAT MDCT_WINDOW_80[160] = { -7.078546706512391e-04, -2.098197727900724e-03, -4.525198076002370e-03, -8.233976327300612e-03, @@ -1143,40 +1210,41 @@ const LC3_FLOAT MDCT_WINDOW_80[160] = { -8.859705468085925e-02, -9.688303623049199e-02, -1.034961241263523e-01, -1.080766457616878e-01, -1.103242262600913e-01, -1.099809851424550e-01, -1.068172142230882e-01, -1.006190418791648e-01, -9.116452506492527e-02, -7.820617483254730e-02, -6.146688124166948e-02, -4.063362855701623e-02, - -1.536329520788766e-02, 1.470155068746303e-02, 4.989736509080558e-02, 9.050369257152079e-02, - 1.366911019414417e-01, 1.884686389218322e-01, 2.456456803467095e-01, 3.077789078889820e-01, - 3.741642373060188e-01, 4.438114799213576e-01, 5.154735456539700e-01, 5.876661722564289e-01, - 6.587619767809000e-01, 7.270576699841359e-01, 7.908752989295335e-01, 8.486643364959733e-01, - 8.991320235484349e-01, 9.413348145272842e-01, 9.747634827941575e-01, 9.994114730415857e-01, - 1.015760373791603e+00, 1.024736164069697e+00, 1.027634294456205e+00, 1.025991493983836e+00, - 1.021427210603284e+00, 1.015439859549357e+00, 1.009366925499550e+00, 1.003508162416449e+00, - 9.988898206257559e-01, 9.953133902427869e-01, 9.925943919208190e-01, 9.905771957917731e-01, - 9.891371616557014e-01, 9.881790747212391e-01, 9.876249269174586e-01, 9.874056275509585e-01, - 9.874524849192456e-01, 9.876951134084213e-01, 9.880640617030884e-01, 9.884926873551375e-01, - 9.889230031022089e-01, 9.893074965384659e-01, 9.896146331889107e-01, 9.898319269347060e-01, - 9.899693102025342e-01, 9.900603352632121e-01, 9.901575015155720e-01, 9.903255289051605e-01, - 9.906303787150326e-01, 9.911298894709990e-01, 9.918665491182922e-01, 9.928619727154252e-01, - 9.941156069136238e-01, 9.956033775539884e-01, 9.972793109558521e-01, 9.990784840729244e-01, - 1.000922365901945e+00, 1.002728111386909e+00, 1.004416038098237e+00, 1.005919224127911e+00, - 1.007189345025525e+00, 1.008200146369426e+00, 1.008949493525753e+00, 1.009458241425143e+00, - 1.009768980817384e+00, 1.009940336228694e+00, 1.010039453539107e+00, 1.010132323996401e+00, - 1.010272524848519e+00, 1.010494354532353e+00, 1.010808068774316e+00, 1.011201071127927e+00, - 1.011641272406023e+00, 1.012080125934687e+00, 1.012458183122033e+00, 1.012706955800289e+00, - 1.012755013843985e+00, 1.012530134411619e+00, 1.011962331100864e+00, 1.010982135506986e+00, - 1.009512438049510e+00, 1.007460860286395e+00, 1.004708677491086e+00, 1.001111413242302e+00, - 9.965041017623596e-01, 9.907199995730845e-01, 9.823765865983288e-01, 9.708821747608998e-01, - 9.546732976073705e-01, 9.321553861564006e-01, 9.018003682081348e-01, 8.623984077953557e-01, - 8.132817365236141e-01, 7.544551974836834e-01, 6.866580716267418e-01, 6.113488038789190e-01, - 5.306181649316597e-01, 4.471309850999502e-01, 3.639114681156236e-01, 2.841647033392408e-01, - 2.110209448747969e-01, 1.472287968327703e-01, 9.482665349502291e-02, 5.482436608328477e-02, - 2.701461405056264e-02, 9.996743588367519e-03, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; + -1.536329520788766e-02, 1.470155068746303e-02, 4.989736509080558e-02, 9.050369257152079e-02, + 1.366911019414417e-01, 1.884686389218322e-01, 2.456456803467095e-01, 3.077789078889820e-01, + 3.741642373060188e-01, 4.438114799213576e-01, 5.154735456539700e-01, 5.876661722564289e-01, + 6.587619767809000e-01, 7.270576699841359e-01, 7.908752989295335e-01, 8.486643364959733e-01, + 8.991320235484349e-01, 9.413348145272842e-01, 9.747634827941575e-01, 9.994114730415857e-01, + 1.015760373791603e+00, 1.024736164069697e+00, 1.027634294456205e+00, 1.025991493983836e+00, + 1.021427210603284e+00, 1.015439859549357e+00, 1.009366925499550e+00, 1.003508162416449e+00, + 9.988898206257559e-01, 9.953133902427869e-01, 9.925943919208190e-01, 9.905771957917731e-01, + 9.891371616557014e-01, 9.881790747212391e-01, 9.876249269174586e-01, 9.874056275509585e-01, + 9.874524849192456e-01, 9.876951134084213e-01, 9.880640617030884e-01, 9.884926873551375e-01, + 9.889230031022089e-01, 9.893074965384659e-01, 9.896146331889107e-01, 9.898319269347060e-01, + 9.899693102025342e-01, 9.900603352632121e-01, 9.901575015155720e-01, 9.903255289051605e-01, + 9.906303787150326e-01, 9.911298894709990e-01, 9.918665491182922e-01, 9.928619727154252e-01, + 9.941156069136238e-01, 9.956033775539884e-01, 9.972793109558521e-01, 9.990784840729244e-01, + 1.000922365901945e+00, 1.002728111386909e+00, 1.004416038098237e+00, 1.005919224127911e+00, + 1.007189345025525e+00, 1.008200146369426e+00, 1.008949493525753e+00, 1.009458241425143e+00, + 1.009768980817384e+00, 1.009940336228694e+00, 1.010039453539107e+00, 1.010132323996401e+00, + 1.010272524848519e+00, 1.010494354532353e+00, 1.010808068774316e+00, 1.011201071127927e+00, + 1.011641272406023e+00, 1.012080125934687e+00, 1.012458183122033e+00, 1.012706955800289e+00, + 1.012755013843985e+00, 1.012530134411619e+00, 1.011962331100864e+00, 1.010982135506986e+00, + 1.009512438049510e+00, 1.007460860286395e+00, 1.004708677491086e+00, 1.001111413242302e+00, + 9.965041017623596e-01, 9.907199995730845e-01, 9.823765865983288e-01, 9.708821747608998e-01, + 9.546732976073705e-01, 9.321553861564006e-01, 9.018003682081348e-01, 8.623984077953557e-01, + 8.132817365236141e-01, 7.544551974836834e-01, 6.866580716267418e-01, 6.113488038789190e-01, + 5.306181649316597e-01, 4.471309850999502e-01, 3.639114681156236e-01, 2.841647033392408e-01, + 2.110209448747969e-01, 1.472287968327703e-01, 9.482665349502291e-02, 5.482436608328477e-02, + 2.701461405056264e-02, 9.996743588367519e-03, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 +}; const LC3_FLOAT MDCT_WINDOW_160[320] = { -4.619898752628163e-04, -9.747166718929050e-04, -1.664473096973725e-03, -2.597106916737789e-03, @@ -1191,74 +1259,75 @@ const LC3_FLOAT MDCT_WINDOW_160[320] = { -1.078834293141886e-01, -1.055612509762041e-01, -1.024650162703341e-01, -9.857014566194629e-02, -9.384684920715425e-02, -8.826309993000785e-02, -8.178792716809512e-02, -7.438785600211463e-02, -6.602189797715241e-02, -5.665655641133161e-02, -4.624456893420224e-02, -3.474585776145929e-02, - -2.211581608120528e-02, -8.310425696208936e-03, 6.717697635290676e-03, 2.300642061077823e-02, - 4.060106462625085e-02, 5.953239090915557e-02, 7.983354189816511e-02, 1.015233140203748e-01, - 1.246171387327525e-01, 1.491152519299797e-01, 1.750067399059861e-01, 2.022699854906251e-01, - 2.308655379767671e-01, 2.607365124918583e-01, 2.918144694729168e-01, 3.240095704645023e-01, - 3.572175180786021e-01, 3.913146885756875e-01, 4.261571642320424e-01, 4.615925445090212e-01, - 4.974471592901086e-01, 5.335326819631583e-01, 5.696546730080154e-01, 6.056083823929643e-01, - 6.411830842823245e-01, 6.761653499550255e-01, 7.103400549562944e-01, 7.434943718765665e-01, - 7.754281892901473e-01, 8.059437233154637e-01, 8.348589373399948e-01, 8.620108336276733e-01, - 8.872599706865123e-01, 9.104863121445679e-01, 9.315962496426278e-01, 9.505220861927248e-01, - 9.672366712325431e-01, 9.817397501303696e-01, 9.940557180662704e-01, 1.004247514102417e+00, - 1.012407428282884e+00, 1.018650990561848e+00, 1.023118841384460e+00, 1.025972450969440e+00, - 1.027397523939210e+00, 1.027585830688143e+00, 1.026738673647482e+00, 1.025061777648234e+00, - 1.022756514615106e+00, 1.020009139549275e+00, 1.016996499560845e+00, 1.013915946100629e+00, - 1.011044869639164e+00, 1.007773858455400e+00, 1.004848753962734e+00, 1.002245009135684e+00, - 9.999393169239009e-01, 9.979055415627330e-01, 9.961203379971326e-01, 9.945597525471822e-01, - 9.932031606606762e-01, 9.920297273323891e-01, 9.910230654424902e-01, 9.901668953434221e-01, - 9.894488374513719e-01, 9.888556356037892e-01, 9.883778520531268e-01, 9.880051626345804e-01, - 9.877295459610343e-01, 9.875412739766566e-01, 9.874329809802893e-01, 9.873949921033299e-01, - 9.874197049003676e-01, 9.874973205882319e-01, 9.876201238703241e-01, 9.877781920433015e-01, - 9.879637979933339e-01, 9.881678007807095e-01, 9.883835200189653e-01, 9.886022219397892e-01, - 9.888182771263505e-01, 9.890247977602895e-01, 9.892178658748239e-01, 9.893923680007577e-01, - 9.895463342815009e-01, 9.896772011542693e-01, 9.897859195209235e-01, 9.898725363809847e-01, - 9.899410789223559e-01, 9.899945557067980e-01, 9.900394023736973e-01, 9.900814722948890e-01, - 9.901293790312005e-01, 9.901902265696609e-01, 9.902734448815004e-01, 9.903862280081246e-01, - 9.905379830873822e-01, 9.907348826312993e-01, 9.909842592301273e-01, 9.912905118607647e-01, - 9.916586940166509e-01, 9.920906151219310e-01, 9.925887208794144e-01, 9.931516528513824e-01, - 9.937790866568735e-01, 9.944668184371617e-01, 9.952116634297566e-01, 9.960068616185641e-01, - 9.968461329825753e-01, 9.977203369515556e-01, 9.986213520769593e-01, 9.995382582242990e-01, - 1.000461955079660e+00, 1.001380551217109e+00, 1.002284871786226e+00, 1.003163845364970e+00, - 1.004009147462043e+00, 1.004811375053364e+00, 1.005563968008037e+00, 1.006259855360867e+00, - 1.006895570408563e+00, 1.007466616298057e+00, 1.007972441990187e+00, 1.008411468616852e+00, - 1.008786009787269e+00, 1.009097763850333e+00, 1.009351762546296e+00, 1.009552401900961e+00, - 1.009707093778162e+00, 1.009822090220407e+00, 1.009906958448099e+00, 1.009969021400474e+00, - 1.010017890428877e+00, 1.010060809299530e+00, 1.010106564965965e+00, 1.010161131093372e+00, - 1.010231078494249e+00, 1.010319484524512e+00, 1.010430470494512e+00, 1.010564099281000e+00, - 1.010721360243234e+00, 1.010899655674578e+00, 1.011096993993037e+00, 1.011308167670753e+00, - 1.011529185153809e+00, 1.011753008569803e+00, 1.011973876511603e+00, 1.012182837094955e+00, - 1.012373028737774e+00, 1.012535058602453e+00, 1.012660975529858e+00, 1.012740575296603e+00, - 1.012765922449960e+00, 1.012726958954961e+00, 1.012615904116265e+00, 1.012422888521601e+00, - 1.012140460211194e+00, 1.011758810583150e+00, 1.011269960947744e+00, 1.010663676735228e+00, - 1.009930754807923e+00, 1.009058249873833e+00, 1.008034308295421e+00, 1.006843352506855e+00, - 1.005470005637052e+00, 1.003894772403371e+00, 1.002098854400575e+00, 1.000060686758758e+00, - 9.977600196406868e-01, 9.951746430061121e-01, 9.922861082472264e-01, 9.890757868707590e-01, - 9.847362453480265e-01, 9.798613526271561e-01, 9.741378617337759e-01, 9.673331975559332e-01, - 9.592539757044516e-01, 9.496984081652284e-01, 9.384634163826711e-01, 9.253567968750328e-01, - 9.101986790930605e-01, 8.928338316495705e-01, 8.731437835983047e-01, 8.510420440685049e-01, - 8.264839911291133e-01, 7.994681492797084e-01, 7.700431275216928e-01, 7.383028603058783e-01, - 7.043814340356083e-01, 6.684616478236647e-01, 6.307755329382612e-01, 5.915799587176216e-01, - 5.511703155400274e-01, 5.098915423728179e-01, 4.681017110047964e-01, 4.261772971493010e-01, - 3.845172335531009e-01, 3.435228672445613e-01, 3.036004651973099e-01, 2.651434678028531e-01, - 2.285283969438072e-01, 1.941021906320984e-01, 1.621735416384830e-01, 1.330015240938615e-01, - 1.067840430193724e-01, 8.365057236623041e-02, 6.365188111381356e-02, 4.676538412257621e-02, - 3.288072750732215e-02, 2.183057564646270e-02, 1.336381425803019e-02, 6.758124889697787e-03, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; + -2.211581608120528e-02, -8.310425696208936e-03, 6.717697635290676e-03, 2.300642061077823e-02, + 4.060106462625085e-02, 5.953239090915557e-02, 7.983354189816511e-02, 1.015233140203748e-01, + 1.246171387327525e-01, 1.491152519299797e-01, 1.750067399059861e-01, 2.022699854906251e-01, + 2.308655379767671e-01, 2.607365124918583e-01, 2.918144694729168e-01, 3.240095704645023e-01, + 3.572175180786021e-01, 3.913146885756875e-01, 4.261571642320424e-01, 4.615925445090212e-01, + 4.974471592901086e-01, 5.335326819631583e-01, 5.696546730080154e-01, 6.056083823929643e-01, + 6.411830842823245e-01, 6.761653499550255e-01, 7.103400549562944e-01, 7.434943718765665e-01, + 7.754281892901473e-01, 8.059437233154637e-01, 8.348589373399948e-01, 8.620108336276733e-01, + 8.872599706865123e-01, 9.104863121445679e-01, 9.315962496426278e-01, 9.505220861927248e-01, + 9.672366712325431e-01, 9.817397501303696e-01, 9.940557180662704e-01, 1.004247514102417e+00, + 1.012407428282884e+00, 1.018650990561848e+00, 1.023118841384460e+00, 1.025972450969440e+00, + 1.027397523939210e+00, 1.027585830688143e+00, 1.026738673647482e+00, 1.025061777648234e+00, + 1.022756514615106e+00, 1.020009139549275e+00, 1.016996499560845e+00, 1.013915946100629e+00, + 1.011044869639164e+00, 1.007773858455400e+00, 1.004848753962734e+00, 1.002245009135684e+00, + 9.999393169239009e-01, 9.979055415627330e-01, 9.961203379971326e-01, 9.945597525471822e-01, + 9.932031606606762e-01, 9.920297273323891e-01, 9.910230654424902e-01, 9.901668953434221e-01, + 9.894488374513719e-01, 9.888556356037892e-01, 9.883778520531268e-01, 9.880051626345804e-01, + 9.877295459610343e-01, 9.875412739766566e-01, 9.874329809802893e-01, 9.873949921033299e-01, + 9.874197049003676e-01, 9.874973205882319e-01, 9.876201238703241e-01, 9.877781920433015e-01, + 9.879637979933339e-01, 9.881678007807095e-01, 9.883835200189653e-01, 9.886022219397892e-01, + 9.888182771263505e-01, 9.890247977602895e-01, 9.892178658748239e-01, 9.893923680007577e-01, + 9.895463342815009e-01, 9.896772011542693e-01, 9.897859195209235e-01, 9.898725363809847e-01, + 9.899410789223559e-01, 9.899945557067980e-01, 9.900394023736973e-01, 9.900814722948890e-01, + 9.901293790312005e-01, 9.901902265696609e-01, 9.902734448815004e-01, 9.903862280081246e-01, + 9.905379830873822e-01, 9.907348826312993e-01, 9.909842592301273e-01, 9.912905118607647e-01, + 9.916586940166509e-01, 9.920906151219310e-01, 9.925887208794144e-01, 9.931516528513824e-01, + 9.937790866568735e-01, 9.944668184371617e-01, 9.952116634297566e-01, 9.960068616185641e-01, + 9.968461329825753e-01, 9.977203369515556e-01, 9.986213520769593e-01, 9.995382582242990e-01, + 1.000461955079660e+00, 1.001380551217109e+00, 1.002284871786226e+00, 1.003163845364970e+00, + 1.004009147462043e+00, 1.004811375053364e+00, 1.005563968008037e+00, 1.006259855360867e+00, + 1.006895570408563e+00, 1.007466616298057e+00, 1.007972441990187e+00, 1.008411468616852e+00, + 1.008786009787269e+00, 1.009097763850333e+00, 1.009351762546296e+00, 1.009552401900961e+00, + 1.009707093778162e+00, 1.009822090220407e+00, 1.009906958448099e+00, 1.009969021400474e+00, + 1.010017890428877e+00, 1.010060809299530e+00, 1.010106564965965e+00, 1.010161131093372e+00, + 1.010231078494249e+00, 1.010319484524512e+00, 1.010430470494512e+00, 1.010564099281000e+00, + 1.010721360243234e+00, 1.010899655674578e+00, 1.011096993993037e+00, 1.011308167670753e+00, + 1.011529185153809e+00, 1.011753008569803e+00, 1.011973876511603e+00, 1.012182837094955e+00, + 1.012373028737774e+00, 1.012535058602453e+00, 1.012660975529858e+00, 1.012740575296603e+00, + 1.012765922449960e+00, 1.012726958954961e+00, 1.012615904116265e+00, 1.012422888521601e+00, + 1.012140460211194e+00, 1.011758810583150e+00, 1.011269960947744e+00, 1.010663676735228e+00, + 1.009930754807923e+00, 1.009058249873833e+00, 1.008034308295421e+00, 1.006843352506855e+00, + 1.005470005637052e+00, 1.003894772403371e+00, 1.002098854400575e+00, 1.000060686758758e+00, + 9.977600196406868e-01, 9.951746430061121e-01, 9.922861082472264e-01, 9.890757868707590e-01, + 9.847362453480265e-01, 9.798613526271561e-01, 9.741378617337759e-01, 9.673331975559332e-01, + 9.592539757044516e-01, 9.496984081652284e-01, 9.384634163826711e-01, 9.253567968750328e-01, + 9.101986790930605e-01, 8.928338316495705e-01, 8.731437835983047e-01, 8.510420440685049e-01, + 8.264839911291133e-01, 7.994681492797084e-01, 7.700431275216928e-01, 7.383028603058783e-01, + 7.043814340356083e-01, 6.684616478236647e-01, 6.307755329382612e-01, 5.915799587176216e-01, + 5.511703155400274e-01, 5.098915423728179e-01, 4.681017110047964e-01, 4.261772971493010e-01, + 3.845172335531009e-01, 3.435228672445613e-01, 3.036004651973099e-01, 2.651434678028531e-01, + 2.285283969438072e-01, 1.941021906320984e-01, 1.621735416384830e-01, 1.330015240938615e-01, + 1.067840430193724e-01, 8.365057236623041e-02, 6.365188111381356e-02, 4.676538412257621e-02, + 3.288072750732215e-02, 2.183057564646270e-02, 1.336381425803019e-02, 6.758124889697787e-03, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 +}; const LC3_FLOAT MDCT_WINDOW_240[480] = { -3.613496418928369e-04, -7.078546706512391e-04, -1.074443637110903e-03, -1.533478537964509e-03, @@ -1280,107 +1349,108 @@ const LC3_FLOAT MDCT_WINDOW_240[480] = { -7.820617483254730e-02, -7.306142427456862e-02, -6.748468182105991e-02, -6.146688124166948e-02, -5.499497258200362e-02, -4.805444424454820e-02, -4.063362855701623e-02, -3.272045590229335e-02, -2.430122582451853e-02, -1.536329520788766e-02, -5.891434269890659e-03, 4.126595858583295e-03, - 1.470155068746303e-02, 2.584738191459814e-02, 3.757652772246801e-02, 4.989736509080558e-02, - 6.282034030592902e-02, 7.635397728566121e-02, 9.050369257152079e-02, 1.052747118478660e-01, - 1.206703467513333e-01, 1.366911019414417e-01, 1.533343890681390e-01, 1.705954709184399e-01, - 1.884686389218322e-01, 2.069449962574092e-01, 2.260093000067393e-01, 2.456456803467095e-01, - 2.658346019332584e-01, 2.865543814049772e-01, 3.077789078889820e-01, 3.294769437072290e-01, - 3.516171481750350e-01, 3.741642373060188e-01, 3.970739591211551e-01, 4.203043046885219e-01, - 4.438114799213576e-01, 4.675442291623012e-01, 4.914498631045615e-01, 5.154735456539700e-01, - 5.395557644293222e-01, 5.636399817032525e-01, 5.876661722564289e-01, 6.115695310143157e-01, - 6.352890592874099e-01, 6.587619767809000e-01, 6.819230974423550e-01, 7.047092819314779e-01, - 7.270576699841359e-01, 7.489068963384272e-01, 7.701990187606995e-01, 7.908752989295335e-01, - 8.108788692151807e-01, 8.301579139160681e-01, 8.486643364959733e-01, 8.663548164329093e-01, - 8.831896853053627e-01, 8.991320235484349e-01, 9.141540563656075e-01, 9.282282546151819e-01, - 9.413348145272842e-01, 9.534619388400459e-01, 9.646048250501910e-01, 9.747634827941575e-01, - 9.839435385219192e-01, 9.921529097154242e-01, 9.994114730415857e-01, 1.005746084650236e+00, - 1.011183971347815e+00, 1.015760373791603e+00, 1.019515072412387e+00, 1.022490937034641e+00, - 1.024736164069697e+00, 1.026304095700693e+00, 1.027250978292214e+00, 1.027634294456205e+00, - 1.027511063644843e+00, 1.026942795115598e+00, 1.025991493983836e+00, 1.024716149969084e+00, - 1.023175976163407e+00, 1.021427210603284e+00, 1.019521566634239e+00, 1.017510118327508e+00, - 1.015439859549357e+00, 1.013460916839174e+00, 1.011654901040475e+00, 1.009366925499550e+00, - 1.007263182132894e+00, 1.005313192386866e+00, 1.003508162416449e+00, 1.001840787319378e+00, - 1.000303927234380e+00, 9.988898206257559e-01, 9.975915283480670e-01, 9.964015284765968e-01, - 9.953133902427869e-01, 9.943201078053212e-01, 9.934158959186011e-01, 9.925943919208190e-01, - 9.918510277326026e-01, 9.911797988363887e-01, 9.905771957917731e-01, 9.900381047643838e-01, - 9.895594394179152e-01, 9.891371616557014e-01, 9.887684373604154e-01, 9.884497924570929e-01, - 9.881790747212391e-01, 9.879528358230726e-01, 9.877691368590689e-01, 9.876249269174586e-01, - 9.875179947346887e-01, 9.874458127312921e-01, 9.874056275509585e-01, 9.873951115886979e-01, - 9.874115368168944e-01, 9.874524849192456e-01, 9.875149888347144e-01, 9.875968894760857e-01, - 9.876951134084213e-01, 9.878075819424549e-01, 9.879311998177238e-01, 9.880640617030884e-01, - 9.882032571565917e-01, 9.883471084085503e-01, 9.884926873551375e-01, 9.886386592120545e-01, - 9.887825578295630e-01, 9.889230031022089e-01, 9.890581715933395e-01, 9.891867674284610e-01, - 9.893074965384659e-01, 9.894196399062921e-01, 9.895220757174378e-01, 9.896146331889107e-01, - 9.896970346678272e-01, 9.897692596535289e-01, 9.898319269347060e-01, 9.898852572653667e-01, - 9.899307640365727e-01, 9.899693102025343e-01, 9.900025692522435e-01, 9.900321562263099e-01, - 9.900603352632121e-01, 9.900889812894406e-01, 9.901206586012907e-01, 9.901575015155720e-01, - 9.902023946214220e-01, 9.902575406142213e-01, 9.903255289051605e-01, 9.904087914462694e-01, - 9.905096491583045e-01, 9.906303787150326e-01, 9.907727108894024e-01, 9.909387444078919e-01, - 9.911298894709990e-01, 9.913476318763218e-01, 9.915928560402563e-01, 9.918665491182922e-01, - 9.921691315380984e-01, 9.925010851461232e-01, 9.928619727154252e-01, 9.932519181564613e-01, - 9.936700207375173e-01, 9.941156069136238e-01, 9.945873147903244e-01, 9.950837402063278e-01, - 9.956033775539884e-01, 9.961439922621166e-01, 9.967034533921340e-01, 9.972793109558521e-01, - 9.978690858367024e-01, 9.984697087896268e-01, 9.990784840729244e-01, 9.996919011206490e-01, - 1.000308193833526e+00, 1.000922365901945e+00, 1.001532636590676e+00, 1.002135464655177e+00, - 1.002728111386909e+00, 1.003307449770187e+00, 1.003870934089686e+00, 1.004416038098237e+00, - 1.004940548815171e+00, 1.005442141810160e+00, 1.005919224127911e+00, 1.006370303149314e+00, - 1.006793927824538e+00, 1.007189345025525e+00, 1.007555573455895e+00, 1.007892674961336e+00, - 1.008200146369426e+00, 1.008478423284851e+00, 1.008727884997619e+00, 1.008949493525753e+00, - 1.009144112734761e+00, 1.009313224929575e+00, 1.009458241425143e+00, 1.009581280555682e+00, - 1.009684090687164e+00, 1.009768980817384e+00, 1.009838308708799e+00, 1.009894548257807e+00, - 1.009940336228694e+00, 1.009977916643680e+00, 1.010010230290263e+00, 1.010039453539107e+00, - 1.010068202038694e+00, 1.010098388689342e+00, 1.010132323996401e+00, 1.010171656775640e+00, - 1.010218096148412e+00, 1.010272524848519e+00, 1.010336490294771e+00, 1.010410221483215e+00, - 1.010494354532353e+00, 1.010588873699422e+00, 1.010693501186928e+00, 1.010808068774316e+00, - 1.010931436739342e+00, 1.011062876503041e+00, 1.011201071127927e+00, 1.011344700694417e+00, - 1.011491904228184e+00, 1.011641272406023e+00, 1.011790282474963e+00, 1.011937567254485e+00, - 1.012080125934687e+00, 1.012216235487353e+00, 1.012342907951334e+00, 1.012458183122033e+00, - 1.012558879696851e+00, 1.012642857380847e+00, 1.012706955800289e+00, 1.012748952907404e+00, - 1.012765799894453e+00, 1.012755013843985e+00, 1.012713798678211e+00, 1.012639775003457e+00, - 1.012530134411619e+00, 1.012382309473470e+00, 1.012194068117524e+00, 1.011962331100864e+00, - 1.011685173724601e+00, 1.011359143572147e+00, 1.010982135506986e+00, 1.010550715971368e+00, - 1.010062133151922e+00, 1.009512438049510e+00, 1.008898689394160e+00, 1.008215923600973e+00, - 1.007460860286395e+00, 1.006627741823389e+00, 1.005712337656749e+00, 1.004708677491086e+00, - 1.003611467285588e+00, 1.002414286392268e+00, 1.001111413242302e+00, 9.996961651093181e-01, - 9.981625949525345e-01, 9.965041017623596e-01, 9.947148884277037e-01, 9.927891912841345e-01, - 9.907199995730845e-01, 9.884793707533194e-01, 9.855347660016696e-01, 9.823765865983286e-01, - 9.789747333404933e-01, 9.751623811486372e-01, 9.708821747608998e-01, 9.660805524695870e-01, - 9.606976399184645e-01, 9.546732976073706e-01, 9.479479345282376e-01, 9.404609052933396e-01, - 9.321553861564006e-01, 9.229775478442888e-01, 9.128745354570823e-01, 9.018003682081348e-01, - 8.897163275605041e-01, 8.765908974996186e-01, 8.623984077953557e-01, 8.471200801854385e-01, - 8.307479727020245e-01, 8.132817365236141e-01, 7.947291447585267e-01, 7.751108841891807e-01, - 7.544551974836834e-01, 7.327963552921717e-01, 7.101790843209148e-01, 6.866580716267418e-01, - 6.622962432368731e-01, 6.371684119604742e-01, 6.113488038789190e-01, 5.849206604934815e-01, - 5.579747428663487e-01, 5.306181649316717e-01, 5.029523957059122e-01, 4.750868825511614e-01, - 4.471309850999535e-01, 4.192049917945288e-01, 3.914252910998820e-01, 3.639114681156252e-01, - 3.367837772954476e-01, 3.101627843160973e-01, 2.841647033392418e-01, 2.589033711808454e-01, - 2.344880603710975e-01, 2.110209448747974e-01, 1.885997642296488e-01, 1.673100807904834e-01, - 1.472287968327706e-01, 1.284223074167396e-01, 1.109422548710344e-01, 9.482665349502306e-02, - 8.009914366829558e-02, 6.676765847398403e-02, 5.482436608328485e-02, 4.424588851571281e-02, - 3.499361000717621e-02, 2.701461405056267e-02, 2.024370180670145e-02, 1.460796755137538e-02, - 9.996743588367531e-03, 5.305235098871444e-03, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; + 1.470155068746303e-02, 2.584738191459814e-02, 3.757652772246801e-02, 4.989736509080558e-02, + 6.282034030592902e-02, 7.635397728566121e-02, 9.050369257152079e-02, 1.052747118478660e-01, + 1.206703467513333e-01, 1.366911019414417e-01, 1.533343890681390e-01, 1.705954709184399e-01, + 1.884686389218322e-01, 2.069449962574092e-01, 2.260093000067393e-01, 2.456456803467095e-01, + 2.658346019332584e-01, 2.865543814049772e-01, 3.077789078889820e-01, 3.294769437072290e-01, + 3.516171481750350e-01, 3.741642373060188e-01, 3.970739591211551e-01, 4.203043046885219e-01, + 4.438114799213576e-01, 4.675442291623012e-01, 4.914498631045615e-01, 5.154735456539700e-01, + 5.395557644293222e-01, 5.636399817032525e-01, 5.876661722564289e-01, 6.115695310143157e-01, + 6.352890592874099e-01, 6.587619767809000e-01, 6.819230974423550e-01, 7.047092819314779e-01, + 7.270576699841359e-01, 7.489068963384272e-01, 7.701990187606995e-01, 7.908752989295335e-01, + 8.108788692151807e-01, 8.301579139160681e-01, 8.486643364959733e-01, 8.663548164329093e-01, + 8.831896853053627e-01, 8.991320235484349e-01, 9.141540563656075e-01, 9.282282546151819e-01, + 9.413348145272842e-01, 9.534619388400459e-01, 9.646048250501910e-01, 9.747634827941575e-01, + 9.839435385219192e-01, 9.921529097154242e-01, 9.994114730415857e-01, 1.005746084650236e+00, + 1.011183971347815e+00, 1.015760373791603e+00, 1.019515072412387e+00, 1.022490937034641e+00, + 1.024736164069697e+00, 1.026304095700693e+00, 1.027250978292214e+00, 1.027634294456205e+00, + 1.027511063644843e+00, 1.026942795115598e+00, 1.025991493983836e+00, 1.024716149969084e+00, + 1.023175976163407e+00, 1.021427210603284e+00, 1.019521566634239e+00, 1.017510118327508e+00, + 1.015439859549357e+00, 1.013460916839174e+00, 1.011654901040475e+00, 1.009366925499550e+00, + 1.007263182132894e+00, 1.005313192386866e+00, 1.003508162416449e+00, 1.001840787319378e+00, + 1.000303927234380e+00, 9.988898206257559e-01, 9.975915283480670e-01, 9.964015284765968e-01, + 9.953133902427869e-01, 9.943201078053212e-01, 9.934158959186011e-01, 9.925943919208190e-01, + 9.918510277326026e-01, 9.911797988363887e-01, 9.905771957917731e-01, 9.900381047643838e-01, + 9.895594394179152e-01, 9.891371616557014e-01, 9.887684373604154e-01, 9.884497924570929e-01, + 9.881790747212391e-01, 9.879528358230726e-01, 9.877691368590689e-01, 9.876249269174586e-01, + 9.875179947346887e-01, 9.874458127312921e-01, 9.874056275509585e-01, 9.873951115886979e-01, + 9.874115368168944e-01, 9.874524849192456e-01, 9.875149888347144e-01, 9.875968894760857e-01, + 9.876951134084213e-01, 9.878075819424549e-01, 9.879311998177238e-01, 9.880640617030884e-01, + 9.882032571565917e-01, 9.883471084085503e-01, 9.884926873551375e-01, 9.886386592120545e-01, + 9.887825578295630e-01, 9.889230031022089e-01, 9.890581715933395e-01, 9.891867674284610e-01, + 9.893074965384659e-01, 9.894196399062921e-01, 9.895220757174378e-01, 9.896146331889107e-01, + 9.896970346678272e-01, 9.897692596535289e-01, 9.898319269347060e-01, 9.898852572653667e-01, + 9.899307640365727e-01, 9.899693102025343e-01, 9.900025692522435e-01, 9.900321562263099e-01, + 9.900603352632121e-01, 9.900889812894406e-01, 9.901206586012907e-01, 9.901575015155720e-01, + 9.902023946214220e-01, 9.902575406142213e-01, 9.903255289051605e-01, 9.904087914462694e-01, + 9.905096491583045e-01, 9.906303787150326e-01, 9.907727108894024e-01, 9.909387444078919e-01, + 9.911298894709990e-01, 9.913476318763218e-01, 9.915928560402563e-01, 9.918665491182922e-01, + 9.921691315380984e-01, 9.925010851461232e-01, 9.928619727154252e-01, 9.932519181564613e-01, + 9.936700207375173e-01, 9.941156069136238e-01, 9.945873147903244e-01, 9.950837402063278e-01, + 9.956033775539884e-01, 9.961439922621166e-01, 9.967034533921340e-01, 9.972793109558521e-01, + 9.978690858367024e-01, 9.984697087896268e-01, 9.990784840729244e-01, 9.996919011206490e-01, + 1.000308193833526e+00, 1.000922365901945e+00, 1.001532636590676e+00, 1.002135464655177e+00, + 1.002728111386909e+00, 1.003307449770187e+00, 1.003870934089686e+00, 1.004416038098237e+00, + 1.004940548815171e+00, 1.005442141810160e+00, 1.005919224127911e+00, 1.006370303149314e+00, + 1.006793927824538e+00, 1.007189345025525e+00, 1.007555573455895e+00, 1.007892674961336e+00, + 1.008200146369426e+00, 1.008478423284851e+00, 1.008727884997619e+00, 1.008949493525753e+00, + 1.009144112734761e+00, 1.009313224929575e+00, 1.009458241425143e+00, 1.009581280555682e+00, + 1.009684090687164e+00, 1.009768980817384e+00, 1.009838308708799e+00, 1.009894548257807e+00, + 1.009940336228694e+00, 1.009977916643680e+00, 1.010010230290263e+00, 1.010039453539107e+00, + 1.010068202038694e+00, 1.010098388689342e+00, 1.010132323996401e+00, 1.010171656775640e+00, + 1.010218096148412e+00, 1.010272524848519e+00, 1.010336490294771e+00, 1.010410221483215e+00, + 1.010494354532353e+00, 1.010588873699422e+00, 1.010693501186928e+00, 1.010808068774316e+00, + 1.010931436739342e+00, 1.011062876503041e+00, 1.011201071127927e+00, 1.011344700694417e+00, + 1.011491904228184e+00, 1.011641272406023e+00, 1.011790282474963e+00, 1.011937567254485e+00, + 1.012080125934687e+00, 1.012216235487353e+00, 1.012342907951334e+00, 1.012458183122033e+00, + 1.012558879696851e+00, 1.012642857380847e+00, 1.012706955800289e+00, 1.012748952907404e+00, + 1.012765799894453e+00, 1.012755013843985e+00, 1.012713798678211e+00, 1.012639775003457e+00, + 1.012530134411619e+00, 1.012382309473470e+00, 1.012194068117524e+00, 1.011962331100864e+00, + 1.011685173724601e+00, 1.011359143572147e+00, 1.010982135506986e+00, 1.010550715971368e+00, + 1.010062133151922e+00, 1.009512438049510e+00, 1.008898689394160e+00, 1.008215923600973e+00, + 1.007460860286395e+00, 1.006627741823389e+00, 1.005712337656749e+00, 1.004708677491086e+00, + 1.003611467285588e+00, 1.002414286392268e+00, 1.001111413242302e+00, 9.996961651093181e-01, + 9.981625949525345e-01, 9.965041017623596e-01, 9.947148884277037e-01, 9.927891912841345e-01, + 9.907199995730845e-01, 9.884793707533194e-01, 9.855347660016696e-01, 9.823765865983286e-01, + 9.789747333404933e-01, 9.751623811486372e-01, 9.708821747608998e-01, 9.660805524695870e-01, + 9.606976399184645e-01, 9.546732976073706e-01, 9.479479345282376e-01, 9.404609052933396e-01, + 9.321553861564006e-01, 9.229775478442888e-01, 9.128745354570823e-01, 9.018003682081348e-01, + 8.897163275605041e-01, 8.765908974996186e-01, 8.623984077953557e-01, 8.471200801854385e-01, + 8.307479727020245e-01, 8.132817365236141e-01, 7.947291447585267e-01, 7.751108841891807e-01, + 7.544551974836834e-01, 7.327963552921717e-01, 7.101790843209148e-01, 6.866580716267418e-01, + 6.622962432368731e-01, 6.371684119604742e-01, 6.113488038789190e-01, 5.849206604934815e-01, + 5.579747428663487e-01, 5.306181649316717e-01, 5.029523957059122e-01, 4.750868825511614e-01, + 4.471309850999535e-01, 4.192049917945288e-01, 3.914252910998820e-01, 3.639114681156252e-01, + 3.367837772954476e-01, 3.101627843160973e-01, 2.841647033392418e-01, 2.589033711808454e-01, + 2.344880603710975e-01, 2.110209448747974e-01, 1.885997642296488e-01, 1.673100807904834e-01, + 1.472287968327706e-01, 1.284223074167396e-01, 1.109422548710344e-01, 9.482665349502306e-02, + 8.009914366829558e-02, 6.676765847398403e-02, 5.482436608328485e-02, 4.424588851571281e-02, + 3.499361000717621e-02, 2.701461405056267e-02, 2.024370180670145e-02, 1.460796755137538e-02, + 9.996743588367531e-03, 5.305235098871444e-03, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 +}; const LC3_FLOAT MDCT_WINDOW_320[640] = { -3.021153494057143e-04, -5.867737487939294e-04, -8.366504004139796e-04, -1.126635355725494e-03, @@ -1408,141 +1478,142 @@ const LC3_FLOAT MDCT_WINDOW_320[640] = { -6.820576796149519e-02, -6.377611429172260e-02, -5.909386001558149e-02, -5.415316322402774e-02, -4.894812724598650e-02, -4.347347112195197e-02, -3.772461300253332e-02, -3.169587609244436e-02, -2.538179830690266e-02, -1.877689096555516e-02, -1.187461378850388e-02, -4.669099247423082e-03, - 2.844096748870385e-03, 1.066976124794342e-02, 1.881355950582949e-02, 2.728156010437695e-02, - 3.607810469851272e-02, 4.520702759803914e-02, 5.467238802204326e-02, 6.447866054615346e-02, - 7.462862199422061e-02, 8.512490568723846e-02, 9.596983987496970e-02, 1.071650779014335e-01, - 1.187115850305241e-01, 1.306101067250375e-01, 1.428596447589721e-01, 1.554584725339102e-01, - 1.684041609371527e-01, 1.816947894623263e-01, 1.953273880886783e-01, 2.092963206850239e-01, - 2.235945635254679e-01, 2.382160219461597e-01, 2.531529721334063e-01, 2.683961570569586e-01, - 2.839361392493072e-01, 2.997624255177811e-01, 3.158619077906196e-01, 3.322210551086769e-01, - 3.488264676990591e-01, 3.656640377499646e-01, 3.827152968157059e-01, 3.999611859760947e-01, - 4.173843265025887e-01, 4.349669624916473e-01, 4.526876397402144e-01, 4.705242008503956e-01, - 4.884539254831315e-01, 5.064545550235134e-01, 5.245006748662190e-01, 5.425674372882107e-01, - 5.606312044701524e-01, 5.786672646386708e-01, 5.966477035050948e-01, 6.145458904162185e-01, - 6.323361944662236e-01, 6.499926319211774e-01, 6.674874032292857e-01, 6.847932667399612e-01, - 7.018835463513400e-01, 7.187322544823347e-01, 7.353128213893310e-01, 7.516001985652684e-01, - 7.675699252273948e-01, 7.831974571624924e-01, 7.984583859818390e-01, 8.133295347030278e-01, - 8.277892271515950e-01, 8.418178561101360e-01, 8.553961300139363e-01, 8.685068980898102e-01, - 8.811334436653052e-01, 8.932596784799233e-01, 9.048748835980528e-01, 9.159657608120536e-01, - 9.265215299450000e-01, 9.365339988633418e-01, 9.459977028429117e-01, 9.549088408436811e-01, - 9.632658122557368e-01, 9.710688896122810e-01, 9.783204156360773e-01, 9.850226760127131e-01, - 9.911792082081333e-01, 9.967989944502682e-01, 1.001894024615659e+00, 1.006474342231823e+00, - 1.010552057109195e+00, 1.014142538208007e+00, 1.017262593268930e+00, 1.019928842669923e+00, - 1.022159867011177e+00, 1.023976320927187e+00, 1.025400734608122e+00, 1.026455340400072e+00, - 1.027164510654160e+00, 1.027552729180790e+00, 1.027644462380432e+00, 1.027463246660797e+00, - 1.027035903410657e+00, 1.026389068000259e+00, 1.025548201799728e+00, 1.024537134749709e+00, - 1.023380803775376e+00, 1.022103695693341e+00, 1.020728359657958e+00, 1.019275334687329e+00, - 1.017765178792830e+00, 1.016217355867531e+00, 1.014665311686846e+00, 1.013249071090664e+00, - 1.011948006992127e+00, 1.010189090179223e+00, 1.008557961167850e+00, 1.007011287608451e+00, - 1.005548764575910e+00, 1.004168417268956e+00, 1.002867268893035e+00, 1.001641769115897e+00, - 1.000489068954641e+00, 9.994060799749374e-01, 9.983898865406841e-01, 9.974370849972721e-01, - 9.965444836911705e-01, 9.957098545943852e-01, 9.949302413030897e-01, 9.942024045863540e-01, - 9.935241604969254e-01, 9.928930430130044e-01, 9.923068103443909e-01, 9.917633778190438e-01, - 9.912597642374404e-01, 9.907954498484041e-01, 9.903677893656558e-01, 9.899751611066148e-01, - 9.896160337369861e-01, 9.892890160408989e-01, 9.889928511129679e-01, 9.887260333430423e-01, - 9.884868721088945e-01, 9.882751039537586e-01, 9.880892168751595e-01, 9.879277114724612e-01, - 9.877898261218510e-01, 9.876743442038471e-01, 9.875807496078497e-01, 9.875072021876561e-01, - 9.874529447589979e-01, 9.874169741527905e-01, 9.873984685207834e-01, 9.873958301311858e-01, - 9.874080027710336e-01, 9.874343401290739e-01, 9.874736235387018e-01, 9.875243137719285e-01, - 9.875856201221135e-01, 9.876563785063032e-01, 9.877358921155149e-01, 9.878225576787804e-01, - 9.879150968481590e-01, 9.880132731565830e-01, 9.881156946084619e-01, 9.882211314188272e-01, - 9.883289032519310e-01, 9.884378310018685e-01, 9.885476787868710e-01, 9.886568414746639e-01, - 9.887645868459630e-01, 9.888708540445242e-01, 9.889744320992592e-01, 9.890747269455915e-01, - 9.891710038703801e-01, 9.892631024032380e-01, 9.893507219573624e-01, 9.894330645494204e-01, - 9.895096919388534e-01, 9.895810813422480e-01, 9.896467469067676e-01, 9.897067365020641e-01, - 9.897606930400666e-01, 9.898094478563998e-01, 9.898530133261707e-01, 9.898914705684924e-01, - 9.899254194103574e-01, 9.899554202030650e-01, 9.899824494486951e-01, 9.900065116928948e-01, - 9.900284805353695e-01, 9.900497484789281e-01, 9.900709561632662e-01, 9.900928358611601e-01, - 9.901163920607219e-01, 9.901427479709606e-01, 9.901734275350572e-01, 9.902087332329851e-01, - 9.902498637985275e-01, 9.902983686695558e-01, 9.903548501470234e-01, 9.904205084933333e-01, - 9.904959297726740e-01, 9.905825150202904e-01, 9.906812569810133e-01, 9.907922087340426e-01, - 9.909165464981378e-01, 9.910550740962871e-01, 9.912084614290896e-01, 9.913768610980639e-01, - 9.915605826937839e-01, 9.917604214872976e-01, 9.919767175562684e-01, 9.922091101818779e-01, - 9.924579135466506e-01, 9.927231225056266e-01, 9.930049538427406e-01, 9.933027281437943e-01, - 9.936161084869942e-01, 9.939453714404443e-01, 9.942895145656371e-01, 9.946481676207727e-01, - 9.950203031067961e-01, 9.954058173659507e-01, 9.958038713694317e-01, 9.962130271017117e-01, - 9.966324689957675e-01, 9.970615306490058e-01, 9.974990583293081e-01, 9.979437430375855e-01, - 9.983940572002874e-01, 9.988493116887893e-01, 9.993083430214909e-01, 9.997689221333534e-01, - 1.000231131275969e+00, 1.000692135698996e+00, 1.001152013920163e+00, 1.001608526000461e+00, - 1.002060493867275e+00, 1.002507212061815e+00, 1.002947129400411e+00, 1.003378909587027e+00, - 1.003801368578070e+00, 1.004213810320699e+00, 1.004615386562846e+00, 1.005004618375781e+00, - 1.005380628601598e+00, 1.005743282364652e+00, 1.006091510392348e+00, 1.006424907424988e+00, - 1.006742427727669e+00, 1.007044321511378e+00, 1.007330218597112e+00, 1.007599401798709e+00, - 1.007852064386603e+00, 1.008088176165563e+00, 1.008308033204578e+00, 1.008511247273756e+00, - 1.008698144207627e+00, 1.008869515256392e+00, 1.009025659761512e+00, 1.009166718967367e+00, - 1.009293362609020e+00, 1.009406398832440e+00, 1.009507017171120e+00, 1.009595264293017e+00, - 1.009672145744679e+00, 1.009739084785160e+00, 1.009796675060142e+00, 1.009846137382005e+00, - 1.009888083631667e+00, 1.009924092276850e+00, 1.009955384765721e+00, 1.009982268770147e+00, - 1.010006298177305e+00, 1.010028618428735e+00, 1.010050254076988e+00, 1.010071952131355e+00, - 1.010094366238073e+00, 1.010118917317053e+00, 1.010146497096682e+00, 1.010177110711677e+00, - 1.010211755260102e+00, 1.010251003469427e+00, 1.010295468653759e+00, 1.010345234996637e+00, - 1.010400316698172e+00, 1.010461564316351e+00, 1.010528615445659e+00, 1.010601521285347e+00, - 1.010679788081867e+00, 1.010763905869062e+00, 1.010853429760676e+00, 1.010947547074519e+00, - 1.011045953108263e+00, 1.011148486293359e+00, 1.011254397791134e+00, 1.011363082075863e+00, - 1.011473302008831e+00, 1.011584996312149e+00, 1.011697416504599e+00, 1.011808919793469e+00, - 1.011919264025716e+00, 1.012027240794153e+00, 1.012132151631041e+00, 1.012232734564333e+00, - 1.012327560477901e+00, 1.012416383754384e+00, 1.012497890726292e+00, 1.012570434021054e+00, - 1.012633295255708e+00, 1.012685277016726e+00, 1.012725564992284e+00, 1.012752577651415e+00, - 1.012765062889864e+00, 1.012762356719162e+00, 1.012743376077777e+00, 1.012706484200181e+00, - 1.012650842226435e+00, 1.012575427778520e+00, 1.012479473490919e+00, 1.012361105121003e+00, - 1.012219809594718e+00, 1.012054359992419e+00, 1.011864000215460e+00, 1.011647223869087e+00, - 1.011402518267713e+00, 1.011129654652857e+00, 1.010826951260377e+00, 1.010492924436361e+00, - 1.010126353960416e+00, 1.009725892479312e+00, 1.009290060983833e+00, 1.008817301052548e+00, - 1.008305027555130e+00, 1.007752833675443e+00, 1.007157827358150e+00, 1.006518049344503e+00, - 1.005831403532018e+00, 1.005095592119373e+00, 1.004308630055050e+00, 1.003467498305776e+00, - 1.002569500413888e+00, 1.001612710105563e+00, 1.000594272975683e+00, 9.995111701168786e-01, - 9.983609218719522e-01, 9.971409288327860e-01, 9.958488863050556e-01, 9.944818543153893e-01, - 9.930375282832211e-01, 9.915146560759479e-01, 9.899136802423638e-01, 9.881930623810997e-01, - 9.859422591203311e-01, 9.835667898378924e-01, 9.811423034808365e-01, 9.785214441250228e-01, - 9.756636036109838e-01, 9.725453442532574e-01, 9.691456634185092e-01, 9.654406178310209e-01, - 9.614043615076308e-01, 9.570113065179300e-01, 9.522367669696690e-01, 9.470548839544214e-01, - 9.414403740008491e-01, 9.353691612846549e-01, 9.288190093977164e-01, 9.217662887169115e-01, - 9.141896283466009e-01, 9.060694681113471e-01, 8.973891675497357e-01, 8.881332000806269e-01, - 8.782893885841422e-01, 8.678469565343039e-01, 8.567970644671067e-01, 8.451334654019180e-01, - 8.328542805780399e-01, 8.199594783897041e-01, 8.064511006873497e-01, 7.923346478686025e-01, - 7.776204488292163e-01, 7.623206183595970e-01, 7.464486491227057e-01, 7.300205729992958e-01, - 7.130567383226717e-01, 6.955805444755916e-01, 6.776173229836567e-01, 6.591955305148172e-01, - 6.403486426892321e-01, 6.211072197441818e-01, 6.015049275244730e-01, 5.815787608870452e-01, - 5.613674511156324e-01, 5.409188627354076e-01, 5.202736834971303e-01, 4.994780733459294e-01, - 4.785774177949064e-01, 4.576172599874928e-01, 4.366490208265804e-01, 4.157221460415995e-01, - 3.948856590950757e-01, 3.741903189229770e-01, 3.536868899553974e-01, 3.334260017756462e-01, - 3.134586473252229e-01, 2.938337904395871e-01, 2.745992637590817e-01, 2.558030636168172e-01, - 2.374902188466697e-01, 2.197036032185785e-01, 2.024855415115456e-01, 1.858749915117319e-01, - 1.699067802117410e-01, 1.546132267478873e-01, 1.400238206749695e-01, 1.261637395672913e-01, - 1.130534434072719e-01, 1.007084973747940e-01, 8.914024389873081e-02, 7.835612100141792e-02, - 6.835821233920988e-02, 5.914211536028976e-02, 5.069893012340832e-02, 4.301717763585550e-02, - 3.608020726673359e-02, 2.986316337017630e-02, 2.433722657129812e-02, 1.947675241971700e-02, - 1.525710171255895e-02, 1.163787492636240e-02, 8.433087782643718e-03, 4.449668997344735e-03, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; + 2.844096748870385e-03, 1.066976124794342e-02, 1.881355950582949e-02, 2.728156010437695e-02, + 3.607810469851272e-02, 4.520702759803914e-02, 5.467238802204326e-02, 6.447866054615346e-02, + 7.462862199422061e-02, 8.512490568723846e-02, 9.596983987496970e-02, 1.071650779014335e-01, + 1.187115850305241e-01, 1.306101067250375e-01, 1.428596447589721e-01, 1.554584725339102e-01, + 1.684041609371527e-01, 1.816947894623263e-01, 1.953273880886783e-01, 2.092963206850239e-01, + 2.235945635254679e-01, 2.382160219461597e-01, 2.531529721334063e-01, 2.683961570569586e-01, + 2.839361392493072e-01, 2.997624255177811e-01, 3.158619077906196e-01, 3.322210551086769e-01, + 3.488264676990591e-01, 3.656640377499646e-01, 3.827152968157059e-01, 3.999611859760947e-01, + 4.173843265025887e-01, 4.349669624916473e-01, 4.526876397402144e-01, 4.705242008503956e-01, + 4.884539254831315e-01, 5.064545550235134e-01, 5.245006748662190e-01, 5.425674372882107e-01, + 5.606312044701524e-01, 5.786672646386708e-01, 5.966477035050948e-01, 6.145458904162185e-01, + 6.323361944662236e-01, 6.499926319211774e-01, 6.674874032292857e-01, 6.847932667399612e-01, + 7.018835463513400e-01, 7.187322544823347e-01, 7.353128213893310e-01, 7.516001985652684e-01, + 7.675699252273948e-01, 7.831974571624924e-01, 7.984583859818390e-01, 8.133295347030278e-01, + 8.277892271515950e-01, 8.418178561101360e-01, 8.553961300139363e-01, 8.685068980898102e-01, + 8.811334436653052e-01, 8.932596784799233e-01, 9.048748835980528e-01, 9.159657608120536e-01, + 9.265215299450000e-01, 9.365339988633418e-01, 9.459977028429117e-01, 9.549088408436811e-01, + 9.632658122557368e-01, 9.710688896122810e-01, 9.783204156360773e-01, 9.850226760127131e-01, + 9.911792082081333e-01, 9.967989944502682e-01, 1.001894024615659e+00, 1.006474342231823e+00, + 1.010552057109195e+00, 1.014142538208007e+00, 1.017262593268930e+00, 1.019928842669923e+00, + 1.022159867011177e+00, 1.023976320927187e+00, 1.025400734608122e+00, 1.026455340400072e+00, + 1.027164510654160e+00, 1.027552729180790e+00, 1.027644462380432e+00, 1.027463246660797e+00, + 1.027035903410657e+00, 1.026389068000259e+00, 1.025548201799728e+00, 1.024537134749709e+00, + 1.023380803775376e+00, 1.022103695693341e+00, 1.020728359657958e+00, 1.019275334687329e+00, + 1.017765178792830e+00, 1.016217355867531e+00, 1.014665311686846e+00, 1.013249071090664e+00, + 1.011948006992127e+00, 1.010189090179223e+00, 1.008557961167850e+00, 1.007011287608451e+00, + 1.005548764575910e+00, 1.004168417268956e+00, 1.002867268893035e+00, 1.001641769115897e+00, + 1.000489068954641e+00, 9.994060799749374e-01, 9.983898865406841e-01, 9.974370849972721e-01, + 9.965444836911705e-01, 9.957098545943852e-01, 9.949302413030897e-01, 9.942024045863540e-01, + 9.935241604969254e-01, 9.928930430130044e-01, 9.923068103443909e-01, 9.917633778190438e-01, + 9.912597642374404e-01, 9.907954498484041e-01, 9.903677893656558e-01, 9.899751611066148e-01, + 9.896160337369861e-01, 9.892890160408989e-01, 9.889928511129679e-01, 9.887260333430423e-01, + 9.884868721088945e-01, 9.882751039537586e-01, 9.880892168751595e-01, 9.879277114724612e-01, + 9.877898261218510e-01, 9.876743442038471e-01, 9.875807496078497e-01, 9.875072021876561e-01, + 9.874529447589979e-01, 9.874169741527905e-01, 9.873984685207834e-01, 9.873958301311858e-01, + 9.874080027710336e-01, 9.874343401290739e-01, 9.874736235387018e-01, 9.875243137719285e-01, + 9.875856201221135e-01, 9.876563785063032e-01, 9.877358921155149e-01, 9.878225576787804e-01, + 9.879150968481590e-01, 9.880132731565830e-01, 9.881156946084619e-01, 9.882211314188272e-01, + 9.883289032519310e-01, 9.884378310018685e-01, 9.885476787868710e-01, 9.886568414746639e-01, + 9.887645868459630e-01, 9.888708540445242e-01, 9.889744320992592e-01, 9.890747269455915e-01, + 9.891710038703801e-01, 9.892631024032380e-01, 9.893507219573624e-01, 9.894330645494204e-01, + 9.895096919388534e-01, 9.895810813422480e-01, 9.896467469067676e-01, 9.897067365020641e-01, + 9.897606930400666e-01, 9.898094478563998e-01, 9.898530133261707e-01, 9.898914705684924e-01, + 9.899254194103574e-01, 9.899554202030650e-01, 9.899824494486951e-01, 9.900065116928948e-01, + 9.900284805353695e-01, 9.900497484789281e-01, 9.900709561632662e-01, 9.900928358611601e-01, + 9.901163920607219e-01, 9.901427479709606e-01, 9.901734275350572e-01, 9.902087332329851e-01, + 9.902498637985275e-01, 9.902983686695558e-01, 9.903548501470234e-01, 9.904205084933333e-01, + 9.904959297726740e-01, 9.905825150202904e-01, 9.906812569810133e-01, 9.907922087340426e-01, + 9.909165464981378e-01, 9.910550740962871e-01, 9.912084614290896e-01, 9.913768610980639e-01, + 9.915605826937839e-01, 9.917604214872976e-01, 9.919767175562684e-01, 9.922091101818779e-01, + 9.924579135466506e-01, 9.927231225056266e-01, 9.930049538427406e-01, 9.933027281437943e-01, + 9.936161084869942e-01, 9.939453714404443e-01, 9.942895145656371e-01, 9.946481676207727e-01, + 9.950203031067961e-01, 9.954058173659507e-01, 9.958038713694317e-01, 9.962130271017117e-01, + 9.966324689957675e-01, 9.970615306490058e-01, 9.974990583293081e-01, 9.979437430375855e-01, + 9.983940572002874e-01, 9.988493116887893e-01, 9.993083430214909e-01, 9.997689221333534e-01, + 1.000231131275969e+00, 1.000692135698996e+00, 1.001152013920163e+00, 1.001608526000461e+00, + 1.002060493867275e+00, 1.002507212061815e+00, 1.002947129400411e+00, 1.003378909587027e+00, + 1.003801368578070e+00, 1.004213810320699e+00, 1.004615386562846e+00, 1.005004618375781e+00, + 1.005380628601598e+00, 1.005743282364652e+00, 1.006091510392348e+00, 1.006424907424988e+00, + 1.006742427727669e+00, 1.007044321511378e+00, 1.007330218597112e+00, 1.007599401798709e+00, + 1.007852064386603e+00, 1.008088176165563e+00, 1.008308033204578e+00, 1.008511247273756e+00, + 1.008698144207627e+00, 1.008869515256392e+00, 1.009025659761512e+00, 1.009166718967367e+00, + 1.009293362609020e+00, 1.009406398832440e+00, 1.009507017171120e+00, 1.009595264293017e+00, + 1.009672145744679e+00, 1.009739084785160e+00, 1.009796675060142e+00, 1.009846137382005e+00, + 1.009888083631667e+00, 1.009924092276850e+00, 1.009955384765721e+00, 1.009982268770147e+00, + 1.010006298177305e+00, 1.010028618428735e+00, 1.010050254076988e+00, 1.010071952131355e+00, + 1.010094366238073e+00, 1.010118917317053e+00, 1.010146497096682e+00, 1.010177110711677e+00, + 1.010211755260102e+00, 1.010251003469427e+00, 1.010295468653759e+00, 1.010345234996637e+00, + 1.010400316698172e+00, 1.010461564316351e+00, 1.010528615445659e+00, 1.010601521285347e+00, + 1.010679788081867e+00, 1.010763905869062e+00, 1.010853429760676e+00, 1.010947547074519e+00, + 1.011045953108263e+00, 1.011148486293359e+00, 1.011254397791134e+00, 1.011363082075863e+00, + 1.011473302008831e+00, 1.011584996312149e+00, 1.011697416504599e+00, 1.011808919793469e+00, + 1.011919264025716e+00, 1.012027240794153e+00, 1.012132151631041e+00, 1.012232734564333e+00, + 1.012327560477901e+00, 1.012416383754384e+00, 1.012497890726292e+00, 1.012570434021054e+00, + 1.012633295255708e+00, 1.012685277016726e+00, 1.012725564992284e+00, 1.012752577651415e+00, + 1.012765062889864e+00, 1.012762356719162e+00, 1.012743376077777e+00, 1.012706484200181e+00, + 1.012650842226435e+00, 1.012575427778520e+00, 1.012479473490919e+00, 1.012361105121003e+00, + 1.012219809594718e+00, 1.012054359992419e+00, 1.011864000215460e+00, 1.011647223869087e+00, + 1.011402518267713e+00, 1.011129654652857e+00, 1.010826951260377e+00, 1.010492924436361e+00, + 1.010126353960416e+00, 1.009725892479312e+00, 1.009290060983833e+00, 1.008817301052548e+00, + 1.008305027555130e+00, 1.007752833675443e+00, 1.007157827358150e+00, 1.006518049344503e+00, + 1.005831403532018e+00, 1.005095592119373e+00, 1.004308630055050e+00, 1.003467498305776e+00, + 1.002569500413888e+00, 1.001612710105563e+00, 1.000594272975683e+00, 9.995111701168786e-01, + 9.983609218719522e-01, 9.971409288327860e-01, 9.958488863050556e-01, 9.944818543153893e-01, + 9.930375282832211e-01, 9.915146560759479e-01, 9.899136802423638e-01, 9.881930623810997e-01, + 9.859422591203311e-01, 9.835667898378924e-01, 9.811423034808365e-01, 9.785214441250228e-01, + 9.756636036109838e-01, 9.725453442532574e-01, 9.691456634185092e-01, 9.654406178310209e-01, + 9.614043615076308e-01, 9.570113065179300e-01, 9.522367669696690e-01, 9.470548839544214e-01, + 9.414403740008491e-01, 9.353691612846549e-01, 9.288190093977164e-01, 9.217662887169115e-01, + 9.141896283466009e-01, 9.060694681113471e-01, 8.973891675497357e-01, 8.881332000806269e-01, + 8.782893885841422e-01, 8.678469565343039e-01, 8.567970644671067e-01, 8.451334654019180e-01, + 8.328542805780399e-01, 8.199594783897041e-01, 8.064511006873497e-01, 7.923346478686025e-01, + 7.776204488292163e-01, 7.623206183595970e-01, 7.464486491227057e-01, 7.300205729992958e-01, + 7.130567383226717e-01, 6.955805444755916e-01, 6.776173229836567e-01, 6.591955305148172e-01, + 6.403486426892321e-01, 6.211072197441818e-01, 6.015049275244730e-01, 5.815787608870452e-01, + 5.613674511156324e-01, 5.409188627354076e-01, 5.202736834971303e-01, 4.994780733459294e-01, + 4.785774177949064e-01, 4.576172599874928e-01, 4.366490208265804e-01, 4.157221460415995e-01, + 3.948856590950757e-01, 3.741903189229770e-01, 3.536868899553974e-01, 3.334260017756462e-01, + 3.134586473252229e-01, 2.938337904395871e-01, 2.745992637590817e-01, 2.558030636168172e-01, + 2.374902188466697e-01, 2.197036032185785e-01, 2.024855415115456e-01, 1.858749915117319e-01, + 1.699067802117410e-01, 1.546132267478873e-01, 1.400238206749695e-01, 1.261637395672913e-01, + 1.130534434072719e-01, 1.007084973747940e-01, 8.914024389873081e-02, 7.835612100141792e-02, + 6.835821233920988e-02, 5.914211536028976e-02, 5.069893012340832e-02, 4.301717763585550e-02, + 3.608020726673359e-02, 2.986316337017630e-02, 2.433722657129812e-02, 1.947675241971700e-02, + 1.525710171255895e-02, 1.163787492636240e-02, 8.433087782643718e-03, 4.449668997344735e-03, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 +}; const LC3_FLOAT MDCT_WINDOW_480[960] = { -2.353032150516754e-04, -4.619898752628163e-04, -6.262931535610879e-04, -7.929180432976445e-04, @@ -1582,209 +1653,210 @@ const LC3_FLOAT MDCT_WINDOW_480[960] = { -5.665655641133161e-02, -5.330406164482222e-02, -4.983427241976235e-02, -4.624456893420224e-02, -4.253455686336916e-02, -3.870195772538443e-02, -3.474585776145929e-02, -3.066341518682682e-02, -2.645425077642105e-02, -2.211581608120528e-02, -1.764740541599136e-02, -1.304581363895818e-02, - -8.310425696208936e-03, -3.438268661133170e-03, 1.570315476576933e-03, 6.717697635290676e-03, - 1.200477020244778e-02, 1.743398319747869e-02, 2.300642061077823e-02, 2.872481423270595e-02, - 3.458896350634671e-02, 4.060106462625085e-02, 4.676102915752826e-02, 5.307133911821893e-02, - 5.953239090915557e-02, 6.614647812869151e-02, 7.291293184312803e-02, 7.983354189816511e-02, - 8.690807412770696e-02, 9.413813765275064e-02, 1.015233140203748e-01, 1.090651518336202e-01, - 1.167626546016197e-01, 1.246171387327525e-01, 1.326272948938113e-01, 1.407938190608664e-01, - 1.491152519299797e-01, 1.575921408388593e-01, 1.662224799248571e-01, 1.750067399059861e-01, - 1.839431938620024e-01, 1.930318183054904e-01, 2.022699854906251e-01, 2.116567430906184e-01, - 2.211888523410642e-01, 2.308655379767671e-01, 2.406837992341654e-01, 2.506420640291662e-01, - 2.607365124918583e-01, 2.709659073501196e-01, 2.813259021832532e-01, 2.918144694729168e-01, - 3.024270279840051e-01, 3.131603499997996e-01, 3.240095704645023e-01, 3.349719592361666e-01, - 3.460422935204829e-01, 3.572175180786021e-01, 3.684915649120530e-01, 3.798595119591716e-01, - 3.913146885756875e-01, 4.028532873867052e-01, 4.144688328137527e-01, 4.261571642320424e-01, - 4.379113897565727e-01, 4.497256320417501e-01, 4.615925445090212e-01, 4.735067030065239e-01, - 4.854600184866710e-01, 4.974471592901086e-01, 5.094597228333853e-01, 5.214909841729947e-01, - 5.335326819631583e-01, 5.455789811615239e-01, 5.576217157959890e-01, 5.696546730080154e-01, - 5.816685576268035e-01, 5.936560624526468e-01, 6.056083823929643e-01, 6.175192060085208e-01, - 6.293796611336280e-01, 6.411830842823245e-01, 6.529203544876097e-01, 6.645840786371451e-01, - 6.761653499550255e-01, 6.876573952173626e-01, 6.990511539119996e-01, 7.103400549562944e-01, - 7.215149331458728e-01, 7.325691772738999e-01, 7.434943718765665e-01, 7.542846327442048e-01, - 7.649313654540612e-01, 7.754281892901473e-01, 7.857670170752049e-01, 7.959414651061612e-01, - 8.059437233154637e-01, 8.157687070715176e-01, 8.254086223972127e-01, 8.348589373399948e-01, - 8.441125827416620e-01, 8.531651194538425e-01, 8.620108336276733e-01, 8.706456337542150e-01, - 8.790631561061171e-01, 8.872599706865123e-01, 8.952313288619367e-01, 9.029751680353524e-01, - 9.104863121445679e-01, 9.177625550620636e-01, 9.247997426966093e-01, 9.315962496426278e-01, - 9.381494858921667e-01, 9.444588390359354e-01, 9.505220861927248e-01, 9.563402921286364e-01, - 9.619114522936701e-01, 9.672366712325431e-01, 9.723156637834687e-01, 9.771501187120180e-01, - 9.817397501303696e-01, 9.860865871353246e-01, 9.901906380163595e-01, 9.940557180662704e-01, - 9.976842395284637e-01, 1.001080961257010e+00, 1.004247514102417e+00, 1.007188578458507e+00, - 1.009906654565108e+00, 1.012407428282884e+00, 1.014694702432600e+00, 1.016774659209400e+00, - 1.018650990561848e+00, 1.020330464463111e+00, 1.021817328911793e+00, 1.023118841384460e+00, - 1.024240262467000e+00, 1.025189721888128e+00, 1.025972450969440e+00, 1.026596938589443e+00, - 1.027069179375841e+00, 1.027397523939210e+00, 1.027587902203109e+00, 1.027648951922701e+00, - 1.027585830688143e+00, 1.027408519661012e+00, 1.027122986826984e+00, 1.026738673647482e+00, - 1.026261663878092e+00, 1.025701002415063e+00, 1.025061777648234e+00, 1.024353980976701e+00, - 1.023582385618774e+00, 1.022756514615106e+00, 1.021880604350422e+00, 1.020963871317665e+00, - 1.020009139549275e+00, 1.019027285501251e+00, 1.018019442784231e+00, 1.016996499560845e+00, - 1.015957433206324e+00, 1.014923441259795e+00, 1.013915946100629e+00, 1.013047565149327e+00, - 1.012216130365610e+00, 1.011044869639164e+00, 1.009914592130044e+00, 1.008824888092573e+00, - 1.007773858455400e+00, 1.006761700412993e+00, 1.005786648810854e+00, 1.004848753962734e+00, - 1.003946083413733e+00, 1.003078846506546e+00, 1.002245009135684e+00, 1.001444733905817e+00, - 1.000676188436651e+00, 9.999393169239009e-01, 9.992320848298057e-01, 9.985548127155425e-01, - 9.979055415627330e-01, 9.972842679758880e-01, 9.966890948441745e-01, 9.961203379971326e-01, - 9.955761256313581e-01, 9.950565724564597e-01, 9.945597525471822e-01, 9.940860378486615e-01, - 9.936337788972491e-01, 9.932031606606759e-01, 9.927921871265732e-01, 9.924015177880798e-01, - 9.920297273323891e-01, 9.916767775088281e-01, 9.913408767719142e-01, 9.910230654424902e-01, - 9.907216425865902e-01, 9.904366799536263e-01, 9.901668953434221e-01, 9.899131011580791e-01, - 9.896735637374597e-01, 9.894488374513719e-01, 9.892374835404283e-01, 9.890401927796704e-01, - 9.888556356037892e-01, 9.886843467692753e-01, 9.885247606051014e-01, 9.883778520531268e-01, - 9.882423270582524e-01, 9.881185638915363e-01, 9.880051626345804e-01, 9.879032023766432e-01, - 9.878111744348976e-01, 9.877295459610343e-01, 9.876571983429736e-01, 9.875949843246187e-01, - 9.875412739766566e-01, 9.874969061399389e-01, 9.874606249127551e-01, 9.874329809802893e-01, - 9.874126414437681e-01, 9.874004750404033e-01, 9.873949921033299e-01, 9.873969162747074e-01, - 9.874049060317581e-01, 9.874197049003676e-01, 9.874399717110517e-01, 9.874663281231737e-01, - 9.874973205882319e-01, 9.875338926695315e-01, 9.875746535410983e-01, 9.876201238703241e-01, - 9.876689801932402e-01, 9.877221556193183e-01, 9.877781920433015e-01, 9.878376489591358e-01, - 9.878991990245439e-01, 9.879637979933339e-01, 9.880300303653743e-01, 9.880984675859855e-01, - 9.881678007807095e-01, 9.882390300097154e-01, 9.883107693992456e-01, 9.883835200189653e-01, - 9.884560159878955e-01, 9.885294200392185e-01, 9.886022219397892e-01, 9.886749404176028e-01, - 9.887466261142505e-01, 9.888182771263505e-01, 9.888882480852147e-01, 9.889574384705896e-01, - 9.890247977602895e-01, 9.890911247701029e-01, 9.891551701556196e-01, 9.892178658748239e-01, - 9.892779555818088e-01, 9.893365186903538e-01, 9.893923680007577e-01, 9.894462830852175e-01, - 9.894972124952000e-01, 9.895463342815009e-01, 9.895923617530382e-01, 9.896362652966239e-01, - 9.896772011542693e-01, 9.897162195263046e-01, 9.897520286480039e-01, 9.897859195209235e-01, - 9.898170267411330e-01, 9.898462068764986e-01, 9.898725363809847e-01, 9.898975138787787e-01, - 9.899200050208486e-01, 9.899410789223559e-01, 9.899600605054418e-01, 9.899782261038060e-01, - 9.899945557067980e-01, 9.900103500807507e-01, 9.900248320990181e-01, 9.900394023736973e-01, - 9.900532105829365e-01, 9.900674746047259e-01, 9.900814722948890e-01, 9.900966926051257e-01, - 9.901122448734595e-01, 9.901293790312005e-01, 9.901474648912307e-01, 9.901680598867444e-01, - 9.901902265696609e-01, 9.902151896501201e-01, 9.902424418296485e-01, 9.902734448815004e-01, - 9.903071270768942e-01, 9.903448913950654e-01, 9.903862280081246e-01, 9.904324484666853e-01, - 9.904825650601110e-01, 9.905379830873822e-01, 9.905980602136440e-01, 9.906640366554630e-01, - 9.907348826312993e-01, 9.908120376822228e-01, 9.908947858311721e-01, 9.909842592301273e-01, - 9.910795247770178e-01, 9.911819240108124e-01, 9.912905118607647e-01, 9.914064705361564e-01, - 9.915288011543961e-01, 9.916586940166509e-01, 9.917952720685562e-01, 9.919396217291009e-01, - 9.920906151219310e-01, 9.922495028313456e-01, 9.924152398352751e-01, 9.925887208794144e-01, - 9.927688708468421e-01, 9.929569112537944e-01, 9.931516528513824e-01, 9.933539244159140e-01, - 9.935626893131695e-01, 9.937790866568735e-01, 9.940016434044485e-01, 9.942312024833810e-01, - 9.944668184371617e-01, 9.947093441694513e-01, 9.949572854565533e-01, 9.952116634297566e-01, - 9.954712635321227e-01, 9.957367951478069e-01, 9.960068616185641e-01, 9.962823025614079e-01, - 9.965617986382630e-01, 9.968461329825753e-01, 9.971338271912752e-01, 9.974256691222113e-01, - 9.977203369515556e-01, 9.980185087055744e-01, 9.983185871761977e-01, 9.986213520769593e-01, - 9.989255426466267e-01, 9.992317314100975e-01, 9.995382582242990e-01, 9.998461160718275e-01, - 1.000153907612080e+00, 1.000461955079660e+00, 1.000768859280338e+00, 1.001075613053728e+00, - 1.001380551217109e+00, 1.001684244734497e+00, 1.001985425397567e+00, 1.002284871786226e+00, - 1.002580975161843e+00, 1.002874411368430e+00, 1.003163845364970e+00, 1.003450063374329e+00, - 1.003731570287893e+00, 1.004009147462043e+00, 1.004281457582935e+00, 1.004549339226336e+00, - 1.004811375053364e+00, 1.005068272394360e+00, 1.005318795748286e+00, 1.005563968008037e+00, - 1.005802269635282e+00, 1.006034554002353e+00, 1.006259855360867e+00, 1.006479018139540e+00, - 1.006690541428116e+00, 1.006895570408563e+00, 1.007093045696527e+00, 1.007283799246233e+00, - 1.007466616298057e+00, 1.007642728426847e+00, 1.007811036585595e+00, 1.007972441990187e+00, - 1.008125875904472e+00, 1.008272602383284e+00, 1.008411468616852e+00, 1.008543573152632e+00, - 1.008668018334797e+00, 1.008786009787269e+00, 1.008896526233555e+00, 1.009000766336071e+00, - 1.009097763850333e+00, 1.009188880897370e+00, 1.009273163797313e+00, 1.009351762546296e+00, - 1.009423944949143e+00, 1.009491175244507e+00, 1.009552401900961e+00, 1.009608886895764e+00, - 1.009659973830751e+00, 1.009707093778162e+00, 1.009749238562067e+00, 1.009787744284661e+00, - 1.009822090220407e+00, 1.009853706282597e+00, 1.009881498943010e+00, 1.009906958448099e+00, - 1.009929567021562e+00, 1.009950573483366e+00, 1.009969021400474e+00, 1.009986499185054e+00, - 1.010002363879044e+00, 1.010017890428877e+00, 1.010032170180360e+00, 1.010046722045583e+00, - 1.010060809299530e+00, 1.010075674445289e+00, 1.010090449982098e+00, 1.010106564965965e+00, - 1.010123226584120e+00, 1.010141762173145e+00, 1.010161131093372e+00, 1.010182635897876e+00, - 1.010205587931660e+00, 1.010231078494249e+00, 1.010257950227988e+00, 1.010287732968580e+00, - 1.010319484524512e+00, 1.010354079663767e+00, 1.010390635488037e+00, 1.010430470494512e+00, - 1.010472266495074e+00, 1.010517096381509e+00, 1.010564099281000e+00, 1.010614266894512e+00, - 1.010666285876455e+00, 1.010721360243234e+00, 1.010778416755264e+00, 1.010838252644461e+00, - 1.010899655674578e+00, 1.010963729626641e+00, 1.011029191301694e+00, 1.011096993993037e+00, - 1.011165861239173e+00, 1.011236610341260e+00, 1.011308167670753e+00, 1.011381453638912e+00, - 1.011454785713102e+00, 1.011529185153809e+00, 1.011603680910505e+00, 1.011678803938046e+00, - 1.011753008569803e+00, 1.011827484797985e+00, 1.011900936547881e+00, 1.011973876511603e+00, - 1.012044885003304e+00, 1.012114985644919e+00, 1.012182837094955e+00, 1.012249023976742e+00, - 1.012312095063070e+00, 1.012373028737774e+00, 1.012430463679316e+00, 1.012484972246822e+00, - 1.012535058602453e+00, 1.012581678169188e+00, 1.012623472898504e+00, 1.012660975529858e+00, - 1.012692758750213e+00, 1.012719789201144e+00, 1.012740575296603e+00, 1.012755753887085e+00, - 1.012763948841204e+00, 1.012765922449960e+00, 1.012760298661069e+00, 1.012747819936584e+00, - 1.012726958954961e+00, 1.012698607692183e+00, 1.012661400539405e+00, 1.012615904116265e+00, - 1.012560833005713e+00, 1.012497050269805e+00, 1.012422888521601e+00, 1.012339226241367e+00, - 1.012244921966297e+00, 1.012140460211194e+00, 1.012024302085441e+00, 1.011897560567707e+00, - 1.011758810583150e+00, 1.011608449127642e+00, 1.011445162723270e+00, 1.011269960947744e+00, - 1.011081255645969e+00, 1.010879608424312e+00, 1.010663676735228e+00, 1.010434184200640e+00, - 1.010189681124657e+00, 1.009930754807923e+00, 1.009655660215271e+00, 1.009365251564694e+00, - 1.009058249873833e+00, 1.008734758578989e+00, 1.008393079963091e+00, 1.008034308295421e+00, - 1.007656661215973e+00, 1.007260142622887e+00, 1.006843352506855e+00, 1.006407009542103e+00, - 1.005949145170711e+00, 1.005470005637052e+00, 1.004967986424467e+00, 1.004443531995945e+00, - 1.003894772403371e+00, 1.003321903663793e+00, 1.002723127308148e+00, 1.002098854400575e+00, - 1.001447278873483e+00, 1.000768505317086e+00, 1.000060686758758e+00, 9.993242684851855e-01, - 9.985573503390627e-01, 9.977600196406868e-01, 9.969306036935497e-01, 9.960694269553644e-01, - 9.951746430061121e-01, 9.942466438407230e-01, 9.932837131068657e-01, 9.922861082472264e-01, - 9.912523092989319e-01, 9.901827419790691e-01, 9.890757868707590e-01, 9.879313024174022e-01, - 9.863553220272523e-01, 9.847362453480265e-01, 9.831750948772566e-01, 9.815583336011345e-01, - 9.798613526271561e-01, 9.780617486993630e-01, 9.761574317374303e-01, 9.741378617337759e-01, - 9.719990112065752e-01, 9.697327413658168e-01, 9.673331975559332e-01, 9.647915124057732e-01, - 9.621011497566145e-01, 9.592539757044516e-01, 9.562427177295731e-01, 9.530600909726344e-01, - 9.496984081652284e-01, 9.461498120176854e-01, 9.424071613625743e-01, 9.384634163826711e-01, - 9.343112966094085e-01, 9.299449872197452e-01, 9.253567968750328e-01, 9.205404627076625e-01, - 9.154896280575360e-01, 9.101986790930605e-01, 9.046620597741508e-01, 8.988755194372424e-01, - 8.928338316495705e-01, 8.865337190368053e-01, 8.799712722567934e-01, 8.731437835983047e-01, - 8.660476534563131e-01, 8.586812520174252e-01, 8.510420440685049e-01, 8.431297226886574e-01, - 8.349435141989714e-01, 8.264839911291133e-01, 8.177505366573690e-01, 8.087449817124315e-01, - 7.994681492797084e-01, 7.899235162194718e-01, 7.801137731566502e-01, 7.700431275216928e-01, - 7.597145736971065e-01, 7.491330971820804e-01, 7.383028603058783e-01, 7.272298755824693e-01, - 7.159201919962611e-01, 7.043814340356083e-01, 6.926196927377140e-01, 6.806438831866077e-01, - 6.684616478236647e-01, 6.560830137986515e-01, 6.435179268559957e-01, 6.307755329382612e-01, - 6.178641647786525e-01, 6.047954625702541e-01, 5.915799587176216e-01, 5.782289366005894e-01, - 5.647535885752191e-01, 5.511703155400274e-01, 5.374905090437071e-01, 5.237263500445715e-01, - 5.098915423728255e-01, 4.960008074926423e-01, 4.820662943337458e-01, 4.681017110048007e-01, - 4.541216995958746e-01, 4.401421815729068e-01, 4.261772971493010e-01, 4.122417888542512e-01, - 3.983499612526493e-01, 3.845172335531009e-01, 3.707583717376236e-01, 3.570886786795506e-01, - 3.435228672445627e-01, 3.300763764703638e-01, 3.167640325043893e-01, 3.036004651973109e-01, - 2.905996158436682e-01, 2.777758503744847e-01, 2.651434678028531e-01, 2.527161881181577e-01, - 2.405069849650012e-01, 2.285283969438072e-01, 2.167933432162879e-01, 2.053139897833021e-01, - 1.941021906320988e-01, 1.831680872008943e-01, 1.725221947208913e-01, 1.621735416384834e-01, - 1.521320683467849e-01, 1.424052801149985e-01, 1.330015240938615e-01, 1.239260664828526e-01, - 1.151858295527293e-01, 1.067840430193724e-01, 9.872637505002878e-02, 9.101379000888035e-02, - 8.365057236623055e-02, 7.663508305536153e-02, 6.997033405748826e-02, 6.365188111381365e-02, - 5.768176015814392e-02, 5.205244216987966e-02, 4.676538412257621e-02, 4.180950541438362e-02, - 3.718640251368464e-02, 3.288072750732215e-02, 2.889548499582958e-02, 2.520980565928884e-02, - 2.183057564646272e-02, 1.872896194002638e-02, 1.592127815153420e-02, 1.336381425803020e-02, - 1.108558877807282e-02, 8.943474189364638e-03, 6.758124889697787e-03, 3.504438130619497e-03, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; + -8.310425696208936e-03, -3.438268661133170e-03, 1.570315476576933e-03, 6.717697635290676e-03, + 1.200477020244778e-02, 1.743398319747869e-02, 2.300642061077823e-02, 2.872481423270595e-02, + 3.458896350634671e-02, 4.060106462625085e-02, 4.676102915752826e-02, 5.307133911821893e-02, + 5.953239090915557e-02, 6.614647812869151e-02, 7.291293184312803e-02, 7.983354189816511e-02, + 8.690807412770696e-02, 9.413813765275064e-02, 1.015233140203748e-01, 1.090651518336202e-01, + 1.167626546016197e-01, 1.246171387327525e-01, 1.326272948938113e-01, 1.407938190608664e-01, + 1.491152519299797e-01, 1.575921408388593e-01, 1.662224799248571e-01, 1.750067399059861e-01, + 1.839431938620024e-01, 1.930318183054904e-01, 2.022699854906251e-01, 2.116567430906184e-01, + 2.211888523410642e-01, 2.308655379767671e-01, 2.406837992341654e-01, 2.506420640291662e-01, + 2.607365124918583e-01, 2.709659073501196e-01, 2.813259021832532e-01, 2.918144694729168e-01, + 3.024270279840051e-01, 3.131603499997996e-01, 3.240095704645023e-01, 3.349719592361666e-01, + 3.460422935204829e-01, 3.572175180786021e-01, 3.684915649120530e-01, 3.798595119591716e-01, + 3.913146885756875e-01, 4.028532873867052e-01, 4.144688328137527e-01, 4.261571642320424e-01, + 4.379113897565727e-01, 4.497256320417501e-01, 4.615925445090212e-01, 4.735067030065239e-01, + 4.854600184866710e-01, 4.974471592901086e-01, 5.094597228333853e-01, 5.214909841729947e-01, + 5.335326819631583e-01, 5.455789811615239e-01, 5.576217157959890e-01, 5.696546730080154e-01, + 5.816685576268035e-01, 5.936560624526468e-01, 6.056083823929643e-01, 6.175192060085208e-01, + 6.293796611336280e-01, 6.411830842823245e-01, 6.529203544876097e-01, 6.645840786371451e-01, + 6.761653499550255e-01, 6.876573952173626e-01, 6.990511539119996e-01, 7.103400549562944e-01, + 7.215149331458728e-01, 7.325691772738999e-01, 7.434943718765665e-01, 7.542846327442048e-01, + 7.649313654540612e-01, 7.754281892901473e-01, 7.857670170752049e-01, 7.959414651061612e-01, + 8.059437233154637e-01, 8.157687070715176e-01, 8.254086223972127e-01, 8.348589373399948e-01, + 8.441125827416620e-01, 8.531651194538425e-01, 8.620108336276733e-01, 8.706456337542150e-01, + 8.790631561061171e-01, 8.872599706865123e-01, 8.952313288619367e-01, 9.029751680353524e-01, + 9.104863121445679e-01, 9.177625550620636e-01, 9.247997426966093e-01, 9.315962496426278e-01, + 9.381494858921667e-01, 9.444588390359354e-01, 9.505220861927248e-01, 9.563402921286364e-01, + 9.619114522936701e-01, 9.672366712325431e-01, 9.723156637834687e-01, 9.771501187120180e-01, + 9.817397501303696e-01, 9.860865871353246e-01, 9.901906380163595e-01, 9.940557180662704e-01, + 9.976842395284637e-01, 1.001080961257010e+00, 1.004247514102417e+00, 1.007188578458507e+00, + 1.009906654565108e+00, 1.012407428282884e+00, 1.014694702432600e+00, 1.016774659209400e+00, + 1.018650990561848e+00, 1.020330464463111e+00, 1.021817328911793e+00, 1.023118841384460e+00, + 1.024240262467000e+00, 1.025189721888128e+00, 1.025972450969440e+00, 1.026596938589443e+00, + 1.027069179375841e+00, 1.027397523939210e+00, 1.027587902203109e+00, 1.027648951922701e+00, + 1.027585830688143e+00, 1.027408519661012e+00, 1.027122986826984e+00, 1.026738673647482e+00, + 1.026261663878092e+00, 1.025701002415063e+00, 1.025061777648234e+00, 1.024353980976701e+00, + 1.023582385618774e+00, 1.022756514615106e+00, 1.021880604350422e+00, 1.020963871317665e+00, + 1.020009139549275e+00, 1.019027285501251e+00, 1.018019442784231e+00, 1.016996499560845e+00, + 1.015957433206324e+00, 1.014923441259795e+00, 1.013915946100629e+00, 1.013047565149327e+00, + 1.012216130365610e+00, 1.011044869639164e+00, 1.009914592130044e+00, 1.008824888092573e+00, + 1.007773858455400e+00, 1.006761700412993e+00, 1.005786648810854e+00, 1.004848753962734e+00, + 1.003946083413733e+00, 1.003078846506546e+00, 1.002245009135684e+00, 1.001444733905817e+00, + 1.000676188436651e+00, 9.999393169239009e-01, 9.992320848298057e-01, 9.985548127155425e-01, + 9.979055415627330e-01, 9.972842679758880e-01, 9.966890948441745e-01, 9.961203379971326e-01, + 9.955761256313581e-01, 9.950565724564597e-01, 9.945597525471822e-01, 9.940860378486615e-01, + 9.936337788972491e-01, 9.932031606606759e-01, 9.927921871265732e-01, 9.924015177880798e-01, + 9.920297273323891e-01, 9.916767775088281e-01, 9.913408767719142e-01, 9.910230654424902e-01, + 9.907216425865902e-01, 9.904366799536263e-01, 9.901668953434221e-01, 9.899131011580791e-01, + 9.896735637374597e-01, 9.894488374513719e-01, 9.892374835404283e-01, 9.890401927796704e-01, + 9.888556356037892e-01, 9.886843467692753e-01, 9.885247606051014e-01, 9.883778520531268e-01, + 9.882423270582524e-01, 9.881185638915363e-01, 9.880051626345804e-01, 9.879032023766432e-01, + 9.878111744348976e-01, 9.877295459610343e-01, 9.876571983429736e-01, 9.875949843246187e-01, + 9.875412739766566e-01, 9.874969061399389e-01, 9.874606249127551e-01, 9.874329809802893e-01, + 9.874126414437681e-01, 9.874004750404033e-01, 9.873949921033299e-01, 9.873969162747074e-01, + 9.874049060317581e-01, 9.874197049003676e-01, 9.874399717110517e-01, 9.874663281231737e-01, + 9.874973205882319e-01, 9.875338926695315e-01, 9.875746535410983e-01, 9.876201238703241e-01, + 9.876689801932402e-01, 9.877221556193183e-01, 9.877781920433015e-01, 9.878376489591358e-01, + 9.878991990245439e-01, 9.879637979933339e-01, 9.880300303653743e-01, 9.880984675859855e-01, + 9.881678007807095e-01, 9.882390300097154e-01, 9.883107693992456e-01, 9.883835200189653e-01, + 9.884560159878955e-01, 9.885294200392185e-01, 9.886022219397892e-01, 9.886749404176028e-01, + 9.887466261142505e-01, 9.888182771263505e-01, 9.888882480852147e-01, 9.889574384705896e-01, + 9.890247977602895e-01, 9.890911247701029e-01, 9.891551701556196e-01, 9.892178658748239e-01, + 9.892779555818088e-01, 9.893365186903538e-01, 9.893923680007577e-01, 9.894462830852175e-01, + 9.894972124952000e-01, 9.895463342815009e-01, 9.895923617530382e-01, 9.896362652966239e-01, + 9.896772011542693e-01, 9.897162195263046e-01, 9.897520286480039e-01, 9.897859195209235e-01, + 9.898170267411330e-01, 9.898462068764986e-01, 9.898725363809847e-01, 9.898975138787787e-01, + 9.899200050208486e-01, 9.899410789223559e-01, 9.899600605054418e-01, 9.899782261038060e-01, + 9.899945557067980e-01, 9.900103500807507e-01, 9.900248320990181e-01, 9.900394023736973e-01, + 9.900532105829365e-01, 9.900674746047259e-01, 9.900814722948890e-01, 9.900966926051257e-01, + 9.901122448734595e-01, 9.901293790312005e-01, 9.901474648912307e-01, 9.901680598867444e-01, + 9.901902265696609e-01, 9.902151896501201e-01, 9.902424418296485e-01, 9.902734448815004e-01, + 9.903071270768942e-01, 9.903448913950654e-01, 9.903862280081246e-01, 9.904324484666853e-01, + 9.904825650601110e-01, 9.905379830873822e-01, 9.905980602136440e-01, 9.906640366554630e-01, + 9.907348826312993e-01, 9.908120376822228e-01, 9.908947858311721e-01, 9.909842592301273e-01, + 9.910795247770178e-01, 9.911819240108124e-01, 9.912905118607647e-01, 9.914064705361564e-01, + 9.915288011543961e-01, 9.916586940166509e-01, 9.917952720685562e-01, 9.919396217291009e-01, + 9.920906151219310e-01, 9.922495028313456e-01, 9.924152398352751e-01, 9.925887208794144e-01, + 9.927688708468421e-01, 9.929569112537944e-01, 9.931516528513824e-01, 9.933539244159140e-01, + 9.935626893131695e-01, 9.937790866568735e-01, 9.940016434044485e-01, 9.942312024833810e-01, + 9.944668184371617e-01, 9.947093441694513e-01, 9.949572854565533e-01, 9.952116634297566e-01, + 9.954712635321227e-01, 9.957367951478069e-01, 9.960068616185641e-01, 9.962823025614079e-01, + 9.965617986382630e-01, 9.968461329825753e-01, 9.971338271912752e-01, 9.974256691222113e-01, + 9.977203369515556e-01, 9.980185087055744e-01, 9.983185871761977e-01, 9.986213520769593e-01, + 9.989255426466267e-01, 9.992317314100975e-01, 9.995382582242990e-01, 9.998461160718275e-01, + 1.000153907612080e+00, 1.000461955079660e+00, 1.000768859280338e+00, 1.001075613053728e+00, + 1.001380551217109e+00, 1.001684244734497e+00, 1.001985425397567e+00, 1.002284871786226e+00, + 1.002580975161843e+00, 1.002874411368430e+00, 1.003163845364970e+00, 1.003450063374329e+00, + 1.003731570287893e+00, 1.004009147462043e+00, 1.004281457582935e+00, 1.004549339226336e+00, + 1.004811375053364e+00, 1.005068272394360e+00, 1.005318795748286e+00, 1.005563968008037e+00, + 1.005802269635282e+00, 1.006034554002353e+00, 1.006259855360867e+00, 1.006479018139540e+00, + 1.006690541428116e+00, 1.006895570408563e+00, 1.007093045696527e+00, 1.007283799246233e+00, + 1.007466616298057e+00, 1.007642728426847e+00, 1.007811036585595e+00, 1.007972441990187e+00, + 1.008125875904472e+00, 1.008272602383284e+00, 1.008411468616852e+00, 1.008543573152632e+00, + 1.008668018334797e+00, 1.008786009787269e+00, 1.008896526233555e+00, 1.009000766336071e+00, + 1.009097763850333e+00, 1.009188880897370e+00, 1.009273163797313e+00, 1.009351762546296e+00, + 1.009423944949143e+00, 1.009491175244507e+00, 1.009552401900961e+00, 1.009608886895764e+00, + 1.009659973830751e+00, 1.009707093778162e+00, 1.009749238562067e+00, 1.009787744284661e+00, + 1.009822090220407e+00, 1.009853706282597e+00, 1.009881498943010e+00, 1.009906958448099e+00, + 1.009929567021562e+00, 1.009950573483366e+00, 1.009969021400474e+00, 1.009986499185054e+00, + 1.010002363879044e+00, 1.010017890428877e+00, 1.010032170180360e+00, 1.010046722045583e+00, + 1.010060809299530e+00, 1.010075674445289e+00, 1.010090449982098e+00, 1.010106564965965e+00, + 1.010123226584120e+00, 1.010141762173145e+00, 1.010161131093372e+00, 1.010182635897876e+00, + 1.010205587931660e+00, 1.010231078494249e+00, 1.010257950227988e+00, 1.010287732968580e+00, + 1.010319484524512e+00, 1.010354079663767e+00, 1.010390635488037e+00, 1.010430470494512e+00, + 1.010472266495074e+00, 1.010517096381509e+00, 1.010564099281000e+00, 1.010614266894512e+00, + 1.010666285876455e+00, 1.010721360243234e+00, 1.010778416755264e+00, 1.010838252644461e+00, + 1.010899655674578e+00, 1.010963729626641e+00, 1.011029191301694e+00, 1.011096993993037e+00, + 1.011165861239173e+00, 1.011236610341260e+00, 1.011308167670753e+00, 1.011381453638912e+00, + 1.011454785713102e+00, 1.011529185153809e+00, 1.011603680910505e+00, 1.011678803938046e+00, + 1.011753008569803e+00, 1.011827484797985e+00, 1.011900936547881e+00, 1.011973876511603e+00, + 1.012044885003304e+00, 1.012114985644919e+00, 1.012182837094955e+00, 1.012249023976742e+00, + 1.012312095063070e+00, 1.012373028737774e+00, 1.012430463679316e+00, 1.012484972246822e+00, + 1.012535058602453e+00, 1.012581678169188e+00, 1.012623472898504e+00, 1.012660975529858e+00, + 1.012692758750213e+00, 1.012719789201144e+00, 1.012740575296603e+00, 1.012755753887085e+00, + 1.012763948841204e+00, 1.012765922449960e+00, 1.012760298661069e+00, 1.012747819936584e+00, + 1.012726958954961e+00, 1.012698607692183e+00, 1.012661400539405e+00, 1.012615904116265e+00, + 1.012560833005713e+00, 1.012497050269805e+00, 1.012422888521601e+00, 1.012339226241367e+00, + 1.012244921966297e+00, 1.012140460211194e+00, 1.012024302085441e+00, 1.011897560567707e+00, + 1.011758810583150e+00, 1.011608449127642e+00, 1.011445162723270e+00, 1.011269960947744e+00, + 1.011081255645969e+00, 1.010879608424312e+00, 1.010663676735228e+00, 1.010434184200640e+00, + 1.010189681124657e+00, 1.009930754807923e+00, 1.009655660215271e+00, 1.009365251564694e+00, + 1.009058249873833e+00, 1.008734758578989e+00, 1.008393079963091e+00, 1.008034308295421e+00, + 1.007656661215973e+00, 1.007260142622887e+00, 1.006843352506855e+00, 1.006407009542103e+00, + 1.005949145170711e+00, 1.005470005637052e+00, 1.004967986424467e+00, 1.004443531995945e+00, + 1.003894772403371e+00, 1.003321903663793e+00, 1.002723127308148e+00, 1.002098854400575e+00, + 1.001447278873483e+00, 1.000768505317086e+00, 1.000060686758758e+00, 9.993242684851855e-01, + 9.985573503390627e-01, 9.977600196406868e-01, 9.969306036935497e-01, 9.960694269553644e-01, + 9.951746430061121e-01, 9.942466438407230e-01, 9.932837131068657e-01, 9.922861082472264e-01, + 9.912523092989319e-01, 9.901827419790691e-01, 9.890757868707590e-01, 9.879313024174022e-01, + 9.863553220272523e-01, 9.847362453480265e-01, 9.831750948772566e-01, 9.815583336011345e-01, + 9.798613526271561e-01, 9.780617486993630e-01, 9.761574317374303e-01, 9.741378617337759e-01, + 9.719990112065752e-01, 9.697327413658168e-01, 9.673331975559332e-01, 9.647915124057732e-01, + 9.621011497566145e-01, 9.592539757044516e-01, 9.562427177295731e-01, 9.530600909726344e-01, + 9.496984081652284e-01, 9.461498120176854e-01, 9.424071613625743e-01, 9.384634163826711e-01, + 9.343112966094085e-01, 9.299449872197452e-01, 9.253567968750328e-01, 9.205404627076625e-01, + 9.154896280575360e-01, 9.101986790930605e-01, 9.046620597741508e-01, 8.988755194372424e-01, + 8.928338316495705e-01, 8.865337190368053e-01, 8.799712722567934e-01, 8.731437835983047e-01, + 8.660476534563131e-01, 8.586812520174252e-01, 8.510420440685049e-01, 8.431297226886574e-01, + 8.349435141989714e-01, 8.264839911291133e-01, 8.177505366573690e-01, 8.087449817124315e-01, + 7.994681492797084e-01, 7.899235162194718e-01, 7.801137731566502e-01, 7.700431275216928e-01, + 7.597145736971065e-01, 7.491330971820804e-01, 7.383028603058783e-01, 7.272298755824693e-01, + 7.159201919962611e-01, 7.043814340356083e-01, 6.926196927377140e-01, 6.806438831866077e-01, + 6.684616478236647e-01, 6.560830137986515e-01, 6.435179268559957e-01, 6.307755329382612e-01, + 6.178641647786525e-01, 6.047954625702541e-01, 5.915799587176216e-01, 5.782289366005894e-01, + 5.647535885752191e-01, 5.511703155400274e-01, 5.374905090437071e-01, 5.237263500445715e-01, + 5.098915423728255e-01, 4.960008074926423e-01, 4.820662943337458e-01, 4.681017110048007e-01, + 4.541216995958746e-01, 4.401421815729068e-01, 4.261772971493010e-01, 4.122417888542512e-01, + 3.983499612526493e-01, 3.845172335531009e-01, 3.707583717376236e-01, 3.570886786795506e-01, + 3.435228672445627e-01, 3.300763764703638e-01, 3.167640325043893e-01, 3.036004651973109e-01, + 2.905996158436682e-01, 2.777758503744847e-01, 2.651434678028531e-01, 2.527161881181577e-01, + 2.405069849650012e-01, 2.285283969438072e-01, 2.167933432162879e-01, 2.053139897833021e-01, + 1.941021906320988e-01, 1.831680872008943e-01, 1.725221947208913e-01, 1.621735416384834e-01, + 1.521320683467849e-01, 1.424052801149985e-01, 1.330015240938615e-01, 1.239260664828526e-01, + 1.151858295527293e-01, 1.067840430193724e-01, 9.872637505002878e-02, 9.101379000888035e-02, + 8.365057236623055e-02, 7.663508305536153e-02, 6.997033405748826e-02, 6.365188111381365e-02, + 5.768176015814392e-02, 5.205244216987966e-02, 4.676538412257621e-02, 4.180950541438362e-02, + 3.718640251368464e-02, 3.288072750732215e-02, 2.889548499582958e-02, 2.520980565928884e-02, + 2.183057564646272e-02, 1.872896194002638e-02, 1.592127815153420e-02, 1.336381425803020e-02, + 1.108558877807282e-02, 8.943474189364638e-03, 6.758124889697787e-03, 3.504438130619497e-03, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 +}; const LC3_FLOAT MDCT_WINDOW_80_5ms[80] = { 9.959086585790517e-04, 3.819056787237678e-03, 9.540832613229890e-03, 1.921659800166160e-02, 3.382719081038548e-02, @@ -1802,7 +1874,8 @@ const LC3_FLOAT MDCT_WINDOW_80_5ms[80] = { 5.282077505750667e-01, 4.486552956056635e-01, 3.691875990296312e-01, 2.924566408966777e-01, 2.210718537110463e-01, 1.573148583944309e-01, 1.030525757797768e-01, 5.982732244758054e-02, 2.871831923385133e-02, 9.683884928956490e-03, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 +}; const LC3_FLOAT MDCT_WINDOW_160_5ms[160] = { 6.143388180964179e-04, 1.489582832987000e-03, 2.884104959764029e-03, 4.934298832466617e-03, 7.779130464154915e-03, @@ -1836,7 +1909,8 @@ const LC3_FLOAT MDCT_WINDOW_160_5ms[160] = { 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 +}; const LC3_FLOAT MDCT_WINDOW_240_5ms[240] = { 5.087227626168386e-04, 9.959086585790517e-04, 1.682208006328800e-03, 2.609697259047744e-03, 3.819056787237678e-03, @@ -1886,7 +1960,8 @@ const LC3_FLOAT MDCT_WINDOW_240_5ms[240] = { 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 +}; const LC3_FLOAT MDCT_WINDOW_320_5ms[320] = { 4.595886345493055e-04, 7.919323614002698e-04, 1.227927169310031e-03, 1.783653266717233e-03, 2.479549413444207e-03, @@ -1952,7 +2027,8 @@ const LC3_FLOAT MDCT_WINDOW_320_5ms[320] = { 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 +}; const LC3_FLOAT MDCT_WINDOW_480_5ms[480] = { 4.090106504820579e-04, 6.143388180964179e-04, 8.571759876954877e-04, 1.147015057857495e-03, 1.489582832987000e-03, @@ -2050,7 +2126,8 @@ const LC3_FLOAT MDCT_WINDOW_480_5ms[480] = { 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 +}; const LC3_FLOAT MDCT_HRA_WINDOW_480_2_5ms[240] = { @@ -2101,7 +2178,8 @@ const LC3_FLOAT MDCT_HRA_WINDOW_480_2_5ms[240] = { 5.471161958930394e-03, 4.249438341364304e-03, 3.263433520599239e-03, 2.475952111493295e-03, 1.853994056678125e-03, 1.368596596909542e-03, 9.946180283333026e-04, 7.104774789034889e-04, 4.978641589703932e-04, 3.414283510010364e-04, 2.284649445606105e-04, 1.485987233730432e-04, 9.347897725317759e-05, 5.648942347847280e-05, 3.247793542861785e-05, - 1.750922386335714e-05, 8.642407336226362e-06, 3.734302301245202e-06, 1.267861256795911e-06, 1.927766981311251e-07}; + 1.750922386335714e-05, 8.642407336226362e-06, 3.734302301245202e-06, 1.267861256795911e-06, 1.927766981311251e-07 +}; const LC3_FLOAT MDCT_HRA_WINDOW_960_2_5ms[480] = { 1.363353492760669e-07, 4.577676005269251e-07, 9.975675168391671e-07, 1.840776229085288e-06, 3.092248230077047e-06, @@ -2199,7 +2277,8 @@ const LC3_FLOAT MDCT_HRA_WINDOW_960_2_5ms[480] = { 2.557066633705375e-04, 2.078978198736850e-04, 1.678018145436083e-04, 1.343753481649133e-04, 1.066879390562912e-04, 8.391313553401788e-05, 6.532005529093359e-05, 5.026527605947520e-05, 3.818509710338716e-05, 2.858818657228189e-05, 2.104862555598476e-05, 1.519935578579325e-05, 1.072603433419925e-05, 7.361295334616452e-06, 4.879415604699819e-06, - 3.091377877253446e-06, 1.840321200267112e-06, 9.973582966273186e-07, 4.576899867970956e-07, 1.363156993327630e-07}; + 3.091377877253446e-06, 1.840321200267112e-06, 9.973582966273186e-07, 4.576899867970956e-07, 1.363156993327630e-07 +}; const LC3_FLOAT MDCT_HRA_WINDOW_480_5ms[480] = { 9.752475122178133e-08, 6.413568706385488e-07, 1.888722582859778e-06, 4.370037451432268e-06, 8.850535239285388e-06, @@ -2297,7 +2376,8 @@ const LC3_FLOAT MDCT_HRA_WINDOW_480_5ms[480] = { 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 +}; const LC3_FLOAT MDCT_HRA_WINDOW_960_5ms[960] = { 6.895487963711672e-08, 2.315162529310440e-07, 5.044776791712418e-07, 9.307951082662299e-07, 1.563406927329763e-06, @@ -2491,7 +2571,8 @@ const LC3_FLOAT MDCT_HRA_WINDOW_960_5ms[960] = { 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 +}; const LC3_FLOAT MDCT_HRA_WINDOW_480_10ms[960] = { 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, @@ -2685,7 +2766,8 @@ const LC3_FLOAT MDCT_HRA_WINDOW_480_10ms[960] = { 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 +}; const LC3_FLOAT MDCT_HRA_WINDOW_960_10ms[1920] = { 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, @@ -3071,733 +3153,765 @@ const LC3_FLOAT MDCT_HRA_WINDOW_960_10ms[1920] = { 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; - + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 +}; -const LC3_FLOAT* MDCT_WINS_10ms[2][6] = { - {MDCT_WINDOW_80, MDCT_WINDOW_160, MDCT_WINDOW_240, MDCT_WINDOW_320, MDCT_WINDOW_480, NULL}, - {NULL, NULL, NULL, NULL, MDCT_HRA_WINDOW_480_10ms, MDCT_HRA_WINDOW_960_10ms}}; -const LC3_INT MDCT_la_zeroes[6] = {30, 60, 90, 120, 180, 360}; +const LC3_FLOAT *MDCT_WINS_10ms[2][6] = { + { MDCT_WINDOW_80, MDCT_WINDOW_160, MDCT_WINDOW_240, MDCT_WINDOW_320, MDCT_WINDOW_480, NULL }, + { NULL, NULL, NULL, NULL, MDCT_HRA_WINDOW_480_10ms, MDCT_HRA_WINDOW_960_10ms } +}; +const LC3_INT MDCT_la_zeroes[6] = { 30, 60, 90, 120, 180, 360 }; -const LC3_FLOAT* MDCT_WINS_2_5ms[2][6] = { - {MDCT_WINDOW_80_2_5ms, MDCT_WINDOW_160_2_5ms, MDCT_WINDOW_240_2_5ms, MDCT_WINDOW_320_2_5ms, MDCT_WINDOW_480_2_5ms, - NULL}, - {NULL, NULL, NULL, NULL, MDCT_HRA_WINDOW_480_2_5ms, MDCT_HRA_WINDOW_960_2_5ms}}; -const LC3_INT MDCT_la_zeroes_2_5ms[6] = {0, 0, 0, 0, 0, 0}; +const LC3_FLOAT *MDCT_WINS_2_5ms[2][6] = { + { MDCT_WINDOW_80_2_5ms, MDCT_WINDOW_160_2_5ms, MDCT_WINDOW_240_2_5ms, MDCT_WINDOW_320_2_5ms, MDCT_WINDOW_480_2_5ms, + NULL }, + { NULL, NULL, NULL, NULL, MDCT_HRA_WINDOW_480_2_5ms, MDCT_HRA_WINDOW_960_2_5ms } +}; +const LC3_INT MDCT_la_zeroes_2_5ms[6] = { 0, 0, 0, 0, 0, 0 }; -const LC3_FLOAT* MDCT_WINS_5ms[2][6] = { - {MDCT_WINDOW_80_5ms, MDCT_WINDOW_160_5ms, MDCT_WINDOW_240_5ms, MDCT_WINDOW_320_5ms, MDCT_WINDOW_480_5ms, NULL}, - {NULL, NULL, NULL, NULL, MDCT_HRA_WINDOW_480_5ms, MDCT_HRA_WINDOW_960_5ms}}; -const LC3_INT MDCT_la_zeroes_5ms[6] = {10, 20, 30, 40, 60, 120}; +const LC3_FLOAT *MDCT_WINS_5ms[2][6] = { + { MDCT_WINDOW_80_5ms, MDCT_WINDOW_160_5ms, MDCT_WINDOW_240_5ms, MDCT_WINDOW_320_5ms, MDCT_WINDOW_480_5ms, NULL }, + { NULL, NULL, NULL, NULL, MDCT_HRA_WINDOW_480_5ms, MDCT_HRA_WINDOW_960_5ms } +}; +const LC3_INT MDCT_la_zeroes_5ms[6] = { 10, 20, 30, 40, 60, 120 }; -const LC3_INT MDCT_WINDOWS_LENGTHS_10ms[6] = {160, 320, 480, 640, 960, 1920}; /* Last 960 dummy */ +const LC3_INT MDCT_WINDOWS_LENGTHS_10ms[6] = { 160, 320, 480, 640, 960, 1920 }; /* Last 960 dummy */ -const LC3_INT MDCT_WINDOWS_LENGTHS_2_5ms[6] = {40, 80, 120, 160, 240, 480}; +const LC3_INT MDCT_WINDOWS_LENGTHS_2_5ms[6] = { 40, 80, 120, 160, 240, 480 }; -const LC3_INT MDCT_WINDOWS_LENGTHS_5ms[6] = {80, 160, 240, 320, 480, 960}; +const LC3_INT MDCT_WINDOWS_LENGTHS_5ms[6] = { 80, 160, 240, 320, 480, 960 }; /* Per band energy */ -const LC3_INT ACC_COEFF_PER_BAND_8[65] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 51, - 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 80}; +const LC3_INT ACC_COEFF_PER_BAND_8[65] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 51, + 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 80 }; -const LC3_INT ACC_COEFF_PER_BAND_16[65] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 32, 34, 36, 38, - 40, 42, 44, 46, 48, 50, 52, 55, 58, 61, 64, 67, 70, 73, 76, 80, 84, - 88, 92, 96, 101, 106, 111, 116, 121, 127, 133, 139, 146, 153, 160}; +const LC3_INT ACC_COEFF_PER_BAND_16[65] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 32, 34, 36, 38, + 40, 42, 44, 46, 48, 50, 52, 55, 58, 61, 64, 67, 70, 73, 76, 80, 84, + 88, 92, 96, 101, 106, 111, 116, 121, 127, 133, 139, 146, 153, 160 }; const LC3_INT ACC_COEFF_PER_BAND_24[65] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, - 22, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 46, 49, 52, 55, 58, 61, 64, 68, 72, 76, - 80, 85, 90, 95, 100, 106, 112, 118, 125, 132, 139, 147, 155, 164, 173, 183, 193, 204, 215, 227, 240}; + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 46, 49, 52, 55, 58, 61, 64, 68, 72, 76, + 80, 85, 90, 95, 100, 106, 112, 118, 125, 132, 139, 147, 155, 164, 173, 183, 193, 204, 215, 227, 240 +}; const LC3_INT ACC_COEFF_PER_BAND_32[65] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, - 24, 26, 28, 30, 32, 34, 36, 38, 41, 44, 47, 50, 53, 56, 60, 64, 68, 72, 76, 81, 86, 91, - 97, 103, 109, 116, 123, 131, 139, 148, 157, 166, 176, 187, 199, 211, 224, 238, 252, 268, 284, 302, 320}; + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, + 24, 26, 28, 30, 32, 34, 36, 38, 41, 44, 47, 50, 53, 56, 60, 64, 68, 72, 76, 81, 86, 91, + 97, 103, 109, 116, 123, 131, 139, 148, 157, 166, 176, 187, 199, 211, 224, 238, 252, 268, 284, 302, 320 +}; const LC3_INT ACC_COEFF_PER_BAND_48[65] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 24, - 26, 28, 30, 32, 34, 36, 39, 42, 45, 48, 51, 55, 59, 63, 67, 71, 76, 81, 86, 92, 98, 105, - 112, 119, 127, 135, 144, 154, 164, 175, 186, 198, 211, 225, 240, 256, 273, 291, 310, 330, 352, 375, 400}; + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 24, + 26, 28, 30, 32, 34, 36, 39, 42, 45, 48, 51, 55, 59, 63, 67, 71, 76, 81, 86, 92, 98, 105, + 112, 119, 127, 135, 144, 154, 164, 175, 186, 198, 211, 225, 240, 256, 273, 291, 310, 330, 352, 375, 400 +}; -const LC3_INT ACC_COEFF_PER_BAND_8_2_5ms[21] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}; +const LC3_INT ACC_COEFF_PER_BAND_8_2_5ms[21] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }; -const LC3_INT ACC_COEFF_PER_BAND_16_2_5ms[36] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 32, 34, 36, 38, 40}; +const LC3_INT ACC_COEFF_PER_BAND_16_2_5ms[36] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 32, 34, 36, 38, 40 }; -const LC3_INT ACC_COEFF_PER_BAND_24_2_5ms[41] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, - 30, 32, 34, 36, 38, 40, 42, 44, 47, 50, 53, 56, 60}; +const LC3_INT ACC_COEFF_PER_BAND_24_2_5ms[41] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, + 30, 32, 34, 36, 38, 40, 42, 44, 47, 50, 53, 56, 60 }; -const LC3_INT ACC_COEFF_PER_BAND_32_2_5ms[44] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 28, 30, 32, 34, - 36, 38, 40, 43, 46, 49, 52, 55, 59, 63, 67, 71, 75, 80}; +const LC3_INT ACC_COEFF_PER_BAND_32_2_5ms[44] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 28, 30, 32, 34, + 36, 38, 40, 43, 46, 49, 52, 55, 59, 63, 67, 71, 75, 80 }; -const LC3_INT ACC_COEFF_PER_BAND_48_2_5ms[45] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 23, 25, 27, 29, 31, 33, 35, 37, - 40, 43, 46, 49, 52, 56, 60, 64, 68, 72, 77, 82, 87, 93, 100}; +const LC3_INT ACC_COEFF_PER_BAND_48_2_5ms[45] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 23, 25, 27, 29, 31, 33, 35, 37, + 40, 43, 46, 49, 52, 56, 60, 64, 68, 72, 77, 82, 87, 93, 100 }; -const LC3_INT ACC_COEFF_PER_BAND_48_2_5ms_HR[46] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 40, 43, 46, - 49, 53, 57, 61, 65, 69, 74, 79, 85, 91, 97, 104, 112, 120}; +const LC3_INT ACC_COEFF_PER_BAND_48_2_5ms_HR[46] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 40, 43, 46, + 49, 53, 57, 61, 65, 69, 74, 79, 85, 91, 97, 104, 112, 120 }; const LC3_INT ACC_COEFF_PER_BAND_96_2_5ms_HR[50] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 22, 24, 26, 28, 30, 32, - 35, 38, 41, 45, 49, 53, 57, 62, 67, 73, 79, 85, 92, 100, 108, 117, 127, 137, 149, 161, 174, 189, 204, 221, 240}; + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 22, 24, 26, 28, 30, 32, + 35, 38, 41, 45, 49, 53, 57, 62, 67, 73, 79, 85, 92, 100, 108, 117, 127, 137, 149, 161, 174, 189, 204, 221, 240 +}; -const LC3_INT ACC_COEFF_PER_BAND_8_5ms[40] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 40}; +const LC3_INT ACC_COEFF_PER_BAND_8_5ms[40] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 40 }; -const LC3_INT ACC_COEFF_PER_BAND_16_5ms[51] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 32, 34, 36, - 38, 40, 42, 44, 46, 48, 50, 52, 54, 57, 60, 63, 66, 69, 72, 76, 80}; +const LC3_INT ACC_COEFF_PER_BAND_16_5ms[51] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 32, 34, 36, + 38, 40, 42, 44, 46, 48, 50, 52, 54, 57, 60, 63, 66, 69, 72, 76, 80 }; const LC3_INT ACC_COEFF_PER_BAND_24_5ms[53] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 28, - 30, 32, 34, 36, 38, 40, 42, 44, 47, 50, 53, 56, 59, 62, 65, 69, 73, 77, 81, 86, 91, 96, 101, 107, 113, 120}; - -const LC3_INT ACC_COEFF_PER_BAND_32_5ms[55] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 26, 28, 30, 32, - 34, 36, 38, 40, 42, 45, 48, 51, 54, 57, 61, 65, 69, 73, - 78, 83, 88, 93, 99, 105, 112, 119, 126, 134, 142, 151, 160}; -const LC3_INT ACC_COEFF_PER_BAND_48_5ms_HR[56] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 21, 23, 25, 27, 29, 31, 33, 35, - 38, 41, 44, 47, 50, 54, 58, 62, 66, 71, 76, 81, 87, 93, - 100, 107, 114, 122, 131, 140, 149, 160, 171, 183, 196, 209, 224, 240}; -const LC3_INT ACC_COEFF_PER_BAND_48_5ms[56] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 23, 25, 27, 29, 31, 33, - 35, 37, 40, 43, 46, 49, 52, 55, 59, 63, 67, 72, 77, 82, - 87, 93, 99, 105, 112, 120, 128, 136, 145, 155, 165, 176, 187, 200}; + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 28, + 30, 32, 34, 36, 38, 40, 42, 44, 47, 50, 53, 56, 59, 62, 65, 69, 73, 77, 81, 86, 91, 96, 101, 107, 113, 120 +}; + +const LC3_INT ACC_COEFF_PER_BAND_32_5ms[55] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 26, 28, 30, 32, + 34, 36, 38, 40, 42, 45, 48, 51, 54, 57, 61, 65, 69, 73, + 78, 83, 88, 93, 99, 105, 112, 119, 126, 134, 142, 151, 160 }; +const LC3_INT ACC_COEFF_PER_BAND_48_5ms_HR[56] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 21, 23, 25, 27, 29, 31, 33, 35, + 38, 41, 44, 47, 50, 54, 58, 62, 66, 71, 76, 81, 87, 93, + 100, 107, 114, 122, 131, 140, 149, 160, 171, 183, 196, 209, 224, 240 }; +const LC3_INT ACC_COEFF_PER_BAND_48_5ms[56] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 23, 25, 27, 29, 31, 33, + 35, 37, 40, 43, 46, 49, 52, 55, 59, 63, 67, 72, 77, 82, + 87, 93, 99, 105, 112, 120, 128, 136, 145, 155, 165, 176, 187, 200 }; const LC3_INT ACC_COEFF_PER_BAND_96_5ms_HR[59] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 21, - 23, 25, 27, 29, 31, 34, 37, 40, 44, 48, 52, 56, 61, 66, 71, 77, 83, 90, 98, 106, - 115, 124, 135, 146, 158, 171, 185, 200, 217, 235, 254, 275, 298, 323, 349, 378, 409, 443, 480}; + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 21, + 23, 25, 27, 29, 31, 34, 37, 40, 44, 48, 52, 56, 61, 66, 71, 77, 83, 90, 98, 106, + 115, 124, 135, 146, 158, 171, 185, 200, 217, 235, 254, 275, 298, 323, 349, 378, 409, 443, 480 +}; const LC3_INT ACC_COEFF_PER_BAND_48_HR[65] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 21, 23, 25, - 27, 29, 31, 33, 36, 39, 42, 45, 48, 51, 55, 59, 63, 67, 72, 77, 83, 89, 95, 101, 108, 116, - 124, 133, 142, 152, 163, 174, 187, 200, 214, 229, 244, 262, 280, 299, 320, 343, 367, 392, 419, 449, 480}; + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 21, 23, 25, + 27, 29, 31, 33, 36, 39, 42, 45, 48, 51, 55, 59, 63, 67, 72, 77, 83, 89, 95, 101, 108, 116, + 124, 133, 142, 152, 163, 174, 187, 200, 214, 229, 244, 262, 280, 299, 320, 343, 367, 392, 419, 449, 480 +}; -const LC3_INT ACC_COEFF_PER_BAND_96_HR[65] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 33, 36, 39, 42, 46, 50, 54, 59, 64, 69, 75, 82, 89, 96, 104, 113, 122, 132, 143, 155, 168, 181, 196, 213, 230, 249, 270, 292, 316, 342, 371, 401, 434, 470, 509, 551, 596, 646, 699, 757, 819, 887, 960}; +const LC3_INT ACC_COEFF_PER_BAND_96_HR[65] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 33, 36, 39, 42, 46, 50, 54, 59, 64, 69, 75, 82, 89, 96, 104, 113, 122, 132, 143, 155, 168, 181, 196, 213, 230, 249, 270, 292, 316, 342, 371, 401, 434, 470, 509, 551, 596, 646, 699, 757, 819, 887, 960 }; -const LC3_INT* ACC_COEFF_PER_BAND_HR[6] = {NULL, NULL, NULL, NULL, ACC_COEFF_PER_BAND_48_HR, ACC_COEFF_PER_BAND_96_HR}; +const LC3_INT *ACC_COEFF_PER_BAND_HR[6] = { NULL, NULL, NULL, NULL, ACC_COEFF_PER_BAND_48_HR, ACC_COEFF_PER_BAND_96_HR }; -const LC3_INT* ACC_COEFF_PER_BAND[6] = {ACC_COEFF_PER_BAND_8, ACC_COEFF_PER_BAND_16, ACC_COEFF_PER_BAND_24, - ACC_COEFF_PER_BAND_32, ACC_COEFF_PER_BAND_48, NULL}; +const LC3_INT *ACC_COEFF_PER_BAND[6] = { ACC_COEFF_PER_BAND_8, ACC_COEFF_PER_BAND_16, ACC_COEFF_PER_BAND_24, + ACC_COEFF_PER_BAND_32, ACC_COEFF_PER_BAND_48, NULL }; -const LC3_INT* ACC_COEFF_PER_BAND_2_5ms_HR[6] = { - NULL, NULL, NULL, NULL, ACC_COEFF_PER_BAND_48_2_5ms_HR, ACC_COEFF_PER_BAND_96_2_5ms_HR}; +const LC3_INT *ACC_COEFF_PER_BAND_2_5ms_HR[6] = { + NULL, NULL, NULL, NULL, ACC_COEFF_PER_BAND_48_2_5ms_HR, ACC_COEFF_PER_BAND_96_2_5ms_HR +}; -const LC3_INT* ACC_COEFF_PER_BAND_2_5ms[5] = {ACC_COEFF_PER_BAND_8_2_5ms, ACC_COEFF_PER_BAND_16_2_5ms, - ACC_COEFF_PER_BAND_24_2_5ms, ACC_COEFF_PER_BAND_32_2_5ms, - ACC_COEFF_PER_BAND_48_2_5ms}; +const LC3_INT *ACC_COEFF_PER_BAND_2_5ms[5] = { ACC_COEFF_PER_BAND_8_2_5ms, ACC_COEFF_PER_BAND_16_2_5ms, + ACC_COEFF_PER_BAND_24_2_5ms, ACC_COEFF_PER_BAND_32_2_5ms, + ACC_COEFF_PER_BAND_48_2_5ms }; -const LC3_INT* ACC_COEFF_PER_BAND_5ms_HR[6] = { - NULL, NULL, NULL, NULL, ACC_COEFF_PER_BAND_48_5ms_HR, ACC_COEFF_PER_BAND_96_5ms_HR}; +const LC3_INT *ACC_COEFF_PER_BAND_5ms_HR[6] = { + NULL, NULL, NULL, NULL, ACC_COEFF_PER_BAND_48_5ms_HR, ACC_COEFF_PER_BAND_96_5ms_HR +}; -const LC3_INT* ACC_COEFF_PER_BAND_5ms[5] = {ACC_COEFF_PER_BAND_8_5ms, ACC_COEFF_PER_BAND_16_5ms, - ACC_COEFF_PER_BAND_24_5ms, ACC_COEFF_PER_BAND_32_5ms, - ACC_COEFF_PER_BAND_48_5ms}; +const LC3_INT *ACC_COEFF_PER_BAND_5ms[5] = { ACC_COEFF_PER_BAND_8_5ms, ACC_COEFF_PER_BAND_16_5ms, + ACC_COEFF_PER_BAND_24_5ms, ACC_COEFF_PER_BAND_32_5ms, + ACC_COEFF_PER_BAND_48_5ms }; /* Near Nyquist detector */ const LC3_INT NN_thresh = 30; -const LC3_INT32 xavg_N_grp[5] = { 4, 5, 6, 7, 8 }; - - -const LC3_INT32 gwlpr[MAX_LGW+1] = { 1, 3*QUOT_LPR_LTR, 5*QUOT_LPR_LTR, 9*QUOT_LPR_LTR, 17*QUOT_LPR_LTR, 33*QUOT_LPR_LTR, 49*QUOT_LPR_LTR, 65*QUOT_LPR_LTR, 81*QUOT_LPR_LTR, 97*QUOT_LPR_LTR}; - - -const LC3_FLOAT PhECU_whr16ms_NB[128]={ -8.000000000000002e-02, 8.393536376804722e-02, 9.567411990702857e-02, 1.150154150448081e-01, 1.416283142591582e-01, -1.750574634660318e-01, 2.147308806541882e-01, 2.599697426559885e-01, 3.099999999999999e-01, 3.639656211120587e-01, -4.209432392528405e-01, 4.799579515787762e-01, 5.400000000000000e-01, 6.000420484212237e-01, 6.590567607471596e-01, -7.160343788879413e-01, 7.699999999999999e-01, 8.200302573440115e-01, 8.652691193458119e-01, 9.049425365339682e-01, -9.383716857408418e-01, 9.649845849551919e-01, 9.843258800929715e-01, 9.960646362319528e-01, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -9.960646362319528e-01, 9.843258800929715e-01, 9.649845849551919e-01, 9.383716857408418e-01, 9.049425365339682e-01, -8.652691193458119e-01, 8.200302573440115e-01, 7.699999999999999e-01, 7.160343788879413e-01, 6.590567607471596e-01, -6.000420484212237e-01, 5.400000000000000e-01, 4.799579515787762e-01, 4.209432392528405e-01, 3.639656211120587e-01, -3.099999999999999e-01, 2.599697426559885e-01, 2.147308806541882e-01, 1.750574634660318e-01, 1.416283142591582e-01, -1.150154150448081e-01, 9.567411990702857e-02, 8.393536376804722e-02 -}; -const LC3_FLOAT PhECU_whr16ms_WB[256]={ -8.000000000000002e-02, 8.098489531024239e-02, 8.393536376804722e-02, 8.883877101451404e-02, 9.567411990702857e-02, -1.044121404322514e-01, 1.150154150448081e-01, 1.274385388949634e-01, 1.416283142591582e-01, 1.575239783408292e-01, -1.750574634660318e-01, 1.941536885596704e-01, 2.147308806541882e-01, 2.367009250539683e-01, 2.599697426559885e-01, -2.844376928109830e-01, 3.099999999999999e-01, 3.365472024992595e-01, 3.639656211120587e-01, 3.921378459605457e-01, -4.209432392528405e-01, 4.502584518725810e-01, 4.799579515787762e-01, 5.099145605541342e-01, 5.400000000000000e-01, -5.700854394458659e-01, 6.000420484212237e-01, 6.297415481274190e-01, 6.590567607471596e-01, 6.878621540394543e-01, -7.160343788879413e-01, 7.434527975007406e-01, 7.699999999999999e-01, 7.955623071890170e-01, 8.200302573440115e-01, -8.432990749460317e-01, 8.652691193458119e-01, 8.858463114403297e-01, 9.049425365339682e-01, 9.224760216591710e-01, -9.383716857408418e-01, 9.525614611050366e-01, 9.649845849551919e-01, 9.755878595677486e-01, 9.843258800929715e-01, -9.911612289854861e-01, 9.960646362319528e-01, 9.990151046897577e-01, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 9.990151046897577e-01, -9.960646362319528e-01, 9.911612289854861e-01, 9.843258800929715e-01, 9.755878595677486e-01, 9.649845849551919e-01, -9.525614611050366e-01, 9.383716857408418e-01, 9.224760216591710e-01, 9.049425365339682e-01, 8.858463114403297e-01, -8.652691193458119e-01, 8.432990749460317e-01, 8.200302573440115e-01, 7.955623071890170e-01, 7.699999999999999e-01, -7.434527975007406e-01, 7.160343788879413e-01, 6.878621540394543e-01, 6.590567607471596e-01, 6.297415481274190e-01, -6.000420484212237e-01, 5.700854394458659e-01, 5.400000000000000e-01, 5.099145605541342e-01, 4.799579515787762e-01, -4.502584518725810e-01, 4.209432392528405e-01, 3.921378459605457e-01, 3.639656211120587e-01, 3.365472024992595e-01, -3.099999999999999e-01, 2.844376928109830e-01, 2.599697426559885e-01, 2.367009250539683e-01, 2.147308806541882e-01, -1.941536885596704e-01, 1.750574634660318e-01, 1.575239783408292e-01, 1.416283142591582e-01, 1.274385388949634e-01, -1.150154150448081e-01, 1.044121404322514e-01, 9.567411990702857e-02, 8.883877101451404e-02, 8.393536376804722e-02, -8.098489531024239e-02 -}; -const LC3_FLOAT PhECU_whr16ms_SSWB[384]={ -8.000000000000002e-02, 8.043781807234540e-02, 8.175043887779704e-02, 8.393536376804722e-02, 8.698843361438435e-02, -9.090383672483066e-02, 9.567411990702857e-02, 1.012902026558156e-01, 1.077413944384821e-01, 1.150154150448081e-01, -1.230984179631410e-01, 1.319750167380180e-01, 1.416283142591582e-01, 1.520399349260726e-01, 1.631900596270638e-01, -1.750574634660318e-01, 1.876195561652702e-01, 2.008524250673430e-01, 2.147308806541882e-01, 2.292285044967963e-01, -2.443176995441919e-01, 2.599697426559885e-01, 2.761548392785189e-01, 2.928421801604610e-01, 3.099999999999999e-01, -3.275956379118843e-01, 3.455955995992783e-01, 3.639656211120587e-01, 3.826707340701924e-01, 4.016753322280344e-01, -4.209432392528405e-01, 4.404377775884727e-01, 4.601218382732121e-01, 4.799579515787762e-01, 4.999083583360772e-01, -5.199350818119455e-01, 5.400000000000000e-01, 5.600649181880546e-01, 5.800916416639228e-01, 6.000420484212237e-01, -6.198781617267880e-01, 6.395622224115274e-01, 6.590567607471596e-01, 6.783246677719657e-01, 6.973292659298076e-01, -7.160343788879413e-01, 7.344044004007217e-01, 7.524043620881156e-01, 7.699999999999999e-01, 7.871578198395390e-01, -8.038451607214812e-01, 8.200302573440115e-01, 8.356823004558082e-01, 8.507714955032037e-01, 8.652691193458119e-01, -8.791475749326572e-01, 8.923804438347298e-01, 9.049425365339682e-01, 9.168099403729364e-01, 9.279600650739274e-01, -9.383716857408418e-01, 9.480249832619820e-01, 9.569015820368590e-01, 9.649845849551919e-01, 9.722586055615179e-01, -9.787097973441844e-01, 9.843258800929715e-01, 9.890961632751694e-01, 9.930115663856157e-01, 9.960646362319528e-01, -9.982495611222031e-01, 9.995621819276547e-01, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 9.995621819276547e-01, 9.982495611222031e-01, -9.960646362319528e-01, 9.930115663856157e-01, 9.890961632751694e-01, 9.843258800929715e-01, 9.787097973441844e-01, -9.722586055615179e-01, 9.649845849551919e-01, 9.569015820368590e-01, 9.480249832619820e-01, 9.383716857408418e-01, -9.279600650739274e-01, 9.168099403729364e-01, 9.049425365339682e-01, 8.923804438347298e-01, 8.791475749326572e-01, -8.652691193458119e-01, 8.507714955032037e-01, 8.356823004558082e-01, 8.200302573440115e-01, 8.038451607214812e-01, -7.871578198395390e-01, 7.699999999999999e-01, 7.524043620881156e-01, 7.344044004007217e-01, 7.160343788879413e-01, -6.973292659298076e-01, 6.783246677719657e-01, 6.590567607471596e-01, 6.395622224115274e-01, 6.198781617267880e-01, -6.000420484212237e-01, 5.800916416639228e-01, 5.600649181880546e-01, 5.400000000000000e-01, 5.199350818119455e-01, -4.999083583360772e-01, 4.799579515787762e-01, 4.601218382732121e-01, 4.404377775884727e-01, 4.209432392528405e-01, -4.016753322280344e-01, 3.826707340701924e-01, 3.639656211120587e-01, 3.455955995992783e-01, 3.275956379118843e-01, -3.099999999999999e-01, 2.928421801604610e-01, 2.761548392785189e-01, 2.599697426559885e-01, 2.443176995441919e-01, -2.292285044967963e-01, 2.147308806541882e-01, 2.008524250673430e-01, 1.876195561652702e-01, 1.750574634660318e-01, -1.631900596270638e-01, 1.520399349260726e-01, 1.416283142591582e-01, 1.319750167380180e-01, 1.230984179631410e-01, -1.150154150448081e-01, 1.077413944384821e-01, 1.012902026558156e-01, 9.567411990702857e-02, 9.090383672483066e-02, -8.698843361438435e-02, 8.393536376804722e-02, 8.175043887779704e-02, 8.043781807234540e-02 -}; -const LC3_FLOAT PhECU_whr16ms_SWB[512]={ -8.000000000000002e-02, 8.024628976087178e-02, 8.098489531024239e-02, 8.221502573078943e-02, 8.393536376804722e-02, -8.614406724095569e-02, 8.883877101451404e-02, 9.201658953242653e-02, 9.567411990702857e-02, 9.980744556318394e-02, -1.044121404322514e-01, 1.094832736916302e-01, 1.150154150448081e-01, 1.210026405362591e-01, 1.274385388949634e-01, -1.343162183997567e-01, 1.416283142591582e-01, 1.493669964977737e-01, 1.575239783408292e-01, 1.660905250878570e-01, -1.750574634660318e-01, 1.844151914531410e-01, 1.941536885596704e-01, 2.042625265589956e-01, 2.147308806541882e-01, -2.255475410694793e-01, 2.367009250539683e-01, 2.481790892847231e-01, 2.599697426559885e-01, 2.720602594408110e-01, -2.844376928109830e-01, 2.970887887008307e-01, 3.099999999999999e-01, 3.231575010600410e-01, 3.365472024992595e-01, -3.501547662899784e-01, 3.639656211120587e-01, 3.779649779562326e-01, 3.921378459605457e-01, 4.064690484629473e-01, -4.209432392528405e-01, 4.355449190041883e-01, 4.502584518725810e-01, 4.650680822384892e-01, 4.799579515787762e-01, -4.949121154484021e-01, 5.099145605541342e-01, 5.249492219019830e-01, 5.400000000000000e-01, 5.550507780980171e-01, -5.700854394458659e-01, 5.850878845515979e-01, 6.000420484212237e-01, 6.149319177615109e-01, 6.297415481274190e-01, -6.444550809958116e-01, 6.590567607471596e-01, 6.735309515370527e-01, 6.878621540394543e-01, 7.020350220437674e-01, -7.160343788879413e-01, 7.298452337100215e-01, 7.434527975007406e-01, 7.568424989399589e-01, 7.699999999999999e-01, -7.829112112991693e-01, 7.955623071890170e-01, 8.079397405591890e-01, 8.200302573440115e-01, 8.318209107152770e-01, -8.432990749460317e-01, 8.544524589305209e-01, 8.652691193458119e-01, 8.757374734410044e-01, 8.858463114403297e-01, -8.955848085468591e-01, 9.049425365339682e-01, 9.139094749121430e-01, 9.224760216591710e-01, 9.306330035022263e-01, -9.383716857408418e-01, 9.456837816002432e-01, 9.525614611050366e-01, 9.589973594637410e-01, 9.649845849551919e-01, -9.705167263083698e-01, 9.755878595677486e-01, 9.801925544368162e-01, 9.843258800929715e-01, 9.879834104675735e-01, -9.911612289854861e-01, 9.938559327590444e-01, 9.960646362319528e-01, 9.977849742692106e-01, 9.990151046897577e-01, -9.997537102391283e-01, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 9.997537102391283e-01, 9.990151046897577e-01, 9.977849742692106e-01, -9.960646362319528e-01, 9.938559327590444e-01, 9.911612289854861e-01, 9.879834104675735e-01, 9.843258800929715e-01, -9.801925544368162e-01, 9.755878595677486e-01, 9.705167263083698e-01, 9.649845849551919e-01, 9.589973594637410e-01, -9.525614611050366e-01, 9.456837816002432e-01, 9.383716857408418e-01, 9.306330035022263e-01, 9.224760216591710e-01, -9.139094749121430e-01, 9.049425365339682e-01, 8.955848085468591e-01, 8.858463114403297e-01, 8.757374734410044e-01, -8.652691193458119e-01, 8.544524589305209e-01, 8.432990749460317e-01, 8.318209107152770e-01, 8.200302573440115e-01, -8.079397405591890e-01, 7.955623071890170e-01, 7.829112112991693e-01, 7.699999999999999e-01, 7.568424989399589e-01, -7.434527975007406e-01, 7.298452337100215e-01, 7.160343788879413e-01, 7.020350220437674e-01, 6.878621540394543e-01, -6.735309515370527e-01, 6.590567607471596e-01, 6.444550809958116e-01, 6.297415481274190e-01, 6.149319177615109e-01, -6.000420484212237e-01, 5.850878845515979e-01, 5.700854394458659e-01, 5.550507780980171e-01, 5.400000000000000e-01, -5.249492219019830e-01, 5.099145605541342e-01, 4.949121154484021e-01, 4.799579515787762e-01, 4.650680822384892e-01, -4.502584518725810e-01, 4.355449190041883e-01, 4.209432392528405e-01, 4.064690484629473e-01, 3.921378459605457e-01, -3.779649779562326e-01, 3.639656211120587e-01, 3.501547662899784e-01, 3.365472024992595e-01, 3.231575010600410e-01, -3.099999999999999e-01, 2.970887887008307e-01, 2.844376928109830e-01, 2.720602594408110e-01, 2.599697426559885e-01, -2.481790892847231e-01, 2.367009250539683e-01, 2.255475410694793e-01, 2.147308806541882e-01, 2.042625265589956e-01, -1.941536885596704e-01, 1.844151914531410e-01, 1.750574634660318e-01, 1.660905250878570e-01, 1.575239783408292e-01, -1.493669964977737e-01, 1.416283142591582e-01, 1.343162183997567e-01, 1.274385388949634e-01, 1.210026405362591e-01, -1.150154150448081e-01, 1.094832736916302e-01, 1.044121404322514e-01, 9.980744556318394e-02, 9.567411990702857e-02, -9.201658953242653e-02, 8.883877101451404e-02, 8.614406724095569e-02, 8.393536376804722e-02, 8.221502573078943e-02, -8.098489531024239e-02, 8.024628976087178e-02 -}; -const LC3_FLOAT PhECU_whr16ms_FB[768]={ -8.000000000000002e-02, 8.010946754324183e-02, 8.043781807234540e-02, 8.098489531024239e-02, 8.175043887779704e-02, -8.273408441773300e-02, 8.393536376804722e-02, 8.535370518483010e-02, 8.698843361438435e-02, 8.883877101451404e-02, -9.090383672483066e-02, 9.318264788589975e-02, 9.567411990702857e-02, 9.837706698247278e-02, 1.012902026558156e-01, -1.044121404322514e-01, 1.077413944384821e-01, 1.112763801299127e-01, 1.150154150448081e-01, 1.189567196050543e-01, -1.230984179631410e-01, 1.274385388949634e-01, 1.319750167380180e-01, 1.367056923745465e-01, 1.416283142591582e-01, -1.467405394904446e-01, 1.520399349260726e-01, 1.575239783408292e-01, 1.631900596270638e-01, 1.690354820369581e-01, -1.750574634660318e-01, 1.812531377772744e-01, 1.876195561652702e-01, 1.941536885596704e-01, 2.008524250673430e-01, -2.077125774525124e-01, 2.147308806541882e-01, 2.219039943401561e-01, 2.292285044967963e-01, 2.367009250539683e-01, -2.443176995441919e-01, 2.520752027953329e-01, 2.599697426559885e-01, 2.679975617527521e-01, 2.761548392785189e-01, -2.844376928109830e-01, 2.928421801604610e-01, 3.013643012461601e-01, 3.099999999999999e-01, 3.187451662970817e-01, -3.275956379118843e-01, 3.365472024992595e-01, 3.455955995992783e-01, 3.547365226649809e-01, 3.639656211120587e-01, -3.732785023894972e-01, 3.826707340701924e-01, 3.921378459605457e-01, 4.016753322280344e-01, 4.112786535457436e-01, -4.209432392528405e-01, 4.306644895299604e-01, 4.404377775884727e-01, 4.502584518725810e-01, 4.601218382732121e-01, -4.700232423526383e-01, 4.799579515787762e-01, 4.899212375680964e-01, 4.999083583360772e-01, 5.099145605541342e-01, -5.199350818119455e-01, 5.299651528841020e-01, 5.400000000000000e-01, 5.500348471158981e-01, 5.600649181880546e-01, -5.700854394458659e-01, 5.800916416639228e-01, 5.900787624319037e-01, 6.000420484212237e-01, 6.099767576473617e-01, -6.198781617267880e-01, 6.297415481274190e-01, 6.395622224115274e-01, 6.493355104700396e-01, 6.590567607471596e-01, -6.687213464542564e-01, 6.783246677719657e-01, 6.878621540394543e-01, 6.973292659298076e-01, 7.067214976105027e-01, -7.160343788879413e-01, 7.252634773350191e-01, 7.344044004007217e-01, 7.434527975007406e-01, 7.524043620881156e-01, -7.612548337029182e-01, 7.699999999999999e-01, 7.786356987538400e-01, 7.871578198395390e-01, 7.955623071890170e-01, -8.038451607214812e-01, 8.120024382472478e-01, 8.200302573440115e-01, 8.279247972046673e-01, 8.356823004558082e-01, -8.432990749460317e-01, 8.507714955032037e-01, 8.580960056598439e-01, 8.652691193458119e-01, 8.722874225474876e-01, -8.791475749326572e-01, 8.858463114403297e-01, 8.923804438347298e-01, 8.987468622227257e-01, 9.049425365339682e-01, -9.109645179630421e-01, 9.168099403729364e-01, 9.224760216591710e-01, 9.279600650739274e-01, 9.332594605095554e-01, -9.383716857408418e-01, 9.432943076254536e-01, 9.480249832619820e-01, 9.525614611050366e-01, 9.569015820368590e-01, -9.610432803949458e-01, 9.649845849551919e-01, 9.687236198700873e-01, 9.722586055615179e-01, 9.755878595677486e-01, -9.787097973441844e-01, 9.816229330175272e-01, 9.843258800929715e-01, 9.868173521141004e-01, 9.890961632751694e-01, -9.911612289854861e-01, 9.930115663856157e-01, 9.946462948151700e-01, 9.960646362319528e-01, 9.972659155822671e-01, -9.982495611222031e-01, 9.990151046897577e-01, 9.995621819276547e-01, 9.998905324567582e-01, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, -9.998905324567582e-01, 9.995621819276547e-01, 9.990151046897577e-01, 9.982495611222031e-01, 9.972659155822671e-01, -9.960646362319528e-01, 9.946462948151700e-01, 9.930115663856157e-01, 9.911612289854861e-01, 9.890961632751694e-01, -9.868173521141004e-01, 9.843258800929715e-01, 9.816229330175272e-01, 9.787097973441844e-01, 9.755878595677486e-01, -9.722586055615179e-01, 9.687236198700873e-01, 9.649845849551919e-01, 9.610432803949458e-01, 9.569015820368590e-01, -9.525614611050366e-01, 9.480249832619820e-01, 9.432943076254536e-01, 9.383716857408418e-01, 9.332594605095554e-01, -9.279600650739274e-01, 9.224760216591710e-01, 9.168099403729364e-01, 9.109645179630421e-01, 9.049425365339682e-01, -8.987468622227257e-01, 8.923804438347298e-01, 8.858463114403297e-01, 8.791475749326572e-01, 8.722874225474876e-01, -8.652691193458119e-01, 8.580960056598439e-01, 8.507714955032037e-01, 8.432990749460317e-01, 8.356823004558082e-01, -8.279247972046673e-01, 8.200302573440115e-01, 8.120024382472478e-01, 8.038451607214812e-01, 7.955623071890170e-01, -7.871578198395390e-01, 7.786356987538400e-01, 7.699999999999999e-01, 7.612548337029182e-01, 7.524043620881156e-01, -7.434527975007406e-01, 7.344044004007217e-01, 7.252634773350191e-01, 7.160343788879413e-01, 7.067214976105027e-01, -6.973292659298076e-01, 6.878621540394543e-01, 6.783246677719657e-01, 6.687213464542564e-01, 6.590567607471596e-01, -6.493355104700396e-01, 6.395622224115274e-01, 6.297415481274190e-01, 6.198781617267880e-01, 6.099767576473617e-01, -6.000420484212237e-01, 5.900787624319037e-01, 5.800916416639228e-01, 5.700854394458659e-01, 5.600649181880546e-01, -5.500348471158981e-01, 5.400000000000000e-01, 5.299651528841020e-01, 5.199350818119455e-01, 5.099145605541342e-01, -4.999083583360772e-01, 4.899212375680964e-01, 4.799579515787762e-01, 4.700232423526383e-01, 4.601218382732121e-01, -4.502584518725810e-01, 4.404377775884727e-01, 4.306644895299604e-01, 4.209432392528405e-01, 4.112786535457436e-01, -4.016753322280344e-01, 3.921378459605457e-01, 3.826707340701924e-01, 3.732785023894972e-01, 3.639656211120587e-01, -3.547365226649809e-01, 3.455955995992783e-01, 3.365472024992595e-01, 3.275956379118843e-01, 3.187451662970817e-01, -3.099999999999999e-01, 3.013643012461601e-01, 2.928421801604610e-01, 2.844376928109830e-01, 2.761548392785189e-01, -2.679975617527521e-01, 2.599697426559885e-01, 2.520752027953329e-01, 2.443176995441919e-01, 2.367009250539683e-01, -2.292285044967963e-01, 2.219039943401561e-01, 2.147308806541882e-01, 2.077125774525124e-01, 2.008524250673430e-01, -1.941536885596704e-01, 1.876195561652702e-01, 1.812531377772744e-01, 1.750574634660318e-01, 1.690354820369581e-01, -1.631900596270638e-01, 1.575239783408292e-01, 1.520399349260726e-01, 1.467405394904446e-01, 1.416283142591582e-01, -1.367056923745465e-01, 1.319750167380180e-01, 1.274385388949634e-01, 1.230984179631410e-01, 1.189567196050543e-01, -1.150154150448081e-01, 1.112763801299127e-01, 1.077413944384821e-01, 1.044121404322514e-01, 1.012902026558156e-01, -9.837706698247278e-02, 9.567411990702857e-02, 9.318264788589975e-02, 9.090383672483066e-02, 8.883877101451404e-02, -8.698843361438435e-02, 8.535370518483010e-02, 8.393536376804722e-02, 8.273408441773300e-02, 8.175043887779704e-02, -8.098489531024239e-02, 8.043781807234540e-02, 8.010946754324183e-02 -}; - -const LC3_FLOAT* PhECU_whr16ms_wins[5] = { - PhECU_whr16ms_NB,PhECU_whr16ms_WB,PhECU_whr16ms_SSWB,PhECU_whr16ms_SWB, PhECU_whr16ms_FB +const LC3_INT32 xavg_N_grp[5] = { 4, 5, 6, 7, 8 }; + + +const LC3_INT32 gwlpr[MAX_LGW + 1] = { 1, 3 * QUOT_LPR_LTR, 5 * QUOT_LPR_LTR, 9 * QUOT_LPR_LTR, 17 * QUOT_LPR_LTR, 33 * QUOT_LPR_LTR, 49 * QUOT_LPR_LTR, 65 * QUOT_LPR_LTR, 81 * QUOT_LPR_LTR, 97 * QUOT_LPR_LTR }; + + +const LC3_FLOAT PhECU_whr16ms_NB[128] = { + 8.000000000000002e-02, 8.393536376804722e-02, 9.567411990702857e-02, 1.150154150448081e-01, 1.416283142591582e-01, + 1.750574634660318e-01, 2.147308806541882e-01, 2.599697426559885e-01, 3.099999999999999e-01, 3.639656211120587e-01, + 4.209432392528405e-01, 4.799579515787762e-01, 5.400000000000000e-01, 6.000420484212237e-01, 6.590567607471596e-01, + 7.160343788879413e-01, 7.699999999999999e-01, 8.200302573440115e-01, 8.652691193458119e-01, 9.049425365339682e-01, + 9.383716857408418e-01, 9.649845849551919e-01, 9.843258800929715e-01, 9.960646362319528e-01, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 9.960646362319528e-01, 9.843258800929715e-01, 9.649845849551919e-01, 9.383716857408418e-01, 9.049425365339682e-01, + 8.652691193458119e-01, 8.200302573440115e-01, 7.699999999999999e-01, 7.160343788879413e-01, 6.590567607471596e-01, + 6.000420484212237e-01, 5.400000000000000e-01, 4.799579515787762e-01, 4.209432392528405e-01, 3.639656211120587e-01, + 3.099999999999999e-01, 2.599697426559885e-01, 2.147308806541882e-01, 1.750574634660318e-01, 1.416283142591582e-01, + 1.150154150448081e-01, 9.567411990702857e-02, 8.393536376804722e-02 +}; +const LC3_FLOAT PhECU_whr16ms_WB[256] = { + 8.000000000000002e-02, 8.098489531024239e-02, 8.393536376804722e-02, 8.883877101451404e-02, 9.567411990702857e-02, + 1.044121404322514e-01, 1.150154150448081e-01, 1.274385388949634e-01, 1.416283142591582e-01, 1.575239783408292e-01, + 1.750574634660318e-01, 1.941536885596704e-01, 2.147308806541882e-01, 2.367009250539683e-01, 2.599697426559885e-01, + 2.844376928109830e-01, 3.099999999999999e-01, 3.365472024992595e-01, 3.639656211120587e-01, 3.921378459605457e-01, + 4.209432392528405e-01, 4.502584518725810e-01, 4.799579515787762e-01, 5.099145605541342e-01, 5.400000000000000e-01, + 5.700854394458659e-01, 6.000420484212237e-01, 6.297415481274190e-01, 6.590567607471596e-01, 6.878621540394543e-01, + 7.160343788879413e-01, 7.434527975007406e-01, 7.699999999999999e-01, 7.955623071890170e-01, 8.200302573440115e-01, + 8.432990749460317e-01, 8.652691193458119e-01, 8.858463114403297e-01, 9.049425365339682e-01, 9.224760216591710e-01, + 9.383716857408418e-01, 9.525614611050366e-01, 9.649845849551919e-01, 9.755878595677486e-01, 9.843258800929715e-01, + 9.911612289854861e-01, 9.960646362319528e-01, 9.990151046897577e-01, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 9.990151046897577e-01, + 9.960646362319528e-01, 9.911612289854861e-01, 9.843258800929715e-01, 9.755878595677486e-01, 9.649845849551919e-01, + 9.525614611050366e-01, 9.383716857408418e-01, 9.224760216591710e-01, 9.049425365339682e-01, 8.858463114403297e-01, + 8.652691193458119e-01, 8.432990749460317e-01, 8.200302573440115e-01, 7.955623071890170e-01, 7.699999999999999e-01, + 7.434527975007406e-01, 7.160343788879413e-01, 6.878621540394543e-01, 6.590567607471596e-01, 6.297415481274190e-01, + 6.000420484212237e-01, 5.700854394458659e-01, 5.400000000000000e-01, 5.099145605541342e-01, 4.799579515787762e-01, + 4.502584518725810e-01, 4.209432392528405e-01, 3.921378459605457e-01, 3.639656211120587e-01, 3.365472024992595e-01, + 3.099999999999999e-01, 2.844376928109830e-01, 2.599697426559885e-01, 2.367009250539683e-01, 2.147308806541882e-01, + 1.941536885596704e-01, 1.750574634660318e-01, 1.575239783408292e-01, 1.416283142591582e-01, 1.274385388949634e-01, + 1.150154150448081e-01, 1.044121404322514e-01, 9.567411990702857e-02, 8.883877101451404e-02, 8.393536376804722e-02, + 8.098489531024239e-02 +}; +const LC3_FLOAT PhECU_whr16ms_SSWB[384] = { + 8.000000000000002e-02, 8.043781807234540e-02, 8.175043887779704e-02, 8.393536376804722e-02, 8.698843361438435e-02, + 9.090383672483066e-02, 9.567411990702857e-02, 1.012902026558156e-01, 1.077413944384821e-01, 1.150154150448081e-01, + 1.230984179631410e-01, 1.319750167380180e-01, 1.416283142591582e-01, 1.520399349260726e-01, 1.631900596270638e-01, + 1.750574634660318e-01, 1.876195561652702e-01, 2.008524250673430e-01, 2.147308806541882e-01, 2.292285044967963e-01, + 2.443176995441919e-01, 2.599697426559885e-01, 2.761548392785189e-01, 2.928421801604610e-01, 3.099999999999999e-01, + 3.275956379118843e-01, 3.455955995992783e-01, 3.639656211120587e-01, 3.826707340701924e-01, 4.016753322280344e-01, + 4.209432392528405e-01, 4.404377775884727e-01, 4.601218382732121e-01, 4.799579515787762e-01, 4.999083583360772e-01, + 5.199350818119455e-01, 5.400000000000000e-01, 5.600649181880546e-01, 5.800916416639228e-01, 6.000420484212237e-01, + 6.198781617267880e-01, 6.395622224115274e-01, 6.590567607471596e-01, 6.783246677719657e-01, 6.973292659298076e-01, + 7.160343788879413e-01, 7.344044004007217e-01, 7.524043620881156e-01, 7.699999999999999e-01, 7.871578198395390e-01, + 8.038451607214812e-01, 8.200302573440115e-01, 8.356823004558082e-01, 8.507714955032037e-01, 8.652691193458119e-01, + 8.791475749326572e-01, 8.923804438347298e-01, 9.049425365339682e-01, 9.168099403729364e-01, 9.279600650739274e-01, + 9.383716857408418e-01, 9.480249832619820e-01, 9.569015820368590e-01, 9.649845849551919e-01, 9.722586055615179e-01, + 9.787097973441844e-01, 9.843258800929715e-01, 9.890961632751694e-01, 9.930115663856157e-01, 9.960646362319528e-01, + 9.982495611222031e-01, 9.995621819276547e-01, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 9.995621819276547e-01, 9.982495611222031e-01, + 9.960646362319528e-01, 9.930115663856157e-01, 9.890961632751694e-01, 9.843258800929715e-01, 9.787097973441844e-01, + 9.722586055615179e-01, 9.649845849551919e-01, 9.569015820368590e-01, 9.480249832619820e-01, 9.383716857408418e-01, + 9.279600650739274e-01, 9.168099403729364e-01, 9.049425365339682e-01, 8.923804438347298e-01, 8.791475749326572e-01, + 8.652691193458119e-01, 8.507714955032037e-01, 8.356823004558082e-01, 8.200302573440115e-01, 8.038451607214812e-01, + 7.871578198395390e-01, 7.699999999999999e-01, 7.524043620881156e-01, 7.344044004007217e-01, 7.160343788879413e-01, + 6.973292659298076e-01, 6.783246677719657e-01, 6.590567607471596e-01, 6.395622224115274e-01, 6.198781617267880e-01, + 6.000420484212237e-01, 5.800916416639228e-01, 5.600649181880546e-01, 5.400000000000000e-01, 5.199350818119455e-01, + 4.999083583360772e-01, 4.799579515787762e-01, 4.601218382732121e-01, 4.404377775884727e-01, 4.209432392528405e-01, + 4.016753322280344e-01, 3.826707340701924e-01, 3.639656211120587e-01, 3.455955995992783e-01, 3.275956379118843e-01, + 3.099999999999999e-01, 2.928421801604610e-01, 2.761548392785189e-01, 2.599697426559885e-01, 2.443176995441919e-01, + 2.292285044967963e-01, 2.147308806541882e-01, 2.008524250673430e-01, 1.876195561652702e-01, 1.750574634660318e-01, + 1.631900596270638e-01, 1.520399349260726e-01, 1.416283142591582e-01, 1.319750167380180e-01, 1.230984179631410e-01, + 1.150154150448081e-01, 1.077413944384821e-01, 1.012902026558156e-01, 9.567411990702857e-02, 9.090383672483066e-02, + 8.698843361438435e-02, 8.393536376804722e-02, 8.175043887779704e-02, 8.043781807234540e-02 +}; +const LC3_FLOAT PhECU_whr16ms_SWB[512] = { + 8.000000000000002e-02, 8.024628976087178e-02, 8.098489531024239e-02, 8.221502573078943e-02, 8.393536376804722e-02, + 8.614406724095569e-02, 8.883877101451404e-02, 9.201658953242653e-02, 9.567411990702857e-02, 9.980744556318394e-02, + 1.044121404322514e-01, 1.094832736916302e-01, 1.150154150448081e-01, 1.210026405362591e-01, 1.274385388949634e-01, + 1.343162183997567e-01, 1.416283142591582e-01, 1.493669964977737e-01, 1.575239783408292e-01, 1.660905250878570e-01, + 1.750574634660318e-01, 1.844151914531410e-01, 1.941536885596704e-01, 2.042625265589956e-01, 2.147308806541882e-01, + 2.255475410694793e-01, 2.367009250539683e-01, 2.481790892847231e-01, 2.599697426559885e-01, 2.720602594408110e-01, + 2.844376928109830e-01, 2.970887887008307e-01, 3.099999999999999e-01, 3.231575010600410e-01, 3.365472024992595e-01, + 3.501547662899784e-01, 3.639656211120587e-01, 3.779649779562326e-01, 3.921378459605457e-01, 4.064690484629473e-01, + 4.209432392528405e-01, 4.355449190041883e-01, 4.502584518725810e-01, 4.650680822384892e-01, 4.799579515787762e-01, + 4.949121154484021e-01, 5.099145605541342e-01, 5.249492219019830e-01, 5.400000000000000e-01, 5.550507780980171e-01, + 5.700854394458659e-01, 5.850878845515979e-01, 6.000420484212237e-01, 6.149319177615109e-01, 6.297415481274190e-01, + 6.444550809958116e-01, 6.590567607471596e-01, 6.735309515370527e-01, 6.878621540394543e-01, 7.020350220437674e-01, + 7.160343788879413e-01, 7.298452337100215e-01, 7.434527975007406e-01, 7.568424989399589e-01, 7.699999999999999e-01, + 7.829112112991693e-01, 7.955623071890170e-01, 8.079397405591890e-01, 8.200302573440115e-01, 8.318209107152770e-01, + 8.432990749460317e-01, 8.544524589305209e-01, 8.652691193458119e-01, 8.757374734410044e-01, 8.858463114403297e-01, + 8.955848085468591e-01, 9.049425365339682e-01, 9.139094749121430e-01, 9.224760216591710e-01, 9.306330035022263e-01, + 9.383716857408418e-01, 9.456837816002432e-01, 9.525614611050366e-01, 9.589973594637410e-01, 9.649845849551919e-01, + 9.705167263083698e-01, 9.755878595677486e-01, 9.801925544368162e-01, 9.843258800929715e-01, 9.879834104675735e-01, + 9.911612289854861e-01, 9.938559327590444e-01, 9.960646362319528e-01, 9.977849742692106e-01, 9.990151046897577e-01, + 9.997537102391283e-01, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 9.997537102391283e-01, 9.990151046897577e-01, 9.977849742692106e-01, + 9.960646362319528e-01, 9.938559327590444e-01, 9.911612289854861e-01, 9.879834104675735e-01, 9.843258800929715e-01, + 9.801925544368162e-01, 9.755878595677486e-01, 9.705167263083698e-01, 9.649845849551919e-01, 9.589973594637410e-01, + 9.525614611050366e-01, 9.456837816002432e-01, 9.383716857408418e-01, 9.306330035022263e-01, 9.224760216591710e-01, + 9.139094749121430e-01, 9.049425365339682e-01, 8.955848085468591e-01, 8.858463114403297e-01, 8.757374734410044e-01, + 8.652691193458119e-01, 8.544524589305209e-01, 8.432990749460317e-01, 8.318209107152770e-01, 8.200302573440115e-01, + 8.079397405591890e-01, 7.955623071890170e-01, 7.829112112991693e-01, 7.699999999999999e-01, 7.568424989399589e-01, + 7.434527975007406e-01, 7.298452337100215e-01, 7.160343788879413e-01, 7.020350220437674e-01, 6.878621540394543e-01, + 6.735309515370527e-01, 6.590567607471596e-01, 6.444550809958116e-01, 6.297415481274190e-01, 6.149319177615109e-01, + 6.000420484212237e-01, 5.850878845515979e-01, 5.700854394458659e-01, 5.550507780980171e-01, 5.400000000000000e-01, + 5.249492219019830e-01, 5.099145605541342e-01, 4.949121154484021e-01, 4.799579515787762e-01, 4.650680822384892e-01, + 4.502584518725810e-01, 4.355449190041883e-01, 4.209432392528405e-01, 4.064690484629473e-01, 3.921378459605457e-01, + 3.779649779562326e-01, 3.639656211120587e-01, 3.501547662899784e-01, 3.365472024992595e-01, 3.231575010600410e-01, + 3.099999999999999e-01, 2.970887887008307e-01, 2.844376928109830e-01, 2.720602594408110e-01, 2.599697426559885e-01, + 2.481790892847231e-01, 2.367009250539683e-01, 2.255475410694793e-01, 2.147308806541882e-01, 2.042625265589956e-01, + 1.941536885596704e-01, 1.844151914531410e-01, 1.750574634660318e-01, 1.660905250878570e-01, 1.575239783408292e-01, + 1.493669964977737e-01, 1.416283142591582e-01, 1.343162183997567e-01, 1.274385388949634e-01, 1.210026405362591e-01, + 1.150154150448081e-01, 1.094832736916302e-01, 1.044121404322514e-01, 9.980744556318394e-02, 9.567411990702857e-02, + 9.201658953242653e-02, 8.883877101451404e-02, 8.614406724095569e-02, 8.393536376804722e-02, 8.221502573078943e-02, + 8.098489531024239e-02, 8.024628976087178e-02 +}; +const LC3_FLOAT PhECU_whr16ms_FB[768] = { + 8.000000000000002e-02, 8.010946754324183e-02, 8.043781807234540e-02, 8.098489531024239e-02, 8.175043887779704e-02, + 8.273408441773300e-02, 8.393536376804722e-02, 8.535370518483010e-02, 8.698843361438435e-02, 8.883877101451404e-02, + 9.090383672483066e-02, 9.318264788589975e-02, 9.567411990702857e-02, 9.837706698247278e-02, 1.012902026558156e-01, + 1.044121404322514e-01, 1.077413944384821e-01, 1.112763801299127e-01, 1.150154150448081e-01, 1.189567196050543e-01, + 1.230984179631410e-01, 1.274385388949634e-01, 1.319750167380180e-01, 1.367056923745465e-01, 1.416283142591582e-01, + 1.467405394904446e-01, 1.520399349260726e-01, 1.575239783408292e-01, 1.631900596270638e-01, 1.690354820369581e-01, + 1.750574634660318e-01, 1.812531377772744e-01, 1.876195561652702e-01, 1.941536885596704e-01, 2.008524250673430e-01, + 2.077125774525124e-01, 2.147308806541882e-01, 2.219039943401561e-01, 2.292285044967963e-01, 2.367009250539683e-01, + 2.443176995441919e-01, 2.520752027953329e-01, 2.599697426559885e-01, 2.679975617527521e-01, 2.761548392785189e-01, + 2.844376928109830e-01, 2.928421801604610e-01, 3.013643012461601e-01, 3.099999999999999e-01, 3.187451662970817e-01, + 3.275956379118843e-01, 3.365472024992595e-01, 3.455955995992783e-01, 3.547365226649809e-01, 3.639656211120587e-01, + 3.732785023894972e-01, 3.826707340701924e-01, 3.921378459605457e-01, 4.016753322280344e-01, 4.112786535457436e-01, + 4.209432392528405e-01, 4.306644895299604e-01, 4.404377775884727e-01, 4.502584518725810e-01, 4.601218382732121e-01, + 4.700232423526383e-01, 4.799579515787762e-01, 4.899212375680964e-01, 4.999083583360772e-01, 5.099145605541342e-01, + 5.199350818119455e-01, 5.299651528841020e-01, 5.400000000000000e-01, 5.500348471158981e-01, 5.600649181880546e-01, + 5.700854394458659e-01, 5.800916416639228e-01, 5.900787624319037e-01, 6.000420484212237e-01, 6.099767576473617e-01, + 6.198781617267880e-01, 6.297415481274190e-01, 6.395622224115274e-01, 6.493355104700396e-01, 6.590567607471596e-01, + 6.687213464542564e-01, 6.783246677719657e-01, 6.878621540394543e-01, 6.973292659298076e-01, 7.067214976105027e-01, + 7.160343788879413e-01, 7.252634773350191e-01, 7.344044004007217e-01, 7.434527975007406e-01, 7.524043620881156e-01, + 7.612548337029182e-01, 7.699999999999999e-01, 7.786356987538400e-01, 7.871578198395390e-01, 7.955623071890170e-01, + 8.038451607214812e-01, 8.120024382472478e-01, 8.200302573440115e-01, 8.279247972046673e-01, 8.356823004558082e-01, + 8.432990749460317e-01, 8.507714955032037e-01, 8.580960056598439e-01, 8.652691193458119e-01, 8.722874225474876e-01, + 8.791475749326572e-01, 8.858463114403297e-01, 8.923804438347298e-01, 8.987468622227257e-01, 9.049425365339682e-01, + 9.109645179630421e-01, 9.168099403729364e-01, 9.224760216591710e-01, 9.279600650739274e-01, 9.332594605095554e-01, + 9.383716857408418e-01, 9.432943076254536e-01, 9.480249832619820e-01, 9.525614611050366e-01, 9.569015820368590e-01, + 9.610432803949458e-01, 9.649845849551919e-01, 9.687236198700873e-01, 9.722586055615179e-01, 9.755878595677486e-01, + 9.787097973441844e-01, 9.816229330175272e-01, 9.843258800929715e-01, 9.868173521141004e-01, 9.890961632751694e-01, + 9.911612289854861e-01, 9.930115663856157e-01, 9.946462948151700e-01, 9.960646362319528e-01, 9.972659155822671e-01, + 9.982495611222031e-01, 9.990151046897577e-01, 9.995621819276547e-01, 9.998905324567582e-01, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, + 9.998905324567582e-01, 9.995621819276547e-01, 9.990151046897577e-01, 9.982495611222031e-01, 9.972659155822671e-01, + 9.960646362319528e-01, 9.946462948151700e-01, 9.930115663856157e-01, 9.911612289854861e-01, 9.890961632751694e-01, + 9.868173521141004e-01, 9.843258800929715e-01, 9.816229330175272e-01, 9.787097973441844e-01, 9.755878595677486e-01, + 9.722586055615179e-01, 9.687236198700873e-01, 9.649845849551919e-01, 9.610432803949458e-01, 9.569015820368590e-01, + 9.525614611050366e-01, 9.480249832619820e-01, 9.432943076254536e-01, 9.383716857408418e-01, 9.332594605095554e-01, + 9.279600650739274e-01, 9.224760216591710e-01, 9.168099403729364e-01, 9.109645179630421e-01, 9.049425365339682e-01, + 8.987468622227257e-01, 8.923804438347298e-01, 8.858463114403297e-01, 8.791475749326572e-01, 8.722874225474876e-01, + 8.652691193458119e-01, 8.580960056598439e-01, 8.507714955032037e-01, 8.432990749460317e-01, 8.356823004558082e-01, + 8.279247972046673e-01, 8.200302573440115e-01, 8.120024382472478e-01, 8.038451607214812e-01, 7.955623071890170e-01, + 7.871578198395390e-01, 7.786356987538400e-01, 7.699999999999999e-01, 7.612548337029182e-01, 7.524043620881156e-01, + 7.434527975007406e-01, 7.344044004007217e-01, 7.252634773350191e-01, 7.160343788879413e-01, 7.067214976105027e-01, + 6.973292659298076e-01, 6.878621540394543e-01, 6.783246677719657e-01, 6.687213464542564e-01, 6.590567607471596e-01, + 6.493355104700396e-01, 6.395622224115274e-01, 6.297415481274190e-01, 6.198781617267880e-01, 6.099767576473617e-01, + 6.000420484212237e-01, 5.900787624319037e-01, 5.800916416639228e-01, 5.700854394458659e-01, 5.600649181880546e-01, + 5.500348471158981e-01, 5.400000000000000e-01, 5.299651528841020e-01, 5.199350818119455e-01, 5.099145605541342e-01, + 4.999083583360772e-01, 4.899212375680964e-01, 4.799579515787762e-01, 4.700232423526383e-01, 4.601218382732121e-01, + 4.502584518725810e-01, 4.404377775884727e-01, 4.306644895299604e-01, 4.209432392528405e-01, 4.112786535457436e-01, + 4.016753322280344e-01, 3.921378459605457e-01, 3.826707340701924e-01, 3.732785023894972e-01, 3.639656211120587e-01, + 3.547365226649809e-01, 3.455955995992783e-01, 3.365472024992595e-01, 3.275956379118843e-01, 3.187451662970817e-01, + 3.099999999999999e-01, 3.013643012461601e-01, 2.928421801604610e-01, 2.844376928109830e-01, 2.761548392785189e-01, + 2.679975617527521e-01, 2.599697426559885e-01, 2.520752027953329e-01, 2.443176995441919e-01, 2.367009250539683e-01, + 2.292285044967963e-01, 2.219039943401561e-01, 2.147308806541882e-01, 2.077125774525124e-01, 2.008524250673430e-01, + 1.941536885596704e-01, 1.876195561652702e-01, 1.812531377772744e-01, 1.750574634660318e-01, 1.690354820369581e-01, + 1.631900596270638e-01, 1.575239783408292e-01, 1.520399349260726e-01, 1.467405394904446e-01, 1.416283142591582e-01, + 1.367056923745465e-01, 1.319750167380180e-01, 1.274385388949634e-01, 1.230984179631410e-01, 1.189567196050543e-01, + 1.150154150448081e-01, 1.112763801299127e-01, 1.077413944384821e-01, 1.044121404322514e-01, 1.012902026558156e-01, + 9.837706698247278e-02, 9.567411990702857e-02, 9.318264788589975e-02, 9.090383672483066e-02, 8.883877101451404e-02, + 8.698843361438435e-02, 8.535370518483010e-02, 8.393536376804722e-02, 8.273408441773300e-02, 8.175043887779704e-02, + 8.098489531024239e-02, 8.043781807234540e-02, 8.010946754324183e-02 +}; + +const LC3_FLOAT *PhECU_whr16ms_wins[5] = { + PhECU_whr16ms_NB, PhECU_whr16ms_WB, PhECU_whr16ms_SSWB, PhECU_whr16ms_SWB, PhECU_whr16ms_FB }; const LC3_FLOAT hannOla_8k[28 / 2 + 1] = { - 0.0000000000, 0.0125360439, 0.0495155660, 0.1090842588, 0.1882550991, 0.2830581304, 0.3887395330, 0.5000000000, 0.6112604670, 0.7169418696, 0.8117449009, 0.8909157412, 0.9504844340, - 0.9874639561, 1.0000000000 }; + 0.0000000000, 0.0125360439, 0.0495155660, 0.1090842588, 0.1882550991, 0.2830581304, 0.3887395330, 0.5000000000, 0.6112604670, 0.7169418696, 0.8117449009, 0.8909157412, 0.9504844340, + 0.9874639561, 1.0000000000 +}; const LC3_FLOAT hannOla_16k[56 / 2 + 1] = { - 0.0000000000, 0.0031438951, 0.0125360439, 0.0280583348, 0.0495155660, 0.0766379004, 0.1090842588, 0.1464466094, 0.1882550991, 0.2339839617, 0.2830581304, 0.3348604690, 0.3887395330, - 0.4440177619, 0.5000000000, 0.5559822381, 0.6112604670, 0.6651395310, 0.7169418696, 0.7660160383, 0.8117449009, 0.8535533906, 0.8909157412, 0.9233620996, 0.9504844340, 0.9719416652, - 0.9874639561, 0.9968561049, 1.0000000000 }; + 0.0000000000, 0.0031438951, 0.0125360439, 0.0280583348, 0.0495155660, 0.0766379004, 0.1090842588, 0.1464466094, 0.1882550991, 0.2339839617, 0.2830581304, 0.3348604690, 0.3887395330, + 0.4440177619, 0.5000000000, 0.5559822381, 0.6112604670, 0.6651395310, 0.7169418696, 0.7660160383, 0.8117449009, 0.8535533906, 0.8909157412, 0.9233620996, 0.9504844340, 0.9719416652, + 0.9874639561, 0.9968561049, 1.0000000000 +}; const LC3_FLOAT hannOla_24k[84 / 2 + 1] = { - 0.0000000000, 0.0013981014, 0.0055845869, 0.0125360439, 0.0222135971, 0.0345631257, 0.0495155660, 0.0669872981, 0.0868806128, 0.1090842588, 0.1334740641, 0.1599136311, 0.1882550991, - 0.2183399710, 0.2500000000, 0.2830581304, 0.3173294878, 0.3526224128, 0.3887395330, 0.4254788669, 0.4626349532, 0.5000000000, 0.5373650468, 0.5745211331, 0.6112604670, 0.6473775872, - 0.6826705122, 0.7169418696, 0.7500000000, 0.7816600290, 0.8117449009, 0.8400863689, 0.8665259359, 0.8909157412, 0.9131193872, 0.9330127019, 0.9504844340, 0.9654368743, 0.9777864029, - 0.9874639561, 0.9944154131, 0.9986018986, 1.0000000000 }; + 0.0000000000, 0.0013981014, 0.0055845869, 0.0125360439, 0.0222135971, 0.0345631257, 0.0495155660, 0.0669872981, 0.0868806128, 0.1090842588, 0.1334740641, 0.1599136311, 0.1882550991, + 0.2183399710, 0.2500000000, 0.2830581304, 0.3173294878, 0.3526224128, 0.3887395330, 0.4254788669, 0.4626349532, 0.5000000000, 0.5373650468, 0.5745211331, 0.6112604670, 0.6473775872, + 0.6826705122, 0.7169418696, 0.7500000000, 0.7816600290, 0.8117449009, 0.8400863689, 0.8665259359, 0.8909157412, 0.9131193872, 0.9330127019, 0.9504844340, 0.9654368743, 0.9777864029, + 0.9874639561, 0.9944154131, 0.9986018986, 1.0000000000 +}; const LC3_FLOAT hannOla_32k[112 / 2 + 1] = { - 0.0000000000, 0.0007865925, 0.0031438951, 0.0070644907, 0.0125360439, 0.0195413390, 0.0280583348, 0.0380602337, 0.0495155660, 0.0623882890, 0.0766379004, 0.0922195655, 0.1090842588, - 0.1271789176, 0.1464466094, 0.1668267110, 0.1882550991, 0.2106643519, 0.2339839617, 0.2581405564, 0.2830581304, 0.3086582838, 0.3348604690, 0.3615822443, 0.3887395330, 0.4162468883, - 0.4440177619, 0.4719647764, 0.5000000000, 0.5280352236, 0.5559822381, 0.5837531117, 0.6112604670, 0.6384177557, 0.6651395310, 0.6913417162, 0.7169418696, 0.7418594436, 0.7660160383, - 0.7893356481, 0.8117449009, 0.8331732890, 0.8535533906, 0.8728210824, 0.8909157412, 0.9077804345, 0.9233620996, 0.9376117110, 0.9504844340, 0.9619397663, 0.9719416652, 0.9804586610, - 0.9874639561, 0.9929355093, 0.9968561049, 0.9992134075, 1.0000000000 }; - -const LC3_FLOAT hannOla_48k[168 / 2 + 1] = { - 0.0000000000, 0.0003496476, 0.0013981014, 0.0031438951, 0.0055845869, 0.0087167634, 0.0125360439, 0.0170370869, 0.0222135971, 0.0280583348, 0.0345631257, 0.0417188721, 0.0495155660, - 0.0579423032, 0.0669872981, 0.0766379004, 0.0868806128, 0.0977011101, 0.1090842588, 0.1210141384, 0.1334740641, 0.1464466094, 0.1599136311, 0.1738562944, 0.1882550991, 0.2030899072, - 0.2183399710, 0.2339839617, 0.2500000000, 0.2663656859, 0.2830581304, 0.3000539878, 0.3173294878, 0.3348604690, 0.3526224128, 0.3705904774, 0.3887395330, 0.4070441964, 0.4254788669, - 0.4440177619, 0.4626349532, 0.4813044029, 0.5000000000, 0.5186955971, 0.5373650468, 0.5559822381, 0.5745211331, 0.5929558036, 0.6112604670, 0.6294095226, 0.6473775872, 0.6651395310, - 0.6826705122, 0.6999460122, 0.7169418696, 0.7336343141, 0.7500000000, 0.7660160383, 0.7816600290, 0.7969100928, 0.8117449009, 0.8261437056, 0.8400863689, 0.8535533906, 0.8665259359, - 0.8789858616, 0.8909157412, 0.9022988899, 0.9131193872, 0.9233620996, 0.9330127019, 0.9420576968, 0.9504844340, 0.9582811279, 0.9654368743, 0.9719416652, 0.9777864029, 0.9829629131, - 0.9874639561, 0.9912832366, 0.9944154131, 0.9968561049, 0.9986018986, 0.9996503524, 1.0000000000 }; + 0.0000000000, 0.0007865925, 0.0031438951, 0.0070644907, 0.0125360439, 0.0195413390, 0.0280583348, 0.0380602337, 0.0495155660, 0.0623882890, 0.0766379004, 0.0922195655, 0.1090842588, + 0.1271789176, 0.1464466094, 0.1668267110, 0.1882550991, 0.2106643519, 0.2339839617, 0.2581405564, 0.2830581304, 0.3086582838, 0.3348604690, 0.3615822443, 0.3887395330, 0.4162468883, + 0.4440177619, 0.4719647764, 0.5000000000, 0.5280352236, 0.5559822381, 0.5837531117, 0.6112604670, 0.6384177557, 0.6651395310, 0.6913417162, 0.7169418696, 0.7418594436, 0.7660160383, + 0.7893356481, 0.8117449009, 0.8331732890, 0.8535533906, 0.8728210824, 0.8909157412, 0.9077804345, 0.9233620996, 0.9376117110, 0.9504844340, 0.9619397663, 0.9719416652, 0.9804586610, + 0.9874639561, 0.9929355093, 0.9968561049, 0.9992134075, 1.0000000000 +}; + +const LC3_FLOAT hannOla_48k[168 / 2 + 1] = { + 0.0000000000, 0.0003496476, 0.0013981014, 0.0031438951, 0.0055845869, 0.0087167634, 0.0125360439, 0.0170370869, 0.0222135971, 0.0280583348, 0.0345631257, 0.0417188721, 0.0495155660, + 0.0579423032, 0.0669872981, 0.0766379004, 0.0868806128, 0.0977011101, 0.1090842588, 0.1210141384, 0.1334740641, 0.1464466094, 0.1599136311, 0.1738562944, 0.1882550991, 0.2030899072, + 0.2183399710, 0.2339839617, 0.2500000000, 0.2663656859, 0.2830581304, 0.3000539878, 0.3173294878, 0.3348604690, 0.3526224128, 0.3705904774, 0.3887395330, 0.4070441964, 0.4254788669, + 0.4440177619, 0.4626349532, 0.4813044029, 0.5000000000, 0.5186955971, 0.5373650468, 0.5559822381, 0.5745211331, 0.5929558036, 0.6112604670, 0.6294095226, 0.6473775872, 0.6651395310, + 0.6826705122, 0.6999460122, 0.7169418696, 0.7336343141, 0.7500000000, 0.7660160383, 0.7816600290, 0.7969100928, 0.8117449009, 0.8261437056, 0.8400863689, 0.8535533906, 0.8665259359, + 0.8789858616, 0.8909157412, 0.9022988899, 0.9131193872, 0.9233620996, 0.9330127019, 0.9420576968, 0.9504844340, 0.9582811279, 0.9654368743, 0.9719416652, 0.9777864029, 0.9829629131, + 0.9874639561, 0.9912832366, 0.9944154131, 0.9968561049, 0.9986018986, 0.9996503524, 1.0000000000 +}; const LC3_FLOAT *hannOla_wins[5] = { hannOla_8k, hannOla_16k, hannOla_24k, hannOla_32k, hannOla_48k }; -const LC3_FLOAT plc_tdc_lpc_8[17] = {1, 0.998890285693703, 0.995568526105076, 0.990056789412169, 0.982391584470799, 0.972623458066693, 0.960816439805232, 0.947047343167065, 0.931404933402306, 0.913988974871173, 0.894909172128633, 0.874284020464791, 0.852239582727672, 0.828908210053904, 0.804427224606163, 0.778937582561901, 0.752582535420797}; +const LC3_FLOAT plc_tdc_lpc_8[17] = { 1, 0.998890285693703, 0.995568526105076, 0.990056789412169, 0.982391584470799, 0.972623458066693, 0.960816439805232, 0.947047343167065, 0.931404933402306, 0.913988974871173, 0.894909172128633, 0.874284020464791, 0.852239582727672, 0.828908210053904, 0.804427224606163, 0.778937582561901, 0.752582535420797 }; -const LC3_FLOAT plc_tdc_lpc_16[17] = {1, 0.999722455898711, 0.998890285693703, 0.997504874399492, 0.995568526105076, 0.993084457588532, 0.990056789412169, 0.986490534532745, 0.982391584470799, 0.977766693092529, 0.972623458066693, 0.966970300067793, 0.960816439805232, 0.954171872966123, 0.947047343167065, 0.939454313017299, 0.931404933402306}; +const LC3_FLOAT plc_tdc_lpc_16[17] = { 1, 0.999722455898711, 0.998890285693703, 0.997504874399492, 0.995568526105076, 0.993084457588532, 0.990056789412169, 0.986490534532745, 0.982391584470799, 0.977766693092529, 0.972623458066693, 0.966970300067793, 0.960816439805232, 0.954171872966123, 0.947047343167065, 0.939454313017299, 0.931404933402306 }; -const LC3_FLOAT plc_tdc_lpc_24[17] = {1, 0.999876637554759, 0.999506641521283, 0.998890285693703, 0.998028026020383, 0.996920500041823, 0.995568526105076, 0.993973102356048, 0.992135405511397, 0.990056789412169, 0.987738783361644, 0.985183090250255, 0.982391584470799, 0.979366309627507, 0.976109476042902, 0.972623458066693, 0.968910791191297}; +const LC3_FLOAT plc_tdc_lpc_24[17] = { 1, 0.999876637554759, 0.999506641521283, 0.998890285693703, 0.998028026020383, 0.996920500041823, 0.995568526105076, 0.993973102356048, 0.992135405511397, 0.990056789412169, 0.987738783361644, 0.985183090250255, 0.982391584470799, 0.979366309627507, 0.976109476042902, 0.972623458066693, 0.968910791191297 }; -const LC3_FLOAT plc_tdc_lpc_32[17] = {1, 0.999930606751878, 0.999722455898711, 0.999375634094057, 0.998890285693703, 0.998266612655538, 0.997504874399492, 0.996605387627705, 0.995568526105076, 0.994394720400431, 0.993084457588532, 0.991638280913245, 0.990056789412169, 0.988340637503103, 0.986490534532745, 0.984507244288062, 0.982391584470799}; +const LC3_FLOAT plc_tdc_lpc_32[17] = { 1, 0.999930606751878, 0.999722455898711, 0.999375634094057, 0.998890285693703, 0.998266612655538, 0.997504874399492, 0.996605387627705, 0.995568526105076, 0.994394720400431, 0.993084457588532, 0.991638280913245, 0.990056789412169, 0.988340637503103, 0.986490534532745, 0.984507244288062, 0.982391584470799 }; -const LC3_FLOAT plc_tdc_lpc_48[17] = {1, 0.999969157961872, 0.999876637554759, 0.999722455898711, 0.999506641521283, 0.999229234348730, 0.998890285693703, 0.998489858239427, 0.998028026020383, 0.997504874399492, 0.996920500041823, 0.996275010884819, 0.995568526105076, 0.994801176081669, 0.993973102356048, 0.993084457588532, 0.992135405511397}; +const LC3_FLOAT plc_tdc_lpc_48[17] = { 1, 0.999969157961872, 0.999876637554759, 0.999722455898711, 0.999506641521283, 0.999229234348730, 0.998890285693703, 0.998489858239427, 0.998028026020383, 0.997504874399492, 0.996920500041823, 0.996275010884819, 0.995568526105076, 0.994801176081669, 0.993973102356048, 0.993084457588532, 0.992135405511397 }; -const LC3_FLOAT plc_tdc_lpc_96[17] = {1, 0.999992289401289, 0.999969157961872, 0.999930606751878, 0.999876637554759, 0.999807252867157, 0.999722455898711, 0.999622250571809, 0.999506641521283, 0.999375634094057, 0.999229234348730, 0.999067449055113, 0.998890285693703, 0.998697752455111, 0.998489858239427, 0.998266612655538, 0.998028026020383}; +const LC3_FLOAT plc_tdc_lpc_96[17] = { 1, 0.999992289401289, 0.999969157961872, 0.999930606751878, 0.999876637554759, 0.999807252867157, 0.999722455898711, 0.999622250571809, 0.999506641521283, 0.999375634094057, 0.999229234348730, 0.999067449055113, 0.998890285693703, 0.998697752455111, 0.998489858239427, 0.998266612655538, 0.998028026020383 }; -const LC3_FLOAT *plc_tdc_lpc_all[6] = {plc_tdc_lpc_8, plc_tdc_lpc_16, plc_tdc_lpc_24, plc_tdc_lpc_32, plc_tdc_lpc_48, plc_tdc_lpc_96}; +const LC3_FLOAT *plc_tdc_lpc_all[6] = { plc_tdc_lpc_8, plc_tdc_lpc_16, plc_tdc_lpc_24, plc_tdc_lpc_32, plc_tdc_lpc_48, plc_tdc_lpc_96 }; -const LC3_FLOAT plc_tdc_lpc_8_25ms[9] = {1, 0.998890285693703, 0.995568526105076, 0.990056789412169, 0.982391584470799, 0.972623458066693, 0.960816439805232, 0.947047343167065, 0.931404933402306}; +const LC3_FLOAT plc_tdc_lpc_8_25ms[9] = { 1, 0.998890285693703, 0.995568526105076, 0.990056789412169, 0.982391584470799, 0.972623458066693, 0.960816439805232, 0.947047343167065, 0.931404933402306 }; -const LC3_FLOAT plc_preemph_fac[] = {0.62, 0.72, 0.82, 0.92, 0.92, 0.92}; +const LC3_FLOAT plc_preemph_fac[] = { 0.62, 0.72, 0.82, 0.92, 0.92, 0.92 }; const LC3_INT ACC_COEFF_PER_BAND_PLC_8_10ms[81] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80}; + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80 +}; const LC3_INT ACC_COEFF_PER_BAND_PLC_16_10ms[81] = { - 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, - 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, - 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, - 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160}; + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, + 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, + 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, + 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160 +}; const LC3_INT ACC_COEFF_PER_BAND_PLC_24_10ms[81] = { - 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, - 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120, 123, + 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, + 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120, 123, 126, 129, 132, 135, 138, 141, 144, 147, 150, 153, 156, 159, 162, 165, 168, 171, 174, 177, 180, 183, 186, - 189, 192, 195, 198, 201, 204, 207, 210, 213, 216, 219, 222, 225, 228, 231, 234, 237, 240}; + 189, 192, 195, 198, 201, 204, 207, 210, 213, 216, 219, 222, 225, 228, 231, 234, 237, 240 +}; const LC3_INT ACC_COEFF_PER_BAND_PLC_32_10ms[81] = { - 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, - 84, 88, 92, 96, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 148, 152, 156, 160, 164, + 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, + 84, 88, 92, 96, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 148, 152, 156, 160, 164, 168, 172, 176, 180, 184, 188, 192, 196, 200, 204, 208, 212, 216, 220, 224, 228, 232, 236, 240, 244, 248, - 252, 256, 260, 264, 268, 272, 276, 280, 284, 288, 292, 296, 300, 304, 308, 312, 316, 320}; + 252, 256, 260, 264, 268, 272, 276, 280, 284, 288, 292, 296, 300, 304, 308, 312, 316, 320 +}; const LC3_INT ACC_COEFF_PER_BAND_PLC_48_10ms[81] = { - 0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, + 0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, 126, 132, 138, 144, 150, 156, 162, 168, 174, 180, 186, 192, 198, 204, 210, 216, 222, 228, 234, 240, 246, 252, 258, 264, 270, 276, 282, 288, 294, 300, 306, 312, 318, 324, 330, 336, 342, 348, 354, 360, 366, 372, - 378, 384, 390, 396 , 402, 408, 414, 420, 426, 432, 438, 444, 450, 456, 462, 468, 474, 480}; + 378, 384, 390, 396, 402, 408, 414, 420, 426, 432, 438, 444, 450, 456, 462, 468, 474, 480 +}; const LC3_INT ACC_COEFF_PER_BAND_PLC_96_10ms[81] = { - 0, 12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240, + 0, 12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240, 252, 264, 276, 288, 300, 312, 324, 336, 348, 360, 372, 384, 396, 408, 420, 432, 444, 456, 468, 480, 492, 504, 516, 528, 540, 552, 564, 576, 588, 600, 612, 624, 636, 648, 660, 672, 684, 696, 708, 720, 732, 744, - 756, 768, 780, 792, 804, 816, 828, 840, 852, 864, 876, 888, 900, 912, 924, 936, 948, 960}; + 756, 768, 780, 792, 804, 816, 828, 840, 852, 864, 876, 888, 900, 912, 924, 936, 948, 960 +}; -const LC3_INT* ACC_COEFF_PER_BAND_PLC[] = { - ACC_COEFF_PER_BAND_PLC_8_10ms, ACC_COEFF_PER_BAND_PLC_16_10ms, ACC_COEFF_PER_BAND_PLC_24_10ms, - ACC_COEFF_PER_BAND_PLC_32_10ms, ACC_COEFF_PER_BAND_PLC_48_10ms, ACC_COEFF_PER_BAND_PLC_96_10ms}; +const LC3_INT *ACC_COEFF_PER_BAND_PLC[] = { + ACC_COEFF_PER_BAND_PLC_8_10ms, ACC_COEFF_PER_BAND_PLC_16_10ms, ACC_COEFF_PER_BAND_PLC_24_10ms, + ACC_COEFF_PER_BAND_PLC_32_10ms, ACC_COEFF_PER_BAND_PLC_48_10ms, ACC_COEFF_PER_BAND_PLC_96_10ms +}; -const LC3_INT ACC_COEFF_PER_BAND_PLC_8_2_5ms[21] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}; +const LC3_INT ACC_COEFF_PER_BAND_PLC_8_2_5ms[21] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }; -const LC3_INT ACC_COEFF_PER_BAND_PLC_16_2_5ms[41] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40}; +const LC3_INT ACC_COEFF_PER_BAND_PLC_16_2_5ms[41] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 }; -const LC3_INT ACC_COEFF_PER_BAND_PLC_24_2_5ms[61] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60}; +const LC3_INT ACC_COEFF_PER_BAND_PLC_24_2_5ms[61] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60 }; const LC3_INT ACC_COEFF_PER_BAND_PLC_32_2_5ms[81] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80}; + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80 +}; const LC3_INT ACC_COEFF_PER_BAND_PLC_48_2_5ms[61] = { - 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, - 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, - 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120}; + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, + 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, + 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120 +}; const LC3_INT ACC_COEFF_PER_BAND_PLC_96_2_5ms[81] = { - 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, - 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120, 123, + 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, + 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120, 123, 126, 129, 132, 135, 138, 141, 144, 147, 150, 153, 156, 159, 162, 165, 168, 171, 174, 177, 180, 183, 186, - 189, 192, 195, 198, 201, 204, 207, 210, 213, 216, 219, 222, 225, 228, 231, 234, 237, 240}; + 189, 192, 195, 198, 201, 204, 207, 210, 213, 216, 219, 222, 225, 228, 231, 234, 237, 240 +}; -const LC3_INT* ACC_COEFF_PER_BAND_PLC_2_5ms[] = { - ACC_COEFF_PER_BAND_PLC_8_2_5ms, ACC_COEFF_PER_BAND_PLC_16_2_5ms, ACC_COEFF_PER_BAND_PLC_24_2_5ms, - ACC_COEFF_PER_BAND_PLC_32_2_5ms, ACC_COEFF_PER_BAND_PLC_48_2_5ms, ACC_COEFF_PER_BAND_PLC_96_2_5ms}; +const LC3_INT *ACC_COEFF_PER_BAND_PLC_2_5ms[] = { + ACC_COEFF_PER_BAND_PLC_8_2_5ms, ACC_COEFF_PER_BAND_PLC_16_2_5ms, ACC_COEFF_PER_BAND_PLC_24_2_5ms, + ACC_COEFF_PER_BAND_PLC_32_2_5ms, ACC_COEFF_PER_BAND_PLC_48_2_5ms, ACC_COEFF_PER_BAND_PLC_96_2_5ms +}; -const LC3_INT ACC_COEFF_PER_BAND_PLC_8_5ms[41] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40}; +const LC3_INT ACC_COEFF_PER_BAND_PLC_8_5ms[41] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 }; const LC3_INT ACC_COEFF_PER_BAND_PLC_16_5ms[81] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80}; + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80 +}; -const LC3_INT ACC_COEFF_PER_BAND_PLC_24_5ms[41] = {0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, - 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, - 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120}; +const LC3_INT ACC_COEFF_PER_BAND_PLC_24_5ms[41] = { 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, + 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, + 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120 }; const LC3_INT ACC_COEFF_PER_BAND_PLC_32_5ms[81] = { - 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, - 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, - 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, - 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160}; + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, + 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, + 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, + 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160 +}; const LC3_INT ACC_COEFF_PER_BAND_PLC_48_5ms[81] = { - 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, - 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120, 123, + 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, + 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120, 123, 126, 129, 132, 135, 138, 141, 144, 147, 150, 153, 156, 159, 162, 165, 168, 171, 174, 177, 180, 183, 186, - 189, 192, 195, 198, 201, 204, 207, 210, 213, 216, 219, 222, 225, 228, 231, 234, 237, 240}; + 189, 192, 195, 198, 201, 204, 207, 210, 213, 216, 219, 222, 225, 228, 231, 234, 237, 240 +}; const LC3_INT ACC_COEFF_PER_BAND_PLC_96_5ms[81] = { - 0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, + 0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, 126, 132, 138, 144, 150, 156, 162, 168, 174, 180, 186, 192, 198, 204, 210, 216, 222, 228, 234, 240, 246, 252, 258, 264, 270, 276, 282, 288, 294, 300, 306, 312, 318, 324, 330, 336, 342, 348, 354, 360, 366, 372, - 378, 384, 390, 396, 402, 408, 414, 420, 426, 432, 438, 444, 450, 456, 462, 468, 474, 480}; + 378, 384, 390, 396, 402, 408, 414, 420, 426, 432, 438, 444, 450, 456, 462, 468, 474, 480 +}; -const LC3_INT* ACC_COEFF_PER_BAND_PLC_5ms[] = { - ACC_COEFF_PER_BAND_PLC_8_5ms, ACC_COEFF_PER_BAND_PLC_16_5ms, ACC_COEFF_PER_BAND_PLC_24_5ms, - ACC_COEFF_PER_BAND_PLC_32_5ms, ACC_COEFF_PER_BAND_PLC_48_5ms, ACC_COEFF_PER_BAND_PLC_96_5ms}; +const LC3_INT *ACC_COEFF_PER_BAND_PLC_5ms[] = { + ACC_COEFF_PER_BAND_PLC_8_5ms, ACC_COEFF_PER_BAND_PLC_16_5ms, ACC_COEFF_PER_BAND_PLC_24_5ms, + ACC_COEFF_PER_BAND_PLC_32_5ms, ACC_COEFF_PER_BAND_PLC_48_5ms, ACC_COEFF_PER_BAND_PLC_96_5ms +}; const LC3_INT32 mdct_grp_bins[10] = { 4, 14, 24, 44, 84, 164, 244, 324, 404, 484 }; - diff --git a/lib_lc3plus/constants.h b/lib_lc3plus/constants.h index c0c9e286e5..de3e093df5 100644 --- a/lib_lc3plus/constants.h +++ b/lib_lc3plus/constants.h @@ -1,12 +1,12 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #ifndef CONSTANTS_H #define CONSTANTS_H @@ -27,7 +27,7 @@ extern const LC3_INT ari_spec_bits_fl[64][17]; /* SNS */ extern const LC3_FLOAT sns_LFCB[8][32]; extern const LC3_FLOAT sns_HFCB[8][32]; -extern const LC3_INT pvq_enc_A[16][11]; +extern const LC3_INT pvq_enc_A[16][11]; extern const LC3_FLOAT idct_lookup[M][M]; /* 12.8 kHz resampler */ @@ -35,15 +35,15 @@ extern const LC3_FLOAT lp_scale_factors[6]; extern const LC3_INT32 resamp_params[][4]; extern const LC3_FLOAT *lp_filter[6]; -extern const LC3_FLOAT highpass50_filt_b[3]; -extern const LC3_FLOAT highpass50_filt_a[3]; -extern const LC3_INT up_fac[6]; +extern const LC3_FLOAT highpass50_filt_b[3]; +extern const LC3_FLOAT highpass50_filt_a[3]; +extern const LC3_INT up_fac[6]; /* TNS */ extern const LC3_FLOAT quants_pts_tns[17]; -extern const LC3_INT huff_bits_tns[8][17]; -extern const LC3_INT order1_tns[8]; -extern const LC3_INT order2_tns[8]; +extern const LC3_INT huff_bits_tns[8][17]; +extern const LC3_INT order1_tns[8]; +extern const LC3_INT order2_tns[8]; extern const LC3_FLOAT lagw_tns[9]; extern const LC3_FLOAT quants_pts_tns[17]; extern const LC3_FLOAT quants_thr_tns[18]; @@ -57,9 +57,9 @@ extern const LC3_FLOAT sns_vq_reg_adj_gains_fl[2]; extern const LC3_FLOAT sns_dec_gains[4][8]; /* Global Gain */ -extern const LC3_INT gg_p1[6]; -extern const LC3_INT gg_p2[6]; -extern const LC3_INT gg_p3[6]; +extern const LC3_INT gg_p1[6]; +extern const LC3_INT gg_p2[6]; +extern const LC3_INT gg_p3[6]; extern const LC3_FLOAT gg_c[6]; extern const LC3_FLOAT gg_d[6]; @@ -82,28 +82,28 @@ extern const LC3_FLOAT enc_inter_filter[4][4]; /* Bandwidth Detector */ extern const LC3_INT threshold_quiet[4]; extern const LC3_INT threshold_brickwall[4]; -extern const LC3_INT brickwall_dist[4]; -extern const LC3_INT BW_warp_idx_start_16k[4]; -extern const LC3_INT BW_warp_idx_stop_16k[4]; -extern const LC3_INT BW_warp_idx_start_24k[4]; -extern const LC3_INT BW_warp_idx_stop_24k[4]; -extern const LC3_INT BW_warp_idx_start_32k[4]; -extern const LC3_INT BW_warp_idx_stop_32k[4]; -extern const LC3_INT BW_warp_idx_start_48k[4]; -extern const LC3_INT BW_warp_idx_stop_48k[4]; -extern const LC3_INT* BW_warp_idx_start_all[4]; -extern const LC3_INT* BW_warp_idx_stop_all[4]; - -extern const LC3_INT BW_warp_idx_start_16k_2_5ms[4]; -extern const LC3_INT BW_warp_idx_stop_16k_2_5ms[4]; -extern const LC3_INT BW_warp_idx_start_24k_2_5ms[4]; -extern const LC3_INT BW_warp_idx_stop_24k_2_5ms[4]; -extern const LC3_INT BW_warp_idx_start_32k_2_5ms[4]; -extern const LC3_INT BW_warp_idx_stop_32k_2_5ms[4]; -extern const LC3_INT BW_warp_idx_start_48k_2_5ms[4]; -extern const LC3_INT BW_warp_idx_stop_48k_2_5ms[4]; -extern const LC3_INT* BW_warp_idx_start_all_2_5ms[4]; -extern const LC3_INT* BW_warp_idx_stop_all_2_5ms[4]; +extern const LC3_INT brickwall_dist[4]; +extern const LC3_INT BW_warp_idx_start_16k[4]; +extern const LC3_INT BW_warp_idx_stop_16k[4]; +extern const LC3_INT BW_warp_idx_start_24k[4]; +extern const LC3_INT BW_warp_idx_stop_24k[4]; +extern const LC3_INT BW_warp_idx_start_32k[4]; +extern const LC3_INT BW_warp_idx_stop_32k[4]; +extern const LC3_INT BW_warp_idx_start_48k[4]; +extern const LC3_INT BW_warp_idx_stop_48k[4]; +extern const LC3_INT *BW_warp_idx_start_all[4]; +extern const LC3_INT *BW_warp_idx_stop_all[4]; + +extern const LC3_INT BW_warp_idx_start_16k_2_5ms[4]; +extern const LC3_INT BW_warp_idx_stop_16k_2_5ms[4]; +extern const LC3_INT BW_warp_idx_start_24k_2_5ms[4]; +extern const LC3_INT BW_warp_idx_stop_24k_2_5ms[4]; +extern const LC3_INT BW_warp_idx_start_32k_2_5ms[4]; +extern const LC3_INT BW_warp_idx_stop_32k_2_5ms[4]; +extern const LC3_INT BW_warp_idx_start_48k_2_5ms[4]; +extern const LC3_INT BW_warp_idx_stop_48k_2_5ms[4]; +extern const LC3_INT *BW_warp_idx_start_all_2_5ms[4]; +extern const LC3_INT *BW_warp_idx_stop_all_2_5ms[4]; extern const LC3_INT BW_cutoff_bin_all_2_5ms_HR[MAX_BW_BANDS_NUMBER]; extern const LC3_INT bands_number_2_5ms_HR[6]; @@ -111,17 +111,17 @@ extern const LC3_INT BW_cutoff_bin_all_2_5ms[MAX_BW_BANDS_NUMBER]; extern const LC3_INT bands_number_2_5ms[5]; -extern const LC3_INT BW_warp_idx_start_16k_5ms[4]; -extern const LC3_INT BW_warp_idx_stop_16k_5ms[4]; -extern const LC3_INT BW_warp_idx_start_24k_5ms[4]; -extern const LC3_INT BW_warp_idx_stop_24k_5ms[4]; -extern const LC3_INT BW_warp_idx_start_32k_5ms[4]; -extern const LC3_INT BW_warp_idx_stop_32k_5ms[4]; -extern const LC3_INT BW_warp_idx_start_48k_5ms[4]; -extern const LC3_INT BW_warp_idx_stop_48k_5ms[4]; -extern const LC3_INT* BW_warp_idx_start_all_5ms[4]; -extern const LC3_INT* BW_warp_idx_stop_all_5ms[4]; -extern const LC3_INT BW_cutoff_bin_all_5ms[MAX_BW_BANDS_NUMBER]; +extern const LC3_INT BW_warp_idx_start_16k_5ms[4]; +extern const LC3_INT BW_warp_idx_stop_16k_5ms[4]; +extern const LC3_INT BW_warp_idx_start_24k_5ms[4]; +extern const LC3_INT BW_warp_idx_stop_24k_5ms[4]; +extern const LC3_INT BW_warp_idx_start_32k_5ms[4]; +extern const LC3_INT BW_warp_idx_stop_32k_5ms[4]; +extern const LC3_INT BW_warp_idx_start_48k_5ms[4]; +extern const LC3_INT BW_warp_idx_stop_48k_5ms[4]; +extern const LC3_INT *BW_warp_idx_start_all_5ms[4]; +extern const LC3_INT *BW_warp_idx_stop_all_5ms[4]; +extern const LC3_INT BW_cutoff_bin_all_5ms[MAX_BW_BANDS_NUMBER]; extern const LC3_INT bands_number_5ms[6]; extern const LC3_INT BW_cutoff_bin_all_HR[MAX_BW_BANDS_NUMBER]; extern const LC3_INT BW_cutoff_bin_all_5ms_HR[MAX_BW_BANDS_NUMBER]; @@ -139,16 +139,16 @@ extern const LC3_FLOAT MDCT_WINDOW_240[480]; extern const LC3_FLOAT MDCT_WINDOW_320[640]; extern const LC3_FLOAT MDCT_WINDOW_480[960]; extern const LC3_FLOAT MDCT_WINDOW_960[1920]; -extern const LC3_FLOAT* MDCT_WINS_10ms[2][6]; -extern const LC3_INT MDCT_la_zeroes[6]; +extern const LC3_FLOAT *MDCT_WINS_10ms[2][6]; +extern const LC3_INT MDCT_la_zeroes[6]; extern const LC3_FLOAT MDCT_WINDOW_80_2_5ms[40]; extern const LC3_FLOAT MDCT_WINDOW_160_2_5ms[80]; extern const LC3_FLOAT MDCT_WINDOW_240_2_5ms[120]; extern const LC3_FLOAT MDCT_WINDOW_320_2_5ms[160]; extern const LC3_FLOAT MDCT_WINDOW_480_2_5ms[240]; -extern const LC3_FLOAT* MDCT_WINS_2_5ms[2][6]; -extern const LC3_INT MDCT_la_zeroes_2_5ms[6]; +extern const LC3_FLOAT *MDCT_WINS_2_5ms[2][6]; +extern const LC3_INT MDCT_la_zeroes_2_5ms[6]; extern const LC3_FLOAT MDCT_WINDOW_80_5ms[80]; @@ -156,8 +156,8 @@ extern const LC3_FLOAT MDCT_WINDOW_160_5ms[160]; extern const LC3_FLOAT MDCT_WINDOW_240_5ms[240]; extern const LC3_FLOAT MDCT_WINDOW_320_5ms[320]; extern const LC3_FLOAT MDCT_WINDOW_480_5ms[480]; -extern const LC3_FLOAT* MDCT_WINS_5ms[2][6]; -extern const LC3_INT MDCT_la_zeroes_5ms[6]; +extern const LC3_FLOAT *MDCT_WINS_5ms[2][6]; +extern const LC3_INT MDCT_la_zeroes_5ms[6]; extern const LC3_INT MDCT_WINDOWS_LENGTHS_10ms[6]; @@ -167,15 +167,15 @@ extern const LC3_INT MDCT_WINDOWS_LENGTHS_2_5ms[6]; extern const LC3_INT MDCT_WINDOWS_LENGTHS_5ms[6]; /* Per band energy */ -extern const LC3_INT* ACC_COEFF_PER_BAND[6]; -extern const LC3_INT* ACC_COEFF_PER_BAND_HR[6]; +extern const LC3_INT *ACC_COEFF_PER_BAND[6]; +extern const LC3_INT *ACC_COEFF_PER_BAND_HR[6]; -extern const LC3_INT* ACC_COEFF_PER_BAND_2_5ms_HR[6]; -extern const LC3_INT* ACC_COEFF_PER_BAND_2_5ms[5]; +extern const LC3_INT *ACC_COEFF_PER_BAND_2_5ms_HR[6]; +extern const LC3_INT *ACC_COEFF_PER_BAND_2_5ms[5]; -extern const LC3_INT* ACC_COEFF_PER_BAND_5ms_HR[6]; -extern const LC3_INT* ACC_COEFF_PER_BAND_5ms[5]; +extern const LC3_INT *ACC_COEFF_PER_BAND_5ms_HR[6]; +extern const LC3_INT *ACC_COEFF_PER_BAND_5ms[5]; /* Near Nyquist detector */ extern const LC3_INT NN_thresh; @@ -183,14 +183,14 @@ extern const LC3_INT NN_thresh; extern const LC3_INT32 xavg_N_grp[5]; extern const LC3_FLOAT *hannOla_wins[5]; -extern const LC3_INT32 gwlpr[MAX_LGW+1]; +extern const LC3_INT32 gwlpr[MAX_LGW + 1]; extern const LC3_INT32 mdct_grp_bins[10]; -extern const LC3_FLOAT* PhECU_whr16ms_wins[5]; +extern const LC3_FLOAT *PhECU_whr16ms_wins[5]; extern const LC3_FLOAT plc_preemph_fac[]; -extern const LC3_INT* ACC_COEFF_PER_BAND_PLC[]; -extern const LC3_INT* ACC_COEFF_PER_BAND_PLC_2_5ms[]; -extern const LC3_INT* ACC_COEFF_PER_BAND_PLC_5ms[]; +extern const LC3_INT *ACC_COEFF_PER_BAND_PLC[]; +extern const LC3_INT *ACC_COEFF_PER_BAND_PLC_2_5ms[]; +extern const LC3_INT *ACC_COEFF_PER_BAND_PLC_5ms[]; extern const LC3_FLOAT *plc_tdc_lpc_all[6]; extern const LC3_FLOAT plc_tdc_lpc_8[17]; extern const LC3_FLOAT plc_tdc_lpc_16[17]; diff --git a/lib_lc3plus/cutoff_bandwidth.c b/lib_lc3plus/cutoff_bandwidth.c index 642b2afda2..3bfa6278b3 100644 --- a/lib_lc3plus/cutoff_bandwidth.c +++ b/lib_lc3plus/cutoff_bandwidth.c @@ -1,27 +1,30 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -void process_cutoff_bandwidth(LC3_FLOAT *d_fl, LC3_INT len, LC3_INT bw_bin) +void process_cutoff_bandwidth( LC3_FLOAT *d_fl, LC3_INT len, LC3_INT bw_bin ) { LC3_INT i = 0; - - if (len > bw_bin){ - for (i = -1; i < 3; i++) { - d_fl[bw_bin + i] = d_fl[bw_bin + i] * LC3_POW(2, -(i + 2)); + + if ( len > bw_bin ) + { + for ( i = -1; i < 3; i++ ) + { + d_fl[bw_bin + i] = d_fl[bw_bin + i] * LC3_POW( 2, -( i + 2 ) ); } - for (i = bw_bin + 3; i < len; i++) { + for ( i = bw_bin + 3; i < len; i++ ) + { d_fl[i] = 0; - } + } } } diff --git a/lib_lc3plus/dct4.c b/lib_lc3plus/dct4.c index 8fd5784b28..a9b146a2af 100644 --- a/lib_lc3plus/dct4.c +++ b/lib_lc3plus/dct4.c @@ -1,95 +1,102 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -void dct2_init(Dct2* dct, int length) +void dct2_init( Dct2 *dct, int length ) { - assert(length <= MAX_LEN); + assert( length <= MAX_LEN ); dct->length = length; - fft_init(&dct->fft, length); + fft_init( &dct->fft, length ); } -void dct2_free(Dct2* dct) +void dct2_free( Dct2 *dct ) { - if (dct) { - fft_free(&dct->fft); - memset(dct, 0, sizeof(*dct)); + if ( dct ) + { + fft_free( &dct->fft ); + memset( dct, 0, sizeof( *dct ) ); } } -void dct2_apply(Dct2* dct, const LC3_FLOAT* input, LC3_FLOAT* output) +void dct2_apply( Dct2 *dct, const LC3_FLOAT *input, LC3_FLOAT *output ) { - Complex tmp1[MAX_LEN]; - Complex tmp2[MAX_LEN]; - int i = 0; + Complex tmp1[MAX_LEN]; + Complex tmp2[MAX_LEN]; + int i = 0; const int len = dct->length; - assert(input != output); + assert( input != output ); - for (i = 0; i < len / 2; i++) { - tmp1[i] = cmplx(input[i * 2], 0); - tmp1[len - i - 1] = cmplx(input[i * 2 + 1], 0); + for ( i = 0; i < len / 2; i++ ) + { + tmp1[i] = cmplx( input[i * 2], 0 ); + tmp1[len - i - 1] = cmplx( input[i * 2 + 1], 0 ); } - fft_apply(&dct->fft, tmp1, tmp2); + fft_apply( &dct->fft, tmp1, tmp2 ); - for (i = 0; i < len; i++) { - output[i] = cmul(tmp2[i], dct2_16[i]).r; + for ( i = 0; i < len; i++ ) + { + output[i] = cmul( tmp2[i], dct2_16[i] ).r; } - output[0] /= (LC3_FLOAT)1.414213562373095; /* SQRT(2) */ + output[0] /= (LC3_FLOAT) 1.414213562373095; /* SQRT(2) */ } -void dct4_init(Dct4* dct, int length) +void dct4_init( Dct4 *dct, int length ) { - int i = 0; - assert(length <= MAX_LEN); + int i = 0; + assert( length <= MAX_LEN ); dct->length = length; - dct->twid1 = calloc(sizeof(*dct->twid1), length / 2); - dct->twid2 = calloc(sizeof(*dct->twid2), length / 2); - for (i = 0; i < length / 2; i++) { - dct->twid1[i] = cexpi(-(LC3_FLOAT)M_PI * (i + (LC3_FLOAT)0.25) / length); - dct->twid2[i] = cexpi(-(LC3_FLOAT)M_PI * i / length); + dct->twid1 = calloc( sizeof( *dct->twid1 ), length / 2 ); + dct->twid2 = calloc( sizeof( *dct->twid2 ), length / 2 ); + for ( i = 0; i < length / 2; i++ ) + { + dct->twid1[i] = cexpi( -(LC3_FLOAT) M_PI * ( i + (LC3_FLOAT) 0.25 ) / length ); + dct->twid2[i] = cexpi( -(LC3_FLOAT) M_PI * i / length ); } - fft_init(&dct->fft, length / 2); + fft_init( &dct->fft, length / 2 ); } -void dct4_free(Dct4* dct) +void dct4_free( Dct4 *dct ) { - if (dct) { - free(dct->twid1); - free(dct->twid2); - fft_free(&dct->fft); - memset(dct, 0, sizeof(*dct)); + if ( dct ) + { + free( dct->twid1 ); + free( dct->twid2 ); + fft_free( &dct->fft ); + memset( dct, 0, sizeof( *dct ) ); } } -void dct4_apply(Dct4* dct, const LC3_FLOAT* input, LC3_FLOAT* output) +void dct4_apply( Dct4 *dct, const LC3_FLOAT *input, LC3_FLOAT *output ) { - Complex tmp2[MAX_LEN / 2]; - int i = 0; - Complex* tmp1 = (Complex*)output; - const int len = dct->length; - const LC3_FLOAT norm = (LC3_FLOAT)1.0 / LC3_SQRT((LC3_FLOAT)(len >> 1)); - assert(input != output); + Complex tmp2[MAX_LEN / 2]; + int i = 0; + Complex *tmp1 = (Complex *) output; + const int len = dct->length; + const LC3_FLOAT norm = (LC3_FLOAT) 1.0 / LC3_SQRT( (LC3_FLOAT) ( len >> 1 ) ); + assert( input != output ); - for (i = 0; i < len / 2; i++) { - tmp1[i] = cmul(cmplx(input[i * 2], input[len - i * 2 - 1]), dct->twid1[i]); + for ( i = 0; i < len / 2; i++ ) + { + tmp1[i] = cmul( cmplx( input[i * 2], input[len - i * 2 - 1] ), dct->twid1[i] ); } - fft_apply(&dct->fft, tmp1, tmp2); + fft_apply( &dct->fft, tmp1, tmp2 ); - for (i = 0; i < len / 2; i++) { - Complex t = cmul(tmp2[i], dct->twid2[i]); - output[i * 2] = t.r * norm; + for ( i = 0; i < len / 2; i++ ) + { + Complex t = cmul( tmp2[i], dct->twid2[i] ); + output[i * 2] = t.r * norm; output[len - i * 2 - 1] = -t.i * norm; } } diff --git a/lib_lc3plus/dec_entropy.c b/lib_lc3plus/dec_entropy.c index d8512a1068..38f8f76a8d 100644 --- a/lib_lc3plus/dec_entropy.c +++ b/lib_lc3plus/dec_entropy.c @@ -1,253 +1,284 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -static void read_bit_fl(LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* bit); -static void read_uint_fl(LC3_INT nbits, LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* val); +static void read_bit_fl( LC3_UINT8 *ptr, LC3_INT *mask_side, LC3_INT *bp_side, LC3_INT *bit ); +static void read_uint_fl( LC3_INT nbits, LC3_UINT8 *ptr, LC3_INT *mask_side, LC3_INT *bp_side, LC3_INT *val ); -void read_bit_fl(LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* bit) +void read_bit_fl( LC3_UINT8 *ptr, LC3_INT *mask_side, LC3_INT *bp_side, LC3_INT *bit ) { - if (ptr[*bp_side] & *mask_side) { + if ( ptr[*bp_side] & *mask_side ) + { *bit = 1; - } else { + } + else + { *bit = 0; } - if (*mask_side == 128) { + if ( *mask_side == 128 ) + { *mask_side = 1; - *bp_side = *bp_side - 1; - } else { + *bp_side = *bp_side - 1; + } + else + { *mask_side = *mask_side * 2; } } -void read_uint_fl(LC3_INT nbits, LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* val) +void read_uint_fl( LC3_INT nbits, LC3_UINT8 *ptr, LC3_INT *mask_side, LC3_INT *bp_side, LC3_INT *val ) { LC3_INT bit = 0, i = 0; - read_bit_fl(ptr, mask_side, bp_side, val); + read_bit_fl( ptr, mask_side, bp_side, val ); - for (i = 1; i < nbits; i++) { - read_bit_fl(ptr, mask_side, bp_side, &bit); - *val = *val + (bit << i); + for ( i = 1; i < nbits; i++ ) + { + read_bit_fl( ptr, mask_side, bp_side, &bit ); + *val = *val + ( bit << i ); } } #ifdef ENABLE_PADDING -LC3_INT paddingDec_fl(LC3_UINT8* bytes, LC3_INT nbbits, LC3_INT L_spec, LC3_INT bw_cutoff_bits, LC3_INT ep_enabled, LC3_INT* total_padding, LC3_INT *np_zero) +LC3_INT paddingDec_fl( LC3_UINT8 *bytes, LC3_INT nbbits, LC3_INT L_spec, LC3_INT bw_cutoff_bits, LC3_INT ep_enabled, LC3_INT *total_padding, LC3_INT *np_zero ) { LC3_INT lastnz_threshold; LC3_INT val, padding_len_bits, padding_len; LC3_INT bp_side; - LC3_INT mask_side; - LC3_UINT8* ptr = bytes; + LC3_INT mask_side; + LC3_UINT8 *ptr = bytes; LC3_INT nbbytes = nbbits >> 3; LC3_INT lastnz; LC3_INT bw_cutoff_idx; - LC3_INT nbits = ceil(LC3_LOGTWO(L_spec / 2)); - - if (nbits > nbbits) + LC3_INT nbits = ceil( LC3_LOGTWO( L_spec / 2 ) ); + + if ( nbits > nbbits ) { return 1; } - + *np_zero = 0; *total_padding = 0; - bp_side = (nbbits - 1) >> 3; - mask_side = 1 << (8 - (nbbits - (bp_side << 3))); + bp_side = ( nbbits - 1 ) >> 3; + mask_side = 1 << ( 8 - ( nbbits - ( bp_side << 3 ) ) ); - if (bp_side < 19 || bp_side >= LC3PLUS_MAX_BYTES) { + if ( bp_side < 19 || bp_side >= LC3PLUS_MAX_BYTES ) + { return 1; } - + ptr = bytes; - if (bw_cutoff_bits > 0) { - read_uint_fl(bw_cutoff_bits, ptr, &mask_side, &bp_side, &bw_cutoff_idx); + if ( bw_cutoff_bits > 0 ) + { + read_uint_fl( bw_cutoff_bits, ptr, &mask_side, &bp_side, &bw_cutoff_idx ); } - read_uint_fl(nbits, ptr, &mask_side, &bp_side, &lastnz); + read_uint_fl( nbits, ptr, &mask_side, &bp_side, &lastnz ); - lastnz_threshold = (1 << nbits) - 1 - 1; + lastnz_threshold = ( 1 << nbits ) - 1 - 1; - while (lastnz == lastnz_threshold) { + while ( lastnz == lastnz_threshold ) + { padding_len_bits = 16 - nbits - bw_cutoff_bits - 4; /*Read padding length*/ - read_uint_fl(padding_len_bits, ptr, &mask_side, &bp_side, &padding_len); + read_uint_fl( padding_len_bits, ptr, &mask_side, &bp_side, &padding_len ); /* Read 4 reserved bits */ - read_uint_fl(4, ptr, &mask_side, &bp_side, &val); - - if (ep_enabled == 0) + read_uint_fl( 4, ptr, &mask_side, &bp_side, &val ); + + if ( ep_enabled == 0 ) { /* Discard padding length bytes */ - bp_side = bp_side - padding_len; + bp_side = bp_side - padding_len; *total_padding = *total_padding + padding_len + 2; } else { *total_padding = *total_padding + 2; - *np_zero = *np_zero + padding_len; + *np_zero = *np_zero + padding_len; } - + /* check if minimum payload size is reached */ - if ((nbbytes - (*total_padding + *np_zero)) < 20) { + if ( ( nbbytes - ( *total_padding + *np_zero ) ) < 20 ) + { return 1; } /* Read bandwidth bits */ - if (bw_cutoff_bits > 0) { - read_uint_fl(bw_cutoff_bits, ptr, &mask_side, &bp_side, &bw_cutoff_idx); + if ( bw_cutoff_bits > 0 ) + { + read_uint_fl( bw_cutoff_bits, ptr, &mask_side, &bp_side, &bw_cutoff_idx ); } - read_uint_fl(nbits, ptr, &mask_side, &bp_side, &lastnz); + read_uint_fl( nbits, ptr, &mask_side, &bp_side, &lastnz ); } - - if (ep_enabled != 0) + + if ( ep_enabled != 0 ) { *total_padding = *total_padding + *np_zero; } - + return 0; } #endif -void processDecoderEntropy_fl(LC3_UINT8* bytes, LC3_INT numbytes, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT N, LC3_INT fs_idx, - LC3_INT bw_cutoff_bits, LC3_INT* bfi, LC3_INT* gg_idx, LC3_INT* scf_idx, LC3_INT* fac_ns_idx, - LC3_INT* tns_numfilters, LC3_INT* tns_order, LC3_INT* ltpf_idx, LC3_INT* bw_cutoff_idx, LC3_INT* lastnz, - LC3_INT* lsbMode, LC3_INT frame_dms) +void processDecoderEntropy_fl( LC3_UINT8 *bytes, LC3_INT numbytes, LC3_INT *mask_side, LC3_INT *bp_side, LC3_INT N, LC3_INT fs_idx, LC3_INT bw_cutoff_bits, LC3_INT *bfi, LC3_INT *gg_idx, LC3_INT *scf_idx, LC3_INT *fac_ns_idx, LC3_INT *tns_numfilters, LC3_INT *tns_order, LC3_INT *ltpf_idx, LC3_INT *bw_cutoff_idx, LC3_INT *lastnz, LC3_INT *lsbMode, LC3_INT frame_dms ) { LC3_INT plc_trigger_bw = 0, plc_trigger_last_nz = 0, plc_trigger_SNS1 = 0, plc_trigger_SNS2 = 0, tmp = 0, bit = 0, - submodeMSB = 0, i = 0, ltpf_tmp[3] = {0}, ind = 0, submodeLSB = 0, bp_side_local = 0, mask_side_local = 0; - LC3_UINT8* ptr; - LC3_INT gainMSBbits[4] = {1, 1, 2, 2}; + submodeMSB = 0, i = 0, ltpf_tmp[3] = { 0 }, ind = 0, submodeLSB = 0, bp_side_local = 0, mask_side_local = 0; + LC3_UINT8 *ptr; + LC3_INT gainMSBbits[4] = { 1, 1, 2, 2 }; *bp_side = -1; - bp_side_local = numbytes - 1; /* Matlab offset by 1 */ + bp_side_local = numbytes - 1; /* Matlab offset by 1 */ mask_side_local = 1; *mask_side = -1; - ptr = bytes; + ptr = bytes; *lsbMode = -1; *lastnz = -1; - plc_trigger_bw = 1; /* Bandwidth */ + plc_trigger_bw = 1; /* Bandwidth */ plc_trigger_last_nz = 1; /* Last non-zero tuple */ - plc_trigger_SNS1 = 1; /* SNS-VQ 2nd stage MPVQ data (24-25 bits) */ - plc_trigger_SNS2 = 1; /* SNS-VQ 2nd stage MPVQ data (24-25 bits) */ - - + plc_trigger_SNS1 = 1; /* SNS-VQ 2nd stage MPVQ data (24-25 bits) */ + plc_trigger_SNS2 = 1; /* SNS-VQ 2nd stage MPVQ data (24-25 bits) */ + /* Bandwidth */ - if (bw_cutoff_bits > 0) { - read_uint_fl(bw_cutoff_bits, ptr, &mask_side_local, &bp_side_local, bw_cutoff_idx); + if ( bw_cutoff_bits > 0 ) + { + read_uint_fl( bw_cutoff_bits, ptr, &mask_side_local, &bp_side_local, bw_cutoff_idx ); - if (fs_idx < *bw_cutoff_idx) { + if ( fs_idx < *bw_cutoff_idx ) + { *bfi = plc_trigger_bw; - if (*bfi) { + if ( *bfi ) + { return; } } - } else { + } + else + { *bw_cutoff_idx = fs_idx; } /* Number of TNS filters */ - if (*bw_cutoff_idx < 3 || frame_dms == 25) { + if ( *bw_cutoff_idx < 3 || frame_dms == 25 ) + { *tns_numfilters = 1; - } else { + } + else + { *tns_numfilters = 2; } /* Last non-zero tuple */ - read_uint_fl(ceil(LC3_LOGTWO(N / 2)), ptr, &mask_side_local, &bp_side_local, lastnz); - *lastnz = (*lastnz + 1) * 2; + read_uint_fl( ceil( LC3_LOGTWO( N / 2 ) ), ptr, &mask_side_local, &bp_side_local, lastnz ); + *lastnz = ( *lastnz + 1 ) * 2; - if (*lastnz > N) { + if ( *lastnz > N ) + { *bfi = plc_trigger_last_nz; - if (*bfi) { + if ( *bfi ) + { return; } } /* LSB mode bit */ - read_bit_fl(ptr, &mask_side_local, &bp_side_local, lsbMode); + read_bit_fl( ptr, &mask_side_local, &bp_side_local, lsbMode ); /* Global gain */ - read_uint_fl(8, ptr, &mask_side_local, &bp_side_local, gg_idx); + read_uint_fl( 8, ptr, &mask_side_local, &bp_side_local, gg_idx ); /* TNS activation flag */ - for (i = 0; i < *tns_numfilters; i++) { - read_bit_fl(ptr, &mask_side_local, &bp_side_local, &bit); + for ( i = 0; i < *tns_numfilters; i++ ) + { + read_bit_fl( ptr, &mask_side_local, &bp_side_local, &bit ); tns_order[i] = bit; } /* LTPF activation flag */ - read_bit_fl(ptr, &mask_side_local, &bp_side_local, <pf_tmp[0]); + read_bit_fl( ptr, &mask_side_local, &bp_side_local, <pf_tmp[0] ); /* SNS-VQ 1st stage */ - read_uint_fl(5, ptr, &mask_side_local, &bp_side_local, &scf_idx[0]); - read_uint_fl(5, ptr, &mask_side_local, &bp_side_local, &scf_idx[1]); + read_uint_fl( 5, ptr, &mask_side_local, &bp_side_local, &scf_idx[0] ); + read_uint_fl( 5, ptr, &mask_side_local, &bp_side_local, &scf_idx[1] ); /* SNS-VQ 2nd stage side-info (3-4 bits) */ - read_bit_fl(ptr, &mask_side_local, &bp_side_local, &submodeMSB); + read_bit_fl( ptr, &mask_side_local, &bp_side_local, &submodeMSB ); scf_idx[2] = submodeMSB * 2; - read_uint_fl(gainMSBbits[scf_idx[2]], ptr, &mask_side_local, &bp_side_local, &scf_idx[3]); - read_bit_fl(ptr, &mask_side_local, &bp_side_local, &scf_idx[4]); + read_uint_fl( gainMSBbits[scf_idx[2]], ptr, &mask_side_local, &bp_side_local, &scf_idx[3] ); + read_bit_fl( ptr, &mask_side_local, &bp_side_local, &scf_idx[4] ); /* SNS-VQ 2nd stage MPVQ data (24-25 bits) */ - if (submodeMSB == 0) { - read_uint_fl(25, ptr, &mask_side_local, &bp_side_local, &tmp); - if (tmp >= 33460056) { + if ( submodeMSB == 0 ) + { + read_uint_fl( 25, ptr, &mask_side_local, &bp_side_local, &tmp ); + if ( tmp >= 33460056 ) + { *bfi = plc_trigger_SNS1; - if (*bfi) { + if ( *bfi ) + { return; } } - ind = floor(tmp / 2390004); + ind = floor( tmp / 2390004 ); scf_idx[5] = tmp - ind * 2390004; - if (ind < 2) { + if ( ind < 2 ) + { submodeLSB = 1; scf_idx[3] = scf_idx[3] * 2 + ind; scf_idx[6] = -2; - } else { + } + else + { submodeLSB = 0; scf_idx[6] = ind - 2; } + } + else + { + read_uint_fl( 24, ptr, &mask_side_local, &bp_side_local, &tmp ); - } else { - read_uint_fl(24, ptr, &mask_side_local, &bp_side_local, &tmp); - - if (tmp >= 16708096) { + if ( tmp >= 16708096 ) + { *bfi = plc_trigger_SNS2; - if (*bfi) { + if ( *bfi ) + { return; } } - if (tmp >= 15158272) { + if ( tmp >= 15158272 ) + { submodeLSB = 1; - scf_idx[3] = scf_idx[3] * 2 + ((tmp - 15158272) & 1); - scf_idx[5] = floor((tmp - 15158272) / 2); + scf_idx[3] = scf_idx[3] * 2 + ( ( tmp - 15158272 ) & 1 ); + scf_idx[5] = floor( ( tmp - 15158272 ) / 2 ); scf_idx[6] = -2; - } else { + } + else + { submodeLSB = 0; scf_idx[5] = tmp; scf_idx[6] = -1; @@ -257,21 +288,25 @@ void processDecoderEntropy_fl(LC3_UINT8* bytes, LC3_INT numbytes, LC3_INT* mask_ scf_idx[2] = scf_idx[2] + submodeLSB; /* LTPF data */ - if (ltpf_tmp[0] == 1) { - read_bit_fl(ptr, &mask_side_local, &bp_side_local, <pf_tmp[1]); - read_uint_fl(9, ptr, &mask_side_local, &bp_side_local, <pf_tmp[2]); - } else { + if ( ltpf_tmp[0] == 1 ) + { + read_bit_fl( ptr, &mask_side_local, &bp_side_local, <pf_tmp[1] ); + read_uint_fl( 9, ptr, &mask_side_local, &bp_side_local, <pf_tmp[2] ); + } + else + { ltpf_tmp[1] = 0; ltpf_tmp[2] = 0; } - for (i = 0; i < 3; i++) { + for ( i = 0; i < 3; i++ ) + { ltpf_idx[i] = ltpf_tmp[i]; } /* Noise factor */ - read_uint_fl(3, ptr, &mask_side_local, &bp_side_local, fac_ns_idx); - + read_uint_fl( 3, ptr, &mask_side_local, &bp_side_local, fac_ns_idx ); + *bp_side = bp_side_local; *mask_side = mask_side_local; } diff --git a/lib_lc3plus/dec_lc3_fl.c b/lib_lc3plus/dec_lc3_fl.c index 88c528b0f6..995e710f9d 100644 --- a/lib_lc3plus/dec_lc3_fl.c +++ b/lib_lc3plus/dec_lc3_fl.c @@ -1,282 +1,286 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -static int Dec_LC3PLUS_Channel_fl(LC3PLUS_Dec* decoder, int channel, uint8_t* bs_in, void* s_out, int bps, int bfi_ext) +static int Dec_LC3PLUS_Channel_fl( LC3PLUS_Dec *decoder, int channel, uint8_t *bs_in, void *s_out, int bps, int bfi_ext ) { - DecSetup* h_DecSetup; - LC3_INT mask_side = 0, bp_side = 0, bfi = 0, gg_idx = 0, fac_ns_idx = 0, tns_numfilters = 0, bw_cutoff_idx = 0, - lastnz = 0, lsbMode = 0, nf_seed = 0, zero_frame = 0, residualPresent = 0, nbits_residual = 0, bitsRead = 0, - i = 0, tns_order[2] = {0}, sqQdec[MAX_LEN] = {0}; + DecSetup *h_DecSetup; + LC3_INT mask_side = 0, bp_side = 0, bfi = 0, gg_idx = 0, fac_ns_idx = 0, tns_numfilters = 0, bw_cutoff_idx = 0, + lastnz = 0, lsbMode = 0, nf_seed = 0, zero_frame = 0, residualPresent = 0, nbits_residual = 0, bitsRead = 0, + i = 0, tns_order[2] = { 0 }, sqQdec[MAX_LEN] = { 0 }; LC3_INT b_left; LC3_FLOAT stab_fac = 0; h_DecSetup = decoder->channel_setup[channel]; - - memset(h_DecSetup->tns_idx, 0, sizeof(*h_DecSetup->tns_idx) * TNS_NUMFILTERS_MAX * MAXLAG); + + memset( h_DecSetup->tns_idx, 0, sizeof( *h_DecSetup->tns_idx ) * TNS_NUMFILTERS_MAX * MAXLAG ); bfi = bfi_ext; decoder->rframe = 0; - if (bfi == 3) + if ( bfi == 3 ) { bfi = 2; decoder->rframe = 1; } /* Entropy decoding */ - if (bfi != 1) { - processDecoderEntropy_fl(bs_in, h_DecSetup->targetBytes, &mask_side, &bp_side, decoder->yLen, decoder->fs_idx, - decoder->BW_cutoff_bits, &bfi, &gg_idx, h_DecSetup->scf_idx, &fac_ns_idx, - &tns_numfilters, tns_order, h_DecSetup->ltpf_param, &bw_cutoff_idx, &lastnz, &lsbMode, decoder->frame_dms - ); + if ( bfi != 1 ) + { + processDecoderEntropy_fl( bs_in, h_DecSetup->targetBytes, &mask_side, &bp_side, decoder->yLen, decoder->fs_idx, + decoder->BW_cutoff_bits, &bfi, &gg_idx, h_DecSetup->scf_idx, &fac_ns_idx, + &tns_numfilters, tns_order, h_DecSetup->ltpf_param, &bw_cutoff_idx, &lastnz, &lsbMode, decoder->frame_dms ); h_DecSetup->BW_cutoff_idx_nf = bw_cutoff_idx; } - + /* Arithmetic decoding */ - if (bfi != 1) { - processAriDecoder_fl(bs_in, bp_side, mask_side, decoder->yLen, decoder->fs_idx, - h_DecSetup->enable_lpc_weighting, tns_numfilters, lsbMode, lastnz, &bfi, tns_order, fac_ns_idx, gg_idx, h_DecSetup->resBits, - sqQdec, &nf_seed, h_DecSetup->tns_idx, &zero_frame, h_DecSetup->targetBytes, &nbits_residual, &residualPresent, decoder->frame_dms, - decoder->n_pc, decoder->be_bp_left, decoder->be_bp_right, 0, &b_left, &h_DecSetup->spec_inv_idx, - decoder->hrmode - ); - - if (decoder->rframe == 1 && zero_frame == 0 && bfi != 1) + if ( bfi != 1 ) + { + processAriDecoder_fl( bs_in, bp_side, mask_side, decoder->yLen, decoder->fs_idx, + h_DecSetup->enable_lpc_weighting, tns_numfilters, lsbMode, lastnz, &bfi, tns_order, fac_ns_idx, gg_idx, h_DecSetup->resBits, + sqQdec, &nf_seed, h_DecSetup->tns_idx, &zero_frame, h_DecSetup->targetBytes, &nbits_residual, &residualPresent, decoder->frame_dms, + decoder->n_pc, decoder->be_bp_left, decoder->be_bp_right, 0, &b_left, &h_DecSetup->spec_inv_idx, + decoder->hrmode ); + + if ( decoder->rframe == 1 && zero_frame == 0 && bfi != 1 ) { LC3_INT32 max_bw_stopband = BW_cutoff_bin_all[bw_cutoff_idx]; bfi = 2; - switch (decoder->frame_dms) + switch ( decoder->frame_dms ) { -# ifdef ENABLE_025_DMS_MODE - case 25: - max_bw_stopband = max_bw_stopband >> 2; - break; -# endif -# ifdef ENABLE_050_DMS_MODE - case 50: - max_bw_stopband = max_bw_stopband >> 1; - break; -# endif -# ifdef ENABLE_075_DMS_MODE - case 75: - max_bw_stopband = 3 * (max_bw_stopband >> 2); - break; -# endif - case 100: - break; +#ifdef ENABLE_025_DMS_MODE + case 25: + max_bw_stopband = max_bw_stopband >> 2; + break; +#endif +#ifdef ENABLE_050_DMS_MODE + case 50: + max_bw_stopband = max_bw_stopband >> 1; + break; +#endif +#ifdef ENABLE_075_DMS_MODE + case 75: + max_bw_stopband = 3 * ( max_bw_stopband >> 2 ); + break; +#endif + case 100: + break; } - - h_DecSetup->spec_inv_idx = MAX(lastnz, max_bw_stopband); + + h_DecSetup->spec_inv_idx = MAX( lastnz, max_bw_stopband ); } /* Cast from int to float */ - for (i = 0; i < decoder->yLen; i++) { - h_DecSetup->sqQdec_fl[i] = (LC3_FLOAT)sqQdec[i]; + for ( i = 0; i < decoder->yLen; i++ ) + { + h_DecSetup->sqQdec_fl[i] = (LC3_FLOAT) sqQdec[i]; } } - - if (bfi != 1) + + if ( bfi != 1 ) { /* SNS Quantize Decoder */ - process_snsQuantizesScf_Dec(h_DecSetup->scf_idx, h_DecSetup->scf_q); + process_snsQuantizesScf_Dec( h_DecSetup->scf_idx, h_DecSetup->scf_q ); } - if (h_DecSetup->PlcAdvSetup) + if ( h_DecSetup->PlcAdvSetup ) { - processPlcComputeStabFacMain_fl(h_DecSetup->scf_q, h_DecSetup->PlcAdvSetup->scf_q_old, h_DecSetup->PlcAdvSetup->scf_q_old_old, bfi, h_DecSetup->PlcSetup.prevBfi, - h_DecSetup->PlcSetup.prevprevBfi, &h_DecSetup->PlcAdvSetup->stabFac); + processPlcComputeStabFacMain_fl( h_DecSetup->scf_q, h_DecSetup->PlcAdvSetup->scf_q_old, h_DecSetup->PlcAdvSetup->scf_q_old_old, bfi, h_DecSetup->PlcSetup.prevBfi, + h_DecSetup->PlcSetup.prevprevBfi, &h_DecSetup->PlcAdvSetup->stabFac ); } - + if ( bfi != 1 ) { stab_fac = 1; - if (h_DecSetup->PlcAdvSetup) + if ( h_DecSetup->PlcAdvSetup ) { stab_fac = h_DecSetup->PlcAdvSetup->stabFac; } /* Partial Concealment */ - processPcMain_fl(&bfi, decoder, h_DecSetup->sqQdec_fl, h_DecSetup, h_DecSetup->ltpf_param[0], stab_fac, gg_idx, h_DecSetup->quantizedGainOff, - fac_ns_idx, &h_DecSetup->statePC, h_DecSetup->spec_inv_idx, decoder->yLen); + processPcMain_fl( &bfi, decoder, h_DecSetup->sqQdec_fl, h_DecSetup, h_DecSetup->ltpf_param[0], stab_fac, gg_idx, h_DecSetup->quantizedGainOff, + fac_ns_idx, &h_DecSetup->statePC, h_DecSetup->spec_inv_idx, decoder->yLen ); } /* Decoding only if no bit error detected */ - if (bfi != 1) { + if ( bfi != 1 ) + { /* Residual decoding */ - if (residualPresent) { - processResidualDecoding_fl(&bitsRead, h_DecSetup->sqQdec_fl, decoder->yLen, h_DecSetup->resBits, - nbits_residual - , decoder->hrmode - ); + if ( residualPresent ) + { + processResidualDecoding_fl( &bitsRead, h_DecSetup->sqQdec_fl, decoder->yLen, h_DecSetup->resBits, + nbits_residual, decoder->hrmode ); } - - + + /* Noise filling */ - if (zero_frame == 0) { - processNoiseFilling_fl(h_DecSetup->sqQdec_fl, nf_seed, fac_ns_idx, decoder->cutoffBins[h_DecSetup->BW_cutoff_idx_nf], decoder->frame_dms, h_DecSetup->prev_fac_ns, h_DecSetup->spec_inv_idx); + if ( zero_frame == 0 ) + { + processNoiseFilling_fl( h_DecSetup->sqQdec_fl, nf_seed, fac_ns_idx, decoder->cutoffBins[h_DecSetup->BW_cutoff_idx_nf], decoder->frame_dms, h_DecSetup->prev_fac_ns, h_DecSetup->spec_inv_idx ); } - + /* Application of global gain */ - processApplyGlobalGain_fl(h_DecSetup->sqQdec_fl, decoder->yLen, gg_idx, h_DecSetup->quantizedGainOff); + processApplyGlobalGain_fl( h_DecSetup->sqQdec_fl, decoder->yLen, gg_idx, h_DecSetup->quantizedGainOff ); /* TNS decoder */ - processTnsDecoder_fl(h_DecSetup->sqQdec_fl, h_DecSetup->tns_idx, tns_order, tns_numfilters, - decoder->cutoffBins[bw_cutoff_idx], h_DecSetup->N_red_tns, h_DecSetup->fs_red_tns); + processTnsDecoder_fl( h_DecSetup->sqQdec_fl, h_DecSetup->tns_idx, tns_order, tns_numfilters, + decoder->cutoffBins[bw_cutoff_idx], h_DecSetup->N_red_tns, h_DecSetup->fs_red_tns ); /* SNS interpolation */ - processSnsInterpolateScf_fl(h_DecSetup->scf_q, 0, decoder->bands_number, h_DecSetup->int_scf); + processSnsInterpolateScf_fl( h_DecSetup->scf_q, 0, decoder->bands_number, h_DecSetup->int_scf ); /* MDCT shaping */ - processMdctShaping_fl(h_DecSetup->sqQdec_fl, h_DecSetup->int_scf, decoder->bands_offset, decoder->bands_number); + processMdctShaping_fl( h_DecSetup->sqQdec_fl, h_DecSetup->int_scf, decoder->bands_offset, decoder->bands_number ); } - + /* PLC */ - processPlcMain_fl(h_DecSetup->sqQdec_fl, h_DecSetup->x_fl, decoder, h_DecSetup, bfi, h_DecSetup->PlcAdvSetup, &h_DecSetup->PlcSetup, - decoder->plcMeth, h_DecSetup->ltpf_mem_pitch, h_DecSetup->ltpf_mem_pitch_fr, decoder->tilt, decoder->bands_offset, - decoder->bands_number, decoder->bands_offsetPLC, decoder->n_bandsPLC, decoder->hrmode, &h_DecSetup->statePC); - - processPlcDampingScramblingMain_fl(&h_DecSetup->PlcNsSetup.seed, - &h_DecSetup->statePC.seed, h_DecSetup->statePC.ns_nbLostCmpt_pc, - h_DecSetup->PlcSetup.nbLostCmpt, &h_DecSetup->PlcAdvSetup->stabFac, - &h_DecSetup->PlcAdvSetup->cum_fading_slow, &h_DecSetup->PlcAdvSetup->cum_fading_fast, - h_DecSetup->PlcSetup.q_d_prev, h_DecSetup->sqQdec_fl, h_DecSetup->spec_inv_idx, decoder->yLen, bfi, - decoder->frame_dms, h_DecSetup->concealMethod, h_DecSetup->ltpf_mem_pitch, h_DecSetup->ltpf_param[0], - &h_DecSetup->PlcAdvSetup->cum_fflcAtten); - + processPlcMain_fl( h_DecSetup->sqQdec_fl, h_DecSetup->x_fl, decoder, h_DecSetup, bfi, h_DecSetup->PlcAdvSetup, &h_DecSetup->PlcSetup, + decoder->plcMeth, h_DecSetup->ltpf_mem_pitch, h_DecSetup->ltpf_mem_pitch_fr, decoder->tilt, decoder->bands_offset, + decoder->bands_number, decoder->bands_offsetPLC, decoder->n_bandsPLC, decoder->hrmode, &h_DecSetup->statePC ); + + processPlcDampingScramblingMain_fl( &h_DecSetup->PlcNsSetup.seed, + &h_DecSetup->statePC.seed, h_DecSetup->statePC.ns_nbLostCmpt_pc, + h_DecSetup->PlcSetup.nbLostCmpt, &h_DecSetup->PlcAdvSetup->stabFac, + &h_DecSetup->PlcAdvSetup->cum_fading_slow, &h_DecSetup->PlcAdvSetup->cum_fading_fast, + h_DecSetup->PlcSetup.q_d_prev, h_DecSetup->sqQdec_fl, h_DecSetup->spec_inv_idx, decoder->yLen, bfi, + decoder->frame_dms, h_DecSetup->concealMethod, h_DecSetup->ltpf_mem_pitch, h_DecSetup->ltpf_param[0], + &h_DecSetup->PlcAdvSetup->cum_fflcAtten ); + /* IMDCT */ - if (h_DecSetup->concealMethod == 4 || bfi != 1 ) + if ( h_DecSetup->concealMethod == 4 || bfi != 1 ) { - ProcessingIMDCT_fl(h_DecSetup->sqQdec_fl, decoder->frame_length, decoder->imdct_win, decoder->imdct_winLen, decoder->imdct_laZeros, - h_DecSetup->imdct_mem, h_DecSetup->x_fl, &h_DecSetup->dct4structImdct); + ProcessingIMDCT_fl( h_DecSetup->sqQdec_fl, decoder->frame_length, decoder->imdct_win, decoder->imdct_winLen, decoder->imdct_laZeros, + h_DecSetup->imdct_mem, h_DecSetup->x_fl, &h_DecSetup->dct4structImdct ); } - processPlcUpdate_fl(h_DecSetup->PlcAdvSetup - , decoder->frame_length, h_DecSetup->x_fl, h_DecSetup->scf_q, - &h_DecSetup->PlcSetup.nbLostCmpt, &h_DecSetup->PlcNsSetup.cum_alpha, bfi, &h_DecSetup->PlcSetup.prevBfi, &h_DecSetup->PlcSetup.prevprevBfi); - + processPlcUpdate_fl( h_DecSetup->PlcAdvSetup, decoder->frame_length, h_DecSetup->x_fl, h_DecSetup->scf_q, + &h_DecSetup->PlcSetup.nbLostCmpt, &h_DecSetup->PlcNsSetup.cum_alpha, bfi, &h_DecSetup->PlcSetup.prevBfi, &h_DecSetup->PlcSetup.prevprevBfi ); + /* LTPF decoder */ - process_ltpf_decoder_fl(h_DecSetup->x_fl, decoder->frame_length, h_DecSetup->x_fl, decoder->fs, - h_DecSetup->ltpf_mem_x, h_DecSetup->ltpf_mem_y, &h_DecSetup->ltpf_mem_pitch, - &h_DecSetup->ltpf_mem_pitch_fr, &h_DecSetup->ltpf_mem_gain, &h_DecSetup->ltpf_mem_beta_idx, - bfi, h_DecSetup->ltpf_param, h_DecSetup->ltpf_param_mem, h_DecSetup->ltpf_conf_beta_idx, - h_DecSetup->ltpf_conf_beta, h_DecSetup->concealMethod, h_DecSetup->alpha - , &h_DecSetup->ltpf_mem_active - ); + process_ltpf_decoder_fl( h_DecSetup->x_fl, decoder->frame_length, h_DecSetup->x_fl, decoder->fs, + h_DecSetup->ltpf_mem_x, h_DecSetup->ltpf_mem_y, &h_DecSetup->ltpf_mem_pitch, + &h_DecSetup->ltpf_mem_pitch_fr, &h_DecSetup->ltpf_mem_gain, &h_DecSetup->ltpf_mem_beta_idx, + bfi, h_DecSetup->ltpf_param, h_DecSetup->ltpf_param_mem, h_DecSetup->ltpf_conf_beta_idx, + h_DecSetup->ltpf_conf_beta, h_DecSetup->concealMethod, h_DecSetup->alpha, &h_DecSetup->ltpf_mem_active ); { /* Round, scale and copy output to output buffer */ - if (bps == 16) { - for (i = 0; i < decoder->frame_length; i++) { - LC3_FLOAT tmp = round(h_DecSetup->x_fl[i]); - ((int16_t*)s_out)[i] = (int16_t)fmaxf(fminf(tmp, 32767), -32768); + if ( bps == 16 ) + { + for ( i = 0; i < decoder->frame_length; i++ ) + { + LC3_FLOAT tmp = round( h_DecSetup->x_fl[i] ); + ( (int16_t *) s_out )[i] = (int16_t) fmaxf( fminf( tmp, 32767 ), -32768 ); } - } else { - for (i = 0; i < decoder->frame_length; i++) { - LC3_FLOAT tmp = round(LC3_CONST_POW_2_23 * LC3_CONST_POW_2_M15 * h_DecSetup->x_fl[i]); - ((int32_t*)s_out)[i] = (int32_t)fmaxf(fminf(tmp, LC3_CONST_POW_2_23_RED), LC3_CONST_POW_2_23_NEG); + } + else + { + for ( i = 0; i < decoder->frame_length; i++ ) + { + LC3_FLOAT tmp = round( LC3_CONST_POW_2_23 * LC3_CONST_POW_2_M15 * h_DecSetup->x_fl[i] ); + ( (int32_t *) s_out )[i] = (int32_t) fmaxf( fminf( tmp, LC3_CONST_POW_2_23_RED ), LC3_CONST_POW_2_23_NEG ); } } } return bfi; } -LC3PLUS_Error Dec_LC3PLUS_fl(LC3PLUS_Dec* decoder, uint8_t* input, LC3_INT32 num_bytes, void** output, LC3_INT32 bps, LC3_INT32 bfi_ext) +LC3PLUS_Error Dec_LC3PLUS_fl( LC3PLUS_Dec *decoder, uint8_t *input, LC3_INT32 num_bytes, void **output, LC3_INT32 bps, LC3_INT32 bfi_ext ) { - LC3_INT32 ch, bfi, lc3_num_bytes; - LC3PLUS_Error err; - LC3_INT32 fec_num_bytes; - LC3_INT32 lc3_channel_num_bytes; - LC3_INT32 channel_bfi, out_bfi; - LC3PLUS_EpModeRequest channel_epmr; - + LC3_INT32 ch, bfi, lc3_num_bytes; + LC3PLUS_Error err; + LC3_INT32 fec_num_bytes; + LC3_INT32 lc3_channel_num_bytes; + LC3_INT32 channel_bfi, out_bfi; + LC3PLUS_EpModeRequest channel_epmr; + bfi = bfi_ext; lc3_num_bytes = 0; err = LC3PLUS_OK; - - if (bfi == 0) + + if ( bfi == 0 ) { bfi = !num_bytes; } - - if (decoder->ep_enabled) + + if ( decoder->ep_enabled ) { decoder->combined_channel_coding = decoder->channels > 1 && num_bytes <= 160; - if (decoder->combined_channel_coding) + if ( decoder->combined_channel_coding ) { fec_num_bytes = num_bytes; decoder->error_report = - fec_decoder(input, fec_num_bytes, &lc3_num_bytes, (LC3PLUS_EpModeRequest*)&decoder->epmr, decoder->combined_channel_coding, - &decoder->n_pccw, &bfi, &decoder->be_bp_left, &decoder->be_bp_right, &decoder->n_pc, &decoder->m_fec); + fec_decoder( input, fec_num_bytes, &lc3_num_bytes, (LC3PLUS_EpModeRequest *) &decoder->epmr, decoder->combined_channel_coding, + &decoder->n_pccw, &bfi, &decoder->be_bp_left, &decoder->be_bp_right, &decoder->n_pc, &decoder->m_fec ); - for (ch = 0; ch < decoder->channels; ch++) + for ( ch = 0; ch < decoder->channels; ch++ ) { - lc3_channel_num_bytes = lc3_num_bytes / decoder->channels + (ch < (lc3_num_bytes % decoder->channels)); + lc3_channel_num_bytes = lc3_num_bytes / decoder->channels + ( ch < ( lc3_num_bytes % decoder->channels ) ); - if (bfi != 1 && lc3_channel_num_bytes != decoder->channel_setup[ch]->last_size) + if ( bfi != 1 && lc3_channel_num_bytes != decoder->channel_setup[ch]->last_size ) { - err = update_dec_bitrate(decoder, ch, lc3_channel_num_bytes); - if (err) + err = update_dec_bitrate( decoder, ch, lc3_channel_num_bytes ); + if ( err ) { bfi = 1; decoder->last_error = err; } else { - decoder->channel_setup[ch]->last_size = lc3_channel_num_bytes; + decoder->channel_setup[ch]->last_size = lc3_channel_num_bytes; } } - bfi = Dec_LC3PLUS_Channel_fl(decoder, ch, input, output[ch], bps, bfi); + bfi = Dec_LC3PLUS_Channel_fl( decoder, ch, input, output[ch], bps, bfi ); input += decoder->channel_setup[ch]->targetBytes; } } else { decoder->epmr = LC3PLUS_EPMR_HIGH_NC; - out_bfi = 0; + out_bfi = 0; - for (ch = 0; ch < decoder->channels; ch++) + for ( ch = 0; ch < decoder->channels; ch++ ) { - fec_num_bytes = num_bytes / decoder->channels + (ch < (num_bytes % decoder->channels)); + fec_num_bytes = num_bytes / decoder->channels + ( ch < ( num_bytes % decoder->channels ) ); - channel_bfi = bfi; + channel_bfi = bfi; - decoder->error_report = fec_decoder(input, fec_num_bytes, &lc3_num_bytes, &channel_epmr, - decoder->combined_channel_coding, &decoder->n_pccw, &channel_bfi, - &decoder->be_bp_left, &decoder->be_bp_right, &decoder->n_pc, &decoder->m_fec); + decoder->error_report = fec_decoder( input, fec_num_bytes, &lc3_num_bytes, &channel_epmr, + decoder->combined_channel_coding, &decoder->n_pccw, &channel_bfi, + &decoder->be_bp_left, &decoder->be_bp_right, &decoder->n_pc, &decoder->m_fec ); + + decoder->epmr = MIN( (LC3PLUS_EpModeRequest) decoder->epmr, channel_epmr ); - decoder->epmr = MIN((LC3PLUS_EpModeRequest) decoder->epmr, channel_epmr); - #ifdef ENABLE_PADDING - if (channel_bfi != 1) + if ( channel_bfi != 1 ) { LC3_INT32 padding_len = 0, np_zero = 0; - if (paddingDec_fl(input, (lc3_num_bytes << 3), decoder->yLen, decoder->BW_cutoff_bits, decoder->ep_enabled, &padding_len, &np_zero)) + if ( paddingDec_fl( input, ( lc3_num_bytes << 3 ), decoder->yLen, decoder->BW_cutoff_bits, decoder->ep_enabled, &padding_len, &np_zero ) ) { channel_bfi = 1; } - input = input + np_zero; - decoder->n_pc = MAX(decoder->n_pc - (2 * np_zero), 0); - - if (channel_bfi == 2) + input = input + np_zero; + decoder->n_pc = MAX( decoder->n_pc - ( 2 * np_zero ), 0 ); + + if ( channel_bfi == 2 ) { - if (decoder->be_bp_right < (8 * np_zero)) + if ( decoder->be_bp_right < ( 8 * np_zero ) ) { channel_bfi = 0; decoder->be_bp_left = -1; @@ -284,18 +288,18 @@ LC3PLUS_Error Dec_LC3PLUS_fl(LC3PLUS_Dec* decoder, uint8_t* input, LC3_INT32 num } else { - decoder->be_bp_right = decoder->be_bp_right - (8 * np_zero); - decoder->be_bp_left = MAX(decoder->be_bp_left - (8 * np_zero), 0); + decoder->be_bp_right = decoder->be_bp_right - ( 8 * np_zero ); + decoder->be_bp_left = MAX( decoder->be_bp_left - ( 8 * np_zero ), 0 ); } } lc3_num_bytes = lc3_num_bytes - padding_len; } #endif - if (channel_bfi != 1 && lc3_num_bytes != decoder->channel_setup[ch]->last_size) + if ( channel_bfi != 1 && lc3_num_bytes != decoder->channel_setup[ch]->last_size ) { - err = update_dec_bitrate(decoder, ch, lc3_num_bytes); - if (err) + err = update_dec_bitrate( decoder, ch, lc3_num_bytes ); + if ( err ) { channel_bfi = 1; decoder->last_error = err; @@ -306,7 +310,7 @@ LC3PLUS_Error Dec_LC3PLUS_fl(LC3PLUS_Dec* decoder, uint8_t* input, LC3_INT32 num } } - channel_bfi = Dec_LC3PLUS_Channel_fl(decoder, ch, input, output[ch], bps, channel_bfi); + channel_bfi = Dec_LC3PLUS_Channel_fl( decoder, ch, input, output[ch], bps, channel_bfi ); out_bfi |= channel_bfi; input += fec_num_bytes; @@ -317,34 +321,34 @@ LC3PLUS_Error Dec_LC3PLUS_fl(LC3PLUS_Dec* decoder, uint8_t* input, LC3_INT32 num } else { - for (ch = 0; ch < decoder->channels; ch++) + for ( ch = 0; ch < decoder->channels; ch++ ) { - lc3_num_bytes = num_bytes / decoder->channels + (ch < (num_bytes % decoder->channels)); + lc3_num_bytes = num_bytes / decoder->channels + ( ch < ( num_bytes % decoder->channels ) ); #ifdef ENABLE_PADDING - if (bfi != 1) + if ( bfi != 1 ) { LC3_INT32 padding_len = 0, np_zero = 0; - if (paddingDec_fl(input, (lc3_num_bytes << 3), decoder->yLen, decoder->BW_cutoff_bits, decoder->ep_enabled, &padding_len, &np_zero)) + if ( paddingDec_fl( input, ( lc3_num_bytes << 3 ), decoder->yLen, decoder->BW_cutoff_bits, decoder->ep_enabled, &padding_len, &np_zero ) ) { bfi = 1; decoder->last_error = LC3PLUS_PADDING_ERROR; } - + lc3_num_bytes = lc3_num_bytes - padding_len; - if (lc3_num_bytes < 20 || lc3_num_bytes > LC3PLUS_MAX_BYTES) + if ( lc3_num_bytes < 20 || lc3_num_bytes > LC3PLUS_MAX_BYTES ) { - bfi = 1; /* mark frame as broken if frame size is below the minimum of 20 bytes or above the maximum of LC3PLUS_MAX_BYTES */ + bfi = 1; /* mark frame as broken if frame size is below the minimum of 20 bytes or above the maximum of LC3PLUS_MAX_BYTES */ decoder->last_error = FRAMESIZE_ERROR; } } -#endif - - if (bfi != 1 && lc3_num_bytes != decoder->channel_setup[ch]->last_size) +#endif + + if ( bfi != 1 && lc3_num_bytes != decoder->channel_setup[ch]->last_size ) { - err = update_dec_bitrate(decoder, ch, lc3_num_bytes); - if (err) + err = update_dec_bitrate( decoder, ch, lc3_num_bytes ); + if ( err ) { bfi = 1; decoder->last_error = err; @@ -355,11 +359,12 @@ LC3PLUS_Error Dec_LC3PLUS_fl(LC3PLUS_Dec* decoder, uint8_t* input, LC3_INT32 num } } - bfi = Dec_LC3PLUS_Channel_fl(decoder, ch, input, output[ch], bps, bfi); + bfi = Dec_LC3PLUS_Channel_fl( decoder, ch, input, output[ch], bps, bfi ); input += decoder->channel_setup[ch]->targetBytes; } } - if (decoder->last_error == LC3PLUS_OK && bfi) decoder->last_error = LC3PLUS_DECODE_ERROR; + if ( decoder->last_error == LC3PLUS_OK && bfi ) + decoder->last_error = LC3PLUS_DECODE_ERROR; return bfi == 1 ? LC3PLUS_DECODE_ERROR : LC3PLUS_OK; } diff --git a/lib_lc3plus/defines.h b/lib_lc3plus/defines.h index d978fa4e15..3a41dec5ea 100644 --- a/lib_lc3plus/defines.h +++ b/lib_lc3plus/defines.h @@ -1,12 +1,12 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #ifndef DEFINES_H #define DEFINES_H @@ -14,13 +14,13 @@ #include "stdint.h" -typedef float LC3_FLOAT; -typedef int32_t LC3_INT; -typedef int16_t LC3_INT16; +typedef float LC3_FLOAT; +typedef int32_t LC3_INT; +typedef int16_t LC3_INT16; typedef uint16_t LC3_UINT16; -typedef short LC3_SHORT; -typedef uint8_t LC3_UINT8; -typedef int8_t LC3_INT8; +typedef short LC3_SHORT; +typedef uint8_t LC3_UINT8; +typedef int8_t LC3_INT8; typedef uint32_t LC3_UINT32; /* Release defines */ @@ -47,159 +47,159 @@ typedef uint32_t LC3_UINT32; #endif /* NO_POST_REL_CHANGES */ /* Precision Defines */ -#define LC3_FABS(x) (fabsf(x)) -#define LC3_POW(x, y) (powf(x, y)) -#define LC3_LOGTEN(x) (log10f(x)) -#define LC3_LOGTWO(x) (log2f(x)) -# define LC3_COS(x) (cos(x)) -# define LC3_SIN(x) (sin(x)) -#define LC3_SQRT(x) (sqrtf(x)) -#define LC3_EXP(x) (expf(x)) - -# define MAX_BR 320000 /* 400 * 800 */ -# define MIN_BR_100DMS 16000 /* 20 * 800 * 100/100 */ -# define MIN_BR_025DMS 64000 /* 20 * 800 * 100/ 25 */ -# define MIN_BR_050DMS 32000 /* 20 * 800 * 100/ 50 */ -# define MAX_BR_050DMS_NB 260800 /* 163 * 800 * 100/ 50 */ -# define MAX_BR_100DMS_NB 114400 /* for 100ms at 8kHz */ - -# define MAX_BR_100DMS_WB 221600 /* for 100ms at 16kHz */ -# define MAX_BR_100DMS_SSWB 314400 /* for 100ms at 24kHz */ - -typedef int32_t LC3_INT32; - -# if defined(__xtensa__) -# define ALIGNMENT_BALLOC 4 -# define ALIGNMENT_BALLOC_RED 3 -# else -# define ALIGNMENT_BALLOC 8 -# define ALIGNMENT_BALLOC_RED 7 -# endif - -# define PLC2_FADEOUT_IN_MS 30 -# define PHECU_FRES 62.5 -# define PHECU_C_JACOB 1.1429 -# define MAX_LGW 9 /* LGW48K + 1 !! */ -# define QUOT_LPR_LTR 4 -# define MAX_PLC_LPROT ((512 * 48) / 32) -# define MAX_PLC_NPLOCS ((MAX_PLC_LPROT / 4) + 1) -# define MAX_PLC_LMSPEC ((MAX_PLC_LPROT / 2) + 1) -# define MAX_PLC_LMEM (400) /* "only" up to 20kHz (400 MDCT bins at 10 ms) at 48 kHz supported by PhEcu */ - -# define POS_ONE_Q15 (32767.0 / 32768.0) -# define PHECU_LTOT_MIN_MAN 1 /* lowest possible mantissa energy value */ -# define PHECU_LTOT_MIN_EXP -61 /* L_tot = PHECU_LTOT_MIN_MAN*2^(PHECU_LTOT_MIN_EXP-31) */ -# define PHECU_LTOT_MIN -# define PHECU_GRP_SHAPE_INIT 0 /* BASOP Q15 */ -# define PHECU_ENV_STAB_LOCAL POS_ONE_Q15 -# define PHECU_DELTA_CORR 5 -# define PHECU_PFIND_SENS 0.93 -# define PHECU_LA 0 - -# define LC3_ROUND(x) (roundf(x)) -# define LC3_FLOOR(x) (floorf(x)) - -# define LC3_CONST_POW_2_16 65536 -# define LC3_CONST_POW_2_M16 1.525878906250000e-05 -# define LC3_CONST_POW_2_100 1.267650600228229e+30 - -# define MAX_LEN_PCM_PLC (MAX_PITCH + MAX_LEN) -# define MAX_PITCH CEILING((MAX_PITCH_12K8 * MAX_LEN * 100), 12800) -# define TDC_L_FIR_HP 11 -# define PLC3_HPBLENDTHROTTLE 30 /* higher numbers increase throttled blending from hp filtered to unfiltered uv excitation (0 is no throttle) */ - -# define PLC_FADEOUT_IN_MS 60 /* fade-out to zero in ms for TD-PLC and NS, minimum value is 20 */ -# define PLC4_TRANSIT_START_IN_MS 20 /* begin of transition time for noise substitution for voiced signals */ -# define PLC4_TRANSIT_END_IN_MS PLC_FADEOUT_IN_MS /* end of transition time for noise substitution */ -# define PLC34_ATTEN_FAC_100 0.5000 /* attenuation factor for NS and TDC @ 10 ms*/ -# define PLC34_ATTEN_FAC_050 0.7071 /* attenuation factor for NS and TDC @ 5.0 ms*/ -# define PLC34_ATTEN_FAC_025 0.8409 /* attenuation factor for NS and TDC @ 2.5 ms*/ - -# define FEC_SLOT_BYTES_MIN 40 -# define FEC_SLOT_BYTES_MAX 400 - - -# define LC3_CONST_POW_2_M15 3.051757812500000e-05 -# define LC3_CONST_POW_2_23 8388608 -# define LC3_CONST_POW_2_23_NEG -8388608 -# define LC3_CONST_POW_2_23_RED 8388607 - -# define LC3_CONST_POW_2_100 1.267650600228229e+30 +#define LC3_FABS( x ) ( fabsf( x ) ) +#define LC3_POW( x, y ) ( powf( x, y ) ) +#define LC3_LOGTEN( x ) ( log10f( x ) ) +#define LC3_LOGTWO( x ) ( log2f( x ) ) +#define LC3_COS( x ) ( cos( x ) ) +#define LC3_SIN( x ) ( sin( x ) ) +#define LC3_SQRT( x ) ( sqrtf( x ) ) +#define LC3_EXP( x ) ( expf( x ) ) + +#define MAX_BR 320000 /* 400 * 800 */ +#define MIN_BR_100DMS 16000 /* 20 * 800 * 100/100 */ +#define MIN_BR_025DMS 64000 /* 20 * 800 * 100/ 25 */ +#define MIN_BR_050DMS 32000 /* 20 * 800 * 100/ 50 */ +#define MAX_BR_050DMS_NB 260800 /* 163 * 800 * 100/ 50 */ +#define MAX_BR_100DMS_NB 114400 /* for 100ms at 8kHz */ + +#define MAX_BR_100DMS_WB 221600 /* for 100ms at 16kHz */ +#define MAX_BR_100DMS_SSWB 314400 /* for 100ms at 24kHz */ + +typedef int32_t LC3_INT32; + +#if defined( __xtensa__ ) +#define ALIGNMENT_BALLOC 4 +#define ALIGNMENT_BALLOC_RED 3 +#else +#define ALIGNMENT_BALLOC 8 +#define ALIGNMENT_BALLOC_RED 7 +#endif + +#define PLC2_FADEOUT_IN_MS 30 +#define PHECU_FRES 62.5 +#define PHECU_C_JACOB 1.1429 +#define MAX_LGW 9 /* LGW48K + 1 !! */ +#define QUOT_LPR_LTR 4 +#define MAX_PLC_LPROT ( ( 512 * 48 ) / 32 ) +#define MAX_PLC_NPLOCS ( ( MAX_PLC_LPROT / 4 ) + 1 ) +#define MAX_PLC_LMSPEC ( ( MAX_PLC_LPROT / 2 ) + 1 ) +#define MAX_PLC_LMEM ( 400 ) /* "only" up to 20kHz (400 MDCT bins at 10 ms) at 48 kHz supported by PhEcu */ + +#define POS_ONE_Q15 ( 32767.0 / 32768.0 ) +#define PHECU_LTOT_MIN_MAN 1 /* lowest possible mantissa energy value */ +#define PHECU_LTOT_MIN_EXP -61 /* L_tot = PHECU_LTOT_MIN_MAN*2^(PHECU_LTOT_MIN_EXP-31) */ +#define PHECU_LTOT_MIN +#define PHECU_GRP_SHAPE_INIT 0 /* BASOP Q15 */ +#define PHECU_ENV_STAB_LOCAL POS_ONE_Q15 +#define PHECU_DELTA_CORR 5 +#define PHECU_PFIND_SENS 0.93 +#define PHECU_LA 0 + +#define LC3_ROUND( x ) ( roundf( x ) ) +#define LC3_FLOOR( x ) ( floorf( x ) ) + +#define LC3_CONST_POW_2_16 65536 +#define LC3_CONST_POW_2_M16 1.525878906250000e-05 +#define LC3_CONST_POW_2_100 1.267650600228229e+30 + +#define MAX_LEN_PCM_PLC ( MAX_PITCH + MAX_LEN ) +#define MAX_PITCH CEILING( ( MAX_PITCH_12K8 * MAX_LEN * 100 ), 12800 ) +#define TDC_L_FIR_HP 11 +#define PLC3_HPBLENDTHROTTLE 30 /* higher numbers increase throttled blending from hp filtered to unfiltered uv excitation (0 is no throttle) */ + +#define PLC_FADEOUT_IN_MS 60 /* fade-out to zero in ms for TD-PLC and NS, minimum value is 20 */ +#define PLC4_TRANSIT_START_IN_MS 20 /* begin of transition time for noise substitution for voiced signals */ +#define PLC4_TRANSIT_END_IN_MS PLC_FADEOUT_IN_MS /* end of transition time for noise substitution */ +#define PLC34_ATTEN_FAC_100 0.5000 /* attenuation factor for NS and TDC @ 10 ms*/ +#define PLC34_ATTEN_FAC_050 0.7071 /* attenuation factor for NS and TDC @ 5.0 ms*/ +#define PLC34_ATTEN_FAC_025 0.8409 /* attenuation factor for NS and TDC @ 2.5 ms*/ + +#define FEC_SLOT_BYTES_MIN 40 +#define FEC_SLOT_BYTES_MAX 400 + + +#define LC3_CONST_POW_2_M15 3.051757812500000e-05 +#define LC3_CONST_POW_2_23 8388608 +#define LC3_CONST_POW_2_23_NEG -8388608 +#define LC3_CONST_POW_2_23_RED 8388607 + +#define LC3_CONST_POW_2_100 1.267650600228229e+30 /* G192 bitstream writing/reading */ #define G192_REDUNDANCY_FRAME 0x6B22 -#define G192_GOOD_FRAME 0x6B21 -#define G192_BAD_FRAME 0x6B20 -#define G192_ZERO 0x007F -#define G192_ONE 0x0081 -#define READ_G192FER /* Allow C executable to also read G192 formatted FER files */ +#define G192_GOOD_FRAME 0x6B21 +#define G192_BAD_FRAME 0x6B20 +#define G192_ZERO 0x007F +#define G192_ONE 0x0081 +#define READ_G192FER /* Allow C executable to also read G192 formatted FER files */ -# define LC3_EPS (1.1e-7f) +#define LC3_EPS ( 1.1e-7f ) #define M_PI 3.14159265358979323846 /* FUNCTION MACROS */ -#define CEILING(x, y) (((x) + (y)-1) / (y)) -#define FRAME2FS_IDX(x) (x / 100) /* 80 -> 0, 160 -> 1, 240 -> 2, 320 -> 3, 480 -> 4*/ -#define FS2FS_IDX(x) \ - (x / 10000) /* 8000 -> 0, 16000 -> 1, 24000 -> 2, 32000 -> 3, 48000 -> 4 \ - */ -#define UNUSED(x) (void)(x) /* silence unused parameter warning */ -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#define STATIC_ASSERTS(cond, s) typedef char assert_##s[(cond) ? 1 : -1] -#define STATIC_ASSERTI(cond, i) STATIC_ASSERTS(cond, i) -#define STATIC_ASSERT(cond) STATIC_ASSERTI(cond, __LINE__) +#define CEILING( x, y ) ( ( ( x ) + (y) -1 ) / ( y ) ) +#define FRAME2FS_IDX( x ) ( x / 100 ) /* 80 -> 0, 160 -> 1, 240 -> 2, 320 -> 3, 480 -> 4*/ +#define FS2FS_IDX( x ) \ + ( x / 10000 ) /* 8000 -> 0, 16000 -> 1, 24000 -> 2, 32000 -> 3, 48000 -> 4 \ + */ +#define UNUSED( x ) (void) ( x ) /* silence unused parameter warning */ +#define MAX( a, b ) ( ( a ) > ( b ) ? ( a ) : ( b ) ) +#define MIN( a, b ) ( ( a ) < ( b ) ? ( a ) : ( b ) ) +#define STATIC_ASSERTS( cond, s ) typedef char assert_##s[( cond ) ? 1 : -1] +#define STATIC_ASSERTI( cond, i ) STATIC_ASSERTS( cond, i ) +#define STATIC_ASSERT( cond ) STATIC_ASSERTI( cond, __LINE__ ) /* For dynamic memory calculations */ -#define CODEC_FS(fs) ((fs) == 44100 ? 48000 : (fs)) -#define DYN_MAX_LEN(fs) MAX(CODEC_FS(fs) / 100, 160) -# define DYN_MAX_LEN_EXT(fs) MAX(CODEC_FS(fs) / 100, 160) /* extension to length 160 for NB(fs=8000) */ -#define DYN_MAX_MDCT_LEN(fs) (DYN_MAX_LEN(fs) - (180 * DYN_MAX_LEN(fs) / 480)) +#define CODEC_FS( fs ) ( ( fs ) == 44100 ? 48000 : ( fs ) ) +#define DYN_MAX_LEN( fs ) MAX( CODEC_FS( fs ) / 100, 160 ) +#define DYN_MAX_LEN_EXT( fs ) MAX( CODEC_FS( fs ) / 100, 160 ) /* extension to length 160 for NB(fs=8000) */ +#define DYN_MAX_MDCT_LEN( fs ) ( DYN_MAX_LEN( fs ) - ( 180 * DYN_MAX_LEN( fs ) / 480 ) ) /* OPTIONS */ -#define MAX_SR 96000 -#define EXT_RES_ITER_MAX 20 +#define MAX_SR 96000 +#define EXT_RES_ITER_MAX 20 #define MAX_BW_BANDS_NUMBER 6 -#define MAX_LEN MAX_SR/100 /* = 10ms at 96kHz */ -#define MAX_RESBITS 5000 -#define MAX_RESBITS_LEN ((MAX_RESBITS + 7)/8) +#define MAX_LEN MAX_SR / 100 /* = 10ms at 96kHz */ +#define MAX_RESBITS 5000 +#define MAX_RESBITS_LEN ( ( MAX_RESBITS + 7 ) / 8 ) #define MAX_CHANNELS 2 -#define MIN_NBYTES 20 /* 100dms: 16 kbps at !=44.1kHz, 14.7kbps at 44.1kHz - 50dms: 32 kbps at !=44.1kHz, 29.4kbps at 44.1kHz - 25dms: 64 kbps at !=44.1kHz, 58.8kbps at 44.1kHz */ -#define MAX_NBYTES_025 100 /* any dms: 320 kbps at !=44.1kHz, 294 kbps at 44.1kHz */ -#define MAX_NBYTES_050 200 /* any dms: 320 kbps at !=44.1kHz, 294 kbps at 44.1kHz */ -#define MAX_NBYTES_100 400 /* any dms: 320 kbps at !=44.1kHz, 294 kbps at 44.1kHz */ +#define MIN_NBYTES 20 /* 100dms: 16 kbps at !=44.1kHz, 14.7kbps at 44.1kHz \ + 50dms: 32 kbps at !=44.1kHz, 29.4kbps at 44.1kHz \ + 25dms: 64 kbps at !=44.1kHz, 58.8kbps at 44.1kHz */ +#define MAX_NBYTES_025 100 /* any dms: 320 kbps at !=44.1kHz, 294 kbps at 44.1kHz */ +#define MAX_NBYTES_050 200 /* any dms: 320 kbps at !=44.1kHz, 294 kbps at 44.1kHz */ +#define MAX_NBYTES_100 400 /* any dms: 320 kbps at !=44.1kHz, 294 kbps at 44.1kHz */ #ifdef ENABLE_HR_MODE_FL -# define MIN_BR_25MS_48KHZ_HR ((int)172800/3200/2)*3200 -# define MIN_BR_25MS_96KHZ_HR ((int)198400/3200/2)*3200 -# define MIN_BR_50MS_48KHZ_HR ((int)148800/1600/2)*1600 -# define MIN_BR_50MS_96KHZ_HR ((int)174400/1600/2)*1600 -# define MIN_BR_100MS_48KHZ_HR ((int)124800/800/2)*800 -# define MIN_BR_100MS_96KHZ_HR ((int)149600/800/2)*800 +#define MIN_BR_25MS_48KHZ_HR ( (int) 172800 / 3200 / 2 ) * 3200 +#define MIN_BR_25MS_96KHZ_HR ( (int) 198400 / 3200 / 2 ) * 3200 +#define MIN_BR_50MS_48KHZ_HR ( (int) 148800 / 1600 / 2 ) * 1600 +#define MIN_BR_50MS_96KHZ_HR ( (int) 174400 / 1600 / 2 ) * 1600 +#define MIN_BR_100MS_48KHZ_HR ( (int) 124800 / 800 / 2 ) * 800 +#define MIN_BR_100MS_96KHZ_HR ( (int) 149600 / 800 / 2 ) * 800 #endif /* ENABLE_HR_MODE */ -#define MAX_NBYTES2 625 -#define BYTESBUFSIZE (MAX_NBYTES2 * MAX_CHANNELS) -#define MAX_BW_BIN 400 +#define MAX_NBYTES2 625 +#define BYTESBUFSIZE ( MAX_NBYTES2 * MAX_CHANNELS ) +#define MAX_BW_BIN 400 #if MAX_BW_BIN > MAX_LEN -# define MAX_BW MAX_LEN +#define MAX_BW MAX_LEN #else -# define MAX_BW MAX_BW_BIN +#define MAX_BW MAX_BW_BIN #endif -# ifdef ENABLE_HR_MODE_FL -# define MAX_BW_HR 960 -# endif +#ifdef ENABLE_HR_MODE_FL +#define MAX_BW_HR 960 +#endif /* SCF */ -#define M 16 -#define MAX_BANDS_NUMBER 64 +#define M 16 +#define MAX_BANDS_NUMBER 64 #define MAX_BANDS_NUMBER_PLC 80 -#define PVQ_MAX_VEC_SIZE M +#define PVQ_MAX_VEC_SIZE M /* PVQ VQ setup */ #define SCF_MAX_PARAM \ @@ -210,28 +210,27 @@ typedef int32_t LC3_INT32; #define NPRM_RESQ 5 * MAX_LEN /* MDCT */ -#define MDCT_MEM_LEN_MAX (MAX_LEN - ((180 * MAX_LEN) / 480)) +#define MDCT_MEM_LEN_MAX ( MAX_LEN - ( ( 180 * MAX_LEN ) / 480 ) ) /* TNS */ #define TNS_NUMFILTERS_MAX 2 -#define MAXLAG 8 +#define MAXLAG 8 /* OLPA/LTPF */ -#define LEN_12K8 128 -#define LEN_6K4 64 -#define MIN_PITCH_6K4 17 -#define MAX_PITCH_6K4 114 +#define LEN_12K8 128 +#define LEN_6K4 64 +#define MIN_PITCH_6K4 17 +#define MAX_PITCH_6K4 114 #define RANGE_PITCH_6K4 98 -#define MIN_PITCH_12K8 32 -#define MAX_PITCH_12K8 228 +#define MIN_PITCH_12K8 32 +#define MAX_PITCH_12K8 228 #define RES2_PITCH_12K8 157 #define RES4_PITCH_12K8 127 -#define LTPF_MEMIN_LEN (MAX_PITCH_12K8 + 4) +#define LTPF_MEMIN_LEN ( MAX_PITCH_12K8 + 4 ) /* Advanced PLC */ - /* some configurations leave empty translation units. */ extern int fix_empty_translation_unit_warning; diff --git a/lib_lc3plus/detect_cutoff_warped.c b/lib_lc3plus/detect_cutoff_warped.c index 9392867208..0f4f18675d 100644 --- a/lib_lc3plus/detect_cutoff_warped.c +++ b/lib_lc3plus/detect_cutoff_warped.c @@ -1,83 +1,89 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -void processDetectCutoffWarped_fl(LC3_FLOAT* d2, LC3_INT fs_idx, LC3_INT frame_dms, LC3_INT* bw_idx) +void processDetectCutoffWarped_fl( LC3_FLOAT *d2, LC3_INT fs_idx, LC3_INT frame_dms, LC3_INT *bw_idx ) { const LC3_INT *warp_idx_start = NULL, *warp_idx_stop = NULL; - LC3_INT counter = 0, brickwall = 0, i = 0, stop = 0, dist = 0; - LC3_FLOAT d2_mean = 0, d2_sum = 0, e_diff = 0, thr = 0; + LC3_INT counter = 0, brickwall = 0, i = 0, stop = 0, dist = 0; + LC3_FLOAT d2_mean = 0, d2_sum = 0, e_diff = 0, thr = 0; const LC3_INT *bw_dist = NULL; warp_idx_start = BW_warp_idx_start_all[fs_idx - 1]; - warp_idx_stop = BW_warp_idx_stop_all[fs_idx - 1]; + warp_idx_stop = BW_warp_idx_stop_all[fs_idx - 1]; - switch (frame_dms) + switch ( frame_dms ) { case 25: warp_idx_start = BW_warp_idx_start_all_2_5ms[fs_idx - 1]; - warp_idx_stop = BW_warp_idx_stop_all_2_5ms[fs_idx - 1]; - bw_dist = brickwall_dist; + warp_idx_stop = BW_warp_idx_stop_all_2_5ms[fs_idx - 1]; + bw_dist = brickwall_dist; break; case 50: warp_idx_start = BW_warp_idx_start_all_5ms[fs_idx - 1]; - warp_idx_stop = BW_warp_idx_stop_all_5ms[fs_idx - 1]; - bw_dist = brickwall_dist; + warp_idx_stop = BW_warp_idx_stop_all_5ms[fs_idx - 1]; + bw_dist = brickwall_dist; break; case 100: warp_idx_start = BW_warp_idx_start_all[fs_idx - 1]; - warp_idx_stop = BW_warp_idx_stop_all[fs_idx - 1]; - bw_dist = brickwall_dist; + warp_idx_stop = BW_warp_idx_stop_all[fs_idx - 1]; + bw_dist = brickwall_dist; break; } - + counter = fs_idx; - - d2_sum = sum_vec(&d2[warp_idx_start[counter - 1]], warp_idx_stop[counter - 1] - warp_idx_start[counter - 1] + 1); - d2_mean = d2_sum / (warp_idx_stop[counter - 1] - warp_idx_start[counter - 1] + 1); + d2_sum = sum_vec( &d2[warp_idx_start[counter - 1]], warp_idx_stop[counter - 1] - warp_idx_start[counter - 1] + 1 ); + + d2_mean = d2_sum / ( warp_idx_stop[counter - 1] - warp_idx_start[counter - 1] + 1 ); - while (d2_mean < threshold_quiet[counter - 1]) { + while ( d2_mean < threshold_quiet[counter - 1] ) + { d2_sum = 0; counter--; - if (counter == 0) { + if ( counter == 0 ) + { break; } /* calculate mean energy per band */ d2_sum = - sum_vec(&d2[warp_idx_start[counter - 1]], warp_idx_stop[counter - 1] - warp_idx_start[counter - 1] + 1); + sum_vec( &d2[warp_idx_start[counter - 1]], warp_idx_stop[counter - 1] - warp_idx_start[counter - 1] + 1 ); - d2_mean = d2_sum / (warp_idx_stop[counter - 1] - warp_idx_start[counter - 1] + 1); + d2_mean = d2_sum / ( warp_idx_stop[counter - 1] - warp_idx_start[counter - 1] + 1 ); } *bw_idx = counter; /* check if energy difference between bands is present */ - if (*bw_idx < fs_idx) { - thr = (LC3_FLOAT)threshold_brickwall[counter]; + if ( *bw_idx < fs_idx ) + { + thr = (LC3_FLOAT) threshold_brickwall[counter]; stop = warp_idx_start[counter]; dist = bw_dist[counter]; - for (i = stop; i >= stop - dist; i--) { - e_diff = 10.0 * LC3_LOGTEN(d2[i - dist + 1] + FLT_EPSILON) - 10.0 * LC3_LOGTEN(d2[i + 1] + FLT_EPSILON); + for ( i = stop; i >= stop - dist; i-- ) + { + e_diff = 10.0 * LC3_LOGTEN( d2[i - dist + 1] + FLT_EPSILON ) - 10.0 * LC3_LOGTEN( d2[i + 1] + FLT_EPSILON ); - if (e_diff > thr) { + if ( e_diff > thr ) + { brickwall = 1; break; } } - if (brickwall == 0) { + if ( brickwall == 0 ) + { *bw_idx = fs_idx; } } diff --git a/lib_lc3plus/enc_entropy.c b/lib_lc3plus/enc_entropy.c index a7ff8cd700..ae9cbbc44e 100644 --- a/lib_lc3plus/enc_entropy.c +++ b/lib_lc3plus/enc_entropy.c @@ -1,126 +1,140 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -void processEncoderEntropy_fl(LC3_UINT8* bytes, LC3_INT* bp_side, LC3_INT* mask_side, LC3_INT numbytes, LC3_INT bw_cutoff_bits, - LC3_INT bw_cutoff_idx, LC3_INT lastnz, LC3_INT N, LC3_INT lsbMode, LC3_INT gg_idx, LC3_INT num_tns_filters, - LC3_INT* tns_order, LC3_INT* ltpf_idx, LC3_INT* scf_idx, LC3_INT fac_ns_idx - , LC3_INT bfi_ext, LC3_INT fs_idx - ) +void processEncoderEntropy_fl( LC3_UINT8 *bytes, LC3_INT *bp_side, LC3_INT *mask_side, LC3_INT numbytes, LC3_INT bw_cutoff_bits, LC3_INT bw_cutoff_idx, LC3_INT lastnz, LC3_INT N, LC3_INT lsbMode, LC3_INT gg_idx, LC3_INT num_tns_filters, LC3_INT *tns_order, LC3_INT *ltpf_idx, LC3_INT *scf_idx, LC3_INT fac_ns_idx, LC3_INT bfi_ext, LC3_INT fs_idx ) { - LC3_UINT8* ptr; - LC3_INT i = 0, submodeMSB = 0, submodeLSB = 0, tmp = 0, gainMSB = 0, gainLSB = 0; - LC3_INT gainMSBbits[4] = {1, 1, 2, 2}, gainLSBbits[4] = {0, 1, 0, 1}; - - LC3_INT16 lastnzTrigger[5] = {63, 127, 127, 255, 255}; + LC3_UINT8 *ptr; + LC3_INT i = 0, submodeMSB = 0, submodeLSB = 0, tmp = 0, gainMSB = 0, gainLSB = 0; + LC3_INT gainMSBbits[4] = { 1, 1, 2, 2 }, gainLSBbits[4] = { 0, 1, 0, 1 }; + + LC3_INT16 lastnzTrigger[5] = { 63, 127, 127, 255, 255 }; - *bp_side = numbytes - 1; + *bp_side = numbytes - 1; *mask_side = 1; - ptr = bytes; + ptr = bytes; /* Bandwidth */ - if (bw_cutoff_bits > 0) { - write_uint_backward_fl(ptr, bp_side, mask_side, bw_cutoff_idx, bw_cutoff_bits); + if ( bw_cutoff_bits > 0 ) + { + write_uint_backward_fl( ptr, bp_side, mask_side, bw_cutoff_idx, bw_cutoff_bits ); } /* Last non zero touple */ - if (bfi_ext == 1) { - write_uint_backward_fl(ptr, bp_side, mask_side, lastnzTrigger[fs_idx], ceil(LC3_LOGTWO(N >> 1))); + if ( bfi_ext == 1 ) + { + write_uint_backward_fl( ptr, bp_side, mask_side, lastnzTrigger[fs_idx], ceil( LC3_LOGTWO( N >> 1 ) ) ); } else { - write_uint_backward_fl(ptr, bp_side, mask_side, lastnz / 2 - 1, ceil(LC3_LOGTWO(N / 2))); + write_uint_backward_fl( ptr, bp_side, mask_side, lastnz / 2 - 1, ceil( LC3_LOGTWO( N / 2 ) ) ); } /* LSB mode bit */ - write_bit_backward_fl(ptr, bp_side, mask_side, lsbMode); + write_bit_backward_fl( ptr, bp_side, mask_side, lsbMode ); /* Global gain */ - write_uint_backward_fl(ptr, bp_side, mask_side, gg_idx, 8); + write_uint_backward_fl( ptr, bp_side, mask_side, gg_idx, 8 ); /* TNS activation flag */ - for (i = 0; i < num_tns_filters; i++) { - write_bit_backward_fl(ptr, bp_side, mask_side, MIN(1, tns_order[i])); + for ( i = 0; i < num_tns_filters; i++ ) + { + write_bit_backward_fl( ptr, bp_side, mask_side, MIN( 1, tns_order[i] ) ); } /* LTPF activation flag */ - write_bit_backward_fl(ptr, bp_side, mask_side, ltpf_idx[0]); + write_bit_backward_fl( ptr, bp_side, mask_side, ltpf_idx[0] ); /* SNS-VQ 1st stage */ - write_uint_backward_fl(ptr, bp_side, mask_side, scf_idx[0], 5); - write_uint_backward_fl(ptr, bp_side, mask_side, scf_idx[1], 5); + write_uint_backward_fl( ptr, bp_side, mask_side, scf_idx[0], 5 ); + write_uint_backward_fl( ptr, bp_side, mask_side, scf_idx[1], 5 ); /* SNS-VQ 2nd stage side-info (3-4 bits) */ submodeMSB = scf_idx[2] / 2; submodeLSB = scf_idx[2] & 1; - write_bit_backward_fl(ptr, bp_side, mask_side, submodeMSB); - gainMSB = scf_idx[3] >> (gainLSBbits[scf_idx[2]]); + write_bit_backward_fl( ptr, bp_side, mask_side, submodeMSB ); + gainMSB = scf_idx[3] >> ( gainLSBbits[scf_idx[2]] ); gainLSB = scf_idx[3] & 1; - write_uint_backward_fl(ptr, bp_side, mask_side, gainMSB, gainMSBbits[scf_idx[2]]); - write_bit_backward_fl(ptr, bp_side, mask_side, scf_idx[4]); + write_uint_backward_fl( ptr, bp_side, mask_side, gainMSB, gainMSBbits[scf_idx[2]] ); + write_bit_backward_fl( ptr, bp_side, mask_side, scf_idx[4] ); /* SNS-VQ 2nd stage MPVQ data (24-25 bits) */ - if (submodeMSB == 0) { - if (submodeLSB == 0) { + if ( submodeMSB == 0 ) + { + if ( submodeLSB == 0 ) + { tmp = scf_idx[6] + 2; - } else { + } + else + { tmp = gainLSB; } tmp = tmp * 2390004 + scf_idx[5]; - write_uint_backward_fl(ptr, bp_side, mask_side, tmp, 25); - } else { + write_uint_backward_fl( ptr, bp_side, mask_side, tmp, 25 ); + } + else + { tmp = scf_idx[5]; - if (submodeLSB != 0) { + if ( submodeLSB != 0 ) + { tmp = 2 * tmp + gainLSB + 15158272; } - write_uint_backward_fl(ptr, bp_side, mask_side, tmp, 24); + write_uint_backward_fl( ptr, bp_side, mask_side, tmp, 24 ); } /* LTPF data */ - if (ltpf_idx[0] == 1) { - write_uint_backward_fl(ptr, bp_side, mask_side, ltpf_idx[1], 1); - write_uint_backward_fl(ptr, bp_side, mask_side, ltpf_idx[2], 9); + if ( ltpf_idx[0] == 1 ) + { + write_uint_backward_fl( ptr, bp_side, mask_side, ltpf_idx[1], 1 ); + write_uint_backward_fl( ptr, bp_side, mask_side, ltpf_idx[2], 9 ); } /* Noise factor */ - write_uint_backward_fl(ptr, bp_side, mask_side, fac_ns_idx, 3); + write_uint_backward_fl( ptr, bp_side, mask_side, fac_ns_idx, 3 ); } -void write_uint_backward_fl(LC3_UINT8* ptr, LC3_INT* bp_side, LC3_INT* mask_side, LC3_INT val, LC3_INT numbits) +void write_uint_backward_fl( LC3_UINT8 *ptr, LC3_INT *bp_side, LC3_INT *mask_side, LC3_INT val, LC3_INT numbits ) { LC3_INT k = 0, bit = 0; - for (k = 0; k < numbits; k++) { + for ( k = 0; k < numbits; k++ ) + { bit = val & 1; - write_bit_backward_fl(ptr, bp_side, mask_side, bit); + write_bit_backward_fl( ptr, bp_side, mask_side, bit ); val = val / 2; } } -void write_bit_backward_fl(LC3_UINT8* ptr, LC3_INT* bp_side, LC3_INT* mask_side, LC3_INT bit) +void write_bit_backward_fl( LC3_UINT8 *ptr, LC3_INT *bp_side, LC3_INT *mask_side, LC3_INT bit ) { - if (bit == 0) { - ptr[*bp_side] = ptr[*bp_side] & (255 - *mask_side); - } else { + if ( bit == 0 ) + { + ptr[*bp_side] = ptr[*bp_side] & ( 255 - *mask_side ); + } + else + { ptr[*bp_side] = ptr[*bp_side] | *mask_side; } - if (*mask_side == 128) { + if ( *mask_side == 128 ) + { *mask_side = 1; - *bp_side = *bp_side - 1; - } else { + *bp_side = *bp_side - 1; + } + else + { *mask_side = *mask_side * 2; } } diff --git a/lib_lc3plus/enc_lc3_fl.c b/lib_lc3plus/enc_lc3_fl.c index c89f7244ca..f5375ed742 100644 --- a/lib_lc3plus/enc_lc3_fl.c +++ b/lib_lc3plus/enc_lc3_fl.c @@ -1,131 +1,139 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -static void Enc_LC3PLUS_Channel_fl(LC3PLUS_Enc* encoder, int channel, int32_t* s_in, uint8_t* bytes, int bps -, LC3_INT32 bfi_ext -) +static void Enc_LC3PLUS_Channel_fl( LC3PLUS_Enc *encoder, int channel, int32_t *s_in, uint8_t *bytes, int bps, LC3_INT32 bfi_ext ) { - EncSetup* h_EncSetup; + EncSetup *h_EncSetup; LC3_INT s_12k8_len = 0, T0_out = 0, ltpfBits = 0, BW_cutoff_idx = 0, tns_numfilters = 0, quantizedGain = 0, - quantizedGainMin = 0, nbits = 0, nbits2 = 0, lastnz = 0, lsbMode = 0, gainChange = 0, bp_side = 0, - mask_side = 0, fac_ns_idx = 0, numResBits = 0, tns_order[2] = {0}, i = 0; + quantizedGainMin = 0, nbits = 0, nbits2 = 0, lastnz = 0, lsbMode = 0, gainChange = 0, bp_side = 0, + mask_side = 0, fac_ns_idx = 0, numResBits = 0, tns_order[2] = { 0 }, i = 0; LC3_FLOAT normcorr = 0, gain = 0; - - LC3_FLOAT d_fl[MAX_LEN] = {0}; - LC3_INT q_d[MAX_LEN] = {0}; - LC3_INT indexes[TNS_NUMFILTERS_MAX * MAXLAG] = {0}; + + LC3_FLOAT d_fl[MAX_LEN] = { 0 }; + LC3_INT q_d[MAX_LEN] = { 0 }; + LC3_INT indexes[TNS_NUMFILTERS_MAX * MAXLAG] = { 0 }; h_EncSetup = encoder->channel_setup[channel]; - memset(bytes, 0, sizeof(uint8_t) * h_EncSetup->targetBytes); + memset( bytes, 0, sizeof( uint8_t ) * h_EncSetup->targetBytes ); - if (bps == 24) { - for (i = 0; i < encoder->frame_length; i++) { - int32_t tmp = ((int32_t*)s_in)[i]; + if ( bps == 24 ) + { + for ( i = 0; i < encoder->frame_length; i++ ) + { + int32_t tmp = ( (int32_t *) s_in )[i]; - if (tmp >= 0) + if ( tmp >= 0 ) { tmp = tmp & 0x007fffff; } else { - tmp = tmp | (int32_t)0xff800000; + tmp = tmp | (int32_t) 0xff800000; } - h_EncSetup->s_in_scaled[i] = ((LC3_FLOAT) tmp / (float) LC3_POW(2, 8)); + h_EncSetup->s_in_scaled[i] = ( (LC3_FLOAT) tmp / (float) LC3_POW( 2, 8 ) ); } - } else if (bps == 16) { - for (i = 0; i < encoder->frame_length; i++) { - h_EncSetup->s_in_scaled[i] = (LC3_FLOAT)((int16_t*)s_in)[i]; + } + else if ( bps == 16 ) + { + for ( i = 0; i < encoder->frame_length; i++ ) + { + h_EncSetup->s_in_scaled[i] = (LC3_FLOAT) ( (int16_t *) s_in )[i]; } } /* MDCT */ - processMdct_fl(h_EncSetup->s_in_scaled, d_fl, &h_EncSetup->mdctStruct); + processMdct_fl( h_EncSetup->s_in_scaled, d_fl, &h_EncSetup->mdctStruct ); /* 12.8 kHz resampler */ - process_resamp12k8_fl(h_EncSetup->s_in_scaled, encoder->frame_length, h_EncSetup->r12k8_mem_in, - encoder->r12k8_mem_in_len, h_EncSetup->r12k8_mem_50, h_EncSetup->r12k8_mem_out, - encoder->r12k8_mem_out_len, h_EncSetup->s_12k8, &s_12k8_len, encoder->fs_idx, - encoder->frame_dms, encoder->fs); + process_resamp12k8_fl( h_EncSetup->s_in_scaled, encoder->frame_length, h_EncSetup->r12k8_mem_in, + encoder->r12k8_mem_in_len, h_EncSetup->r12k8_mem_50, h_EncSetup->r12k8_mem_out, + encoder->r12k8_mem_out_len, h_EncSetup->s_12k8, &s_12k8_len, encoder->fs_idx, + encoder->frame_dms, encoder->fs ); /* Pitch estimation */ - processOlpa_fl(h_EncSetup->s_12k8, h_EncSetup->olpa_mem_s12k8, h_EncSetup->olpa_mem_s6k4, - &h_EncSetup->olpa_mem_pitch, &T0_out, &normcorr, s_12k8_len, encoder->frame_dms); + processOlpa_fl( h_EncSetup->s_12k8, h_EncSetup->olpa_mem_s12k8, h_EncSetup->olpa_mem_s6k4, + &h_EncSetup->olpa_mem_pitch, &T0_out, &normcorr, s_12k8_len, encoder->frame_dms ); /* LTPF encoder */ - process_ltpf_coder_fl(h_EncSetup->s_12k8, s_12k8_len + 1, h_EncSetup->ltpf_enable, T0_out, normcorr, - encoder->frame_dms, h_EncSetup->ltpf_mem_in, encoder->ltpf_mem_in_len, - &h_EncSetup->ltpf_mem_normcorr, &h_EncSetup->ltpf_mem_ltpf_on, - &h_EncSetup->ltpf_mem_pitch, h_EncSetup->ltpf_param, &h_EncSetup->ltpf_mem_mem_normcorr, - <pfBits); + process_ltpf_coder_fl( h_EncSetup->s_12k8, s_12k8_len + 1, h_EncSetup->ltpf_enable, T0_out, normcorr, + encoder->frame_dms, h_EncSetup->ltpf_mem_in, encoder->ltpf_mem_in_len, + &h_EncSetup->ltpf_mem_normcorr, &h_EncSetup->ltpf_mem_ltpf_on, + &h_EncSetup->ltpf_mem_pitch, h_EncSetup->ltpf_param, &h_EncSetup->ltpf_mem_mem_normcorr, + <pfBits ); /* Attack detector */ - attack_detector_fl(h_EncSetup->s_in_scaled, encoder->frame_length, encoder->fs, &h_EncSetup->attdec_position, - &h_EncSetup->attdec_acc_energy, &h_EncSetup->attdec_detected, h_EncSetup->attdec_filter_mem, - h_EncSetup->attack_handling, encoder->attdec_nblocks, encoder->attdec_hangover_thresh); + attack_detector_fl( h_EncSetup->s_in_scaled, encoder->frame_length, encoder->fs, &h_EncSetup->attdec_position, + &h_EncSetup->attdec_acc_energy, &h_EncSetup->attdec_detected, h_EncSetup->attdec_filter_mem, + h_EncSetup->attack_handling, encoder->attdec_nblocks, encoder->attdec_hangover_thresh ); /* Per-band energy */ - processPerBandEnergy_fl(encoder->bands_number, encoder->bands_offset, encoder->hrmode, encoder->frame_dms, h_EncSetup->ener, d_fl); + processPerBandEnergy_fl( encoder->bands_number, encoder->bands_offset, encoder->hrmode, encoder->frame_dms, h_EncSetup->ener, d_fl ); /* Near Nyquist detector */ - processNearNyquistdetector_fl(&encoder->near_nyquist_flag, encoder->fs_idx, encoder->near_nyquist_index, encoder->bands_number, h_EncSetup->ener); + processNearNyquistdetector_fl( &encoder->near_nyquist_flag, encoder->fs_idx, encoder->near_nyquist_index, encoder->bands_number, h_EncSetup->ener ); /* Disable LTPF if nyquist detector triggers or -lfe mode is active*/ - if (encoder->near_nyquist_flag != 0 || h_EncSetup->lfe == 1) + if ( encoder->near_nyquist_flag != 0 || h_EncSetup->lfe == 1 ) { h_EncSetup->ltpf_mem_ltpf_on = 0; h_EncSetup->ltpf_param[1] = 0; } /* Bandwidth cut-off detection */ - if (h_EncSetup->lfe == 0) { - /* No BW Cutoff for 8 kHz and 96 kHz. No detection if bandwidth controller is active */ - if (encoder->fs_idx > 0 && encoder->hrmode == 0 && encoder->bw_ctrl_active == 0) { - processDetectCutoffWarped_fl(h_EncSetup->ener, encoder->fs_idx, encoder->frame_dms, &BW_cutoff_idx); - } else { - BW_cutoff_idx = encoder->fs_idx; + if ( h_EncSetup->lfe == 0 ) + { + /* No BW Cutoff for 8 kHz and 96 kHz. No detection if bandwidth controller is active */ + if ( encoder->fs_idx > 0 && encoder->hrmode == 0 && encoder->bw_ctrl_active == 0 ) + { + processDetectCutoffWarped_fl( h_EncSetup->ener, encoder->fs_idx, encoder->frame_dms, &BW_cutoff_idx ); + } + else + { + BW_cutoff_idx = encoder->fs_idx; + } } - } else { + else + { BW_cutoff_idx = 0; } - processSnsComputeScf_fl(h_EncSetup->ener, encoder->tilt, encoder->bands_number, h_EncSetup->scf, - h_EncSetup->attdec_detected, encoder->sns_damping, encoder->attdec_damping); + processSnsComputeScf_fl( h_EncSetup->ener, encoder->tilt, encoder->bands_number, h_EncSetup->scf, + h_EncSetup->attdec_detected, encoder->sns_damping, encoder->attdec_damping ); /* SNS Quantizer */ - process_snsQuantizesScf_Enc(h_EncSetup->scf, h_EncSetup->L_scf_idx, h_EncSetup->scf_q, h_EncSetup->dct2StructSNS); + process_snsQuantizesScf_Enc( h_EncSetup->scf, h_EncSetup->L_scf_idx, h_EncSetup->scf_q, h_EncSetup->dct2StructSNS ); /* SNS Interpolation */ - processSnsInterpolateScf_fl(h_EncSetup->scf_q, 1, encoder->bands_number, h_EncSetup->int_scf); + processSnsInterpolateScf_fl( h_EncSetup->scf_q, 1, encoder->bands_number, h_EncSetup->int_scf ); /* MDCT shaping */ - processMdctShaping_fl(d_fl, h_EncSetup->int_scf, encoder->bands_offset, encoder->bands_number); - + processMdctShaping_fl( d_fl, h_EncSetup->int_scf, encoder->bands_offset, encoder->bands_number ); + /* Bandwidth controller */ - if (encoder->bandwidth < encoder->fs / 2) { - process_cutoff_bandwidth(d_fl, encoder->yLen, encoder->bw_ctrl_cutoff_bin); - BW_cutoff_idx = MIN(BW_cutoff_idx, encoder->bw_index); + if ( encoder->bandwidth < encoder->fs / 2 ) + { + process_cutoff_bandwidth( d_fl, encoder->yLen, encoder->bw_ctrl_cutoff_bin ); + BW_cutoff_idx = MIN( BW_cutoff_idx, encoder->bw_index ); } - + /* TNS encoder */ - if (h_EncSetup->lfe == 0) + if ( h_EncSetup->lfe == 0 ) { - processTnsCoder_fl(d_fl, BW_cutoff_idx, encoder->cutoffBins[BW_cutoff_idx], encoder->fs, encoder->frame_length, - encoder->frame_dms, h_EncSetup->total_bits, tns_order, indexes, &tns_numfilters, - &(h_EncSetup->tns_bits) - , encoder->near_nyquist_flag - ); + processTnsCoder_fl( d_fl, BW_cutoff_idx, encoder->cutoffBins[BW_cutoff_idx], encoder->fs, encoder->frame_length, + encoder->frame_dms, h_EncSetup->total_bits, tns_order, indexes, &tns_numfilters, + &( h_EncSetup->tns_bits ), encoder->near_nyquist_flag ); } else { @@ -134,119 +142,109 @@ static void Enc_LC3PLUS_Channel_fl(LC3PLUS_Enc* encoder, int channel, int32_t* s h_EncSetup->tns_bits = tns_numfilters; } /* Global Gain Estimation */ - h_EncSetup->targetBitsQuant = h_EncSetup->targetBitsInit - (h_EncSetup->tns_bits + ltpfBits); + h_EncSetup->targetBitsQuant = h_EncSetup->targetBitsInit - ( h_EncSetup->tns_bits + ltpfBits ); - if (h_EncSetup->targetBitsQuant < 0 && ltpfBits > 1) + if ( h_EncSetup->targetBitsQuant < 0 && ltpfBits > 1 ) { /* Disable LTPF */ h_EncSetup->ltpf_mem_ltpf_on = 0; - h_EncSetup->ltpf_param[1] = 0; - ltpfBits = 1; - h_EncSetup->targetBitsQuant = h_EncSetup->targetBitsInit - (h_EncSetup->tns_bits + ltpfBits); + h_EncSetup->ltpf_param[1] = 0; + ltpfBits = 1; + h_EncSetup->targetBitsQuant = h_EncSetup->targetBitsInit - ( h_EncSetup->tns_bits + ltpfBits ); } - processEstimateGlobalGain_fl(d_fl, encoder->yLen, h_EncSetup->targetBitsQuant, &gain, &quantizedGain, - &quantizedGainMin, h_EncSetup->quantizedGainOff, &h_EncSetup->targetBitsOff, - &h_EncSetup->mem_targetBits, h_EncSetup->mem_specBits - , encoder->hrmode, h_EncSetup->regBits, encoder->frame_ms + processEstimateGlobalGain_fl( d_fl, encoder->yLen, h_EncSetup->targetBitsQuant, &gain, &quantizedGain, + &quantizedGainMin, h_EncSetup->quantizedGainOff, &h_EncSetup->targetBitsOff, + &h_EncSetup->mem_targetBits, h_EncSetup->mem_specBits, encoder->hrmode, h_EncSetup->regBits, encoder->frame_ms ); /* 1. Quantization */ - processQuantizeSpec_fl(d_fl, gain, q_d, encoder->yLen, h_EncSetup->total_bits, &nbits, &nbits2, encoder->fs, - &lastnz, h_EncSetup->codingdata, &lsbMode, -1, h_EncSetup->targetBitsQuant, encoder->hrmode - ); + processQuantizeSpec_fl( d_fl, gain, q_d, encoder->yLen, h_EncSetup->total_bits, &nbits, &nbits2, encoder->fs, + &lastnz, h_EncSetup->codingdata, &lsbMode, -1, h_EncSetup->targetBitsQuant, encoder->hrmode ); h_EncSetup->mem_specBits = nbits; /* Global Gain Adjustment */ - processAdjustGlobalGain_fl(&quantizedGain, quantizedGainMin, h_EncSetup->quantizedGainOff, &gain, - h_EncSetup->targetBitsQuant, h_EncSetup->mem_specBits, &gainChange, encoder->fs_idx - , encoder->hrmode, encoder->frame_dms - ); + processAdjustGlobalGain_fl( &quantizedGain, quantizedGainMin, h_EncSetup->quantizedGainOff, &gain, + h_EncSetup->targetBitsQuant, h_EncSetup->mem_specBits, &gainChange, encoder->fs_idx, encoder->hrmode, encoder->frame_dms ); /* 2. Quantization */ - if (gainChange) { - processQuantizeSpec_fl(d_fl, gain, q_d, encoder->yLen, h_EncSetup->total_bits, &nbits, &nbits2, encoder->fs, - &lastnz, - h_EncSetup->codingdata, - &lsbMode, 0, h_EncSetup->targetBitsQuant - , encoder->hrmode - ); + if ( gainChange ) + { + processQuantizeSpec_fl( d_fl, gain, q_d, encoder->yLen, h_EncSetup->total_bits, &nbits, &nbits2, encoder->fs, + &lastnz, + h_EncSetup->codingdata, + &lsbMode, 0, h_EncSetup->targetBitsQuant, encoder->hrmode ); } /* Noise factor */ - if (h_EncSetup->lfe == 0) - { - processNoiseFactor_fl(&fac_ns_idx, d_fl, q_d, gain, encoder->cutoffBins[BW_cutoff_idx], encoder->frame_dms, - h_EncSetup->targetBytes - ); + if ( h_EncSetup->lfe == 0 ) + { + processNoiseFactor_fl( &fac_ns_idx, d_fl, q_d, gain, encoder->cutoffBins[BW_cutoff_idx], encoder->frame_dms, + h_EncSetup->targetBytes ); } else { fac_ns_idx = 7; } /* Residual Coding */ - if (lsbMode == 0) { - processResidualCoding_fl(d_fl, q_d, gain, encoder->yLen, h_EncSetup->targetBitsQuant, nbits2, - h_EncSetup->resBits, &numResBits - , encoder->hrmode - ); - } else { + if ( lsbMode == 0 ) + { + processResidualCoding_fl( d_fl, q_d, gain, encoder->yLen, h_EncSetup->targetBitsQuant, nbits2, + h_EncSetup->resBits, &numResBits, encoder->hrmode ); + } + else + { numResBits = 0; } /* Entropy encoding */ - processEncoderEntropy_fl(bytes, &bp_side, &mask_side, h_EncSetup->targetBytes, encoder->BW_cutoff_bits, - BW_cutoff_idx, lastnz, encoder->yLen, lsbMode, quantizedGain, tns_numfilters, tns_order, - h_EncSetup->ltpf_param, h_EncSetup->L_scf_idx, fac_ns_idx - , bfi_ext, encoder->fs_idx - ); + processEncoderEntropy_fl( bytes, &bp_side, &mask_side, h_EncSetup->targetBytes, encoder->BW_cutoff_bits, + BW_cutoff_idx, lastnz, encoder->yLen, lsbMode, quantizedGain, tns_numfilters, tns_order, + h_EncSetup->ltpf_param, h_EncSetup->L_scf_idx, fac_ns_idx, bfi_ext, encoder->fs_idx ); /* Artithmetic encoding */ - processAriEncoder_fl(bytes, bp_side, mask_side, q_d, tns_order, tns_numfilters, indexes, lastnz, - h_EncSetup->codingdata, - h_EncSetup->resBits, numResBits, lsbMode, h_EncSetup->targetBitsAri, - h_EncSetup->enable_lpc_weighting); - - if (encoder->combined_channel_coding == 0 && h_EncSetup->n_pc > 0) + processAriEncoder_fl( bytes, bp_side, mask_side, q_d, tns_order, tns_numfilters, indexes, lastnz, + h_EncSetup->codingdata, + h_EncSetup->resBits, numResBits, lsbMode, h_EncSetup->targetBitsAri, + h_EncSetup->enable_lpc_weighting ); + + if ( encoder->combined_channel_coding == 0 && h_EncSetup->n_pc > 0 ) { - LC3_INT32 xbuf[MAX_LEN] = {0}, nf_seed, tns_idx[M], zero_frame, nbits_residual, residualPresent, b_left, spec_inv_idx; - - memset(h_EncSetup->resBits, 0, sizeof(*(h_EncSetup->resBits)) * MAX_RESBITS_LEN); - - processAriDecoder_fl(bytes, bp_side, mask_side, encoder->yLen, encoder->fs_idx, h_EncSetup->enable_lpc_weighting, - tns_numfilters, lsbMode, lastnz, &bfi_ext, tns_order, fac_ns_idx, quantizedGain, - h_EncSetup->resBits, xbuf, &nf_seed, tns_idx, &zero_frame, h_EncSetup->targetBytes, &nbits_residual, - &residualPresent, encoder->frame_dms, h_EncSetup->n_pc, 0, h_EncSetup->total_bits >> 3, 1, &b_left, - &spec_inv_idx, encoder->hrmode); - - processReorderBitstream_fl(bytes, h_EncSetup->n_pccw, h_EncSetup->n_pc, b_left, h_EncSetup->targetBytes); + LC3_INT32 xbuf[MAX_LEN] = { 0 }, nf_seed, tns_idx[M], zero_frame, nbits_residual, residualPresent, b_left, spec_inv_idx; + + memset( h_EncSetup->resBits, 0, sizeof( *( h_EncSetup->resBits ) ) * MAX_RESBITS_LEN ); + + processAriDecoder_fl( bytes, bp_side, mask_side, encoder->yLen, encoder->fs_idx, h_EncSetup->enable_lpc_weighting, + tns_numfilters, lsbMode, lastnz, &bfi_ext, tns_order, fac_ns_idx, quantizedGain, + h_EncSetup->resBits, xbuf, &nf_seed, tns_idx, &zero_frame, h_EncSetup->targetBytes, &nbits_residual, + &residualPresent, encoder->frame_dms, h_EncSetup->n_pc, 0, h_EncSetup->total_bits >> 3, 1, &b_left, + &spec_inv_idx, encoder->hrmode ); + + processReorderBitstream_fl( bytes, h_EncSetup->n_pccw, h_EncSetup->n_pc, b_left, h_EncSetup->targetBytes ); } - } -int Enc_LC3PLUS_fl(LC3PLUS_Enc* encoder, void** input, uint8_t* output, int bps -, LC3_INT32 bfi_ext -) +int Enc_LC3PLUS_fl( LC3PLUS_Enc *encoder, void **input, uint8_t *output, int bps, LC3_INT32 bfi_ext ) { - int ch = 0, output_size = 0; - uint8_t* lc3buf = output; + int ch = 0, output_size = 0; + uint8_t *lc3buf = output; LC3_INT32 totalBytes; LC3_INT32 output_size2, input_size; - - totalBytes = encoder->bitrate * encoder->frame_length / (8 * encoder->fs_in); - for (ch = 0; ch < encoder->channels; ch++) + totalBytes = encoder->bitrate * encoder->frame_length / ( 8 * encoder->fs_in ); + + for ( ch = 0; ch < encoder->channels; ch++ ) { - Enc_LC3PLUS_Channel_fl(encoder, ch, input[ch], lc3buf, bps, bfi_ext); - if (encoder->epmode && encoder->combined_channel_coding == 0) + Enc_LC3PLUS_Channel_fl( encoder, ch, input[ch], lc3buf, bps, bfi_ext ); + if ( encoder->epmode && encoder->combined_channel_coding == 0 ) { - output_size2 = totalBytes / encoder->channels + (ch < (totalBytes % encoder->channels)); + output_size2 = totalBytes / encoder->channels + ( ch < ( totalBytes % encoder->channels ) ); - fec_encoder(encoder->epmode, encoder->epmr, lc3buf, encoder->channel_setup[ch]->targetBytes, output_size2, - encoder->channel_setup[ch]->n_pccw); + fec_encoder( encoder->epmode, encoder->epmr, lc3buf, encoder->channel_setup[ch]->targetBytes, output_size2, + encoder->channel_setup[ch]->n_pccw ); lc3buf += output_size2; output_size += output_size2; @@ -258,13 +256,13 @@ int Enc_LC3PLUS_fl(LC3PLUS_Enc* encoder, void** input, uint8_t* output, int bps } } - if (encoder->epmode > 0 && encoder->combined_channel_coding) + if ( encoder->epmode > 0 && encoder->combined_channel_coding ) { - input_size = output_size; - output_size = encoder->bitrate * encoder->frame_length / (8 * encoder->fs_in); + input_size = output_size; + output_size = encoder->bitrate * encoder->frame_length / ( 8 * encoder->fs_in ); - fec_encoder(encoder->epmode, encoder->epmr, output, input_size, output_size, encoder->channel_setup[0]->n_pccw); + fec_encoder( encoder->epmode, encoder->epmr, output, input_size, output_size, encoder->channel_setup[0]->n_pccw ); } - + return output_size; } diff --git a/lib_lc3plus/estimate_global_gain.c b/lib_lc3plus/estimate_global_gain.c index df9b1f5f23..6d637f82ea 100644 --- a/lib_lc3plus/estimate_global_gain.c +++ b/lib_lc3plus/estimate_global_gain.c @@ -1,107 +1,121 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -void processEstimateGlobalGain_fl(LC3_FLOAT x[], LC3_INT lg, LC3_INT nbitsSQ, LC3_FLOAT* gain, LC3_INT* quantizedGain, - LC3_INT* quantizedGainMin, LC3_INT quantizedGainOff, LC3_FLOAT* targetBitsOff, - LC3_INT* old_targetBits, LC3_INT old_specBits - , LC3_INT hrmode , LC3_INT regBits, LC3_FLOAT frame_ms -) +void processEstimateGlobalGain_fl( LC3_FLOAT x[], LC3_INT lg, LC3_INT nbitsSQ, LC3_FLOAT *gain, LC3_INT *quantizedGain, LC3_INT *quantizedGainMin, LC3_INT quantizedGainOff, LC3_FLOAT *targetBitsOff, LC3_INT *old_targetBits, LC3_INT old_specBits, LC3_INT hrmode, LC3_INT regBits, LC3_FLOAT frame_ms ) { - LC3_INT i = 0, N = 0, offset = 0, j = 0, iszero = 0; + LC3_INT i = 0, N = 0, offset = 0, j = 0, iszero = 0; LC3_FLOAT g_min = 0, x_max = 0, tmp = 0, ind = 0, ind_min = 0, target = 0, fac = 0, ener = 0; - LC3_FLOAT en[MAX_LEN / 4] = {0}; + LC3_FLOAT en[MAX_LEN / 4] = { 0 }; LC3_FLOAT reg_val = 4.656612873077393e-10; - if (*old_targetBits < 0) { + if ( *old_targetBits < 0 ) + { *targetBitsOff = 0; - } else { - tmp = MIN(40, MAX(-40, *targetBitsOff + *old_targetBits - old_specBits)); + } + else + { + tmp = MIN( 40, MAX( -40, *targetBitsOff + *old_targetBits - old_specBits ) ); *targetBitsOff = 0.8 * *targetBitsOff + 0.2 * tmp; } *old_targetBits = nbitsSQ; - nbitsSQ = nbitsSQ + round(*targetBitsOff); + nbitsSQ = nbitsSQ + round( *targetBitsOff ); - x_max = array_max_abs(x, lg); + x_max = array_max_abs( x, lg ); - if (hrmode && regBits > 0) + if ( hrmode && regBits > 0 ) { LC3_FLOAT M0 = 1e-5, M1 = 1e-5, rB_offset; - LC3_FLOAT thresh = 2*frame_ms; - for (i = 0; i < lg; i++) + LC3_FLOAT thresh = 2 * frame_ms; + for ( i = 0; i < lg; i++ ) { - M0 += fabs(x[i]); - M1 += i*fabs(x[i]); + M0 += fabs( x[i] ); + M1 += i * fabs( x[i] ); } - rB_offset = 8 * (1 - MIN(M1/M0, thresh) / thresh); - reg_val = x_max * LC3_POW(2,-regBits - rB_offset); + rB_offset = 8 * ( 1 - MIN( M1 / M0, thresh ) / thresh ); + reg_val = x_max * LC3_POW( 2, -regBits - rB_offset ); } - if (x_max < LC3_EPS) + if ( x_max < LC3_EPS ) { - ind_min = quantizedGainOff; - ind = 0; + ind_min = quantizedGainOff; + ind = 0; *old_targetBits = -1; - } else { - if (hrmode == 1) { - g_min = x_max / (32768 * 256 - 2); - } else { - g_min = x_max / (32767 - 0.375); + } + else + { + if ( hrmode == 1 ) + { + g_min = x_max / ( 32768 * 256 - 2 ); + } + else + { + g_min = x_max / ( 32767 - 0.375 ); } /* Prevent positive rounding errors from LC3_LOGTEN function */ - ind_min = 28.0 * LC3_LOGTEN(g_min); + ind_min = 28.0 * LC3_LOGTEN( g_min ); + + ind_min = ceil( ind_min + LC3_FABS( ind_min ) * LC3_EPS ); - ind_min = ceil(ind_min + LC3_FABS(ind_min) * LC3_EPS); - - assert(LC3_POW(10, ind_min / 28.0) >= g_min); - assert(ind_min <= (255 + quantizedGainOff)); + assert( LC3_POW( 10, ind_min / 28.0 ) >= g_min ); + assert( ind_min <= ( 255 + quantizedGainOff ) ); N = lg; j = 0; - for (i = 0; i < N; i = i + 4) { + for ( i = 0; i < N; i = i + 4 ) + { tmp = x[i] * x[i]; tmp += x[i + 1] * x[i + 1]; tmp += x[i + 2] * x[i + 2]; tmp += x[i + 3] * x[i + 3]; - en[j] = (28.0 / 20.0) * (7 + 10.0 * LC3_LOGTEN(tmp + reg_val)); + en[j] = ( 28.0 / 20.0 ) * ( 7 + 10.0 * LC3_LOGTEN( tmp + reg_val ) ); j++; } - target = (28.0 / 20.0) * (1.4) * nbitsSQ; - fac = 256; + target = ( 28.0 / 20.0 ) * ( 1.4 ) * nbitsSQ; + fac = 256; offset = 255 + quantizedGainOff; - for (i = 0; i < 8; i++) { - fac = fac * 0.5; + for ( i = 0; i < 8; i++ ) + { + fac = fac * 0.5; offset = offset - fac; - ener = 0; + ener = 0; iszero = 1; - for (j = N / 4 - 1; j >= 0; j--) { + for ( j = N / 4 - 1; j >= 0; j-- ) + { tmp = en[j] - offset; - if (tmp < (7.0) * (28.0 / 20.0)) { - if (iszero == 0) { - ener = ener + (2.7) * (28.0 / 20.0); + if ( tmp < ( 7.0 ) * ( 28.0 / 20.0 ) ) + { + if ( iszero == 0 ) + { + ener = ener + ( 2.7 ) * ( 28.0 / 20.0 ); } - } else { - if (tmp > (50.0) * (28.0 / 20.0)) { - ener = ener + 2.0 * tmp - (50.0) * (28.0 / 20.0); - } else { + } + else + { + if ( tmp > ( 50.0 ) * ( 28.0 / 20.0 ) ) + { + ener = ener + 2.0 * tmp - ( 50.0 ) * ( 28.0 / 20.0 ); + } + else + { ener = ener + tmp; } @@ -109,20 +123,22 @@ void processEstimateGlobalGain_fl(LC3_FLOAT x[], LC3_INT lg, LC3_INT nbitsSQ, LC } } - if (ener > target && iszero == 0) { + if ( ener > target && iszero == 0 ) + { offset = offset + fac; } } - if (offset < ind_min) { + if ( offset < ind_min ) + { *old_targetBits = -1; } - ind = MAX(ind_min, offset) - quantizedGainOff; + ind = MAX( ind_min, offset ) - quantizedGainOff; } *quantizedGainMin = ind_min; - *quantizedGain = ind; + *quantizedGain = ind; - *gain = LC3_POW(10.0, ((ind + quantizedGainOff) / 28.0)); + *gain = LC3_POW( 10.0, ( ( ind + quantizedGainOff ) / 28.0 ) ); } diff --git a/lib_lc3plus/functions.h b/lib_lc3plus/functions.h index 7a529a25d7..543fc9b7fd 100644 --- a/lib_lc3plus/functions.h +++ b/lib_lc3plus/functions.h @@ -1,12 +1,12 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #ifndef FUNCTIONS_H #define FUNCTIONS_H @@ -24,281 +24,234 @@ #include "fft/iisfft.h" /* fft.c */ -void real_fft_init(Fft* fft, LC3_INT32 length, HANDLE_IIS_FFT *handle); -void real_ifft_init(Fft* fft, LC3_INT32 length, HANDLE_IIS_FFT *handle); -void real_fft_apply(Fft* fft, const LC3_FLOAT* in, LC3_FLOAT* out); +void real_fft_init( Fft *fft, LC3_INT32 length, HANDLE_IIS_FFT *handle ); +void real_ifft_init( Fft *fft, LC3_INT32 length, HANDLE_IIS_FFT *handle ); +void real_fft_apply( Fft *fft, const LC3_FLOAT *in, LC3_FLOAT *out ); -void fft_init(Fft* fft, LC3_INT length); -void fft_free(Fft* fft); -void real_fft_free(Fft* fft); -void fft_apply(Fft* fft, const Complex* input, Complex* output); +void fft_init( Fft *fft, LC3_INT length ); +void fft_free( Fft *fft ); +void real_fft_free( Fft *fft ); +void fft_apply( Fft *fft, const Complex *input, Complex *output ); /* dct.c */ -void dct2_init(Dct2* dct, LC3_INT length); -void dct2_free(Dct2* dct); -void dct2_apply(Dct2* dct, const LC3_FLOAT* input, LC3_FLOAT* output); +void dct2_init( Dct2 *dct, LC3_INT length ); +void dct2_free( Dct2 *dct ); +void dct2_apply( Dct2 *dct, const LC3_FLOAT *input, LC3_FLOAT *output ); -void dct3_init(Dct3* dct, LC3_INT length); -void dct3_free(Dct3* dct); -void dct3_apply(Dct3* dct, const LC3_FLOAT* input, LC3_FLOAT* output); +void dct3_init( Dct3 *dct, LC3_INT length ); +void dct3_free( Dct3 *dct ); +void dct3_apply( Dct3 *dct, const LC3_FLOAT *input, LC3_FLOAT *output ); -void dct4_init(Dct4* dct, LC3_INT length); -void dct4_free(Dct4* dct); -void dct4_apply(Dct4* dct, const LC3_FLOAT* input, LC3_FLOAT* output); +void dct4_init( Dct4 *dct, LC3_INT length ); +void dct4_free( Dct4 *dct ); +void dct4_apply( Dct4 *dct, const LC3_FLOAT *input, LC3_FLOAT *output ); /* mdct.c */ -void mdct_init(Mdct* mdct, LC3_INT length, LC3_INT frame_dms, LC3_INT fs_idx, LC3_INT hrmode); -void mdct_free(Mdct* mdct); -void mdct_apply(const LC3_FLOAT* input, LC3_FLOAT* output, Mdct* mdct); +void mdct_init( Mdct *mdct, LC3_INT length, LC3_INT frame_dms, LC3_INT fs_idx, LC3_INT hrmode ); +void mdct_free( Mdct *mdct ); +void mdct_apply( const LC3_FLOAT *input, LC3_FLOAT *output, Mdct *mdct ); #ifdef ENABLE_PADDING -LC3_INT paddingDec_fl(LC3_UINT8* bytes, LC3_INT nbbits, LC3_INT L_spec, LC3_INT bw_cutoff_bits, LC3_INT ep_enabled, LC3_INT* total_padding, LC3_INT *np_zero); +LC3_INT paddingDec_fl( LC3_UINT8 *bytes, LC3_INT nbbits, LC3_INT L_spec, LC3_INT bw_cutoff_bits, LC3_INT ep_enabled, LC3_INT *total_padding, LC3_INT *np_zero ); #endif -void processEncoderEntropy_fl(LC3_UINT8* bytes, LC3_INT* bp_side, LC3_INT* mask_side, LC3_INT numbytes, LC3_INT bw_cutoff_bits, - LC3_INT bw_cutoff_idx, LC3_INT lastnz, LC3_INT N, LC3_INT lsbMode, LC3_INT gg_idx, LC3_INT num_tns_filters, - LC3_INT* tns_order, LC3_INT* ltpf_idx, LC3_INT* scf_idx, LC3_INT fac_ns_idx - , LC3_INT bfi_ext, LC3_INT fs_idx - ); -void processDecoderEntropy_fl(LC3_UINT8* bytes, LC3_INT numbytes, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT N, LC3_INT fs_idx, - LC3_INT bw_cutoff_bits, LC3_INT* bfi, LC3_INT* gg_idx, LC3_INT* scf_idx, LC3_INT* fac_ns_idx, - LC3_INT* tns_numfilters, LC3_INT* tns_order, LC3_INT* ltpf_idx, LC3_INT* bw_cutoff_idx, LC3_INT* lastnz, - LC3_INT* lsbMode, LC3_INT frame_dms - ); -void processQuantizeSpec_fl(LC3_FLOAT x[], LC3_FLOAT gain, LC3_INT xq[], LC3_INT nt, LC3_INT totalBits, LC3_INT* nbits, LC3_INT* nbits2, LC3_INT fs, - LC3_INT* lastnzout, LC3_INT* codingdata, LC3_INT* lsbMode, LC3_INT mode, LC3_INT target, LC3_INT hrmode); - -void processEstimateGlobalGain_fl(LC3_FLOAT x[], LC3_INT lg, LC3_INT nbitsSQ, LC3_FLOAT* gain, LC3_INT* quantizedGain, - LC3_INT* quantizedGainMin, LC3_INT quantizedGainOff, LC3_FLOAT* targetBitsOff, - LC3_INT* old_targetBits, LC3_INT old_specBits, LC3_INT bq_mode - , LC3_INT regBits, LC3_FLOAT frame_ms -); +void processEncoderEntropy_fl( LC3_UINT8 *bytes, LC3_INT *bp_side, LC3_INT *mask_side, LC3_INT numbytes, LC3_INT bw_cutoff_bits, LC3_INT bw_cutoff_idx, LC3_INT lastnz, LC3_INT N, LC3_INT lsbMode, LC3_INT gg_idx, LC3_INT num_tns_filters, LC3_INT *tns_order, LC3_INT *ltpf_idx, LC3_INT *scf_idx, LC3_INT fac_ns_idx, LC3_INT bfi_ext, LC3_INT fs_idx ); +void processDecoderEntropy_fl( LC3_UINT8 *bytes, LC3_INT numbytes, LC3_INT *mask_side, LC3_INT *bp_side, LC3_INT N, LC3_INT fs_idx, LC3_INT bw_cutoff_bits, LC3_INT *bfi, LC3_INT *gg_idx, LC3_INT *scf_idx, LC3_INT *fac_ns_idx, LC3_INT *tns_numfilters, LC3_INT *tns_order, LC3_INT *ltpf_idx, LC3_INT *bw_cutoff_idx, LC3_INT *lastnz, LC3_INT *lsbMode, LC3_INT frame_dms ); +void processQuantizeSpec_fl( LC3_FLOAT x[], LC3_FLOAT gain, LC3_INT xq[], LC3_INT nt, LC3_INT totalBits, LC3_INT *nbits, LC3_INT *nbits2, LC3_INT fs, LC3_INT *lastnzout, LC3_INT *codingdata, LC3_INT *lsbMode, LC3_INT mode, LC3_INT target, LC3_INT hrmode ); -void processAriDecoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side, LC3_INT L_spec, LC3_INT fs_idx, LC3_INT enable_lpc_weighting, - LC3_INT tns_numfilters, LC3_INT lsbMode, LC3_INT lastnz, LC3_INT* bfi, LC3_INT* tns_order, LC3_INT fac_ns_idx, - LC3_INT gg_idx, uint8_t* resBits, LC3_INT* x, LC3_INT* nf_seed, LC3_INT* tns_idx, LC3_INT* zero_frame, LC3_INT numbytes, - LC3_INT* nbits_residual, LC3_INT* residualPresent, LC3_INT frame_dms, - LC3_INT32 n_pc, LC3_INT32 be_bp_left, LC3_INT32 be_bp_right, LC3_INT32 enc, LC3_INT32 *b_left, LC3_INT32 *spec_inv_idx, - LC3_INT hrmode - ); +void processEstimateGlobalGain_fl( LC3_FLOAT x[], LC3_INT lg, LC3_INT nbitsSQ, LC3_FLOAT *gain, LC3_INT *quantizedGain, LC3_INT *quantizedGainMin, LC3_INT quantizedGainOff, LC3_FLOAT *targetBitsOff, LC3_INT *old_targetBits, LC3_INT old_specBits, LC3_INT bq_mode, LC3_INT regBits, LC3_FLOAT frame_ms ); -void processMdctShaping_fl(LC3_FLOAT x[], LC3_FLOAT gains[], const LC3_INT bands_offset[], LC3_INT fdns_npts); +void processAriDecoder_fl( LC3_UINT8 *bytes, LC3_INT bp_side, LC3_INT mask_side, LC3_INT L_spec, LC3_INT fs_idx, LC3_INT enable_lpc_weighting, LC3_INT tns_numfilters, LC3_INT lsbMode, LC3_INT lastnz, LC3_INT *bfi, LC3_INT *tns_order, LC3_INT fac_ns_idx, LC3_INT gg_idx, uint8_t *resBits, LC3_INT *x, LC3_INT *nf_seed, LC3_INT *tns_idx, LC3_INT *zero_frame, LC3_INT numbytes, LC3_INT *nbits_residual, LC3_INT *residualPresent, LC3_INT frame_dms, LC3_INT32 n_pc, LC3_INT32 be_bp_left, LC3_INT32 be_bp_right, LC3_INT32 enc, LC3_INT32 *b_left, LC3_INT32 *spec_inv_idx, LC3_INT hrmode ); -void processResidualCoding_fl(LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gain, LC3_INT L_spec, LC3_INT targetBits, LC3_INT nBits, uint8_t * resBits, - LC3_INT* numResBits - , LC3_INT hrmode -); +void processMdctShaping_fl( LC3_FLOAT x[], LC3_FLOAT gains[], const LC3_INT bands_offset[], LC3_INT fdns_npts ); -void processResidualDecoding_fl(LC3_INT* bitsRead, LC3_FLOAT x[], LC3_INT L_spec, uint8_t prm[], LC3_INT resQBits - , LC3_INT hrmode -); +void processResidualCoding_fl( LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gain, LC3_INT L_spec, LC3_INT targetBits, LC3_INT nBits, uint8_t *resBits, LC3_INT *numResBits, LC3_INT hrmode ); -void processAdjustGlobalGain_fl(LC3_INT* gg_idx, LC3_INT gg_idx_min, LC3_INT gg_idx_off, LC3_FLOAT* gain, LC3_INT target, LC3_INT nBits, - LC3_INT* gainChange, LC3_INT fs_idx - , LC3_INT16 hrmode, LC3_INT16 frame_dms - ); +void processResidualDecoding_fl( LC3_INT *bitsRead, LC3_FLOAT x[], LC3_INT L_spec, uint8_t prm[], LC3_INT resQBits, LC3_INT hrmode ); -void processApplyGlobalGain_fl(LC3_FLOAT x[], LC3_INT xLen, LC3_INT global_gain_idx, LC3_INT global_gain_off); +void processAdjustGlobalGain_fl( LC3_INT *gg_idx, LC3_INT gg_idx_min, LC3_INT gg_idx_off, LC3_FLOAT *gain, LC3_INT target, LC3_INT nBits, LC3_INT *gainChange, LC3_INT fs_idx, LC3_INT16 hrmode, LC3_INT16 frame_dms ); -void processNoiseFactor_fl(LC3_INT* fac_ns_idx, LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gg, LC3_INT BW_cutoff_idx, LC3_INT frame_dms, - LC3_INT target_bytes - ); +void processApplyGlobalGain_fl( LC3_FLOAT x[], LC3_INT xLen, LC3_INT global_gain_idx, LC3_INT global_gain_off ); -void processNoiseFilling_fl(LC3_FLOAT xq[], LC3_INT nfseed, LC3_INT fac_ns_idx, LC3_INT bw_stopband, LC3_INT frame_dms, LC3_FLOAT fac_ns_pc, LC3_INT spec_inv_idx); +void processNoiseFactor_fl( LC3_INT *fac_ns_idx, LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gg, LC3_INT BW_cutoff_idx, LC3_INT frame_dms, LC3_INT target_bytes ); -void processOlpa_fl(LC3_FLOAT* s_12k8, LC3_FLOAT* mem_s12k8, LC3_FLOAT* mem_s6k4, LC3_INT* mem_old_T0, LC3_INT* T0_out, - LC3_FLOAT* normcorr_out, LC3_INT len, LC3_INT frame_dms); +void processNoiseFilling_fl( LC3_FLOAT xq[], LC3_INT nfseed, LC3_INT fac_ns_idx, LC3_INT bw_stopband, LC3_INT frame_dms, LC3_FLOAT fac_ns_pc, LC3_INT spec_inv_idx ); -void processTnsCoder_fl(LC3_FLOAT* x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, LC3_INT fs, LC3_INT N, LC3_INT frame_dms, LC3_INT nBits, - LC3_INT* order_out, LC3_INT* rc_idx, LC3_INT* tns_numfilters, LC3_INT* bits_out - , LC3_INT16 near_nyquist_flag - ); -void levinsonDurbin(LC3_FLOAT* r, LC3_FLOAT* out_lev, LC3_FLOAT* rc_unq, LC3_FLOAT* error, LC3_INT len); +void processOlpa_fl( LC3_FLOAT *s_12k8, LC3_FLOAT *mem_s12k8, LC3_FLOAT *mem_s6k4, LC3_INT *mem_old_T0, LC3_INT *T0_out, LC3_FLOAT *normcorr_out, LC3_INT len, LC3_INT frame_dms ); -void processTnsDecoder_fl(LC3_FLOAT* x, LC3_INT* rc_idx, LC3_INT* order, LC3_INT numfilters, LC3_INT bw_fcbin, LC3_INT N, LC3_INT fs); +void processTnsCoder_fl( LC3_FLOAT *x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, LC3_INT fs, LC3_INT N, LC3_INT frame_dms, LC3_INT nBits, LC3_INT *order_out, LC3_INT *rc_idx, LC3_INT *tns_numfilters, LC3_INT *bits_out, LC3_INT16 near_nyquist_flag ); +void levinsonDurbin( LC3_FLOAT *r, LC3_FLOAT *out_lev, LC3_FLOAT *rc_unq, LC3_FLOAT *error, LC3_INT len ); -void processSnsComputeScf_fl(LC3_FLOAT* x, LC3_INT tilt, LC3_INT xLen, LC3_FLOAT* gains, LC3_INT smooth, LC3_FLOAT sns_damping, LC3_FLOAT attdec_damping_factor); +void processTnsDecoder_fl( LC3_FLOAT *x, LC3_INT *rc_idx, LC3_INT *order, LC3_INT numfilters, LC3_INT bw_fcbin, LC3_INT N, LC3_INT fs ); -void processSnsInterpolateScf_fl(LC3_FLOAT* gains, LC3_INT encoder_side, LC3_INT bands_number, LC3_FLOAT* gains_LC3_INT); +void processSnsComputeScf_fl( LC3_FLOAT *x, LC3_INT tilt, LC3_INT xLen, LC3_FLOAT *gains, LC3_INT smooth, LC3_FLOAT sns_damping, LC3_FLOAT attdec_damping_factor ); -void processDetectCutoffWarped_fl(LC3_FLOAT* d2, LC3_INT fs_idx, LC3_INT frame_dms, LC3_INT* bw_idx); -void processNearNyquistdetector_fl(LC3_INT16* near_nyquist_flag, const LC3_INT fs_idx, const LC3_INT near_nyquist_index, - const LC3_INT bands_number, const LC3_FLOAT* ener); +void processSnsInterpolateScf_fl( LC3_FLOAT *gains, LC3_INT encoder_side, LC3_INT bands_number, LC3_FLOAT *gains_LC3_INT ); -void processPerBandEnergy_fl(LC3_INT bands_number, const LC3_INT* acc_coeff_per_band, LC3_INT16 hrmode, LC3_INT16 frame_dms, LC3_FLOAT* d2, LC3_FLOAT* d); +void processDetectCutoffWarped_fl( LC3_FLOAT *d2, LC3_INT fs_idx, LC3_INT frame_dms, LC3_INT *bw_idx ); +void processNearNyquistdetector_fl( LC3_INT16 *near_nyquist_flag, const LC3_INT fs_idx, const LC3_INT near_nyquist_index, const LC3_INT bands_number, const LC3_FLOAT *ener ); -void ProcessingIMDCT_fl(LC3_FLOAT* y, LC3_INT yLen, const LC3_FLOAT* win, LC3_INT winLen, LC3_INT last_zeros, LC3_FLOAT* mem, LC3_FLOAT* x, - Dct4* dct); +void processPerBandEnergy_fl( LC3_INT bands_number, const LC3_INT *acc_coeff_per_band, LC3_INT16 hrmode, LC3_INT16 frame_dms, LC3_FLOAT *d2, LC3_FLOAT *d ); -void ProcessingITDA_WIN_OLA_fl(LC3_FLOAT* x_tda, LC3_INT32 yLen, const LC3_FLOAT* win, LC3_INT32 winLen, LC3_INT32 last_zeros, LC3_FLOAT* mem, LC3_FLOAT* x); +void ProcessingIMDCT_fl( LC3_FLOAT *y, LC3_INT yLen, const LC3_FLOAT *win, LC3_INT winLen, LC3_INT last_zeros, LC3_FLOAT *mem, LC3_FLOAT *x, Dct4 *dct ); -void process_ltpf_coder_fl(LC3_FLOAT* xin, LC3_INT xLen, LC3_INT ltpf_enable, LC3_INT pitch_ol, LC3_FLOAT pitch_ol_norm_corr, LC3_INT frame_dms, - LC3_FLOAT* mem_old_x, LC3_INT memLen, LC3_FLOAT* mem_norm_corr_past, LC3_INT* mem_on, LC3_FLOAT* mem_pitch, - LC3_INT* param, LC3_FLOAT* mem_norm_corr_past_past, LC3_INT* bits); +void ProcessingITDA_WIN_OLA_fl( LC3_FLOAT *x_tda, LC3_INT32 yLen, const LC3_FLOAT *win, LC3_INT32 winLen, LC3_INT32 last_zeros, LC3_FLOAT *mem, LC3_FLOAT *x ); -void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT fs, LC3_FLOAT* mem_old_x, LC3_FLOAT* mem_old_y, - LC3_INT* mem_pitch_LC3_INT, LC3_INT* mem_pitch_fr, LC3_FLOAT* mem_gain, LC3_INT* mem_beta_idx, LC3_INT bfi, - LC3_INT* param, LC3_INT* mem_param, LC3_INT conf_beta_idx, LC3_FLOAT conf_beta, LC3_INT concealMethod, LC3_FLOAT damping - , LC3_INT *mem_ltpf_active -); +void process_ltpf_coder_fl( LC3_FLOAT *xin, LC3_INT xLen, LC3_INT ltpf_enable, LC3_INT pitch_ol, LC3_FLOAT pitch_ol_norm_corr, LC3_INT frame_dms, LC3_FLOAT *mem_old_x, LC3_INT memLen, LC3_FLOAT *mem_norm_corr_past, LC3_INT *mem_on, LC3_FLOAT *mem_pitch, LC3_INT *param, LC3_FLOAT *mem_norm_corr_past_past, LC3_INT *bits ); + +void process_ltpf_decoder_fl( LC3_FLOAT *x, LC3_INT xLen, LC3_FLOAT *y, LC3_INT fs, LC3_FLOAT *mem_old_x, LC3_FLOAT *mem_old_y, LC3_INT *mem_pitch_LC3_INT, LC3_INT *mem_pitch_fr, LC3_FLOAT *mem_gain, LC3_INT *mem_beta_idx, LC3_INT bfi, LC3_INT *param, LC3_INT *mem_param, LC3_INT conf_beta_idx, LC3_FLOAT conf_beta, LC3_INT concealMethod, LC3_FLOAT damping, LC3_INT *mem_ltpf_active ); -void process_resamp12k8_fl(LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC3_INT mem_in_len, LC3_FLOAT mem_50[], LC3_FLOAT mem_out[], - LC3_INT mem_out_len, LC3_FLOAT y[], LC3_INT* y_len, LC3_INT fs_idx, LC3_INT frame_dms, LC3_INT fs); +void process_resamp12k8_fl( LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC3_INT mem_in_len, LC3_FLOAT mem_50[], LC3_FLOAT mem_out[], LC3_INT mem_out_len, LC3_FLOAT y[], LC3_INT *y_len, LC3_INT fs_idx, LC3_INT frame_dms, LC3_INT fs ); -void write_bit_backward_fl(LC3_UINT8* ptr, LC3_INT* bp_side, LC3_INT* mask_side, LC3_INT bit); -void write_uint_backward_fl(LC3_UINT8* ptr, LC3_INT* bp_side, LC3_INT* mask_side, LC3_INT val, LC3_INT numbits); +void write_bit_backward_fl( LC3_UINT8 *ptr, LC3_INT *bp_side, LC3_INT *mask_side, LC3_INT bit ); +void write_uint_backward_fl( LC3_UINT8 *ptr, LC3_INT *bp_side, LC3_INT *mask_side, LC3_INT val, LC3_INT numbits ); -void processAriEncoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side, LC3_INT* x, LC3_INT* tns_order, LC3_INT tns_numfilters, - LC3_INT* tns_idx, LC3_INT lastnz, - LC3_INT* codingdata, uint8_t* res_bits, LC3_INT resBitsLen, LC3_INT lsbMode, - LC3_INT nbbits, LC3_INT enable_lpc_weighting); +void processAriEncoder_fl( LC3_UINT8 *bytes, LC3_INT bp_side, LC3_INT mask_side, LC3_INT *x, LC3_INT *tns_order, LC3_INT tns_numfilters, LC3_INT *tns_idx, LC3_INT lastnz, LC3_INT *codingdata, uint8_t *res_bits, LC3_INT resBitsLen, LC3_INT lsbMode, LC3_INT nbbits, LC3_INT enable_lpc_weighting ); -void attack_detector_fl(LC3_FLOAT* in, LC3_INT frame_size, LC3_INT fs, LC3_INT* lastAttackPosition, LC3_FLOAT* accNrg, LC3_INT* attackFlag, - LC3_FLOAT* attdec_filter_mem, LC3_INT attackHandlingOn, LC3_INT attdec_nblocks, LC3_INT attdec_hangover_threshold); +void attack_detector_fl( LC3_FLOAT *in, LC3_INT frame_size, LC3_INT fs, LC3_INT *lastAttackPosition, LC3_FLOAT *accNrg, LC3_INT *attackFlag, LC3_FLOAT *attdec_filter_mem, LC3_INT attackHandlingOn, LC3_INT attdec_nblocks, LC3_INT attdec_hangover_threshold ); -void process_snsQuantizesScf_Enc(LC3_FLOAT* env, LC3_INT* index, LC3_FLOAT* envq, Dct2 dct2structSNS); +void process_snsQuantizesScf_Enc( LC3_FLOAT *env, LC3_INT *index, LC3_FLOAT *envq, Dct2 dct2structSNS ); -void process_snsQuantizesScf_Dec(LC3_INT* scf_idx, LC3_FLOAT* scf_q); +void process_snsQuantizesScf_Dec( LC3_INT *scf_idx, LC3_FLOAT *scf_q ); -void processMdct_fl(LC3_FLOAT* in, LC3_FLOAT* out, Mdct* mdctStruct); +void processMdct_fl( LC3_FLOAT *in, LC3_FLOAT *out, Mdct *mdctStruct ); -int alloc_encoder(LC3PLUS_Enc* encoder, int channels); -void set_enc_frame_params(LC3PLUS_Enc* encoder); -LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate); +int alloc_encoder( LC3PLUS_Enc *encoder, int channels ); +void set_enc_frame_params( LC3PLUS_Enc *encoder ); +LC3PLUS_Error update_enc_bitrate( LC3PLUS_Enc *encoder, int bitrate ); -LC3PLUS_Error FillEncSetup(LC3PLUS_Enc* encoder, int samplerate, int channels, int hrmode, int32_t lfe_channel_array[]); +LC3PLUS_Error FillEncSetup( LC3PLUS_Enc *encoder, int samplerate, int channels, int hrmode, int32_t lfe_channel_array[] ); /* Setup Functions */ -int alloc_decoder(LC3PLUS_Dec* decoder, int samplerate, int channels); -void set_dec_frame_params(LC3PLUS_Dec* decoder); -LC3PLUS_Error update_dec_bitrate(LC3PLUS_Dec* decoder, int ch, int nBytes); +int alloc_decoder( LC3PLUS_Dec *decoder, int samplerate, int channels ); +void set_dec_frame_params( LC3PLUS_Dec *decoder ); +LC3PLUS_Error update_dec_bitrate( LC3PLUS_Dec *decoder, int ch, int nBytes ); -LC3PLUS_Error FillDecSetup(LC3PLUS_Dec* decoder, int samplerate, int channels, LC3PLUS_PlcMode plc_mode, int hrmode); +LC3PLUS_Error FillDecSetup( LC3PLUS_Dec *decoder, int samplerate, int channels, LC3PLUS_PlcMode plc_mode, int hrmode ); -int Enc_LC3PLUS_fl(LC3PLUS_Enc* encoder, void** input, LC3_UINT8* output, int bps -, LC3_INT32 bfi_ext -); -LC3PLUS_Error Dec_LC3PLUS_fl(LC3PLUS_Dec* decoder, LC3_UINT8* input, int input_bytes, void** output, int bps, int bfi_ext); +int Enc_LC3PLUS_fl( LC3PLUS_Enc *encoder, void **input, LC3_UINT8 *output, int bps, LC3_INT32 bfi_ext ); +LC3PLUS_Error Dec_LC3PLUS_fl( LC3PLUS_Dec *decoder, LC3_UINT8 *input, int input_bytes, void **output, int bps, int bfi_ext ); -void* balloc(void* base, size_t* base_size, size_t size); +void *balloc( void *base, size_t *base_size, size_t size ); -void processPlcMain_fl(LC3_FLOAT *q_d_fl_c, LC3_FLOAT *syntM_fl_c, LC3PLUS_Dec* decoder, DecSetup* h_DecSetup, LC3_INT bfi, - PlcAdvSetup *PlcAdvSetup, PlcSetup *PlcSetup, LC3_INT plcMeth, LC3_INT ltpf_pitch_int, LC3_INT ltpf_pitch_fr, - LC3_INT tilt, const LC3_INT *bands_offset, LC3_INT bands_number, const LC3_INT *bands_offsetPLC, - LC3_INT n_bandsPLC, LC3_INT16 hrmode, pcState *statePC); +void processPlcMain_fl( LC3_FLOAT *q_d_fl_c, LC3_FLOAT *syntM_fl_c, LC3PLUS_Dec *decoder, DecSetup *h_DecSetup, LC3_INT bfi, PlcAdvSetup *PlcAdvSetup, PlcSetup *PlcSetup, LC3_INT plcMeth, LC3_INT ltpf_pitch_int, LC3_INT ltpf_pitch_fr, LC3_INT tilt, const LC3_INT *bands_offset, LC3_INT bands_number, const LC3_INT *bands_offsetPLC, LC3_INT n_bandsPLC, LC3_INT16 hrmode, pcState *statePC ); -void processPlcUpdate_fl(PlcAdvSetup *PlcAdvSetup, LC3_INT32 frame_length, LC3_FLOAT *syntM, LC3_FLOAT *scf_q, - LC3_INT32 *nbLostCmpt, LC3_FLOAT *cum_alpha, LC3_INT32 bfi, LC3_INT32 *prevBfi, LC3_INT32 *prevprevBfi); +void processPlcUpdate_fl( PlcAdvSetup *PlcAdvSetup, LC3_INT32 frame_length, LC3_FLOAT *syntM, LC3_FLOAT *scf_q, LC3_INT32 *nbLostCmpt, LC3_FLOAT *cum_alpha, LC3_INT32 bfi, LC3_INT32 *prevBfi, LC3_INT32 *prevprevBfi ); -void processPlcUpdateSpec_fl(LC3_FLOAT *q_d_prev, LC3_FLOAT *q_d_fl_c, LC3_INT yLen); +void processPlcUpdateSpec_fl( LC3_FLOAT *q_d_prev, LC3_FLOAT *q_d_fl_c, LC3_INT yLen ); -void processNoiseSubstitution_fl(LC3_FLOAT* spec, LC3_FLOAT* spec_prev, LC3_INT32 yLen); +void processNoiseSubstitution_fl( LC3_FLOAT *spec, LC3_FLOAT *spec_prev, LC3_INT32 yLen ); -void process_cutoff_bandwidth(LC3_FLOAT* d_fl, LC3_INT len, LC3_INT bw_bin); -void update_enc_bandwidth(LC3PLUS_Enc* encoder, LC3_INT bandwidth); +void process_cutoff_bandwidth( LC3_FLOAT *d_fl, LC3_INT len, LC3_INT bw_bin ); +void update_enc_bandwidth( LC3PLUS_Enc *encoder, LC3_INT bandwidth ); /* al_fec.c */ -LC3_INT16 fec_get_n_pccw(LC3_INT16 slot_bytes, LC3_INT16 fec_mode, LC3_INT16 ccc_flag); -LC3_INT16 fec_get_data_size(LC3_INT16 fec_mode, LC3_INT16 ccc_flag, LC3_INT16 slot_bytes); -LC3_INT16 fec_get_n_pc(LC3_INT16 fec_mode, LC3_INT16 n_pccw, LC3_INT16 slot_bytes); -void processReorderBitstream_fl(LC3_UINT8* bytes, LC3_INT32 n_pccw, LC3_INT32 n_pc, LC3_INT32 b_left, LC3_INT32 len); -void fec_encoder(LC3_INT16 mode, LC3_INT16 epmr, LC3_UINT8 *iobuf, LC3_INT16 data_bytes, LC3_INT16 slot_bytes, LC3_INT16 n_pccw); -LC3_INT32 fec_decoder(LC3_UINT8 *iobuf, LC3_INT16 slot_bytes, LC3_INT32 *data_bytes, LC3PLUS_EpModeRequest *epmr, LC3_INT16 ccc_flag, LC3_INT16 *n_pccw, LC3_INT32 *bfi, - LC3_INT16 *be_bp_left, LC3_INT16 *be_bp_right, LC3_INT16 *n_pc, LC3_INT16 *m_fec); - -LC3_FLOAT array_max_abs(LC3_FLOAT *in, LC3_INT32 len); - -void processPcClassify_fl(LC3_INT32 pitch_present, LC3_INT32 frame_dms, LC3_FLOAT *q_d_prev, LC3_FLOAT *q_old_res, LC3_INT32 yLen, LC3_INT32 spec_inv_idx, LC3_FLOAT stab_fac, LC3_INT32 *bfi); -void processPcMain_fl(LC3_INT32 *bfi, LC3PLUS_Dec* decoder, LC3_FLOAT *sqQdec, DecSetup* h_DecSetup, LC3_INT32 pitch_present, LC3_FLOAT stab_fac, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_INT32 fac_ns_idx, pcState *statePC, LC3_INT32 spec_inv_idx, LC3_INT32 yLen); -void processPcUpdate_fl(LC3_INT32 bfi, LC3_FLOAT *q_res, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_INT32 rframe, LC3_INT32 *BW_cutoff_idx_nf, LC3_INT32 *prev_BW_cutoff_idx_nf, LC3_INT32 fac_ns_idx, LC3_FLOAT *prev_fac_ns, LC3_FLOAT *fac, LC3_FLOAT *q_old_res, LC3_FLOAT *prev_gg, LC3_INT32 spec_inv_idx, LC3_INT32 yLen); -void processPcApply_fl(LC3_FLOAT *q_res, LC3_FLOAT *q_old_res, LC3_FLOAT *q_d_prev, LC3_INT32 spec_inv_idx, LC3_INT32 yLen, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_FLOAT *prev_gg, LC3_FLOAT *fac, LC3_INT32 *pc_nbLostCmpt); - -void processPlcClassify_fl(LC3_INT plcMeth, LC3_INT *concealMethod, LC3_INT32 *nbLostCmpt, LC3_INT32 bfi, - LC3_FLOAT *xcorr, LC3_INT32 framelength, LC3_INT32 frame_dms, LC3_INT32 pitch_int, - LC3_INT32 fs, const LC3_INT *band_offsets, LC3_INT32 bands_number, LC3_INT32 tilt, PlcAdvSetup *plcAd - , LC3_INT32 hrmode +LC3_INT16 fec_get_n_pccw( LC3_INT16 slot_bytes, LC3_INT16 fec_mode, LC3_INT16 ccc_flag ); +LC3_INT16 fec_get_data_size( LC3_INT16 fec_mode, LC3_INT16 ccc_flag, LC3_INT16 slot_bytes ); +LC3_INT16 fec_get_n_pc( LC3_INT16 fec_mode, LC3_INT16 n_pccw, LC3_INT16 slot_bytes ); +void processReorderBitstream_fl( LC3_UINT8 *bytes, LC3_INT32 n_pccw, LC3_INT32 n_pc, LC3_INT32 b_left, LC3_INT32 len ); +void fec_encoder( LC3_INT16 mode, LC3_INT16 epmr, LC3_UINT8 *iobuf, LC3_INT16 data_bytes, LC3_INT16 slot_bytes, LC3_INT16 n_pccw ); +LC3_INT32 fec_decoder( LC3_UINT8 *iobuf, LC3_INT16 slot_bytes, LC3_INT32 *data_bytes, LC3PLUS_EpModeRequest *epmr, LC3_INT16 ccc_flag, LC3_INT16 *n_pccw, LC3_INT32 *bfi, LC3_INT16 *be_bp_left, LC3_INT16 *be_bp_right, LC3_INT16 *n_pc, LC3_INT16 *m_fec ); + +LC3_FLOAT array_max_abs( LC3_FLOAT *in, LC3_INT32 len ); + +void processPcClassify_fl( LC3_INT32 pitch_present, LC3_INT32 frame_dms, LC3_FLOAT *q_d_prev, LC3_FLOAT *q_old_res, LC3_INT32 yLen, LC3_INT32 spec_inv_idx, LC3_FLOAT stab_fac, LC3_INT32 *bfi ); +void processPcMain_fl( LC3_INT32 *bfi, LC3PLUS_Dec *decoder, LC3_FLOAT *sqQdec, DecSetup *h_DecSetup, LC3_INT32 pitch_present, LC3_FLOAT stab_fac, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_INT32 fac_ns_idx, pcState *statePC, LC3_INT32 spec_inv_idx, LC3_INT32 yLen ); +void processPcUpdate_fl( LC3_INT32 bfi, LC3_FLOAT *q_res, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_INT32 rframe, LC3_INT32 *BW_cutoff_idx_nf, LC3_INT32 *prev_BW_cutoff_idx_nf, LC3_INT32 fac_ns_idx, LC3_FLOAT *prev_fac_ns, LC3_FLOAT *fac, LC3_FLOAT *q_old_res, LC3_FLOAT *prev_gg, LC3_INT32 spec_inv_idx, LC3_INT32 yLen ); +void processPcApply_fl( LC3_FLOAT *q_res, LC3_FLOAT *q_old_res, LC3_FLOAT *q_d_prev, LC3_INT32 spec_inv_idx, LC3_INT32 yLen, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_FLOAT *prev_gg, LC3_FLOAT *fac, LC3_INT32 *pc_nbLostCmpt ); + +void processPlcClassify_fl( LC3_INT plcMeth, LC3_INT *concealMethod, LC3_INT32 *nbLostCmpt, LC3_INT32 bfi, LC3_FLOAT *xcorr, LC3_INT32 framelength, LC3_INT32 frame_dms, LC3_INT32 pitch_int, LC3_INT32 fs, const LC3_INT *band_offsets, LC3_INT32 bands_number, LC3_INT32 tilt, PlcAdvSetup *plcAd, LC3_INT32 hrmode ); +void processPlcComputeStabFacMain_fl( LC3_FLOAT *scf_q, LC3_FLOAT *old_scf_q, LC3_FLOAT *old_old_scf_q, LC3_INT32 bfi, LC3_INT32 prev_bfi, LC3_INT32 prev_prev_bfi, LC3_FLOAT *stab_fac ); + +void processPlcDampingScramblingMain_fl( LC3_INT32 *ns_seed, + LC3_INT32 *pc_seed, + LC3_INT32 ns_nbLostCmpt_pc, + LC3_INT32 ns_nbLostCmpt, + LC3_FLOAT *stabFac, + LC3_FLOAT *cum_fading_slow, + LC3_FLOAT *cum_fading_fast, + LC3_FLOAT *spec_prev, + LC3_FLOAT *spec, + LC3_INT32 spec_inv_idx, + LC3_INT32 yLen, + LC3_INT32 bfi, + LC3_INT32 frame_dms, + LC3_INT32 concealMethod, + LC3_INT32 pitch_present_bfi1, + LC3_INT32 pitch_present_bfi2, + LC3_FLOAT *cum_fflcAtten ); +void processPlcDampingScrambling_fl( LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 nbLostCmpt, LC3_FLOAT *stabFac, LC3_INT32 processDampScramb, LC3_FLOAT *cum_fflcAtten, LC3_INT32 pitch_present, LC3_INT32 frame_dms, LC3_FLOAT *cum_fading_slow, LC3_FLOAT *cum_fading_fast, LC3_INT32 *seed, LC3_INT32 spec_inv_idx ); + +void plc_phEcu_F0_refine_first( LC3_INT32 *plocs, LC3_INT32 n_plocs, LC3_FLOAT *f0est, const LC3_INT32 Xabs_len, LC3_FLOAT *f0binPtr, LC3_FLOAT *f0gainPtr, const LC3_INT32 nSubm ); +void processTdcLpcEstimation_fl( LC3_FLOAT *r, LC3_INT32 fs_idx, LC3_INT32 len, LC3_FLOAT *A, LC3_INT32 frame_dms ); + +LC3_FLOAT plc_phEcuSetF0Hz( LC3_INT32 fs, LC3_FLOAT *old_pitchPtr ); + +void plc_phEcu_processPLCspec2shape( LC3_INT16 prev_bfi, LC3_INT16 bfi, LC3_FLOAT q_d[], LC3_INT32 yLen, LC3_FLOAT *stPhECU_oold_grp_shape, LC3_FLOAT *stPhECU_old_grp_shape ); +void plc_phEcu_LF_peak_analysis( LC3_INT32 *plocs, LC3_INT32 *n_plocs, LC3_FLOAT *f0est, const LC3_FLOAT *Xabs, LC3_FLOAT *f0binPtr, LC3_FLOAT *f0gainPtr, const LC3_INT32 nSubm ); + +void plc_phEcu_F0_refine_first( LC3_INT32 *plocs, LC3_INT32 n_plocs, LC3_FLOAT *f0est, const LC3_INT32 Xabs_len, LC3_FLOAT *f0binPtr, LC3_FLOAT *f0gainPtr, const LC3_INT32 nSubm ); + +LC3_FLOAT plc_phEcu_imax2_jacobsen_mag( const Complex *y, LC3_FLOAT *c_jacobPtr ); +LC3_FLOAT plc_phEcu_interp_max( const LC3_FLOAT *y, LC3_INT32 y_len ); +void plc_phEcu_fft_spec2_sqrt_approx( const Complex *x, LC3_INT32 x_len, LC3_FLOAT *x_abs ); +LC3_INT32 plc_phEcu_pitch_in_plocs( LC3_INT32 *plocs, LC3_INT32 n_plocs ); +void plc_phEcu_spec_ana( LC3_FLOAT *xfp, LC3_INT32 xfp_len, const LC3_FLOAT *whr, LC3_FLOAT *pfind_sensPtr, LC3_INT32 *plocs, LC3_INT32 *n_plocs, LC3_FLOAT *f0est, Complex *x, LC3_INT32 *x_len, LC3_FLOAT *f0hzLtpBinPtr, LC3_FLOAT *f0gainLtpPtr, LC3_INT32 bw_idx, Fft *PhEcu_Fft ); +void plc_phEcu_subst_spec( LC3_INT32 *plocs, LC3_INT32 n_plocs, LC3_FLOAT *f0est, LC3_INT32 time_offs, Complex *X, LC3_INT32 X_len, LC3_FLOAT *mag_chg_gr, LC3_INT32 *seed, LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *Xavg, LC3_INT32 t_adv_in, LC3_INT32 Lprot, LC3_INT32 delta_corr, LC3_FLOAT *corr_phase_dbg, LC3_FLOAT *X_i_new_re_dbg, LC3_FLOAT *X_i_new_im_dbg ); +void plc_phEcu_rec_frame( Complex *X_in, LC3_INT32 xfp_len, LC3_INT32 Lecu, const LC3_FLOAT *whr, const LC3_FLOAT *winMDCT, LC3_INT32 Lprot, LC3_FLOAT *xfp, LC3_INT32 time_offs, LC3_FLOAT *x_out, Complex *full_spec_dbg, LC3_FLOAT *ifft_out_dbg, LC3_FLOAT *xsubst_dbg, LC3_INT32 LA_ZEROS, LC3_INT32 LA, Fft *PhEcu_Ifft + ); -void processPlcComputeStabFacMain_fl(LC3_FLOAT *scf_q, LC3_FLOAT *old_scf_q, LC3_FLOAT *old_old_scf_q, LC3_INT32 bfi, LC3_INT32 prev_bfi, LC3_INT32 prev_prev_bfi, LC3_FLOAT *stab_fac); - -void processPlcDampingScramblingMain_fl(LC3_INT32 *ns_seed, - LC3_INT32 *pc_seed, LC3_INT32 ns_nbLostCmpt_pc, - LC3_INT32 ns_nbLostCmpt, LC3_FLOAT *stabFac, LC3_FLOAT *cum_fading_slow, LC3_FLOAT *cum_fading_fast, - LC3_FLOAT *spec_prev, LC3_FLOAT *spec, LC3_INT32 spec_inv_idx, LC3_INT32 yLen, LC3_INT32 bfi, - LC3_INT32 frame_dms, LC3_INT32 concealMethod, LC3_INT32 pitch_present_bfi1, LC3_INT32 pitch_present_bfi2, - LC3_FLOAT *cum_fflcAtten); -void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 nbLostCmpt, LC3_FLOAT *stabFac, LC3_INT32 processDampScramb, - LC3_FLOAT *cum_fflcAtten, LC3_INT32 pitch_present, LC3_INT32 frame_dms, LC3_FLOAT *cum_fading_slow, - LC3_FLOAT *cum_fading_fast, LC3_INT32 *seed, LC3_INT32 spec_inv_idx); - -void plc_phEcu_F0_refine_first(LC3_INT32 *plocs, LC3_INT32 n_plocs, LC3_FLOAT *f0est, const LC3_INT32 Xabs_len, - LC3_FLOAT *f0binPtr, LC3_FLOAT *f0gainPtr, const LC3_INT32 nSubm); -void processTdcLpcEstimation_fl(LC3_FLOAT *r, LC3_INT32 fs_idx, LC3_INT32 len, LC3_FLOAT *A, LC3_INT32 frame_dms); - -LC3_FLOAT plc_phEcuSetF0Hz(LC3_INT32 fs, LC3_FLOAT *old_pitchPtr); - -void plc_phEcu_processPLCspec2shape(LC3_INT16 prev_bfi, LC3_INT16 bfi, LC3_FLOAT q_d[], LC3_INT32 yLen, LC3_FLOAT *stPhECU_oold_grp_shape, LC3_FLOAT *stPhECU_old_grp_shape); -void plc_phEcu_LF_peak_analysis(LC3_INT32 *plocs, LC3_INT32 *n_plocs, LC3_FLOAT *f0est, const LC3_FLOAT *Xabs, - LC3_FLOAT *f0binPtr, LC3_FLOAT *f0gainPtr, const LC3_INT32 nSubm); - -void plc_phEcu_F0_refine_first(LC3_INT32 *plocs, LC3_INT32 n_plocs, LC3_FLOAT *f0est, const LC3_INT32 Xabs_len, - LC3_FLOAT *f0binPtr, LC3_FLOAT *f0gainPtr, const LC3_INT32 nSubm); - -LC3_FLOAT plc_phEcu_imax2_jacobsen_mag(const Complex *y, LC3_FLOAT *c_jacobPtr); -LC3_FLOAT plc_phEcu_interp_max(const LC3_FLOAT *y, LC3_INT32 y_len); -void plc_phEcu_fft_spec2_sqrt_approx(const Complex* x, LC3_INT32 x_len, LC3_FLOAT* x_abs); -LC3_INT32 plc_phEcu_pitch_in_plocs(LC3_INT32* plocs, LC3_INT32 n_plocs); -void plc_phEcu_spec_ana(LC3_FLOAT* xfp, LC3_INT32 xfp_len, const LC3_FLOAT* whr, - LC3_FLOAT* pfind_sensPtr, LC3_INT32* plocs, - LC3_INT32* n_plocs, LC3_FLOAT* f0est, Complex* x, LC3_INT32* x_len, - LC3_FLOAT* f0hzLtpBinPtr, LC3_FLOAT* f0gainLtpPtr, LC3_INT32 bw_idx, Fft* PhEcu_Fft); -void plc_phEcu_subst_spec(LC3_INT32* plocs, LC3_INT32 n_plocs, LC3_FLOAT* f0est, LC3_INT32 time_offs, Complex* X, LC3_INT32 X_len, - LC3_FLOAT* mag_chg_gr, LC3_INT32 *seed, LC3_FLOAT* alpha, LC3_FLOAT* beta, LC3_FLOAT* Xavg, - LC3_INT32 t_adv_in, LC3_INT32 Lprot, LC3_INT32 delta_corr, LC3_FLOAT *corr_phase_dbg, - LC3_FLOAT *X_i_new_re_dbg, LC3_FLOAT *X_i_new_im_dbg); -void plc_phEcu_rec_frame(Complex *X_in, LC3_INT32 xfp_len, LC3_INT32 Lecu, const LC3_FLOAT *whr, const LC3_FLOAT *winMDCT, LC3_INT32 Lprot, - LC3_FLOAT *xfp, LC3_INT32 time_offs, LC3_FLOAT *x_out, - Complex *full_spec_dbg, LC3_FLOAT* ifft_out_dbg, LC3_FLOAT* xsubst_dbg, - LC3_INT32 LA_ZEROS, LC3_INT32 LA, Fft* PhEcu_Ifft - - ); -void plc_phEcu_tba_spect_Xavg(LC3_INT32 fs_idx, LC3_INT32 n_grp, LC3_FLOAT *oold_spec_shape, - LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_spec_shape, LC3_FLOAT *old_EwPtr, - LC3_FLOAT *gr_pow_left, LC3_FLOAT *gr_pow_right, LC3_FLOAT *Xavg); -void plc_phEcu_tba_per_band_gain(LC3_INT32 n_grp, LC3_FLOAT *gr_pow_left, LC3_FLOAT *gr_pow_right, LC3_FLOAT *trans, LC3_FLOAT *grp_pow_change); -void plc_phEcu_tba_trans_dect_gains(LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FLOAT *grp_pow_change, - LC3_FLOAT *stPhECU_beta_mute, LC3_FLOAT *stPhECU_mag_chg_1st, - LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *mag_chg, LC3_FLOAT *ph_dith, LC3_INT32 *tr_dec, - LC3_FLOAT *att_val, LC3_INT32 *attDegreeFrames, LC3_FLOAT *thresh_dbg); -void plc_phEcu_trans_burst_ana_sub(LC3_INT32 fs_idx, LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FLOAT *oold_spect_shape, - LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_spect_shape, - LC3_FLOAT *old_EwPtr, LC3_FLOAT *stPhECU_beta_mute, - LC3_FLOAT *stPhECU_mag_chg_1st, LC3_FLOAT *stPhECU_Xavg, LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *mag_chg, - LC3_INT32 *tr_dec_dbg, LC3_FLOAT *gpc_dbg); +void plc_phEcu_tba_spect_Xavg( LC3_INT32 fs_idx, LC3_INT32 n_grp, LC3_FLOAT *oold_spec_shape, LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_spec_shape, LC3_FLOAT *old_EwPtr, LC3_FLOAT *gr_pow_left, LC3_FLOAT *gr_pow_right, LC3_FLOAT *Xavg ); +void plc_phEcu_tba_per_band_gain( LC3_INT32 n_grp, LC3_FLOAT *gr_pow_left, LC3_FLOAT *gr_pow_right, LC3_FLOAT *trans, LC3_FLOAT *grp_pow_change ); +void plc_phEcu_tba_trans_dect_gains( LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FLOAT *grp_pow_change, LC3_FLOAT *stPhECU_beta_mute, LC3_FLOAT *stPhECU_mag_chg_1st, LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *mag_chg, LC3_FLOAT *ph_dith, LC3_INT32 *tr_dec, LC3_FLOAT *att_val, LC3_INT32 *attDegreeFrames, LC3_FLOAT *thresh_dbg ); +void plc_phEcu_trans_burst_ana_sub( LC3_INT32 fs_idx, LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FLOAT *oold_spect_shape, LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_spect_shape, LC3_FLOAT *old_EwPtr, LC3_FLOAT *stPhECU_beta_mute, LC3_FLOAT *stPhECU_mag_chg_1st, LC3_FLOAT *stPhECU_Xavg, LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *mag_chg, LC3_INT32 *tr_dec_dbg, LC3_FLOAT *gpc_dbg ); void plc_phEcu_hq_ecu( - LC3_FLOAT *f0binPtr, LC3_FLOAT *f0ltpGainPtr, - LC3_FLOAT *xfp, LC3_INT16 prev_bfi, LC3_INT32 *short_flag_prev, - LC3_INT32 fs, LC3_INT32 * time_offs, - Complex *X_sav_m, LC3_INT32 *n_plocs, LC3_INT32 *plocs, LC3_FLOAT *f0est, const LC3_FLOAT *mdctWin, - LC3_FLOAT *env_stabPtr, LC3_INT32 delta_corr, + LC3_FLOAT *f0binPtr, + LC3_FLOAT *f0ltpGainPtr, + LC3_FLOAT *xfp, + LC3_INT16 prev_bfi, + LC3_INT32 *short_flag_prev, + LC3_INT32 fs, + LC3_INT32 *time_offs, + Complex *X_sav_m, + LC3_INT32 *n_plocs, + LC3_INT32 *plocs, + LC3_FLOAT *f0est, + const LC3_FLOAT *mdctWin, + LC3_FLOAT *env_stabPtr, + LC3_INT32 delta_corr, LC3_FLOAT *pfind_sensPtr, - LC3_INT32 PhECU_LA, LC3_INT32 t_adv, const LC3_FLOAT *winWhr, LC3_FLOAT *oold_grp_shape, - LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_grp_shape, + LC3_INT32 PhECU_LA, + LC3_INT32 t_adv, + const LC3_FLOAT *winWhr, + LC3_FLOAT *oold_grp_shape, + LC3_FLOAT *oold_EwPtr, + LC3_FLOAT *old_grp_shape, LC3_FLOAT *old_EwPtr, - LC3_FLOAT *st_beta_mute, LC3_FLOAT *st_mag_chg_1st, LC3_FLOAT *st_Xavg, LC3_INT32 LA_ZEROS, LC3_FLOAT *x_tda, LC3_FLOAT *xsubst_dbg, Complex *X_out_m_dbg, - LC3_INT32 *seed_dbg, LC3_FLOAT *mag_chg_dbg, LC3_INT32 *tr_dec_dbg, LC3_FLOAT *gpc_dbg, LC3_FLOAT *X_i_new_re_dbg, LC3_FLOAT *X_i_new_im_dbg, LC3_FLOAT *corr_phase_dbg - ,Fft* PhEcu_Fft,Fft* PhEcu_Ifft -); - -void processTdcPreemphasis_fl(LC3_FLOAT *in, LC3_FLOAT *pre_emph_factor, LC3_INT32 n_bands); - -void processTdcTdac_fl(const LC3_FLOAT *synth_inp, const LC3_FLOAT *win, LC3_INT32 frame_length, LC3_INT32 la_zeroes, LC3_FLOAT *ola_mem); -void processTdcInverseOdft_fl(LC3_FLOAT *in, LC3_INT32 n_bands, LC3_FLOAT *out, LC3_INT32 lpc_order); - -void processTdcApply_fl(const LC3_INT32 pitch_LC3_INT, const LC3_FLOAT *preemphFac, const LC3_FLOAT* A, const LC3_INT32 lpc_order, const LC3_FLOAT* pcmbufHist, const LC3_INT32 max_len_pcm_plc, const LC3_INT32 N, const LC3_INT32 frame_dms, - const LC3_INT32 SampRate, const LC3_INT32 nbLostCmpt, const LC3_INT32 overlap, const LC3_FLOAT *stabFac, LC3_FLOAT harmonicBuf[MAX_PITCH], LC3_FLOAT synthHist[M], - LC3_INT32* fract, LC3_INT16* seed, LC3_FLOAT* gain_c, LC3_FLOAT* alpha, LC3_FLOAT* synth); -void* balloc(void* base, size_t* base_size, size_t size); - + LC3_FLOAT *st_beta_mute, + LC3_FLOAT *st_mag_chg_1st, + LC3_FLOAT *st_Xavg, + LC3_INT32 LA_ZEROS, + LC3_FLOAT *x_tda, + LC3_FLOAT *xsubst_dbg, + Complex *X_out_m_dbg, + LC3_INT32 *seed_dbg, + LC3_FLOAT *mag_chg_dbg, + LC3_INT32 *tr_dec_dbg, + LC3_FLOAT *gpc_dbg, + LC3_FLOAT *X_i_new_re_dbg, + LC3_FLOAT *X_i_new_im_dbg, + LC3_FLOAT *corr_phase_dbg, + Fft *PhEcu_Fft, + Fft *PhEcu_Ifft ); + +void processTdcPreemphasis_fl( LC3_FLOAT *in, LC3_FLOAT *pre_emph_factor, LC3_INT32 n_bands ); + +void processTdcTdac_fl( const LC3_FLOAT *synth_inp, const LC3_FLOAT *win, LC3_INT32 frame_length, LC3_INT32 la_zeroes, LC3_FLOAT *ola_mem ); +void processTdcInverseOdft_fl( LC3_FLOAT *in, LC3_INT32 n_bands, LC3_FLOAT *out, LC3_INT32 lpc_order ); + +void processTdcApply_fl( const LC3_INT32 pitch_LC3_INT, const LC3_FLOAT *preemphFac, const LC3_FLOAT *A, const LC3_INT32 lpc_order, const LC3_FLOAT *pcmbufHist, const LC3_INT32 max_len_pcm_plc, const LC3_INT32 N, const LC3_INT32 frame_dms, const LC3_INT32 SampRate, const LC3_INT32 nbLostCmpt, const LC3_INT32 overlap, const LC3_FLOAT *stabFac, LC3_FLOAT harmonicBuf[MAX_PITCH], LC3_FLOAT synthHist[M], LC3_INT32 *fract, LC3_INT16 *seed, LC3_FLOAT *gain_c, LC3_FLOAT *alpha, LC3_FLOAT *synth ); +void *balloc( void *base, size_t *base_size, size_t size ); #endif diff --git a/lib_lc3plus/imdct.c b/lib_lc3plus/imdct.c index 5d38aa6cc7..7e1d9ca6d0 100644 --- a/lib_lc3plus/imdct.c +++ b/lib_lc3plus/imdct.c @@ -1,102 +1,112 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" /* Function expects already flipped window */ -void ProcessingIMDCT_fl(LC3_FLOAT* y, LC3_INT yLen, const LC3_FLOAT* win, LC3_INT winLen, LC3_INT last_zeros, LC3_FLOAT* mem, LC3_FLOAT* x, Dct4* dct) +void ProcessingIMDCT_fl( LC3_FLOAT *y, LC3_INT yLen, const LC3_FLOAT *win, LC3_INT winLen, LC3_INT last_zeros, LC3_FLOAT *mem, LC3_FLOAT *x, Dct4 *dct ) { - LC3_FLOAT x_tda[MAX_LEN] = {0}, x_ov[2 * MAX_LEN] = {0}; - LC3_INT i = 0, j = 0; + LC3_FLOAT x_tda[MAX_LEN] = { 0 }, x_ov[2 * MAX_LEN] = { 0 }; + LC3_INT i = 0, j = 0; /* Flip imdct window up to down */ i = winLen - 1; j = 0; - dct4_apply(dct, y, x_tda); + dct4_apply( dct, y, x_tda ); - move_float(x_ov, &x_tda[yLen / 2], yLen / 2); + move_float( x_ov, &x_tda[yLen / 2], yLen / 2 ); j = yLen / 2; - for (i = 0; i < yLen / 2; i++) { + for ( i = 0; i < yLen / 2; i++ ) + { x_ov[j] = -x_tda[yLen - 1 - i]; j++; } j = yLen; - for (i = 0; i < yLen / 2; i++) { + for ( i = 0; i < yLen / 2; i++ ) + { x_ov[j] = -x_tda[yLen / 2 - 1 - i]; j++; } j = yLen + yLen / 2; - for (i = 0; i < yLen / 2; i++) { + for ( i = 0; i < yLen / 2; i++ ) + { x_ov[j] = -x_tda[i]; j++; } - for (i = 0; i < winLen; i++) { + for ( i = 0; i < winLen; i++ ) + { x_ov[i] = x_ov[i] * win[winLen - 1 - i]; } /* Buffer update */ j = 0; - for (i = last_zeros; i < yLen; i++) { + for ( i = last_zeros; i < yLen; i++ ) + { x_ov[i] = x_ov[i] + mem[j]; j++; } - move_float(&x[0], &x_ov[last_zeros], yLen); + move_float( &x[0], &x_ov[last_zeros], yLen ); - move_float(&mem[0], &x_ov[yLen + last_zeros], (winLen - (yLen + last_zeros))); + move_float( &mem[0], &x_ov[yLen + last_zeros], ( winLen - ( yLen + last_zeros ) ) ); } -void ProcessingITDA_WIN_OLA_fl(LC3_FLOAT* x_tda, LC3_INT32 yLen, const LC3_FLOAT* win, LC3_INT32 winLen, LC3_INT32 last_zeros, LC3_FLOAT* mem, LC3_FLOAT* x) +void ProcessingITDA_WIN_OLA_fl( LC3_FLOAT *x_tda, LC3_INT32 yLen, const LC3_FLOAT *win, LC3_INT32 winLen, LC3_INT32 last_zeros, LC3_FLOAT *mem, LC3_FLOAT *x ) { - LC3_FLOAT x_ov[2 * MAX_LEN] = {0}; + LC3_FLOAT x_ov[2 * MAX_LEN] = { 0 }; LC3_INT32 i, j; - move_float(x_ov, &x_tda[yLen / 2], yLen / 2); + move_float( x_ov, &x_tda[yLen / 2], yLen / 2 ); j = yLen / 2; - for (i = 0; i < yLen / 2; i++) { + for ( i = 0; i < yLen / 2; i++ ) + { x_ov[j] = -x_tda[yLen - 1 - i]; j++; } j = yLen; - for (i = 0; i < yLen / 2; i++) { + for ( i = 0; i < yLen / 2; i++ ) + { x_ov[j] = -x_tda[yLen / 2 - 1 - i]; j++; } j = yLen + yLen / 2; - for (i = 0; i < yLen / 2; i++) { + for ( i = 0; i < yLen / 2; i++ ) + { x_ov[j] = -x_tda[i]; j++; } - for (i = 0; i < winLen; i++) { + for ( i = 0; i < winLen; i++ ) + { x_ov[i] = x_ov[i] * win[winLen - 1 - i]; } /* Buffer update */ j = 0; - for (i = last_zeros; i < yLen; i++) { + for ( i = last_zeros; i < yLen; i++ ) + { x[j] = x_ov[i] + mem[j]; j++; } - move_float(&x[j], &x_ov[last_zeros+j], yLen-j); + move_float( &x[j], &x_ov[last_zeros + j], yLen - j ); - move_float(&mem[0], &x_ov[yLen + last_zeros], (winLen - (yLen + last_zeros))); + move_float( &mem[0], &x_ov[yLen + last_zeros], ( winLen - ( yLen + last_zeros ) ) ); } diff --git a/lib_lc3plus/lc3.c b/lib_lc3plus/lc3.c index 17d2ccb712..0bffb1877e 100644 --- a/lib_lc3plus/lc3.c +++ b/lib_lc3plus/lc3.c @@ -1,12 +1,12 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "lc3.h" @@ -17,409 +17,416 @@ #include "setup_dec_lc3.h" #include "setup_enc_lc3.h" -#define RETURN_IF(cond, error) \ - if (cond) \ - return (error) +#define RETURN_IF( cond, error ) \ + if ( cond ) \ + return ( error ) /* ensure api header constants are up to date */ -STATIC_ASSERT(LC3PLUS_MAX_SAMPLES >= MAX_LEN); -STATIC_ASSERT(LC3PLUS_MAX_CHANNELS >= MAX_CHANNELS); -STATIC_ASSERT(LC3PLUS_MAX_BYTES >= BYTESBUFSIZE); +STATIC_ASSERT( LC3PLUS_MAX_SAMPLES >= MAX_LEN ); +STATIC_ASSERT( LC3PLUS_MAX_CHANNELS >= MAX_CHANNELS ); +STATIC_ASSERT( LC3PLUS_MAX_BYTES >= BYTESBUFSIZE ); /* misc functions ************************************************************/ -int lc3plus_version(void) +int lc3plus_version( void ) { return LC3PLUS_VERSION; } -int lc3plus_channels_supported(int channels) +int lc3plus_channels_supported( int channels ) { return channels >= 1 && channels <= MAX_CHANNELS; } -int lc3plus_samplerate_supported(int samplerate) +int lc3plus_samplerate_supported( int samplerate ) { - switch (samplerate) + switch ( samplerate ) { - case 8000: return 1; - case 16000: return 1; - case 24000: return 1; - case 32000: return 1; - case 44100: return 1; - case 48000: return 1; - case 96000: return 1; - default: break; + case 8000: + return 1; + case 16000: + return 1; + case 24000: + return 1; + case 32000: + return 1; + case 44100: + return 1; + case 48000: + return 1; + case 96000: + return 1; + default: + break; } return 0; } -static int lc3plus_plc_mode_supported(LC3PLUS_PlcMode plc_mode) +static int lc3plus_plc_mode_supported( LC3PLUS_PlcMode plc_mode ) { - switch ((int)plc_mode) + switch ( (int) plc_mode ) { - case LC3PLUS_PLC_ADVANCED: /* fallthru */ - return 1; - default: break; + case LC3PLUS_PLC_ADVANCED: /* fallthru */ + return 1; + default: + break; } return 0; } -static int lc3plus_frame_size_supported(float frame_ms) +static int lc3plus_frame_size_supported( float frame_ms ) { - switch ((int)(ceil(frame_ms * 10))) + switch ( (int) ( ceil( frame_ms * 10 ) ) ) { - case 25: /* fallthru */ - case 50: /* fallthru */ - case 100: return 1; - default: break; + case 25: /* fallthru */ + case 50: /* fallthru */ + case 100: + return 1; + default: + break; } return 0; } -static int null_in_list(void **list, int n) +static int null_in_list( void **list, int n ) { - while (--n >= 0) - RETURN_IF(list[n] == NULL, 1); + while ( --n >= 0 ) + RETURN_IF( list[n] == NULL, 1 ); return 0; } /* return pointer to aligned base + base_size, *base_size += size + 4 bytes align */ -void *balloc(void *base, size_t *base_size, size_t size) +void *balloc( void *base, size_t *base_size, size_t size ) { - uintptr_t ptr = ((uintptr_t)base + *base_size + 3) & ~3; - assert((uintptr_t)base % 4 == 0); /* base must be 4-byte aligned */ - *base_size = (*base_size + size + 3) & ~3; - return (void *)ptr; + uintptr_t ptr = ( (uintptr_t) base + *base_size + 3 ) & ~3; + assert( (uintptr_t) base % 4 == 0 ); /* base must be 4-byte aligned */ + *base_size = ( *base_size + size + 3 ) & ~3; + return (void *) ptr; } -int32_t lc3_enc_supported_lfe(void) +int32_t lc3_enc_supported_lfe( void ) { return 1; } /* encoder functions *********************************************************/ -LC3PLUS_Error lc3plus_enc_init(LC3PLUS_Enc *encoder, int samplerate, int channels, int hrmode, int32_t lfe_channel_array[]) +LC3PLUS_Error lc3plus_enc_init( LC3PLUS_Enc *encoder, int samplerate, int channels, int hrmode, int32_t lfe_channel_array[] ) { int ch = 0; - RETURN_IF(encoder == NULL, LC3PLUS_NULL_ERROR); - RETURN_IF((uintptr_t)encoder % 4 != 0, LC3PLUS_ALIGN_ERROR); - RETURN_IF(!lc3plus_samplerate_supported(samplerate), LC3PLUS_SAMPLERATE_ERROR); - RETURN_IF(!lc3plus_channels_supported(channels), LC3PLUS_CHANNELS_ERROR); - RETURN_IF(samplerate==96000 && hrmode == 0, LC3PLUS_HRMODE_ERROR); + RETURN_IF( encoder == NULL, LC3PLUS_NULL_ERROR ); + RETURN_IF( (uintptr_t) encoder % 4 != 0, LC3PLUS_ALIGN_ERROR ); + RETURN_IF( !lc3plus_samplerate_supported( samplerate ), LC3PLUS_SAMPLERATE_ERROR ); + RETURN_IF( !lc3plus_channels_supported( channels ), LC3PLUS_CHANNELS_ERROR ); + RETURN_IF( samplerate == 96000 && hrmode == 0, LC3PLUS_HRMODE_ERROR ); - for (ch = 0; ch < channels; ch++) + for ( ch = 0; ch < channels; ch++ ) { - RETURN_IF(!lc3_enc_supported_lfe() && lfe_channel_array[ch], LC3PLUS_LFE_MODE_NOT_SUPPORTED); + RETURN_IF( !lc3_enc_supported_lfe() && lfe_channel_array[ch], LC3PLUS_LFE_MODE_NOT_SUPPORTED ); } - return FillEncSetup(encoder, samplerate, channels, hrmode, lfe_channel_array); /* real bitrate check happens here */ + return FillEncSetup( encoder, samplerate, channels, hrmode, lfe_channel_array ); /* real bitrate check happens here */ } -int lc3plus_enc_get_size(int samplerate, int channels) +int lc3plus_enc_get_size( int samplerate, int channels ) { - RETURN_IF(!lc3plus_samplerate_supported(samplerate), 0); - RETURN_IF(!lc3plus_channels_supported(channels), 0); - return alloc_encoder(NULL, channels); + RETURN_IF( !lc3plus_samplerate_supported( samplerate ), 0 ); + RETURN_IF( !lc3plus_channels_supported( channels ), 0 ); + return alloc_encoder( NULL, channels ); } /* Dummy function for API alignment */ -int lc3plus_enc_get_scratch_size(const LC3PLUS_Enc *encoder) +int lc3plus_enc_get_scratch_size( const LC3PLUS_Enc *encoder ) { - UNUSED(encoder); + UNUSED( encoder ); return 0; } -int lc3plus_enc_get_input_samples(const LC3PLUS_Enc *encoder) +int lc3plus_enc_get_input_samples( const LC3PLUS_Enc *encoder ) { - RETURN_IF(encoder == NULL, 0); + RETURN_IF( encoder == NULL, 0 ); return encoder->frame_length; } -int lc3plus_enc_get_num_bytes(const LC3PLUS_Enc *encoder) +int lc3plus_enc_get_num_bytes( const LC3PLUS_Enc *encoder ) { - RETURN_IF(encoder == NULL, 0); - - return encoder->bitrate * encoder->frame_length / (8 * encoder->fs_in); + RETURN_IF( encoder == NULL, 0 ); + + return encoder->bitrate * encoder->frame_length / ( 8 * encoder->fs_in ); } -int lc3plus_enc_get_real_bitrate(const LC3PLUS_Enc *encoder) +int lc3plus_enc_get_real_bitrate( const LC3PLUS_Enc *encoder ) { int ch = 0, totalBytes = 0; int bitrate; - RETURN_IF(encoder == NULL, 0); - RETURN_IF(!encoder->lc3_br_set, LC3PLUS_BITRATE_UNSET_ERROR); - - for (ch = 0; ch < encoder->channels; ch++) + RETURN_IF( encoder == NULL, 0 ); + RETURN_IF( !encoder->lc3_br_set, LC3PLUS_BITRATE_UNSET_ERROR ); + + for ( ch = 0; ch < encoder->channels; ch++ ) { totalBytes += encoder->channel_setup[ch]->targetBytes; } - - bitrate = (totalBytes * 80000.0 + encoder->frame_dms - 1) / encoder->frame_dms; - - if (encoder->fs_in == 44100) + + bitrate = ( totalBytes * 80000.0 + encoder->frame_dms - 1 ) / encoder->frame_dms; + + if ( encoder->fs_in == 44100 ) { int rem = bitrate % 480; - bitrate = ((bitrate - rem) / 480) * 441 + (rem * 441) / 480; + bitrate = ( ( bitrate - rem ) / 480 ) * 441 + ( rem * 441 ) / 480; } - + return bitrate; } -LC3PLUS_Error lc3plus_enc_set_bitrate(LC3PLUS_Enc *encoder, int bitrate) +LC3PLUS_Error lc3plus_enc_set_bitrate( LC3PLUS_Enc *encoder, int bitrate ) { - RETURN_IF(encoder == NULL, LC3PLUS_NULL_ERROR); - RETURN_IF(bitrate <= 0, LC3PLUS_BITRATE_ERROR); + RETURN_IF( encoder == NULL, LC3PLUS_NULL_ERROR ); + RETURN_IF( bitrate <= 0, LC3PLUS_BITRATE_ERROR ); #ifndef STRIP_HR_MODE_API - RETURN_IF(encoder->fs_idx == 5 && encoder->hrmode == 0, LC3PLUS_HRMODE_ERROR); + RETURN_IF( encoder->fs_idx == 5 && encoder->hrmode == 0, LC3PLUS_HRMODE_ERROR ); #endif - return update_enc_bitrate(encoder, bitrate); + return update_enc_bitrate( encoder, bitrate ); } -int lc3plus_enc_get_delay(const LC3PLUS_Enc *encoder) +int lc3plus_enc_get_delay( const LC3PLUS_Enc *encoder ) { - RETURN_IF(encoder == NULL, 0); + RETURN_IF( encoder == NULL, 0 ); return encoder->frame_length - 2 * encoder->la_zeroes; } -LC3PLUS_Error lc3plus_enc_set_frame_dms(LC3PLUS_Enc *encoder, int frame_dms) +LC3PLUS_Error lc3plus_enc_set_frame_dms( LC3PLUS_Enc *encoder, int frame_dms ) { - RETURN_IF(encoder == NULL, LC3PLUS_NULL_ERROR); - RETURN_IF(!lc3plus_frame_size_supported(frame_dms / 10.0), LC3PLUS_FRAMEMS_ERROR); - RETURN_IF(encoder->lc3_br_set, LC3PLUS_BITRATE_SET_ERROR); + RETURN_IF( encoder == NULL, LC3PLUS_NULL_ERROR ); + RETURN_IF( !lc3plus_frame_size_supported( frame_dms / 10.0 ), LC3PLUS_FRAMEMS_ERROR ); + RETURN_IF( encoder->lc3_br_set, LC3PLUS_BITRATE_SET_ERROR ); encoder->frame_dms = frame_dms; encoder->frame_ms = frame_dms / 10.0; - set_enc_frame_params(encoder); + set_enc_frame_params( encoder ); return LC3PLUS_OK; } -LC3PLUS_Error lc3plus_enc_set_bandwidth(LC3PLUS_Enc *encoder, int bandwidth) +LC3PLUS_Error lc3plus_enc_set_bandwidth( LC3PLUS_Enc *encoder, int bandwidth ) { LC3_INT effective_fs; - RETURN_IF(encoder == NULL, LC3PLUS_NULL_ERROR); + RETURN_IF( encoder == NULL, LC3PLUS_NULL_ERROR ); #ifdef ENABLE_HR_MODE_FL_FLAG - RETURN_IF(encoder->hrmode == 1, LC3PLUS_HRMODE_BW_ERROR); + RETURN_IF( encoder->hrmode == 1, LC3PLUS_HRMODE_BW_ERROR ); #endif effective_fs = encoder->fs_in; - if (encoder->bandwidth != bandwidth) { - if (encoder->fs_in > 40000) { + if ( encoder->bandwidth != bandwidth ) + { + if ( encoder->fs_in > 40000 ) + { effective_fs = 40000; } - if ((bandwidth * 2) > effective_fs) { + if ( ( bandwidth * 2 ) > effective_fs ) + { return LC3PLUS_BW_WARNING; } - else { + else + { encoder->bandwidth = bandwidth; encoder->bandwidth_preset = bandwidth; - encoder->bw_ctrl_active = 1; - update_enc_bitrate(encoder, encoder->bitrate); + encoder->bw_ctrl_active = 1; + update_enc_bitrate( encoder, encoder->bitrate ); } } return LC3PLUS_OK; } -LC3PLUS_Error lc3plus_enc16(LC3PLUS_Enc* encoder, int16_t** input_samples, void* output_bytes, int* num_bytes -, void *scratch -) +LC3PLUS_Error lc3plus_enc16( LC3PLUS_Enc *encoder, int16_t **input_samples, void *output_bytes, int *num_bytes, void *scratch ) { - UNUSED(scratch); - return lc3plus_enc_fl(encoder, (void**)input_samples, 16, output_bytes, num_bytes); + UNUSED( scratch ); + return lc3plus_enc_fl( encoder, (void **) input_samples, 16, output_bytes, num_bytes ); } -LC3PLUS_Error lc3plus_enc24(LC3PLUS_Enc* encoder, int32_t** input_samples, void* output_bytes, int* num_bytes -, void *scratch -) +LC3PLUS_Error lc3plus_enc24( LC3PLUS_Enc *encoder, int32_t **input_samples, void *output_bytes, int *num_bytes, void *scratch ) { - UNUSED(scratch); - return lc3plus_enc_fl(encoder, (void**)input_samples, 24, output_bytes, num_bytes); + UNUSED( scratch ); + return lc3plus_enc_fl( encoder, (void **) input_samples, 24, output_bytes, num_bytes ); } -LC3PLUS_Error lc3plus_enc_fl(LC3PLUS_Enc* encoder, void** input_samples, int bitdepth, void* output_bytes, int* num_bytes) +LC3PLUS_Error lc3plus_enc_fl( LC3PLUS_Enc *encoder, void **input_samples, int bitdepth, void *output_bytes, int *num_bytes ) { - RETURN_IF(!encoder || !input_samples || !output_bytes || !num_bytes, LC3PLUS_NULL_ERROR); - RETURN_IF(null_in_list(input_samples, encoder->channels), LC3PLUS_NULL_ERROR); - RETURN_IF(bitdepth != 16 && bitdepth != 24, LC3PLUS_ERROR); - *num_bytes = Enc_LC3PLUS_fl(encoder, input_samples, output_bytes, bitdepth - , *num_bytes == -1 - ); - assert(*num_bytes == lc3plus_enc_get_num_bytes(encoder)); + RETURN_IF( !encoder || !input_samples || !output_bytes || !num_bytes, LC3PLUS_NULL_ERROR ); + RETURN_IF( null_in_list( input_samples, encoder->channels ), LC3PLUS_NULL_ERROR ); + RETURN_IF( bitdepth != 16 && bitdepth != 24, LC3PLUS_ERROR ); + *num_bytes = Enc_LC3PLUS_fl( encoder, input_samples, output_bytes, bitdepth, *num_bytes == -1 ); + assert( *num_bytes == lc3plus_enc_get_num_bytes( encoder ) ); return LC3PLUS_OK; } /* decoder functions *********************************************************/ -LC3PLUS_Error lc3plus_dec_init(LC3PLUS_Dec* decoder, int samplerate, int channels, LC3PLUS_PlcMode plc_mode, int hrmode) +LC3PLUS_Error lc3plus_dec_init( LC3PLUS_Dec *decoder, int samplerate, int channels, LC3PLUS_PlcMode plc_mode, int hrmode ) { - RETURN_IF(decoder == NULL, LC3PLUS_NULL_ERROR); - RETURN_IF(!lc3plus_samplerate_supported(samplerate), LC3PLUS_SAMPLERATE_ERROR); - RETURN_IF(!lc3plus_channels_supported(channels), LC3PLUS_CHANNELS_ERROR); - RETURN_IF(!lc3plus_plc_mode_supported(plc_mode), LC3PLUS_PLCMODE_ERROR); - RETURN_IF(samplerate==96000 && hrmode == 0, LC3PLUS_HRMODE_ERROR); - return FillDecSetup(decoder, samplerate, channels, plc_mode, hrmode); + RETURN_IF( decoder == NULL, LC3PLUS_NULL_ERROR ); + RETURN_IF( !lc3plus_samplerate_supported( samplerate ), LC3PLUS_SAMPLERATE_ERROR ); + RETURN_IF( !lc3plus_channels_supported( channels ), LC3PLUS_CHANNELS_ERROR ); + RETURN_IF( !lc3plus_plc_mode_supported( plc_mode ), LC3PLUS_PLCMODE_ERROR ); + RETURN_IF( samplerate == 96000 && hrmode == 0, LC3PLUS_HRMODE_ERROR ); + return FillDecSetup( decoder, samplerate, channels, plc_mode, hrmode ); } -int lc3plus_dec_get_size(int samplerate, int channels) +int lc3plus_dec_get_size( int samplerate, int channels ) { - RETURN_IF(!lc3plus_samplerate_supported(samplerate), 0); - RETURN_IF(!lc3plus_channels_supported(channels), 0); - return alloc_decoder(NULL, samplerate, channels); + RETURN_IF( !lc3plus_samplerate_supported( samplerate ), 0 ); + RETURN_IF( !lc3plus_channels_supported( channels ), 0 ); + return alloc_decoder( NULL, samplerate, channels ); } /* Dummy function for API alignment */ -int lc3plus_dec_get_scratch_size(const LC3PLUS_Dec *decoder) +int lc3plus_dec_get_scratch_size( const LC3PLUS_Dec *decoder ) { - UNUSED(decoder); + UNUSED( decoder ); return 0; } -LC3PLUS_Error lc3plus_dec_set_frame_dms(LC3PLUS_Dec *decoder, int frame_dms) +LC3PLUS_Error lc3plus_dec_set_frame_dms( LC3PLUS_Dec *decoder, int frame_dms ) { - RETURN_IF(decoder == NULL, LC3PLUS_NULL_ERROR); - RETURN_IF(!lc3plus_frame_size_supported(frame_dms / 10.0), LC3PLUS_FRAMEMS_ERROR); - RETURN_IF(decoder->plcMeth == 2 && frame_dms != 100, LC3PLUS_FRAMEMS_ERROR); + RETURN_IF( decoder == NULL, LC3PLUS_NULL_ERROR ); + RETURN_IF( !lc3plus_frame_size_supported( frame_dms / 10.0 ), LC3PLUS_FRAMEMS_ERROR ); + RETURN_IF( decoder->plcMeth == 2 && frame_dms != 100, LC3PLUS_FRAMEMS_ERROR ); decoder->frame_dms = frame_dms; decoder->frame_ms = frame_dms / 10.0; - set_dec_frame_params(decoder); + set_dec_frame_params( decoder ); return LC3PLUS_OK; } -int lc3plus_dec_get_output_samples(const LC3PLUS_Dec* decoder) +int lc3plus_dec_get_output_samples( const LC3PLUS_Dec *decoder ) { - RETURN_IF(decoder == NULL, 0); + RETURN_IF( decoder == NULL, 0 ); return decoder->frame_length; } -int lc3plus_dec_get_delay(const LC3PLUS_Dec* decoder) +int lc3plus_dec_get_delay( const LC3PLUS_Dec *decoder ) { - RETURN_IF(decoder == NULL, 0); + RETURN_IF( decoder == NULL, 0 ); return decoder->frame_length - 2 * decoder->la_zeroes; } -LC3PLUS_Error lc3plus_dec_fl(LC3PLUS_Dec* decoder, void* input_bytes, int num_bytes, void** output_samples, int bps, int bfi_ext) +LC3PLUS_Error lc3plus_dec_fl( LC3PLUS_Dec *decoder, void *input_bytes, int num_bytes, void **output_samples, int bps, int bfi_ext ) { - RETURN_IF(!decoder || !input_bytes || !output_samples, LC3PLUS_NULL_ERROR); - RETURN_IF(null_in_list((void**)output_samples, decoder->channels), LC3PLUS_NULL_ERROR); - return Dec_LC3PLUS_fl(decoder, input_bytes, num_bytes, output_samples, bps, bfi_ext); + RETURN_IF( !decoder || !input_bytes || !output_samples, LC3PLUS_NULL_ERROR ); + RETURN_IF( null_in_list( (void **) output_samples, decoder->channels ), LC3PLUS_NULL_ERROR ); + return Dec_LC3PLUS_fl( decoder, input_bytes, num_bytes, output_samples, bps, bfi_ext ); } -LC3PLUS_Error lc3plus_dec16(LC3PLUS_Dec* decoder, void* input_bytes, int num_bytes, int16_t** output_samples, - void* scratch, - int bfi_ext) +LC3PLUS_Error lc3plus_dec16( LC3PLUS_Dec *decoder, void *input_bytes, int num_bytes, int16_t **output_samples, void *scratch, int bfi_ext ) { - UNUSED(scratch); - return lc3plus_dec_fl(decoder, input_bytes, num_bytes, (void**)output_samples, 16, bfi_ext); + UNUSED( scratch ); + return lc3plus_dec_fl( decoder, input_bytes, num_bytes, (void **) output_samples, 16, bfi_ext ); } -LC3PLUS_Error lc3plus_dec24(LC3PLUS_Dec* decoder, void* input_bytes, int num_bytes, int32_t** output_samples, - void* scratch, - int bfi_ext) +LC3PLUS_Error lc3plus_dec24( LC3PLUS_Dec *decoder, void *input_bytes, int num_bytes, int32_t **output_samples, void *scratch, int bfi_ext ) { - UNUSED(scratch); - return lc3plus_dec_fl(decoder, input_bytes, num_bytes, (void**)output_samples, 24, bfi_ext); + UNUSED( scratch ); + return lc3plus_dec_fl( decoder, input_bytes, num_bytes, (void **) output_samples, 24, bfi_ext ); } /* memory functions *********************************************************/ -LC3PLUS_Error lc3plus_enc_free_memory(LC3PLUS_Enc* encoder) +LC3PLUS_Error lc3plus_enc_free_memory( LC3PLUS_Enc *encoder ) { - RETURN_IF(!encoder, LC3PLUS_NULL_ERROR); + RETURN_IF( !encoder, LC3PLUS_NULL_ERROR ); - lc3plus_free_encoder_structs(encoder); + lc3plus_free_encoder_structs( encoder ); return LC3PLUS_OK; } -LC3PLUS_Error lc3plus_dec_free_memory(LC3PLUS_Dec* decoder) +LC3PLUS_Error lc3plus_dec_free_memory( LC3PLUS_Dec *decoder ) { - RETURN_IF(!decoder, LC3PLUS_NULL_ERROR); + RETURN_IF( !decoder, LC3PLUS_NULL_ERROR ); - lc3plus_free_decoder_structs(decoder); + lc3plus_free_decoder_structs( decoder ); return LC3PLUS_OK; } -LC3PLUS_Error lc3plus_free_encoder_structs(LC3PLUS_Enc* encoder) +LC3PLUS_Error lc3plus_free_encoder_structs( LC3PLUS_Enc *encoder ) { int ch = 0; - RETURN_IF(!encoder, LC3PLUS_NULL_ERROR); + RETURN_IF( !encoder, LC3PLUS_NULL_ERROR ); - for (ch = 0; ch < encoder->channels; ch++) { - mdct_free(&encoder->channel_setup[ch]->mdctStruct); - dct2_free(&encoder->channel_setup[ch]->dct2StructSNS); + for ( ch = 0; ch < encoder->channels; ch++ ) + { + mdct_free( &encoder->channel_setup[ch]->mdctStruct ); + dct2_free( &encoder->channel_setup[ch]->dct2StructSNS ); } return LC3PLUS_OK; } -LC3PLUS_Error lc3plus_free_decoder_structs(LC3PLUS_Dec* decoder) +LC3PLUS_Error lc3plus_free_decoder_structs( LC3PLUS_Dec *decoder ) { int ch = 0; - RETURN_IF(!decoder, LC3PLUS_NULL_ERROR); + RETURN_IF( !decoder, LC3PLUS_NULL_ERROR ); - for (ch = 0; ch < decoder->channels; ch++) { - dct4_free(&decoder->channel_setup[ch]->dct4structImdct); - real_fft_free(&decoder->channel_setup[ch]->PlcAdvSetup->PlcPhEcuSetup.PhEcu_Fft); - real_fft_free(&decoder->channel_setup[ch]->PlcAdvSetup->PlcPhEcuSetup.PhEcu_Ifft); + for ( ch = 0; ch < decoder->channels; ch++ ) + { + dct4_free( &decoder->channel_setup[ch]->dct4structImdct ); + real_fft_free( &decoder->channel_setup[ch]->PlcAdvSetup->PlcPhEcuSetup.PhEcu_Fft ); + real_fft_free( &decoder->channel_setup[ch]->PlcAdvSetup->PlcPhEcuSetup.PhEcu_Ifft ); } return LC3PLUS_OK; } -LC3PLUS_EpModeRequest lc3plus_dec_get_ep_mode_request(const LC3PLUS_Dec *decoder) +LC3PLUS_EpModeRequest lc3plus_dec_get_ep_mode_request( const LC3PLUS_Dec *decoder ) { - RETURN_IF(decoder == NULL, LC3PLUS_EPMR_ZERO); - return (LC3PLUS_EpModeRequest)decoder->epmr; + RETURN_IF( decoder == NULL, LC3PLUS_EPMR_ZERO ); + return (LC3PLUS_EpModeRequest) decoder->epmr; } -int lc3plus_dec_get_error_report(const LC3PLUS_Dec *decoder) +int lc3plus_dec_get_error_report( const LC3PLUS_Dec *decoder ) { - RETURN_IF(decoder == NULL, 0); + RETURN_IF( decoder == NULL, 0 ); return decoder->error_report == 2047 ? -1 : decoder->error_report & 0x07FF; } -LC3PLUS_Error lc3plus_enc_set_ep_mode(LC3PLUS_Enc *encoder, LC3PLUS_EpMode epmode) +LC3PLUS_Error lc3plus_enc_set_ep_mode( LC3PLUS_Enc *encoder, LC3PLUS_EpMode epmode ) { LC3PLUS_EpMode oldEpmode; LC3PLUS_Error error; - RETURN_IF(encoder == NULL, LC3PLUS_NULL_ERROR); - RETURN_IF((unsigned)epmode > LC3PLUS_EP_HIGH, LC3PLUS_EPMODE_ERROR); + RETURN_IF( encoder == NULL, LC3PLUS_NULL_ERROR ); + RETURN_IF( (unsigned) epmode > LC3PLUS_EP_HIGH, LC3PLUS_EPMODE_ERROR ); oldEpmode = encoder->epmode; encoder->epmode = epmode; - error = encoder->lc3_br_set ? update_enc_bitrate(encoder, encoder->bitrate) : LC3PLUS_OK; - if (error != LC3PLUS_OK) + error = encoder->lc3_br_set ? update_enc_bitrate( encoder, encoder->bitrate ) : LC3PLUS_OK; + if ( error != LC3PLUS_OK ) { - encoder->epmode = oldEpmode; // preserve old epmode in case of failure + encoder->epmode = oldEpmode; // preserve old epmode in case of failure } return error; } -LC3PLUS_Error lc3plus_enc_set_ep_mode_request(LC3PLUS_Enc *encoder, LC3PLUS_EpModeRequest epmr) +LC3PLUS_Error lc3plus_enc_set_ep_mode_request( LC3PLUS_Enc *encoder, LC3PLUS_EpModeRequest epmr ) { - RETURN_IF(encoder == NULL, LC3PLUS_NULL_ERROR); - RETURN_IF((unsigned)epmr > LC3PLUS_EPMR_HIGH, LC3PLUS_EPMODE_ERROR); + RETURN_IF( encoder == NULL, LC3PLUS_NULL_ERROR ); + RETURN_IF( (unsigned) epmr > LC3PLUS_EPMR_HIGH, LC3PLUS_EPMODE_ERROR ); encoder->epmr = epmr; return LC3PLUS_OK; } -LC3PLUS_Error lc3plus_dec_set_ep_enabled(LC3PLUS_Dec *decoder, int32_t ep_enabled) +LC3PLUS_Error lc3plus_dec_set_ep_enabled( LC3PLUS_Dec *decoder, int32_t ep_enabled ) { - RETURN_IF(decoder == NULL, LC3PLUS_NULL_ERROR); + RETURN_IF( decoder == NULL, LC3PLUS_NULL_ERROR ); decoder->ep_enabled = ep_enabled != 0; - decoder->epmr = LC3PLUS_EPMR_ZERO; + decoder->epmr = LC3PLUS_EPMR_ZERO; return LC3PLUS_OK; } -int lc3plus_dec_get_epok_flags(const LC3PLUS_Dec *decoder) +int lc3plus_dec_get_epok_flags( const LC3PLUS_Dec *decoder ) { - RETURN_IF(decoder == NULL, 0); + RETURN_IF( decoder == NULL, 0 ); return decoder->error_report >> 11; } @@ -428,4 +435,3 @@ int lc3plus_dec_get_epok_flags(const LC3PLUS_Dec *decoder) #ifndef STRIP_ERROR_PROTECTION_API_FL #endif /* STRIP_ERROR_PROTECTION_API_FL */ - diff --git a/lib_lc3plus/lc3.h b/lib_lc3plus/lc3.h index 3e45438fed..bb835554bb 100644 --- a/lib_lc3plus/lc3.h +++ b/lib_lc3plus/lc3.h @@ -1,18 +1,18 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + /*! \file lc3.h * This header provides the API for LC3plus. * * This library is targeting devices with extreme memory limitations, so memory management - * must be handeled by the user. This includes allocating memory for the structs. The structs are persistent + * must be handeled by the user. This includes allocating memory for the structs. The structs are persistent * between function calls. * * The amount of memory needed for various configurations can be obtained from the lc3plus_*_get_size @@ -28,15 +28,15 @@ #include #else typedef unsigned char uint8_t; -typedef __int16 int16_t; -typedef __int32 int32_t; +typedef __int16 int16_t; +typedef __int32 int32_t; #endif /*! Construct version number from major/minor/micro values. */ -#define LC3PLUS_VERSION_INT(major, minor, micro) (((major) << 16) | ((minor) << 8) | (micro)) +#define LC3PLUS_VERSION_INT( major, minor, micro ) ( ( ( major ) << 16 ) | ( ( minor ) << 8 ) | ( micro ) ) /*! Version number to ensure header and binary are matching. */ -#define LC3PLUS_VERSION LC3PLUS_VERSION_INT(1, 6, 9) +#define LC3PLUS_VERSION LC3PLUS_VERSION_INT( 1, 6, 9 ) /*! Maximum number of supported channels. The actual binary might support * less, use lc3plus_channels_supported() to check. */ @@ -58,64 +58,64 @@ typedef __int32 int32_t; /*! Error codes returned by functions. */ typedef enum { - LC3PLUS_PLC_ADVANCED = 1 /*!< Enhanced concealment method */ + LC3PLUS_PLC_ADVANCED = 1 /*!< Enhanced concealment method */ } LC3PLUS_PlcMode; /*! Error protection mode. LC3PLUS_EP_ZERO differs to LC3PLUS_EP_OFF in that * errors can be detected but not corrected. */ typedef enum { - LC3PLUS_EP_OFF = 0, /*!< Error protection is disabled */ - LC3PLUS_EP_ZERO = 1, /*!< Error protection with 0 bit correction */ - LC3PLUS_EP_LOW = 2, /*!< Error protection correcting one symbol per codeword */ + LC3PLUS_EP_OFF = 0, /*!< Error protection is disabled */ + LC3PLUS_EP_ZERO = 1, /*!< Error protection with 0 bit correction */ + LC3PLUS_EP_LOW = 2, /*!< Error protection correcting one symbol per codeword */ LC3PLUS_EP_MEDIUM = 3, /*!< Error protection correcting two symbols per codeword */ - LC3PLUS_EP_HIGH = 4 /*!< Error protection correcting three symbols per codeword */ + LC3PLUS_EP_HIGH = 4 /*!< Error protection correcting three symbols per codeword */ } LC3PLUS_EpMode; /*! Error protection mode request. On the encoder sidem, LC3PLUS_EPMR_ZERO to LC3PLUS_EPMR_HIGH * can be set. The decoder returns mode requests with different confidences. */ typedef enum { - LC3PLUS_EPMR_ZERO = 0, /*!< Request no error correction. High confidence if returned by decoder. */ - LC3PLUS_EPMR_LOW = 1, /*!< Request low error correction. High confidence if returned by decoder. */ - LC3PLUS_EPMR_MEDIUM = 2, /*!< Request medium error correction. High confidence if returned by decoder. */ - LC3PLUS_EPMR_HIGH = 3, /*!< Request high error correction. High confidence if returned by decoder. */ - LC3PLUS_EPMR_ZERO_MC = 4, /*!< No error correction requested, medium confidence. */ - LC3PLUS_EPMR_LOW_MC = 5, /*!< Low error correction requested, medium confidence. */ + LC3PLUS_EPMR_ZERO = 0, /*!< Request no error correction. High confidence if returned by decoder. */ + LC3PLUS_EPMR_LOW = 1, /*!< Request low error correction. High confidence if returned by decoder. */ + LC3PLUS_EPMR_MEDIUM = 2, /*!< Request medium error correction. High confidence if returned by decoder. */ + LC3PLUS_EPMR_HIGH = 3, /*!< Request high error correction. High confidence if returned by decoder. */ + LC3PLUS_EPMR_ZERO_MC = 4, /*!< No error correction requested, medium confidence. */ + LC3PLUS_EPMR_LOW_MC = 5, /*!< Low error correction requested, medium confidence. */ LC3PLUS_EPMR_MEDIUM_MC = 6, /*!< Medium error correction requested, medium confidence. */ - LC3PLUS_EPMR_HIGH_MC = 7, /*!< High error correction requested, medium confidence. */ - LC3PLUS_EPMR_ZERO_NC = 8, /*!< No error correction requested, unvalidated. */ - LC3PLUS_EPMR_LOW_NC = 9, /*!< Low error correction requested, unvalidated. */ + LC3PLUS_EPMR_HIGH_MC = 7, /*!< High error correction requested, medium confidence. */ + LC3PLUS_EPMR_ZERO_NC = 8, /*!< No error correction requested, unvalidated. */ + LC3PLUS_EPMR_LOW_NC = 9, /*!< Low error correction requested, unvalidated. */ LC3PLUS_EPMR_MEDIUM_NC = 10, /*!< Medium error correction requested, unvalidated. */ - LC3PLUS_EPMR_HIGH_NC = 11 /*!< High error correction requested, unvalidated. */ + LC3PLUS_EPMR_HIGH_NC = 11 /*!< High error correction requested, unvalidated. */ } LC3PLUS_EpModeRequest; /*! Error codes returned by functions. */ typedef enum { - LC3PLUS_OK = 0, /*!< No error occurred */ - LC3PLUS_ERROR = 1, /*!< Function call failed */ - LC3PLUS_DECODE_ERROR = 2, /*!< Frame failed to decode and was concealed */ - LC3PLUS_NULL_ERROR = 3, /*!< Pointer argument is null */ - LC3PLUS_SAMPLERATE_ERROR = 4, /*!< Invalid samplerate value */ - LC3PLUS_CHANNELS_ERROR = 5, /*!< Invalid channels value */ - LC3PLUS_BITRATE_ERROR = 6, /*!< Invalid bitrate value */ - LC3PLUS_NUMBYTES_ERROR = 7, /*!< Invalid num_bytes value */ - LC3PLUS_EPMODE_ERROR = 8, /*!< Invalid plc_method value */ - LC3PLUS_FRAMEMS_ERROR = 9, /*!< Invalid epmode value */ - LC3PLUS_ALIGN_ERROR = 10, /*!< Invalid frame_ms value */ - LC3PLUS_HRMODE_ERROR = 11, /*!< Unaligned pointer */ - LC3PLUS_BITRATE_UNSET_ERROR = 12, /*!< Invalid epmr value */ - LC3PLUS_BITRATE_SET_ERROR = 13, /*!< Invalid usage of hrmode, sampling rate and frame size */ - LC3PLUS_HRMODE_BW_ERROR = 14, /*!< Function called before bitrate has been set */ - LC3PLUS_PLCMODE_ERROR = 15, /*!< Function called after bitrate has been set */ - LC3PLUS_EPMR_ERROR = 16, /*!< Invalid external bad frame index */ - LC3PLUS_PADDING_ERROR = 17, /*!< Incorrect padding value */ - FRAMESIZE_ERROR = 18, /*!< Incorrect frame size during decoding */ + LC3PLUS_OK = 0, /*!< No error occurred */ + LC3PLUS_ERROR = 1, /*!< Function call failed */ + LC3PLUS_DECODE_ERROR = 2, /*!< Frame failed to decode and was concealed */ + LC3PLUS_NULL_ERROR = 3, /*!< Pointer argument is null */ + LC3PLUS_SAMPLERATE_ERROR = 4, /*!< Invalid samplerate value */ + LC3PLUS_CHANNELS_ERROR = 5, /*!< Invalid channels value */ + LC3PLUS_BITRATE_ERROR = 6, /*!< Invalid bitrate value */ + LC3PLUS_NUMBYTES_ERROR = 7, /*!< Invalid num_bytes value */ + LC3PLUS_EPMODE_ERROR = 8, /*!< Invalid plc_method value */ + LC3PLUS_FRAMEMS_ERROR = 9, /*!< Invalid epmode value */ + LC3PLUS_ALIGN_ERROR = 10, /*!< Invalid frame_ms value */ + LC3PLUS_HRMODE_ERROR = 11, /*!< Unaligned pointer */ + LC3PLUS_BITRATE_UNSET_ERROR = 12, /*!< Invalid epmr value */ + LC3PLUS_BITRATE_SET_ERROR = 13, /*!< Invalid usage of hrmode, sampling rate and frame size */ + LC3PLUS_HRMODE_BW_ERROR = 14, /*!< Function called before bitrate has been set */ + LC3PLUS_PLCMODE_ERROR = 15, /*!< Function called after bitrate has been set */ + LC3PLUS_EPMR_ERROR = 16, /*!< Invalid external bad frame index */ + LC3PLUS_PADDING_ERROR = 17, /*!< Incorrect padding value */ + FRAMESIZE_ERROR = 18, /*!< Incorrect frame size during decoding */ LC3PLUS_LFE_MODE_NOT_SUPPORTED = 19, /*!< LFE support not available */ /* START WARNING */ - LC3PLUS_WARNING = 20, + LC3PLUS_WARNING = 20, LC3PLUS_BW_WARNING = 21 /*!< Invalid bandwidth cutoff frequency */ } LC3PLUS_Error; @@ -127,29 +127,29 @@ typedef struct LC3PLUS_Dec LC3PLUS_Dec; /*!< Opaque decoder struct. */ * \{ */ /*! Test LFE mode support. - * + * * Tests the support of the LFE mode. * * \return 1 for true, 0 for false. */ -int32_t lc3_enc_supported_lfe(void); +int32_t lc3_enc_supported_lfe( void ); /*! Return library version number. It should match LC3PLUS_VERSION. */ -int lc3plus_version(void); +int lc3plus_version( void ); /*! Tests if the library supports number of channels. * * \param[in] channels Number of channels. * \return 1 for true, 0 for false. */ -int lc3plus_channels_supported(int channels); +int lc3plus_channels_supported( int channels ); /*! Tests if the library supports a sampling rate. * * \param[in] samplerate Sampling rate * \return 1 for true, 0 for false */ -int lc3plus_samplerate_supported(int samplerate); +int lc3plus_samplerate_supported( int samplerate ); /*! \} * \addtogroup Encoder @@ -171,7 +171,7 @@ int lc3plus_samplerate_supported(int samplerate); * \param[in] hrmode High resolution mode. * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_enc_init(LC3PLUS_Enc* encoder, int samplerate, int channels, int hrmode, int32_t lfe_channel_array[]); +LC3PLUS_Error lc3plus_enc_init( LC3PLUS_Enc *encoder, int samplerate, int channels, int hrmode, int32_t lfe_channel_array[] ); /*! * Encode LC3plus frame with 16 bit input. @@ -190,24 +190,20 @@ LC3PLUS_Error lc3plus_enc_init(LC3PLUS_Enc* encoder, int samplerate, int channel * \param scratch See comment above. * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_enc16(LC3PLUS_Enc* encoder, int16_t** input_samples, void* output_bytes, int* num_bytes -, void *scratch -); +LC3PLUS_Error lc3plus_enc16( LC3PLUS_Enc *encoder, int16_t **input_samples, void *output_bytes, int *num_bytes, void *scratch ); /*! Encode LC3plus frame with 24 bit input. * * The input samples are expected to be 24-bit values, sign-extended to 32-bit. * See lc3plus_enc16() for parameter documentation. */ -LC3PLUS_Error lc3plus_enc24(LC3PLUS_Enc* encoder, int32_t** input_samples, void* output_bytes, int* num_bytes -, void *scratch -); +LC3PLUS_Error lc3plus_enc24( LC3PLUS_Enc *encoder, int32_t **input_samples, void *output_bytes, int *num_bytes, void *scratch ); /*! * Internal function. Use lc3plus_enc16() or lc3plus_enc24() for encoding. */ -LC3PLUS_Error lc3plus_enc_fl(LC3PLUS_Enc* encoder, void** input_samples, int bitdepth, void* output_bytes, int* num_bytes); +LC3PLUS_Error lc3plus_enc_fl( LC3PLUS_Enc *encoder, void **input_samples, int bitdepth, void *output_bytes, int *num_bytes ); /*! Get the size of the LC3plus encoder struct for a samplerate / channel * configuration. If memory is not restricted LC3PLUS_ENC_MAX_SIZE can be used for @@ -217,21 +213,21 @@ LC3PLUS_Error lc3plus_enc_fl(LC3PLUS_Enc* encoder, void** input_samples, int bit * \param[in] channels Number of channels. * \return Size in bytes or 0 on error. */ -int lc3plus_enc_get_size(int samplerate, int channels); +int lc3plus_enc_get_size( int samplerate, int channels ); /*! Dummy function as no scratch management available in floating-point code. Returns always zero. Used to align fixed-point and floating-point APIs. * * \param[in] encoder Encoder handle. * \return Size in bytes or 0 on error. */ -int lc3plus_enc_get_scratch_size(const LC3PLUS_Enc *encoder); +int lc3plus_enc_get_scratch_size( const LC3PLUS_Enc *encoder ); /*! Get number of samples per channel expected by lc3plus_enc16() or lc3plus_enc24(). * * \param[in] encoder Encoder handle. * \return Number of samples or 0 on error. */ -int lc3plus_enc_get_input_samples(const LC3PLUS_Enc* encoder); +int lc3plus_enc_get_input_samples( const LC3PLUS_Enc *encoder ); /*! Get real internal bitrate of the encoder. It might differ from the requested * bitrate due to 44.1 kHz input. @@ -239,7 +235,7 @@ int lc3plus_enc_get_input_samples(const LC3PLUS_Enc* encoder); * \param[in] encoder Encoder handle. * \return Bitrate in bits per second or 0 on error. */ -int lc3plus_enc_get_real_bitrate(const LC3PLUS_Enc* encoder); +int lc3plus_enc_get_real_bitrate( const LC3PLUS_Enc *encoder ); /*! Get the maximum number of bytes produced by lc3plus_enc16() or lc3plus_enc24() for the current * bitrate. It should be equal to the num_bytes output of lc3plus_enc16/24(). @@ -247,7 +243,7 @@ int lc3plus_enc_get_real_bitrate(const LC3PLUS_Enc* encoder); * \param[in] encoder Encoder handle. * \return Size in bytes or 0 on error. */ -int lc3plus_enc_get_num_bytes(const LC3PLUS_Enc *encoder); +int lc3plus_enc_get_num_bytes( const LC3PLUS_Enc *encoder ); /*! Set encoder bitrate for all channels. * This function must be called at least once before encoding the first frame, but @@ -261,20 +257,20 @@ int lc3plus_enc_get_num_bytes(const LC3PLUS_Enc *encoder); * 24 | 48 * 32 | 64 * 44.1/48 | 80(voice) 128(music) - * 96 | 128 + * 96 | 128 * * \param[in] encoder Encoder handle. * \param[in] bitrate Bitrate in bits per second. * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_enc_set_bitrate(LC3PLUS_Enc* encoder, int bitrate); +LC3PLUS_Error lc3plus_enc_set_bitrate( LC3PLUS_Enc *encoder, int bitrate ); /*! Get the encoder delay in number of samples. * * \param[in] encoder Encoder handle. * \return Encoder in samples or 0 on error. */ -int lc3plus_enc_get_delay(const LC3PLUS_Enc *encoder); +int lc3plus_enc_get_delay( const LC3PLUS_Enc *encoder ); /*! Set the frame length for LC3plus decoder in deci milliseconds. * Not all lengths may be enabled, in that case LC3PLUS_FRAMEMS_ERROR is returned. @@ -284,7 +280,7 @@ int lc3plus_enc_get_delay(const LC3PLUS_Enc *encoder); * \param[in] frame_ms Frame length in ms. * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_enc_set_frame_dms(LC3PLUS_Enc *encoder, int frame_ms); +LC3PLUS_Error lc3plus_enc_set_frame_dms( LC3PLUS_Enc *encoder, int frame_ms ); /*! Set encoder Low-frequency effect moded. deactivates LTPF, TNS, NF @@ -293,14 +289,14 @@ LC3PLUS_Error lc3plus_enc_set_frame_dms(LC3PLUS_Enc *encoder, int frame_ms); * \param[in] lfe LFE mode flag * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_enc_set_lfe(LC3PLUS_Enc* encoder, int lfe); +LC3PLUS_Error lc3plus_enc_set_lfe( LC3PLUS_Enc *encoder, int lfe ); /*! Free memory allocated within LC3plus encoder struct. * * \param[in] encoder Encoder handle. * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_enc_free_memory(LC3PLUS_Enc* encoder); +LC3PLUS_Error lc3plus_enc_free_memory( LC3PLUS_Enc *encoder ); /*! Set encoder bandwidth to a different value. All frequency bins above the cutoff * frequency are cut off. Allowed frequencies are: 4 kHz, 8 kHz, 12 kHz, 16 kHz and 24 kHz. @@ -309,14 +305,14 @@ LC3PLUS_Error lc3plus_enc_free_memory(LC3PLUS_Enc* encoder); * \param[in] bandwidth Cutoff Frequency in Hz * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_enc_set_bandwidth(LC3PLUS_Enc *encoder, int bandwidth); +LC3PLUS_Error lc3plus_enc_set_bandwidth( LC3PLUS_Enc *encoder, int bandwidth ); /*! Internal function called by lc3plus_enc_free_memory. * * \param[in] encoder Encoder handle. * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_free_encoder_structs(LC3PLUS_Enc* encoder); +LC3PLUS_Error lc3plus_free_encoder_structs( LC3PLUS_Enc *encoder ); /*! Sets error protection mode request transmitted in each channel encoded frame. * The channel coder includes an error protection mode request (EPMR) in every frame. @@ -328,7 +324,7 @@ LC3PLUS_Error lc3plus_free_encoder_structs(LC3PLUS_Enc* encoder); * \param[in] epmr Error Protection Mode Request * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_enc_set_ep_mode_request(LC3PLUS_Enc *encoder, LC3PLUS_EpModeRequest epmr); +LC3PLUS_Error lc3plus_enc_set_ep_mode_request( LC3PLUS_Enc *encoder, LC3PLUS_EpModeRequest epmr ); /*! Set error protection mode. The default is LC3PLUS_EP_OFF. It is possible to switch between * different modees during encoding. Dynamic switching is only allowed between LC3PLUS_EP_ZERO, @@ -339,7 +335,7 @@ LC3PLUS_Error lc3plus_enc_set_ep_mode_request(LC3PLUS_Enc *encoder, LC3PLUS_EpMo * \param[in] epmode Error protection mode. * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_enc_set_ep_mode(LC3PLUS_Enc *encoder, LC3PLUS_EpMode epmode); +LC3PLUS_Error lc3plus_enc_set_ep_mode( LC3PLUS_Enc *encoder, LC3PLUS_EpMode epmode ); /*! \} * \addtogroup Decoder @@ -362,8 +358,7 @@ LC3PLUS_Error lc3plus_enc_set_ep_mode(LC3PLUS_Enc *encoder, LC3PLUS_EpMode epmod * * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_dec_init(LC3PLUS_Dec* decoder, int samplerate, int channels, LC3PLUS_PlcMode plc_mode, int hrmode); - +LC3PLUS_Error lc3plus_dec_init( LC3PLUS_Dec *decoder, int samplerate, int channels, LC3PLUS_PlcMode plc_mode, int hrmode ); /*! @@ -389,21 +384,17 @@ LC3PLUS_Error lc3plus_dec_init(LC3PLUS_Dec* decoder, int samplerate, int channel * \return Returns LC3PLUS_OK on success or appropriate error code. Note there is * a special case for LC3PLUS_DECODE_ERROR where the output is still valid. */ -LC3PLUS_Error lc3plus_dec16(LC3PLUS_Dec* decoder, void* input_bytes, int num_bytes, int16_t** output_samples, - void* scratch, - int bfi_ext); +LC3PLUS_Error lc3plus_dec16( LC3PLUS_Dec *decoder, void *input_bytes, int num_bytes, int16_t **output_samples, void *scratch, int bfi_ext ); /*! Decode compressed LC3plus frame to 24 bit PCM output. * * The output samples are 24-bit values, sign-extended to 32-bit. * See lc3plus_dec16() for parameter documentation. */ -LC3PLUS_Error lc3plus_dec24(LC3PLUS_Dec* decoder, void* input_bytes, int num_bytes, int32_t** output_samples, - void* scratch, - int bfi_ext); +LC3PLUS_Error lc3plus_dec24( LC3PLUS_Dec *decoder, void *input_bytes, int num_bytes, int32_t **output_samples, void *scratch, int bfi_ext ); /* Internal function */ - LC3PLUS_Error lc3plus_dec_fl(LC3PLUS_Dec* decoder, void* input_bytes, int num_bytes, void** output_samples, int bps, int bfi_ext); +LC3PLUS_Error lc3plus_dec_fl( LC3PLUS_Dec *decoder, void *input_bytes, int num_bytes, void **output_samples, int bps, int bfi_ext ); /*! Get the size of the LC3plus decoder struct for a samplerate / channel * configuration. If memory is not restricted LC3PLUS_DEC_MAX_SIZE can be used for @@ -413,28 +404,28 @@ LC3PLUS_Error lc3plus_dec24(LC3PLUS_Dec* decoder, void* input_bytes, int num_byt * \param[in] samplerate Sampling rate. * \return Size in bytes or 0 on error. */ -int lc3plus_dec_get_size(int samplerate, int channels); +int lc3plus_dec_get_size( int samplerate, int channels ); /*! Dummy function as no scratch management available in floating-point code. Returns always zero. Used to align fixed-point and floating-point APIs. * * \param[in] decoder Decoder handle. * \return Size in bytes or 0 on error. */ -int lc3plus_dec_get_scratch_size(const LC3PLUS_Dec *decoder); +int lc3plus_dec_get_scratch_size( const LC3PLUS_Dec *decoder ); /*! Get the number of samples per channel produced by lc3plus_dec16() or lc3plus_dec24. * * \param[in] decoder Decoder handle. * \return Number of samples or 0 on error. */ -int lc3plus_dec_get_output_samples(const LC3PLUS_Dec* decoder); +int lc3plus_dec_get_output_samples( const LC3PLUS_Dec *decoder ); /*! Get the decoder delay in number of samples. * * \param[in] decoder Decoder handle. * \return Delay in samples or 0 on error. */ -int lc3plus_dec_get_delay(const LC3PLUS_Dec* decoder); +int lc3plus_dec_get_delay( const LC3PLUS_Dec *decoder ); /*! Set the frame length for LC3plus encoder in deci milliseconds. * Not all lengths may be enabled, in that case LC3PLUS_FRAMEMS_ERROR is returned. @@ -445,7 +436,7 @@ int lc3plus_dec_get_delay(const LC3PLUS_Dec* decoder); * \param[in] frame_ms Frame length in ms. * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_dec_set_frame_dms(LC3PLUS_Dec *decoder, int frame_ms); +LC3PLUS_Error lc3plus_dec_set_frame_dms( LC3PLUS_Dec *decoder, int frame_ms ); /*! Free memory allocated within LC3plus decoder struct. @@ -453,14 +444,14 @@ LC3PLUS_Error lc3plus_dec_set_frame_dms(LC3PLUS_Dec *decoder, int frame_ms); * \param[in] decoder Decoder handle. * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_dec_free_memory(LC3PLUS_Dec* decoder); +LC3PLUS_Error lc3plus_dec_free_memory( LC3PLUS_Dec *decoder ); /*! Internal function called by lc3plus_dec_free_memory. * * \param[in] decoder Decoder handle. * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_free_decoder_structs(LC3PLUS_Dec* decoder); +LC3PLUS_Error lc3plus_free_decoder_structs( LC3PLUS_Dec *decoder ); /*! Enable or disable error protection. Default value is 0 (disabled). If error protection is * enabled, the decoder expects that the frames were encoded with error protection mode @@ -470,7 +461,7 @@ LC3PLUS_Error lc3plus_free_decoder_structs(LC3PLUS_Dec* decoder); * \param[in] ep_enabled 1 (or any nonzero) for true, 0 for false. * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_dec_set_ep_enabled(LC3PLUS_Dec *decoder, int ep_enabled); +LC3PLUS_Error lc3plus_dec_set_ep_enabled( LC3PLUS_Dec *decoder, int ep_enabled ); /*! Retrieves the error protection mode reqeust from channel decoder. * @@ -492,7 +483,7 @@ LC3PLUS_Error lc3plus_dec_set_ep_enabled(LC3PLUS_Dec *decoder, int ep_enabled); * \param[in] decoder Decoder handle. * \return Error protection mode reqeust. */ -LC3PLUS_EpModeRequest lc3plus_dec_get_ep_mode_request(const LC3PLUS_Dec *decoder); +LC3PLUS_EpModeRequest lc3plus_dec_get_ep_mode_request( const LC3PLUS_Dec *decoder ); /*! Get the number of corrected bit errors in the last decoded frame. This only works if * error protection is active. If the number of errors is greater than the current error @@ -502,7 +493,7 @@ LC3PLUS_EpModeRequest lc3plus_dec_get_ep_mode_request(const LC3PLUS_Dec *decoder * \param[in] decoder Decoder handle. * \return Number of corrected bits or -1. See description for details. */ -int lc3plus_dec_get_error_report(const LC3PLUS_Dec *decoder); +int lc3plus_dec_get_error_report( const LC3PLUS_Dec *decoder ); /*! This function returns an set of flags indicating whether the last frame * would have been channel decodable in epmode m, m ranging from 1 to 4. Note that * this information is not available in case the last frame was not channel @@ -511,7 +502,7 @@ int lc3plus_dec_get_error_report(const LC3PLUS_Dec *decoder); * Otherwise, if the frame would not have been decodable or if this information * cannot be retrieved, the m-1th bit of the return value will be 0. */ -int lc3plus_dec_get_epok_flags(const LC3PLUS_Dec *decoder); +int lc3plus_dec_get_epok_flags( const LC3PLUS_Dec *decoder ); /*! \} */ #endif /* LC3plus */ diff --git a/lib_lc3plus/lc3plus_fft.c b/lib_lc3plus/lc3plus_fft.c index 14f443f860..01e09ff8ab 100644 --- a/lib_lc3plus/lc3plus_fft.c +++ b/lib_lc3plus/lc3plus_fft.c @@ -1,11 +1,11 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ #include "options.h" @@ -14,86 +14,88 @@ #include "fft/iisfft.c" #include "fft/cfft.c" -void fft_init(Fft* fft, int length) +void fft_init( Fft *fft, int length ) { HANDLE_IIS_FFT handle = NULL; IIS_FFT_ERROR error = 0; - assert(length % 2 == 0); + assert( length % 2 == 0 ); fft->length = length; - error = LC3_IIS_CFFT_Create(&handle, length, IIS_FFT_FWD); + error = LC3_IIS_CFFT_Create( &handle, length, IIS_FFT_FWD ); - assert(error == IIS_FFT_NO_ERROR); + assert( error == IIS_FFT_NO_ERROR ); fft->handle = handle; } -void fft_free(Fft* fft) +void fft_free( Fft *fft ) { IIS_FFT_ERROR error = 0; - if (fft) { - error = LC3_IIS_CFFT_Destroy((HANDLE_IIS_FFT *) &fft->handle); + if ( fft ) + { + error = LC3_IIS_CFFT_Destroy( (HANDLE_IIS_FFT *) &fft->handle ); - assert(error == IIS_FFT_NO_ERROR); - memset(fft, 0, sizeof(*fft)); + assert( error == IIS_FFT_NO_ERROR ); + memset( fft, 0, sizeof( *fft ) ); } } -void real_fft_free(Fft* fft) +void real_fft_free( Fft *fft ) { IIS_FFT_ERROR error = 0; - if (fft) { - error = LC3_IIS_RFFT_Destroy((HANDLE_IIS_FFT *) &fft->handle); + if ( fft ) + { + error = LC3_IIS_RFFT_Destroy( (HANDLE_IIS_FFT *) &fft->handle ); - assert(error == IIS_FFT_NO_ERROR); - memset(fft, 0, sizeof(*fft)); + assert( error == IIS_FFT_NO_ERROR ); + memset( fft, 0, sizeof( *fft ) ); } } -void real_fft_init(Fft* fft, LC3_INT32 length, HANDLE_IIS_FFT *handle) +void real_fft_init( Fft *fft, LC3_INT32 length, HANDLE_IIS_FFT *handle ) { IIS_FFT_ERROR error = IIS_FFT_NO_ERROR; - assert(length % 4 == 0); /* due to current limitation of core complex FFTs*/ + assert( length % 4 == 0 ); /* due to current limitation of core complex FFTs*/ fft->length = length; - error = LC3_IIS_RFFT_Create(handle, length, IIS_FFT_FWD); - assert(error == IIS_FFT_NO_ERROR); + error = LC3_IIS_RFFT_Create( handle, length, IIS_FFT_FWD ); + assert( error == IIS_FFT_NO_ERROR ); fft->handle = *handle; } -void real_ifft_init(Fft* fft, LC3_INT32 length, HANDLE_IIS_FFT *handle) +void real_ifft_init( Fft *fft, LC3_INT32 length, HANDLE_IIS_FFT *handle ) { IIS_FFT_ERROR error = IIS_FFT_NO_ERROR; - assert(length % 4 == 0); /* due to current limitation of core complex FFTs*/ + assert( length % 4 == 0 ); /* due to current limitation of core complex FFTs*/ fft->length = length; - error = LC3_IIS_RFFT_Create(handle, length, IIS_FFT_BWD); + error = LC3_IIS_RFFT_Create( handle, length, IIS_FFT_BWD ); - assert(error == IIS_FFT_NO_ERROR); + assert( error == IIS_FFT_NO_ERROR ); fft->handle = *handle; } -void fft_apply(Fft* fft, const Complex* input, Complex* output) +void fft_apply( Fft *fft, const Complex *input, Complex *output ) { IIS_FFT_ERROR error = 0; - error = LC3_IIS_FFT_Apply_CFFT(fft->handle, input, output); + error = LC3_IIS_FFT_Apply_CFFT( fft->handle, input, output ); - assert(error == IIS_FFT_NO_ERROR); + assert( error == IIS_FFT_NO_ERROR ); } -void real_fft_apply(Fft* fft, const LC3_FLOAT* input, LC3_FLOAT* output) +void real_fft_apply( Fft *fft, const LC3_FLOAT *input, LC3_FLOAT *output ) { IIS_FFT_ERROR error = IIS_FFT_NO_ERROR; - UNUSED(error); + UNUSED( error ); - error = LC3_IIS_FFT_Apply_RFFT(fft->handle, input, output); + error = LC3_IIS_FFT_Apply_RFFT( fft->handle, input, output ); - assert(error == IIS_FFT_NO_ERROR); + assert( error == IIS_FFT_NO_ERROR ); } diff --git a/lib_lc3plus/license.h b/lib_lc3plus/license.h index d9d6c89675..513b89d7c7 100644 --- a/lib_lc3plus/license.h +++ b/lib_lc3plus/license.h @@ -1,12 +1,12 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "defines.h" diff --git a/lib_lc3plus/ltpf_coder.c b/lib_lc3plus/ltpf_coder.c index fac8c481c0..14262cbba6 100644 --- a/lib_lc3plus/ltpf_coder.c +++ b/lib_lc3plus/ltpf_coder.c @@ -1,30 +1,33 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -static LC3_INT searchMaxIndice(LC3_FLOAT* in, LC3_INT len); +static LC3_INT searchMaxIndice( LC3_FLOAT *in, LC3_INT len ); -LC3_INT searchMaxIndice(LC3_FLOAT* in, LC3_INT len) +LC3_INT searchMaxIndice( LC3_FLOAT *in, LC3_INT len ) { - LC3_INT max_i = 0, i = 0; + LC3_INT max_i = 0, i = 0; LC3_FLOAT max = 0; - if (len <= 0) { + if ( len <= 0 ) + { return -128; } - for (i = 0; i < len; i++) { - if (in[i] > max) { - max = in[i]; + for ( i = 0; i < len; i++ ) + { + if ( in[i] > max ) + { + max = in[i]; max_i = i; } } @@ -32,42 +35,41 @@ LC3_INT searchMaxIndice(LC3_FLOAT* in, LC3_INT len) return max_i; } -void process_ltpf_coder_fl(LC3_FLOAT* xin, LC3_INT xLen, LC3_INT ltpf_enable, LC3_INT pitch_ol, LC3_FLOAT pitch_ol_norm_corr, LC3_INT frame_dms, - LC3_FLOAT* mem_old_x, LC3_INT memLen, LC3_FLOAT* mem_norm_corr_past, LC3_INT* mem_on, LC3_FLOAT* mem_pitch, - LC3_INT* param, LC3_FLOAT* mem_norm_corr_past_past, LC3_INT* bits) +void process_ltpf_coder_fl( LC3_FLOAT *xin, LC3_INT xLen, LC3_INT ltpf_enable, LC3_INT pitch_ol, LC3_FLOAT pitch_ol_norm_corr, LC3_INT frame_dms, LC3_FLOAT *mem_old_x, LC3_INT memLen, LC3_FLOAT *mem_norm_corr_past, LC3_INT *mem_on, LC3_FLOAT *mem_pitch, LC3_INT *param, LC3_FLOAT *mem_norm_corr_past_past, LC3_INT *bits ) { - LC3_FLOAT buffer[LTPF_MEMIN_LEN + LEN_12K8 + 1 + (LEN_12K8 >> 2)] = {0}, sum = 0, buf_tmp[MAX_LEN] = {0}, cor_up[MAX_LEN] = {0}, *x; - LC3_INT i = 0, j = 0, k = 0, n = 0, step = 0, N = 0, ltpf_active = 0, pitch_search_delta = 0, - pitch_search_upsamp = 0, pitch_search_L_interpol1 = 0, - t0_min = 0, t0_max = 0, t_min = 0, t_max = 0, temp2 = 0, t1 = 0, pitch_int = 0, pitch_fr = 0, midpoint = 0, - delta_up = 0, delta_down = 0, pitch_index = 0, gain = 0, acflen = 0; - LC3_FLOAT norm_corr = 0, cor[MAX_LEN] = {0}, cor_int[MAX_LEN] = {0}, currFrame[MAX_LEN] = {0}, predFrame[MAX_LEN] = {0}, sum1 = 0, sum2 = 0, sum3 = 0; + LC3_FLOAT buffer[LTPF_MEMIN_LEN + LEN_12K8 + 1 + ( LEN_12K8 >> 2 )] = { 0 }, sum = 0, buf_tmp[MAX_LEN] = { 0 }, cor_up[MAX_LEN] = { 0 }, *x; + LC3_INT i = 0, j = 0, k = 0, n = 0, step = 0, N = 0, ltpf_active = 0, pitch_search_delta = 0, + pitch_search_upsamp = 0, pitch_search_L_interpol1 = 0, + t0_min = 0, t0_max = 0, t_min = 0, t_max = 0, temp2 = 0, t1 = 0, pitch_int = 0, pitch_fr = 0, midpoint = 0, + delta_up = 0, delta_down = 0, pitch_index = 0, gain = 0, acflen = 0; + LC3_FLOAT norm_corr = 0, cor[MAX_LEN] = { 0 }, cor_int[MAX_LEN] = { 0 }, currFrame[MAX_LEN] = { 0 }, predFrame[MAX_LEN] = { 0 }, sum1 = 0, sum2 = 0, sum3 = 0; LC3_FLOAT pitch = 0; /* Signal Buffer */ N = xLen - 1; x = &buffer[memLen]; - move_float(buffer, mem_old_x, memLen); - move_float(x, xin, xLen); - move_float(mem_old_x, &buffer[N], xLen + memLen - N); + move_float( buffer, mem_old_x, memLen ); + move_float( x, xin, xLen ); + move_float( mem_old_x, &buffer[N], xLen + memLen - N ); ltpf_active = 0; - norm_corr = 0; + norm_corr = 0; - pitch_search_delta = 4; - pitch_search_upsamp = 4; + pitch_search_delta = 4; + pitch_search_upsamp = 4; pitch_search_L_interpol1 = 4; - if (pitch_ol_norm_corr > 0.6) { + if ( pitch_ol_norm_corr > 0.6 ) + { /* Search Bounds */ t0_min = pitch_ol - pitch_search_delta; t0_max = pitch_ol + pitch_search_delta; - t0_min = MAX(t0_min, MIN_PITCH_12K8); - t0_max = MIN(t0_max, MAX_PITCH_12K8); + t0_min = MAX( t0_min, MIN_PITCH_12K8 ); + t0_max = MIN( t0_max, MAX_PITCH_12K8 ); acflen = N; - - if (frame_dms == 25) + + if ( frame_dms == 25 ) { acflen = 2 * N; x = x - N; @@ -79,59 +81,68 @@ void process_ltpf_coder_fl(LC3_FLOAT* xin, LC3_INT xLen, LC3_INT ltpf_enable, LC /* Compute norm */ sum1 = sum2 = 0; - for (j = 0; j < acflen; j++) { + for ( j = 0; j < acflen; j++ ) + { sum1 += x[j] * x[j]; sum2 += x[j - t_min] * x[j - t_min]; } /* Compute Cross-Correlation */ - for (i = t_min; i <= t_max; i++) { + for ( i = t_min; i <= t_max; i++ ) + { sum = 0; - for (j = 0; j < acflen; j++) { + for ( j = 0; j < acflen; j++ ) + { sum += x[j] * x[j - i]; } - if (i > t_min) { - sum2 = sum2 + x[-i]*x[-i] - - x[acflen - 1 - ( i - 1 )]*x[acflen - 1 - ( i - 1 )]; + if ( i > t_min ) + { + sum2 = sum2 + x[-i] * x[-i] - x[acflen - 1 - ( i - 1 )] * x[acflen - 1 - ( i - 1 )]; } - sum3 = LC3_SQRT(sum1 * sum2) + LC3_POW(10, -5); + sum3 = LC3_SQRT( sum1 * sum2 ) + LC3_POW( 10, -5 ); norm_corr = sum / sum3; - - norm_corr = MAX(0, norm_corr); - cor[i - t_min] = norm_corr; + norm_corr = MAX( 0, norm_corr ); + cor[i - t_min] = norm_corr; } /* Find Integer Pitch-Lag */ j = 0; - for (i = pitch_search_L_interpol1; i <= t_max - t_min - pitch_search_L_interpol1; i++) { + for ( i = pitch_search_L_interpol1; i <= t_max - t_min - pitch_search_L_interpol1; i++ ) + { buf_tmp[j] = cor[i]; j++; } - temp2 = searchMaxIndice(buf_tmp, j); + temp2 = searchMaxIndice( buf_tmp, j ); t1 = temp2 + t0_min; - assert(t1 >= t0_min && t1 <= t0_max); + assert( t1 >= t0_min && t1 <= t0_max ); /* Find Fractional Pitch-Lag */ - if (t1 >= RES2_PITCH_12K8) { + if ( t1 >= RES2_PITCH_12K8 ) + { pitch_int = t1; - pitch_fr = 0; - } else { + pitch_fr = 0; + } + else + { j = 0; - - for (i = 0; i < pitch_search_upsamp * (t_max - t_min) + 1; i = i + pitch_search_upsamp) { + + for ( i = 0; i < pitch_search_upsamp * ( t_max - t_min ) + 1; i = i + pitch_search_upsamp ) + { cor_up[i] = cor[j]; j++; } - for (i = 0; i < pitch_search_upsamp * (t0_max - t0_min + 1); i++) { + for ( i = 0; i < pitch_search_upsamp * ( t0_max - t0_min + 1 ); i++ ) + { sum = 0; k = 0; - for (j = i; j < i + 32; j++) { + for ( j = i; j < i + 32; j++ ) + { sum += cor_up[j] * inter4_1[k]; k++; } @@ -139,63 +150,78 @@ void process_ltpf_coder_fl(LC3_FLOAT* xin, LC3_INT xLen, LC3_INT ltpf_enable, LC cor_int[i] = sum; } - if (t1 >= RES4_PITCH_12K8) { + if ( t1 >= RES4_PITCH_12K8 ) + { step = 2; - } else { + } + else + { step = 1; } - midpoint = pitch_search_upsamp * (t1 - t0_min) + 1; + midpoint = pitch_search_upsamp * ( t1 - t0_min ) + 1; delta_up = pitch_search_upsamp - step; - if (t1 == t0_min) { + if ( t1 == t0_min ) + { delta_down = 0; - } else { + } + else + { delta_down = pitch_search_upsamp - step; } j = 0; - for (i = midpoint - delta_down - 1; i <= midpoint + delta_up; i = i + step) { + for ( i = midpoint - delta_down - 1; i <= midpoint + delta_up; i = i + step ) + { buf_tmp[j] = cor_int[i]; j++; } - temp2 = searchMaxIndice(buf_tmp, ((midpoint + delta_up) - (midpoint - delta_down)) / step + 1); + temp2 = searchMaxIndice( buf_tmp, ( ( midpoint + delta_up ) - ( midpoint - delta_down ) ) / step + 1 ); pitch_fr = temp2 * step - delta_down; - if (pitch_fr >= 0) { + if ( pitch_fr >= 0 ) + { pitch_int = t1; - } else { + } + else + { pitch_int = t1 - 1; - pitch_fr = pitch_search_upsamp + pitch_fr; + pitch_fr = pitch_search_upsamp + pitch_fr; } } - assert((pitch_int <= MAX_PITCH_12K8 && pitch_int >= RES2_PITCH_12K8 && pitch_fr == 0) || - (pitch_int < RES2_PITCH_12K8 && pitch_int >= RES4_PITCH_12K8 && (pitch_fr == 0 || pitch_fr == 2)) || - (pitch_int < RES4_PITCH_12K8 && pitch_int >= MIN_PITCH_12K8 && - (pitch_fr == 0 || pitch_fr == 1 || pitch_fr == 2 || pitch_fr == 3))); - - if (pitch_int < RES4_PITCH_12K8) { - pitch_index = pitch_int * 4 + pitch_fr - (MIN_PITCH_12K8 * 4); - } else if (pitch_int < RES2_PITCH_12K8) { - pitch_index = pitch_int * 2 + floor(pitch_fr / 2) - (RES4_PITCH_12K8 * 2) + ((RES4_PITCH_12K8 - MIN_PITCH_12K8) * 4); - } else { - pitch_index = pitch_int - RES2_PITCH_12K8 + ((RES4_PITCH_12K8 - MIN_PITCH_12K8) * 4) + ((RES2_PITCH_12K8 - RES4_PITCH_12K8) * 2); + assert( ( pitch_int <= MAX_PITCH_12K8 && pitch_int >= RES2_PITCH_12K8 && pitch_fr == 0 ) || + ( pitch_int < RES2_PITCH_12K8 && pitch_int >= RES4_PITCH_12K8 && ( pitch_fr == 0 || pitch_fr == 2 ) ) || + ( pitch_int < RES4_PITCH_12K8 && pitch_int >= MIN_PITCH_12K8 && + ( pitch_fr == 0 || pitch_fr == 1 || pitch_fr == 2 || pitch_fr == 3 ) ) ); + + if ( pitch_int < RES4_PITCH_12K8 ) + { + pitch_index = pitch_int * 4 + pitch_fr - ( MIN_PITCH_12K8 * 4 ); + } + else if ( pitch_int < RES2_PITCH_12K8 ) + { + pitch_index = pitch_int * 2 + floor( pitch_fr / 2 ) - ( RES4_PITCH_12K8 * 2 ) + ( ( RES4_PITCH_12K8 - MIN_PITCH_12K8 ) * 4 ); + } + else + { + pitch_index = pitch_int - RES2_PITCH_12K8 + ( ( RES4_PITCH_12K8 - MIN_PITCH_12K8 ) * 4 ) + ( ( RES2_PITCH_12K8 - RES4_PITCH_12K8 ) * 2 ); } - assert(pitch_index >= 0 && pitch_index < 512); + assert( pitch_index >= 0 && pitch_index < 512 ); pitch = (LC3_FLOAT) pitch_int + (LC3_FLOAT) pitch_fr / 4.0; - - for (n = 0; n < acflen; n++) + + for ( n = 0; n < acflen; n++ ) { currFrame[n] = x[n + 1] * enc_inter_filter[0][0] + - x[n] * enc_inter_filter[0][1] + + x[n] * enc_inter_filter[0][1] + x[n - 1] * enc_inter_filter[0][2]; predFrame[n] = x[n - pitch_int + 1] * enc_inter_filter[pitch_fr][0] + - x[n - pitch_int] * enc_inter_filter[pitch_fr][1] + + x[n - pitch_int] * enc_inter_filter[pitch_fr][1] + x[n - pitch_int - 1] * enc_inter_filter[pitch_fr][2] + x[n - pitch_int - 2] * enc_inter_filter[pitch_fr][3]; } @@ -203,62 +229,73 @@ void process_ltpf_coder_fl(LC3_FLOAT* xin, LC3_INT xLen, LC3_INT ltpf_enable, LC /* Normalized Correlation */ sum1 = sum2 = sum3 = 0; - for (i = 0; i < acflen; i++) { + for ( i = 0; i < acflen; i++ ) + { sum1 += currFrame[i] * predFrame[i]; } - for (i = 0; i < acflen; i++) { + for ( i = 0; i < acflen; i++ ) + { sum2 += currFrame[i] * currFrame[i]; } - for (i = 0; i < acflen; i++) { + for ( i = 0; i < acflen; i++ ) + { sum3 += predFrame[i] * predFrame[i]; } - sum2 = LC3_SQRT(sum2 * sum3) + LC3_POW(10, -5); + sum2 = LC3_SQRT( sum2 * sum3 ) + LC3_POW( 10, -5 ); norm_corr = sum1 / sum2; - assert(norm_corr >= -1.00001 && norm_corr <= 1.00001); - norm_corr = MIN(1, MAX(-1, norm_corr)); - if (norm_corr < 0) { + assert( norm_corr >= -1.00001 && norm_corr <= 1.00001 ); + norm_corr = MIN( 1, MAX( -1, norm_corr ) ); + if ( norm_corr < 0 ) + { norm_corr = 0; } - if (ltpf_enable == 1) { + if ( ltpf_enable == 1 ) + { /* Decision if ltpf active */ - if ((*mem_on == 0 && (frame_dms == 100 || *mem_norm_corr_past_past > 0.94) && *mem_norm_corr_past > 0.94 && - norm_corr > 0.94) || - (*mem_on == 1 && norm_corr > 0.9) || - (*mem_on == 1 && LC3_FABS(pitch - *mem_pitch) < 2 && (norm_corr - *mem_norm_corr_past) > -0.1 && - norm_corr > 0.84)) { + if ( ( *mem_on == 0 && ( frame_dms == 100 || *mem_norm_corr_past_past > 0.94 ) && *mem_norm_corr_past > 0.94 && + norm_corr > 0.94 ) || + ( *mem_on == 1 && norm_corr > 0.9 ) || + ( *mem_on == 1 && LC3_FABS( pitch - *mem_pitch ) < 2 && ( norm_corr - *mem_norm_corr_past ) > -0.1 && + norm_corr > 0.84 ) ) + { ltpf_active = 1; } } gain = 4; - - } else { - gain = 0; + } + else + { + gain = 0; norm_corr = pitch_ol_norm_corr; - pitch = 0; + pitch = 0; } - if (gain > 0) { + if ( gain > 0 ) + { param[0] = 1; param[1] = ltpf_active; param[2] = pitch_index; - *bits = 11; - } else { - zero_int(param, 3); + *bits = 11; + } + else + { + zero_int( param, 3 ); *bits = 1; } - if (frame_dms < 100) { + if ( frame_dms < 100 ) + { *mem_norm_corr_past_past = *mem_norm_corr_past; } *mem_norm_corr_past = norm_corr; - *mem_on = ltpf_active; - *mem_pitch = pitch; + *mem_on = ltpf_active; + *mem_pitch = pitch; } diff --git a/lib_lc3plus/ltpf_decoder.c b/lib_lc3plus/ltpf_decoder.c index a40c85213a..6ce7797193 100644 --- a/lib_lc3plus/ltpf_decoder.c +++ b/lib_lc3plus/ltpf_decoder.c @@ -1,211 +1,239 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT fs, LC3_FLOAT* mem_old_x, LC3_FLOAT* mem_old_y, - LC3_INT* mem_pitch_int, LC3_INT* mem_pitch_fr, LC3_FLOAT* mem_gain, LC3_INT* mem_beta_idx, LC3_INT bfi, - LC3_INT* param, LC3_INT* mem_param, LC3_INT conf_beta_idx, LC3_FLOAT conf_beta, LC3_INT concealMethod, - LC3_FLOAT damping - , LC3_INT *mem_ltpf_active -) +void process_ltpf_decoder_fl( LC3_FLOAT *x, LC3_INT xLen, LC3_FLOAT *y, LC3_INT fs, LC3_FLOAT *mem_old_x, LC3_FLOAT *mem_old_y, LC3_INT *mem_pitch_int, LC3_INT *mem_pitch_fr, LC3_FLOAT *mem_gain, LC3_INT *mem_beta_idx, LC3_INT bfi, LC3_INT *param, LC3_INT *mem_param, LC3_INT conf_beta_idx, LC3_FLOAT conf_beta, LC3_INT concealMethod, LC3_FLOAT damping, LC3_INT *mem_ltpf_active ) { LC3_INT i = 0, j = 0, n = 0, N = 0, L_past_x = 0, N4 = 0, N34 = 0, - pitch_int = 0, pitch_fr = 0, p1 = 0, p2 = 0, L_past_y = 0, inter_len = 0, tilt_len = 0, - tilt_len_r = 0, inter_len_r = 0, old_x_len = 0, old_y_len = 0; + pitch_int = 0, pitch_fr = 0, p1 = 0, p2 = 0, L_past_y = 0, inter_len = 0, tilt_len = 0, + tilt_len_r = 0, inter_len_r = 0, old_x_len = 0, old_y_len = 0; - LC3_FLOAT conf_alpha = 0, gain = 0, a1[MAX_LEN] = {0}, a2[MAX_LEN] = {0}, b1[MAX_LEN] = {0}, b2[MAX_LEN] = {0}, - buf_x[4 * MAX_LEN] = {0}, buf_y[4 * MAX_LEN] = {0}, buf_z[4 * MAX_LEN] = {0}, pitch = 0, sum1 = 0, sum2 = 0; + LC3_FLOAT conf_alpha = 0, gain = 0, a1[MAX_LEN] = { 0 }, a2[MAX_LEN] = { 0 }, b1[MAX_LEN] = { 0 }, b2[MAX_LEN] = { 0 }, + buf_x[4 * MAX_LEN] = { 0 }, buf_y[4 * MAX_LEN] = { 0 }, buf_z[4 * MAX_LEN] = { 0 }, pitch = 0, sum1 = 0, sum2 = 0; const LC3_FLOAT *inter_filter[4], *tilt_filter[4]; conf_alpha = 0.85; - if (bfi != 1) { + if ( bfi != 1 ) + { /* Decode pitch */ - if (param[0] == 1) { - if (param[2] < (RES4_PITCH_12K8 - MIN_PITCH_12K8) * 4) { - pitch_int = MIN_PITCH_12K8 + floor(param[2] / 4); - pitch_fr = param[2] - ((pitch_int - MIN_PITCH_12K8) * 4); - } else if (param[2] < ((RES4_PITCH_12K8 - MIN_PITCH_12K8) * 4) + ((RES2_PITCH_12K8 - RES4_PITCH_12K8) * 2)) { - param[2] = param[2] - ((RES4_PITCH_12K8 - MIN_PITCH_12K8) * 4); - pitch_int = RES4_PITCH_12K8 + floor(param[2] / 2); - pitch_fr = param[2] - ((pitch_int - RES4_PITCH_12K8) * 2); - pitch_fr = pitch_fr * 2; - } else { + if ( param[0] == 1 ) + { + if ( param[2] < ( RES4_PITCH_12K8 - MIN_PITCH_12K8 ) * 4 ) + { + pitch_int = MIN_PITCH_12K8 + floor( param[2] / 4 ); + pitch_fr = param[2] - ( ( pitch_int - MIN_PITCH_12K8 ) * 4 ); + } + else if ( param[2] < ( ( RES4_PITCH_12K8 - MIN_PITCH_12K8 ) * 4 ) + ( ( RES2_PITCH_12K8 - RES4_PITCH_12K8 ) * 2 ) ) + { + param[2] = param[2] - ( ( RES4_PITCH_12K8 - MIN_PITCH_12K8 ) * 4 ); + pitch_int = RES4_PITCH_12K8 + floor( param[2] / 2 ); + pitch_fr = param[2] - ( ( pitch_int - RES4_PITCH_12K8 ) * 2 ); + pitch_fr = pitch_fr * 2; + } + else + { pitch_int = - param[2] + (RES2_PITCH_12K8 - ((RES4_PITCH_12K8 - MIN_PITCH_12K8) * 4) - ((RES2_PITCH_12K8 - RES4_PITCH_12K8) * 2)); + param[2] + ( RES2_PITCH_12K8 - ( ( RES4_PITCH_12K8 - MIN_PITCH_12K8 ) * 4 ) - ( ( RES2_PITCH_12K8 - RES4_PITCH_12K8 ) * 2 ) ); pitch_fr = 0; } - pitch = ((LC3_FLOAT)pitch_int + (LC3_FLOAT)pitch_fr / 4.0) * (LC3_FLOAT)fs / 12800.0; - pitch = round(pitch * 4.0) / 4.0; - pitch_int = floor(pitch); - pitch_fr = (LC3_INT)((pitch - (LC3_FLOAT)pitch_int) * 4.0); - } else { + pitch = ( (LC3_FLOAT) pitch_int + (LC3_FLOAT) pitch_fr / 4.0 ) * (LC3_FLOAT) fs / 12800.0; + pitch = round( pitch * 4.0 ) / 4.0; + pitch_int = floor( pitch ); + pitch_fr = (LC3_INT) ( ( pitch - (LC3_FLOAT) pitch_int ) * 4.0 ); + } + else + { pitch_int = 0; - pitch_fr = 0; + pitch_fr = 0; } /* Decode gain */ - if (conf_beta_idx < 0) { + if ( conf_beta_idx < 0 ) + { param[1] = 0; } - if (param[1] == 1) { + if ( param[1] == 1 ) + { gain = conf_beta; - } else { + } + else + { gain = 0; } } - else if (concealMethod > 0) { - if (conf_beta_idx < 0) { - if (mem_param[1] && *mem_beta_idx >= 0) + else if ( concealMethod > 0 ) + { + if ( conf_beta_idx < 0 ) + { + if ( mem_param[1] && *mem_beta_idx >= 0 ) { conf_beta_idx = *mem_beta_idx; } } - memmove(param, mem_param, sizeof(LC3_INT32) * 3); - if (concealMethod == 2) + memmove( param, mem_param, sizeof( LC3_INT32 ) * 3 ); + if ( concealMethod == 2 ) { /* cause the ltpf to "fade_out" and only filter during initial 2.5 ms and then its buffer during 7.5 ms */ - assert(bfi == 1); + assert( bfi == 1 ); param[1] = 0; /* ltpf_active = 0 */ } pitch_int = *mem_pitch_int; - pitch_fr = *mem_pitch_fr; - gain = (LC3_FLOAT) *mem_gain * damping; + pitch_fr = *mem_pitch_fr; + gain = (LC3_FLOAT) *mem_gain * damping; } - if ((conf_beta <= 0) && (*mem_ltpf_active == 0)) + if ( ( conf_beta <= 0 ) && ( *mem_ltpf_active == 0 ) ) + { + if ( fs == 8000 || fs == 16000 ) { - if (fs == 8000 || fs == 16000) { - tilt_len = 4 - 2; - } - else if (fs == 24000) { - tilt_len = 6 - 2; - } - else if (fs == 32000) { - tilt_len = 8 - 2; - } - else if (fs == 44100 || fs == 48000) { - tilt_len = 12 - 2; - } + tilt_len = 4 - 2; + } + else if ( fs == 24000 ) + { + tilt_len = 6 - 2; + } + else if ( fs == 32000 ) + { + tilt_len = 8 - 2; + } + else if ( fs == 44100 || fs == 48000 ) + { + tilt_len = 12 - 2; + } - N = xLen; - old_x_len = tilt_len; - inter_len = MAX(fs, 16000) / 8000; - old_y_len = ceilf((LC3_FLOAT)228.0 * fs / 12800.0) + inter_len; /* 228.0 needed to make use of ceil */ + N = xLen; + old_x_len = tilt_len; + inter_len = MAX( fs, 16000 ) / 8000; + old_y_len = ceilf( (LC3_FLOAT) 228.0 * fs / 12800.0 ) + inter_len; /* 228.0 needed to make use of ceil */ - move_float(mem_old_y, &mem_old_y[N], (old_y_len - N)); - move_float(&mem_old_y[old_y_len - N], x, N); - move_float(mem_old_x, &x[N - old_x_len], old_x_len); + move_float( mem_old_y, &mem_old_y[N], ( old_y_len - N ) ); + move_float( &mem_old_y[old_y_len - N], x, N ); + move_float( mem_old_x, &x[N - old_x_len], old_x_len ); - *mem_ltpf_active = 0; - } - else + *mem_ltpf_active = 0; + } + else + { + inter_len_r = 0; + tilt_len_r = 0; + if ( fs == 8000 || fs == 16000 ) { - inter_len_r = 0; tilt_len_r = 0; - if (fs == 8000 || fs == 16000) { inter_filter[0] = conf_inter_filter_16[0]; inter_filter[1] = conf_inter_filter_16[1]; inter_filter[2] = conf_inter_filter_16[2]; inter_filter[3] = conf_inter_filter_16[3]; - inter_len_r = 4; + inter_len_r = 4; tilt_filter[0] = conf_tilt_filter_16[0]; tilt_filter[1] = conf_tilt_filter_16[1]; tilt_filter[2] = conf_tilt_filter_16[2]; tilt_filter[3] = conf_tilt_filter_16[3]; - tilt_len = 4 - 2; - tilt_len_r = 3; - } else if (fs == 24000) { + tilt_len = 4 - 2; + tilt_len_r = 3; + } + else if ( fs == 24000 ) + { inter_filter[0] = conf_inter_filter_24[0]; inter_filter[1] = conf_inter_filter_24[1]; inter_filter[2] = conf_inter_filter_24[2]; inter_filter[3] = conf_inter_filter_24[3]; - inter_len_r = 6; + inter_len_r = 6; tilt_filter[0] = conf_tilt_filter_24[0]; tilt_filter[1] = conf_tilt_filter_24[1]; tilt_filter[2] = conf_tilt_filter_24[2]; tilt_filter[3] = conf_tilt_filter_24[3]; - tilt_len = 6 - 2; - tilt_len_r = 5; - } else if (fs == 32000) { + tilt_len = 6 - 2; + tilt_len_r = 5; + } + else if ( fs == 32000 ) + { inter_filter[0] = conf_inter_filter_32[0]; inter_filter[1] = conf_inter_filter_32[1]; inter_filter[2] = conf_inter_filter_32[2]; inter_filter[3] = conf_inter_filter_32[3]; - inter_len_r = 8; + inter_len_r = 8; tilt_filter[0] = conf_tilt_filter_32[0]; tilt_filter[1] = conf_tilt_filter_32[1]; tilt_filter[2] = conf_tilt_filter_32[2]; tilt_filter[3] = conf_tilt_filter_32[3]; - tilt_len = 8 - 2; - tilt_len_r = 7; - } else if (fs == 44100 || fs == 48000) { + tilt_len = 8 - 2; + tilt_len_r = 7; + } + else if ( fs == 44100 || fs == 48000 ) + { inter_filter[0] = conf_inter_filter_48[0]; inter_filter[1] = conf_inter_filter_48[1]; inter_filter[2] = conf_inter_filter_48[2]; inter_filter[3] = conf_inter_filter_48[3]; - inter_len_r = 12; + inter_len_r = 12; tilt_filter[0] = conf_tilt_filter_48[0]; tilt_filter[1] = conf_tilt_filter_48[1]; tilt_filter[2] = conf_tilt_filter_48[2]; tilt_filter[3] = conf_tilt_filter_48[3]; - tilt_len = 12 - 2; - tilt_len_r = 11; + tilt_len = 12 - 2; + tilt_len_r = 11; } - inter_len = MAX(fs, 16000) / 8000; + inter_len = MAX( fs, 16000 ) / 8000; /* Init buffers */ - N = xLen; + N = xLen; old_x_len = tilt_len; - old_y_len = ceilf(228.0 * fs / 12800.0) + inter_len; + old_y_len = ceilf( 228.0 * fs / 12800.0 ) + inter_len; L_past_x = old_x_len; - move_float(buf_x, mem_old_x, old_x_len); - move_float(&buf_x[old_x_len], x, xLen); + move_float( buf_x, mem_old_x, old_x_len ); + move_float( &buf_x[old_x_len], x, xLen ); L_past_y = old_y_len; - move_float(buf_y, mem_old_y, old_y_len); - zero_float(&buf_y[old_y_len], xLen); + move_float( buf_y, mem_old_y, old_y_len ); + zero_float( &buf_y[old_y_len], xLen ); - N4 = fs * 0.0025; + N4 = fs * 0.0025; N34 = N - N4; /* Init filter parameters */ - if (mem_param[1] == 1) { - for (i = 0; i < inter_len_r; i++) { + if ( mem_param[1] == 1 ) + { + for ( i = 0; i < inter_len_r; i++ ) + { a1[i] = *mem_gain * inter_filter[*mem_pitch_fr][i]; } - for (i = 0; i < tilt_len_r; i++) { - b1[i] = conf_alpha * (*mem_gain) * tilt_filter[*mem_beta_idx][i]; + for ( i = 0; i < tilt_len_r; i++ ) + { + b1[i] = conf_alpha * ( *mem_gain ) * tilt_filter[*mem_beta_idx][i]; } p1 = *mem_pitch_int; } - if (param[1] == 1) { - for (i = 0; i < tilt_len_r; i++) { + if ( param[1] == 1 ) + { + for ( i = 0; i < tilt_len_r; i++ ) + { b2[i] = conf_alpha * gain * tilt_filter[conf_beta_idx][i]; } - for (i = 0; i < inter_len_r; i++) { + for ( i = 0; i < inter_len_r; i++ ) + { a2[i] = gain * inter_filter[pitch_fr][i]; } @@ -213,122 +241,150 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f } /* First quarter of the current frame: cross-fading */ - if (mem_param[1] == 0 && param[1] == 0) { - memmove(&buf_y[L_past_y], &buf_x[L_past_x], sizeof(LC3_FLOAT) * N4); - - } else if (mem_param[1] == 1 && param[1] == 0) { - for (n = 0; n < N4; n++) { + if ( mem_param[1] == 0 && param[1] == 0 ) + { + memmove( &buf_y[L_past_y], &buf_x[L_past_x], sizeof( LC3_FLOAT ) * N4 ); + } + else if ( mem_param[1] == 1 && param[1] == 0 ) + { + for ( n = 0; n < N4; n++ ) + { sum1 = 0; sum2 = 0; - j = 0; - for (i = L_past_x + n; i >= L_past_x + n - tilt_len; i--) { + j = 0; + for ( i = L_past_x + n; i >= L_past_x + n - tilt_len; i-- ) + { sum1 += b1[j] * buf_x[i]; j++; } j = 0; - for (i = L_past_y + n - p1 + inter_len - 1; i >= L_past_y + n - p1 - inter_len; i--) { + for ( i = L_past_y + n - p1 + inter_len - 1; i >= L_past_y + n - p1 - inter_len; i-- ) + { sum2 += a1[j] * buf_y[i]; j++; } - buf_y[L_past_y + n] = buf_x[L_past_x + n] - (((LC3_FLOAT)N4 - (LC3_FLOAT)n) / (LC3_FLOAT)N4) * sum1 + - (((LC3_FLOAT)N4 - (LC3_FLOAT)n) / (LC3_FLOAT)N4) * sum2; + buf_y[L_past_y + n] = buf_x[L_past_x + n] - ( ( (LC3_FLOAT) N4 - (LC3_FLOAT) n ) / (LC3_FLOAT) N4 ) * sum1 + + ( ( (LC3_FLOAT) N4 - (LC3_FLOAT) n ) / (LC3_FLOAT) N4 ) * sum2; } - - } else if (mem_param[1] == 0 && param[1] == 1) { - for (n = 0; n < N4; n++) { + } + else if ( mem_param[1] == 0 && param[1] == 1 ) + { + for ( n = 0; n < N4; n++ ) + { sum1 = 0; sum2 = 0; - j = 0; - for (i = L_past_x + n; i >= L_past_x + n - tilt_len; i--) { + j = 0; + for ( i = L_past_x + n; i >= L_past_x + n - tilt_len; i-- ) + { sum1 += b2[j] * buf_x[i]; j++; } j = 0; - for (i = L_past_y + n - p2 + inter_len - 1; i >= L_past_y + n - p2 - inter_len; i--) { + for ( i = L_past_y + n - p2 + inter_len - 1; i >= L_past_y + n - p2 - inter_len; i-- ) + { sum2 += a2[j] * buf_y[i]; j++; } - buf_y[L_past_y + n] = buf_x[L_past_x + n] - ((LC3_FLOAT)n / (LC3_FLOAT)N4) * sum1 + ((LC3_FLOAT)n / (LC3_FLOAT)N4) * sum2; + buf_y[L_past_y + n] = buf_x[L_past_x + n] - ( (LC3_FLOAT) n / (LC3_FLOAT) N4 ) * sum1 + ( (LC3_FLOAT) n / (LC3_FLOAT) N4 ) * sum2; } - } else if (*mem_pitch_int == pitch_int && *mem_pitch_fr == pitch_fr) { - for (n = 0; n < N4; n++) { + } + else if ( *mem_pitch_int == pitch_int && *mem_pitch_fr == pitch_fr ) + { + for ( n = 0; n < N4; n++ ) + { sum1 = 0; sum2 = 0; - j = 0; - for (i = L_past_x + n; i >= L_past_x + n - tilt_len; i--) { + j = 0; + for ( i = L_past_x + n; i >= L_past_x + n - tilt_len; i-- ) + { sum1 += b2[j] * buf_x[i]; j++; } j = 0; - for (i = L_past_y + n - p2 + inter_len - 1; i >= L_past_y + n - p2 - inter_len; i--) { + for ( i = L_past_y + n - p2 + inter_len - 1; i >= L_past_y + n - p2 - inter_len; i-- ) + { sum2 += a2[j] * buf_y[i]; j++; } buf_y[L_past_y + n] = buf_x[L_past_x + n] - sum1 + sum2; } - } else { - for (n = 0; n < N4; n++) { + } + else + { + for ( n = 0; n < N4; n++ ) + { sum1 = 0; sum2 = 0; - j = 0; - for (i = L_past_x + n; i >= L_past_x + n - tilt_len; i--) { + j = 0; + for ( i = L_past_x + n; i >= L_past_x + n - tilt_len; i-- ) + { sum1 += b1[j] * buf_x[i]; j++; } j = 0; - for (i = L_past_y + n - p1 + inter_len - 1; i >= L_past_y + n - p1 - inter_len; i--) { + for ( i = L_past_y + n - p1 + inter_len - 1; i >= L_past_y + n - p1 - inter_len; i-- ) + { sum2 += a1[j] * buf_y[i]; j++; } - buf_y[L_past_y + n] = buf_x[L_past_x + n] - (((LC3_FLOAT)N4 - (LC3_FLOAT)n) / (LC3_FLOAT)N4) * sum1 + - (((LC3_FLOAT)N4 - (LC3_FLOAT)n) / (LC3_FLOAT)N4) * sum2; + buf_y[L_past_y + n] = buf_x[L_past_x + n] - ( ( (LC3_FLOAT) N4 - (LC3_FLOAT) n ) / (LC3_FLOAT) N4 ) * sum1 + + ( ( (LC3_FLOAT) N4 - (LC3_FLOAT) n ) / (LC3_FLOAT) N4 ) * sum2; } - memmove(buf_z, buf_y, sizeof(LC3_FLOAT) * 4 * MAX_LEN); + memmove( buf_z, buf_y, sizeof( LC3_FLOAT ) * 4 * MAX_LEN ); - for (n = 0; n < N4; n++) { + for ( n = 0; n < N4; n++ ) + { sum1 = 0; sum2 = 0; - j = 0; - for (i = L_past_y + n; i >= L_past_y + n - tilt_len; i--) { + j = 0; + for ( i = L_past_y + n; i >= L_past_y + n - tilt_len; i-- ) + { sum1 += b2[j] * buf_z[i]; j++; } j = 0; - for (i = L_past_y + n - p2 + inter_len - 1; i >= L_past_y + n - p2 - inter_len; i--) { + for ( i = L_past_y + n - p2 + inter_len - 1; i >= L_past_y + n - p2 - inter_len; i-- ) + { sum2 += a2[j] * buf_y[i]; j++; } - buf_y[L_past_y + n] = buf_z[L_past_y + n] - ((LC3_FLOAT)n / (LC3_FLOAT)N4) * sum1 + ((LC3_FLOAT)n / (LC3_FLOAT)N4) * sum2; + buf_y[L_past_y + n] = buf_z[L_past_y + n] - ( (LC3_FLOAT) n / (LC3_FLOAT) N4 ) * sum1 + ( (LC3_FLOAT) n / (LC3_FLOAT) N4 ) * sum2; } } /* Second quarter of the current frame */ - if (param[1] == 0) { - memmove(&buf_y[L_past_y + N4], &buf_x[L_past_x + N4], - sizeof(LC3_FLOAT) * ((L_past_x + N4 + N34) - (L_past_x + N4))); - } else { - for (n = 0; n < N34; n++) { + if ( param[1] == 0 ) + { + memmove( &buf_y[L_past_y + N4], &buf_x[L_past_x + N4], + sizeof( LC3_FLOAT ) * ( ( L_past_x + N4 + N34 ) - ( L_past_x + N4 ) ) ); + } + else + { + for ( n = 0; n < N34; n++ ) + { sum1 = 0; sum2 = 0; - j = 0; - for (i = L_past_x + N4 + n; i >= L_past_x + n + N4 - tilt_len; i--) { + j = 0; + for ( i = L_past_x + N4 + n; i >= L_past_x + n + N4 - tilt_len; i-- ) + { sum1 += b2[j] * buf_x[i]; j++; } j = 0; - for (i = L_past_y + N4 + n - p2 + inter_len - 1; i >= L_past_y + N4 + n - p2 - inter_len; i--) { + for ( i = L_past_y + N4 + n - p2 + inter_len - 1; i >= L_past_y + N4 + n - p2 - inter_len; i-- ) + { sum2 += a2[j] * buf_y[i]; j++; } @@ -338,19 +394,19 @@ void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT f } /* Output */ - move_float(y, &buf_y[L_past_y], N); + move_float( y, &buf_y[L_past_y], N ); /* Update memory */ - move_float(mem_old_x, &buf_x[N], old_x_len); - move_float(mem_old_y, &buf_y[N], old_y_len); + move_float( mem_old_x, &buf_x[N], old_x_len ); + move_float( mem_old_y, &buf_y[N], old_y_len ); - *mem_ltpf_active = (conf_beta > 0); + *mem_ltpf_active = ( conf_beta > 0 ); } /* Update ltpf param memory */ - move_int(mem_param, param, 3); + move_int( mem_param, param, 3 ); *mem_pitch_int = pitch_int; - *mem_pitch_fr = pitch_fr; - *mem_gain = gain; - *mem_beta_idx = conf_beta_idx; + *mem_pitch_fr = pitch_fr; + *mem_gain = gain; + *mem_beta_idx = conf_beta_idx; } diff --git a/lib_lc3plus/mdct.c b/lib_lc3plus/mdct.c index 11618b9465..39efa26cee 100644 --- a/lib_lc3plus/mdct.c +++ b/lib_lc3plus/mdct.c @@ -1,128 +1,140 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -static const LC3_FLOAT* mdct_window(LC3_INT length, LC3_INT frame_dms, LC3_INT hrmode) +static const LC3_FLOAT *mdct_window( LC3_INT length, LC3_INT frame_dms, LC3_INT hrmode ) { - if (frame_dms == 100) { - switch (length) { - case 80: - return MDCT_WINS_10ms[hrmode][0]; - case 160: - return MDCT_WINS_10ms[hrmode][1]; - case 240: - return MDCT_WINS_10ms[hrmode][2]; - case 320: - return MDCT_WINS_10ms[hrmode][3]; - case 480: - return MDCT_WINS_10ms[hrmode][4]; - case 960: - return MDCT_WINS_10ms[hrmode][5]; - default: - return NULL; + if ( frame_dms == 100 ) + { + switch ( length ) + { + case 80: + return MDCT_WINS_10ms[hrmode][0]; + case 160: + return MDCT_WINS_10ms[hrmode][1]; + case 240: + return MDCT_WINS_10ms[hrmode][2]; + case 320: + return MDCT_WINS_10ms[hrmode][3]; + case 480: + return MDCT_WINS_10ms[hrmode][4]; + case 960: + return MDCT_WINS_10ms[hrmode][5]; + default: + return NULL; } } - else if (frame_dms == 50) { - switch (length) { - case 40: - return MDCT_WINS_5ms[hrmode][0]; - case 80: - return MDCT_WINS_5ms[hrmode][1]; - case 120: - return MDCT_WINS_5ms[hrmode][2]; - case 160: - return MDCT_WINS_5ms[hrmode][3]; - case 240: - return MDCT_WINS_5ms[hrmode][4]; - case 480: - return MDCT_WINS_5ms[hrmode][5]; - default: - return NULL; + else if ( frame_dms == 50 ) + { + switch ( length ) + { + case 40: + return MDCT_WINS_5ms[hrmode][0]; + case 80: + return MDCT_WINS_5ms[hrmode][1]; + case 120: + return MDCT_WINS_5ms[hrmode][2]; + case 160: + return MDCT_WINS_5ms[hrmode][3]; + case 240: + return MDCT_WINS_5ms[hrmode][4]; + case 480: + return MDCT_WINS_5ms[hrmode][5]; + default: + return NULL; } } - else if (frame_dms == 25) { - switch (length) { - case 20: - return MDCT_WINS_2_5ms[hrmode][0]; - case 40: - return MDCT_WINS_2_5ms[hrmode][1]; - case 60: - return MDCT_WINS_2_5ms[hrmode][2]; - case 80: - return MDCT_WINS_2_5ms[hrmode][3]; - case 120: - return MDCT_WINS_2_5ms[hrmode][4]; - case 240: - return MDCT_WINS_2_5ms[hrmode][5]; - default: - return NULL; + else if ( frame_dms == 25 ) + { + switch ( length ) + { + case 20: + return MDCT_WINS_2_5ms[hrmode][0]; + case 40: + return MDCT_WINS_2_5ms[hrmode][1]; + case 60: + return MDCT_WINS_2_5ms[hrmode][2]; + case 80: + return MDCT_WINS_2_5ms[hrmode][3]; + case 120: + return MDCT_WINS_2_5ms[hrmode][4]; + case 240: + return MDCT_WINS_2_5ms[hrmode][5]; + default: + return NULL; } } return NULL; } -void mdct_init(Mdct* mdct, LC3_INT length, LC3_INT frame_dms, LC3_INT fs_idx, LC3_INT hrmode) +void mdct_init( Mdct *mdct, LC3_INT length, LC3_INT frame_dms, LC3_INT fs_idx, LC3_INT hrmode ) { - if (frame_dms == 100) { + if ( frame_dms == 100 ) + { mdct->leading_zeros = MDCT_la_zeroes[fs_idx]; - } - else if (frame_dms == 50) { + } + else if ( frame_dms == 50 ) + { mdct->leading_zeros = MDCT_la_zeroes_5ms[fs_idx]; - } - else if (frame_dms == 25) { + } + else if ( frame_dms == 25 ) + { mdct->leading_zeros = MDCT_la_zeroes_2_5ms[fs_idx]; } - else { - assert(!"invalid frame_ms"); + else + { + assert( !"invalid frame_ms" ); } - mdct->length = length; + mdct->length = length; mdct->mem_length = length - mdct->leading_zeros; - mdct->window = mdct_window(length, frame_dms, hrmode); - mdct->mem = calloc(sizeof(*mdct->mem), mdct->mem_length); - dct4_init(&mdct->dct, length); + mdct->window = mdct_window( length, frame_dms, hrmode ); + mdct->mem = calloc( sizeof( *mdct->mem ), mdct->mem_length ); + dct4_init( &mdct->dct, length ); } -void mdct_free(Mdct* mdct) +void mdct_free( Mdct *mdct ) { - if (mdct) { - free(mdct->mem); - dct4_free(&mdct->dct); - memset(mdct, 0, sizeof(*mdct)); + if ( mdct ) + { + free( mdct->mem ); + dct4_free( &mdct->dct ); + memset( mdct, 0, sizeof( *mdct ) ); } } -void mdct_apply(const LC3_FLOAT* input, LC3_FLOAT* output, Mdct* mdct) +void mdct_apply( const LC3_FLOAT *input, LC3_FLOAT *output, Mdct *mdct ) { - LC3_FLOAT tmp[MAX_LEN * 2] = {0}; - LC3_INT i = 0; + LC3_FLOAT tmp[MAX_LEN * 2] = { 0 }; + LC3_INT i = 0; LC3_INT hlen; - move_float(tmp, mdct->mem, mdct->mem_length); - move_float(tmp + mdct->mem_length, input, mdct->length); - zero_float(tmp + mdct->length * 2 - mdct->leading_zeros, mdct->leading_zeros); - move_float(mdct->mem, tmp + mdct->length, mdct->mem_length); + move_float( tmp, mdct->mem, mdct->mem_length ); + move_float( tmp + mdct->mem_length, input, mdct->length ); + zero_float( tmp + mdct->length * 2 - mdct->leading_zeros, mdct->leading_zeros ); + move_float( mdct->mem, tmp + mdct->length, mdct->mem_length ); - mult_vec(tmp, mdct->window, mdct->length * 2); + mult_vec( tmp, mdct->window, mdct->length * 2 ); hlen = mdct->length / 2; - for (i = 0; i < hlen; i++) { - output[i] = -tmp[hlen * 3 - i - 1] - tmp[hlen * 3 + i]; + for ( i = 0; i < hlen; i++ ) + { + output[i] = -tmp[hlen * 3 - i - 1] - tmp[hlen * 3 + i]; output[hlen + i] = tmp[i] - tmp[hlen * 2 - i - 1]; } - move_float(tmp, output, mdct->length); + move_float( tmp, output, mdct->length ); - dct4_apply(&mdct->dct, tmp, output); + dct4_apply( &mdct->dct, tmp, output ); } -void processMdct_fl(LC3_FLOAT* in, LC3_FLOAT* out, Mdct* mdctStruct) { mdct_apply(in, out, mdctStruct); } +void processMdct_fl( LC3_FLOAT *in, LC3_FLOAT *out, Mdct *mdctStruct ) { mdct_apply( in, out, mdctStruct ); } diff --git a/lib_lc3plus/mdct_shaping.c b/lib_lc3plus/mdct_shaping.c index 1876192504..bcbcd1fab1 100644 --- a/lib_lc3plus/mdct_shaping.c +++ b/lib_lc3plus/mdct_shaping.c @@ -1,22 +1,24 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -void processMdctShaping_fl(LC3_FLOAT x[], LC3_FLOAT scf[], const LC3_INT bands_offset[], LC3_INT fdns_npts) +void processMdctShaping_fl( LC3_FLOAT x[], LC3_FLOAT scf[], const LC3_INT bands_offset[], LC3_INT fdns_npts ) { LC3_INT i = 0, j = 0; - for (i = 0; i < fdns_npts; i++) { - for (; j < bands_offset[i + 1]; j++) { + for ( i = 0; i < fdns_npts; i++ ) + { + for ( ; j < bands_offset[i + 1]; j++ ) + { x[j] = x[j] * scf[i]; } } diff --git a/lib_lc3plus/near_nyquist_detector.c b/lib_lc3plus/near_nyquist_detector.c index ce94351302..a6e74e6cca 100644 --- a/lib_lc3plus/near_nyquist_detector.c +++ b/lib_lc3plus/near_nyquist_detector.c @@ -1,37 +1,37 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ #include "functions.h" #include "options.h" -void processNearNyquistdetector_fl(LC3_INT16* near_nyquist_flag, const LC3_INT fs_idx, const LC3_INT near_nyquist_index, - const LC3_INT bands_number, const LC3_FLOAT* ener) +void processNearNyquistdetector_fl( LC3_INT16 *near_nyquist_flag, const LC3_INT fs_idx, const LC3_INT near_nyquist_index, const LC3_INT bands_number, const LC3_FLOAT *ener ) { *near_nyquist_flag = 0; - if (fs_idx < 4) + if ( fs_idx < 4 ) { - LC3_INT i = 0; + LC3_INT i = 0; LC3_FLOAT ener_low = FLT_EPSILON, ener_high = 0; - for (i=0; i NN_thresh * ener_low){ + if ( ener_high > NN_thresh * ener_low ) + { *near_nyquist_flag = 1; } } diff --git a/lib_lc3plus/noise_factor.c b/lib_lc3plus/noise_factor.c index c5aa582e45..2f9e634b01 100644 --- a/lib_lc3plus/noise_factor.c +++ b/lib_lc3plus/noise_factor.c @@ -1,26 +1,24 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -void processNoiseFactor_fl(LC3_INT* fac_ns_idx, LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gg, LC3_INT BW_cutoff_idx, LC3_INT frame_dms, - LC3_INT target_bytes -) +void processNoiseFactor_fl( LC3_INT *fac_ns_idx, LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gg, LC3_INT BW_cutoff_idx, LC3_INT frame_dms, LC3_INT target_bytes ) { LC3_INT sumZeroLines = 0, kZeroLines = 0, startOffset = 0, nTransWidth = 0, end = 0, start = 0, i = 0, j = 0, k = 0, - allZeros = 0, m = 0; + allZeros = 0, m = 0; LC3_FLOAT fac_ns_unq = 0, mean = 0, idx = 0, nsf1 = 0, nsf2 = 0; - LC3_INT zeroLines[MAX_LEN] = {0}, zL1[MAX_LEN] = {0}, zL2[MAX_LEN] = {0}; + LC3_INT zeroLines[MAX_LEN] = { 0 }, zL1[MAX_LEN] = { 0 }, zL2[MAX_LEN] = { 0 }; - switch (frame_dms) + switch ( frame_dms ) { case 25: nTransWidth = 4; @@ -36,77 +34,92 @@ void processNoiseFactor_fl(LC3_INT* fac_ns_idx, LC3_FLOAT x[], LC3_INT xq[], LC3 break; } - for (k = startOffset; k < BW_cutoff_idx; k++) { + for ( k = startOffset; k < BW_cutoff_idx; k++ ) + { allZeros = 1; - start = k - (nTransWidth - 2) / 2; - end = MIN(BW_cutoff_idx - 1, k + (nTransWidth - 2) / 2); + start = k - ( nTransWidth - 2 ) / 2; + end = MIN( BW_cutoff_idx - 1, k + ( nTransWidth - 2 ) / 2 ); - for (i = start; i <= end; i++) { - if (xq[i] != 0) { + for ( i = start; i <= end; i++ ) + { + if ( xq[i] != 0 ) + { allZeros = 0; } } - if (allZeros == 1) { + if ( allZeros == 1 ) + { zeroLines[j] = k + 1; kZeroLines++; j++; } } - for (i = 0; i < kZeroLines; i++) { + for ( i = 0; i < kZeroLines; i++ ) + { sumZeroLines += zeroLines[i]; } - if (sumZeroLines > 0) { - for (j = 0; j < kZeroLines; j++) { - mean += LC3_FABS(x[zeroLines[j] - 1]); + if ( sumZeroLines > 0 ) + { + for ( j = 0; j < kZeroLines; j++ ) + { + mean += LC3_FABS( x[zeroLines[j] - 1] ); } - fac_ns_unq = mean / (gg * kZeroLines); - } else { + fac_ns_unq = mean / ( gg * kZeroLines ); + } + else + { fac_ns_unq = 0; } - if (kZeroLines > 0) + if ( kZeroLines > 0 ) { - if (target_bytes <= 20 && frame_dms == 100) { + if ( target_bytes <= 20 && frame_dms == 100 ) + { j = 0, k = 0; - m = floor(sumZeroLines / kZeroLines); + m = floor( sumZeroLines / kZeroLines ); - for (i = 0; i < kZeroLines; i++) { - if (zeroLines[i] <= m) { + for ( i = 0; i < kZeroLines; i++ ) + { + if ( zeroLines[i] <= m ) + { zL1[j] = zeroLines[i]; j++; } - if (zeroLines[i] > m) { + if ( zeroLines[i] > m ) + { zL2[k] = zeroLines[i]; k++; } } mean = 0; - for (i = 0; i < j; i++) { - mean += LC3_FABS(x[zL1[i] - 1]) / gg; + for ( i = 0; i < j; i++ ) + { + mean += LC3_FABS( x[zL1[i] - 1] ) / gg; } nsf1 = mean / j; mean = 0; - for (i = 0; i < k; i++) { - mean += LC3_FABS(x[zL2[i] - 1]) / gg; + for ( i = 0; i < k; i++ ) + { + mean += LC3_FABS( x[zL2[i] - 1] ) / gg; } nsf2 = mean / k; - fac_ns_unq = MIN(nsf1, nsf2); + fac_ns_unq = MIN( nsf1, nsf2 ); } } - idx = round(8 - 16 * fac_ns_unq); - idx = MIN(MAX(idx, 0), 7); + idx = round( 8 - 16 * fac_ns_unq ); + idx = MIN( MAX( idx, 0 ), 7 ); *fac_ns_idx = idx; } diff --git a/lib_lc3plus/noise_filling.c b/lib_lc3plus/noise_filling.c index 7fac5e0f72..85361c8091 100644 --- a/lib_lc3plus/noise_filling.c +++ b/lib_lc3plus/noise_filling.c @@ -1,23 +1,23 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -void processNoiseFilling_fl(LC3_FLOAT xq[], LC3_INT nfseed, LC3_INT fac_ns_idx, LC3_INT bw_stopband, LC3_INT frame_dms, LC3_FLOAT fac_ns_pc, LC3_INT spec_inv_idx) +void processNoiseFilling_fl( LC3_FLOAT xq[], LC3_INT nfseed, LC3_INT fac_ns_idx, LC3_INT bw_stopband, LC3_INT frame_dms, LC3_FLOAT fac_ns_pc, LC3_INT spec_inv_idx ) { - LC3_INT zeroLines[MAX_LEN] = {0}; - LC3_INT nTransWidth = 0, startOffset = 0, i = 0, j = 0, k = 0, start = 0, end = 0, allZeros = 0, kZeroLines = 0; + LC3_INT zeroLines[MAX_LEN] = { 0 }; + LC3_INT nTransWidth = 0, startOffset = 0, i = 0, j = 0, k = 0, start = 0, end = 0, allZeros = 0, kZeroLines = 0; LC3_FLOAT fac_ns = 0; - switch (frame_dms) + switch ( frame_dms ) { case 25: nTransWidth = 1; @@ -33,45 +33,57 @@ void processNoiseFilling_fl(LC3_FLOAT xq[], LC3_INT nfseed, LC3_INT fac_ns_idx, break; } - fac_ns = (8.0 - fac_ns_idx) / 16.0; + fac_ns = ( 8.0 - fac_ns_idx ) / 16.0; j = 0; - for (k = startOffset; k < bw_stopband; k++) { + for ( k = startOffset; k < bw_stopband; k++ ) + { allZeros = 1; start = k - nTransWidth; - end = MIN(bw_stopband - 1, k + nTransWidth); + end = MIN( bw_stopband - 1, k + nTransWidth ); - for (i = start; i <= end; i++) { - if (xq[i] != 0) { + for ( i = start; i <= end; i++ ) + { + if ( xq[i] != 0 ) + { allZeros = 0; } } - if (allZeros == 1) { + if ( allZeros == 1 ) + { zeroLines[j] = k; kZeroLines++; j++; } } - for (k = 0; k < kZeroLines; k++) { - nfseed = (13849 + (nfseed + 32768) * 31821) & 65535; + for ( k = 0; k < kZeroLines; k++ ) + { + nfseed = ( 13849 + ( nfseed + 32768 ) * 31821 ) & 65535; nfseed -= 32768; - if (nfseed >= 0) { - if (zeroLines[k] < spec_inv_idx) + if ( nfseed >= 0 ) + { + if ( zeroLines[k] < spec_inv_idx ) { xq[zeroLines[k]] = fac_ns; - } else { + } + else + { xq[zeroLines[k]] = fac_ns_pc; } - } else { - if (zeroLines[k] < spec_inv_idx) + } + else + { + if ( zeroLines[k] < spec_inv_idx ) { xq[zeroLines[k]] = -fac_ns; - } else { + } + else + { xq[zeroLines[k]] = -fac_ns_pc; } } diff --git a/lib_lc3plus/olpa.c b/lib_lc3plus/olpa.c index 6bec50952e..13340ff6f9 100644 --- a/lib_lc3plus/olpa.c +++ b/lib_lc3plus/olpa.c @@ -1,29 +1,31 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -static void filter_olpa(LC3_FLOAT* in, LC3_FLOAT* out, const LC3_FLOAT* buf, LC3_FLOAT len_buf, LC3_INT len_input); -static LC3_INT searchMaxIndice(LC3_FLOAT* in, LC3_INT len); +static void filter_olpa( LC3_FLOAT *in, LC3_FLOAT *out, const LC3_FLOAT *buf, LC3_FLOAT len_buf, LC3_INT len_input ); +static LC3_INT searchMaxIndice( LC3_FLOAT *in, LC3_INT len ); -void filter_olpa(LC3_FLOAT* in, LC3_FLOAT* out, const LC3_FLOAT* buf, LC3_FLOAT len_buf, LC3_INT len_input) +void filter_olpa( LC3_FLOAT *in, LC3_FLOAT *out, const LC3_FLOAT *buf, LC3_FLOAT len_buf, LC3_INT len_input ) { - LC3_INT i = 0, j = 0; + LC3_INT i = 0, j = 0; LC3_FLOAT sum = 0; /* a = 1, so denominator == 1, nothing to do here */ - for (i = 0; i < len_input; i++) { - j = 0; + for ( i = 0; i < len_input; i++ ) + { + j = 0; sum = 0; - for (j = 0; (j < len_buf) && (j <= i); j++) { + for ( j = 0; ( j < len_buf ) && ( j <= i ); j++ ) + { sum += buf[j] * in[i - j]; } @@ -31,18 +33,21 @@ void filter_olpa(LC3_FLOAT* in, LC3_FLOAT* out, const LC3_FLOAT* buf, LC3_FLOAT } } -LC3_INT searchMaxIndice(LC3_FLOAT* in, LC3_INT len) +LC3_INT searchMaxIndice( LC3_FLOAT *in, LC3_INT len ) { - LC3_INT max_i = 0, i = 0; + LC3_INT max_i = 0, i = 0; LC3_FLOAT max = in[0]; - if (len <= 0) { + if ( len <= 0 ) + { return -128; } - for (i = 0; i < len; i++) { - if (in[i] > max) { - max = in[i]; + for ( i = 0; i < len; i++ ) + { + if ( in[i] > max ) + { + max = in[i]; max_i = i; } } @@ -50,95 +55,102 @@ LC3_INT searchMaxIndice(LC3_FLOAT* in, LC3_INT len) return max_i; } -void processOlpa_fl(LC3_FLOAT* s_12k8, LC3_FLOAT* mem_s12k8, LC3_FLOAT* mem_s6k4, LC3_INT* mem_old_T0, LC3_INT* T0_out, - LC3_FLOAT* normcorr_out, LC3_INT len, LC3_INT frame_dms) +void processOlpa_fl( LC3_FLOAT *s_12k8, LC3_FLOAT *mem_s12k8, LC3_FLOAT *mem_s6k4, LC3_INT *mem_old_T0, LC3_INT *T0_out, LC3_FLOAT *normcorr_out, LC3_INT len, LC3_INT frame_dms ) { LC3_FLOAT norm_corr = 0, sum = 0, sum0 = 0, sum1 = 0, sum2 = 0, norm_corr2 = 0, *s6k4; - LC3_FLOAT buf[LEN_6K4 + MAX_PITCH_6K4] = {0}, filt_out[LEN_12K8 + 3] = {0}, d_wsp[LEN_6K4] = {0}, R0[RANGE_PITCH_6K4] = {0}, R[RANGE_PITCH_6K4] = {0}; /* constant length */ - LC3_INT i = 0, j = 0, len2 = 0, T0 = 0, T02 = 0, min_pitch = 0, max_pitch = 0, L = 0, mem_in_len = 0, acflen = 0; - + LC3_FLOAT buf[LEN_6K4 + MAX_PITCH_6K4] = { 0 }, filt_out[LEN_12K8 + 3] = { 0 }, d_wsp[LEN_6K4] = { 0 }, R0[RANGE_PITCH_6K4] = { 0 }, R[RANGE_PITCH_6K4] = { 0 }; /* constant length */ + LC3_INT i = 0, j = 0, len2 = 0, T0 = 0, T02 = 0, min_pitch = 0, max_pitch = 0, L = 0, mem_in_len = 0, acflen = 0; + mem_in_len = MAX_PITCH_6K4; - len2 = len / 2; - acflen = len2; - if (frame_dms == 25) + len2 = len / 2; + acflen = len2; + if ( frame_dms == 25 ) { mem_in_len += 16; - acflen += 16; + acflen += 16; } /* Downsampling */ - move_float(buf, mem_s12k8, 3); - move_float(&buf[3], s_12k8, len); - move_float(mem_s12k8, &buf[len], 3); - filter_olpa(buf, filt_out, olpa_down2, 5, len + 3); - for (i = 4, j = 0; i < len + 3; i = i + 2) { + move_float( buf, mem_s12k8, 3 ); + move_float( &buf[3], s_12k8, len ); + move_float( mem_s12k8, &buf[len], 3 ); + filter_olpa( buf, filt_out, olpa_down2, 5, len + 3 ); + for ( i = 4, j = 0; i < len + 3; i = i + 2 ) + { d_wsp[j] = filt_out[i]; j++; } /* Compute autocorrelation */ s6k4 = &buf[mem_in_len]; - move_float(buf, mem_s6k4, mem_in_len); - move_float(s6k4, d_wsp, len2); - move_float(mem_s6k4, &buf[len2], mem_in_len); - if (frame_dms == 25) + move_float( buf, mem_s6k4, mem_in_len ); + move_float( s6k4, d_wsp, len2 ); + move_float( mem_s6k4, &buf[len2], mem_in_len ); + if ( frame_dms == 25 ) { s6k4 = s6k4 - 16; } - for (i = MIN_PITCH_6K4; i <= MAX_PITCH_6K4; i++) { + for ( i = MIN_PITCH_6K4; i <= MAX_PITCH_6K4; i++ ) + { sum = 0; - for (j = 0; j < acflen; j++) { + for ( j = 0; j < acflen; j++ ) + { sum += s6k4[j] * s6k4[j - i]; } R0[i - MIN_PITCH_6K4] = sum; } /* Weight autocorrelation and find maximum */ - move_float(R, R0, RANGE_PITCH_6K4); - for (i = 0; i < RANGE_PITCH_6K4; i++) { + move_float( R, R0, RANGE_PITCH_6K4 ); + for ( i = 0; i < RANGE_PITCH_6K4; i++ ) + { R0[i] = R0[i] * olpa_acw[i]; } - L = searchMaxIndice(R0, RANGE_PITCH_6K4); + L = searchMaxIndice( R0, RANGE_PITCH_6K4 ); T0 = L + MIN_PITCH_6K4; /* Compute normalized correlation */ sum0 = sum1 = sum2 = 0; - for (i = 0; i < acflen; i++) { + for ( i = 0; i < acflen; i++ ) + { sum0 += s6k4[i] * s6k4[i - T0]; sum1 += s6k4[i - T0] * s6k4[i - T0]; sum2 += s6k4[i] * s6k4[i]; } sum1 = sum1 * sum2; - sum1 = LC3_SQRT(sum1) + LC3_POW(10.0, -5.0); + sum1 = LC3_SQRT( sum1 ) + LC3_POW( 10.0, -5.0 ); norm_corr = sum0 / sum1; - norm_corr = MAX(0, norm_corr); + norm_corr = MAX( 0, norm_corr ); /* Second try in the neighborhood of the previous pitch */ - min_pitch = MAX(MIN_PITCH_6K4, *mem_old_T0 - 4); - max_pitch = MIN(MAX_PITCH_6K4, *mem_old_T0 + 4); - L = searchMaxIndice(&R[min_pitch - MIN_PITCH_6K4], max_pitch - min_pitch + 1 ); + min_pitch = MAX( MIN_PITCH_6K4, *mem_old_T0 - 4 ); + max_pitch = MIN( MAX_PITCH_6K4, *mem_old_T0 + 4 ); + L = searchMaxIndice( &R[min_pitch - MIN_PITCH_6K4], max_pitch - min_pitch + 1 ); T02 = L + min_pitch; - if (T02 != T0) { + if ( T02 != T0 ) + { sum0 = sum1 = sum2 = 0; - for (i = 0; i < acflen; i++) { + for ( i = 0; i < acflen; i++ ) + { sum0 += s6k4[i] * s6k4[i - T02]; sum1 += s6k4[i - T02] * s6k4[i - T02]; sum2 += s6k4[i] * s6k4[i]; } sum1 = sum1 * sum2; - sum1 = LC3_SQRT(sum1) + LC3_POW(10.0, -5.0); + sum1 = LC3_SQRT( sum1 ) + LC3_POW( 10.0, -5.0 ); norm_corr2 = sum0 / sum1; - norm_corr2 = MAX(0, norm_corr2); + norm_corr2 = MAX( 0, norm_corr2 ); - if (norm_corr2 > (norm_corr * 0.85)) { - T0 = T02; + if ( norm_corr2 > ( norm_corr * 0.85 ) ) + { + T0 = T02; norm_corr = norm_corr2; } } - *mem_old_T0 = T0; - *T0_out = T0 * 2.0; + *mem_old_T0 = T0; + *T0_out = T0 * 2.0; *normcorr_out = norm_corr; } diff --git a/lib_lc3plus/pc_apply.c b/lib_lc3plus/pc_apply.c index 1d1bc40005..3befa3a68c 100644 --- a/lib_lc3plus/pc_apply.c +++ b/lib_lc3plus/pc_apply.c @@ -1,73 +1,75 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -void processPcApply_fl(LC3_FLOAT *q_res, LC3_FLOAT *q_old_res, LC3_FLOAT *q_d_prev, LC3_INT32 spec_inv_idx, LC3_INT32 yLen, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_FLOAT *prev_gg, LC3_FLOAT *fac, LC3_INT32 *pc_nbLostCmpt) +void processPcApply_fl( LC3_FLOAT *q_res, LC3_FLOAT *q_old_res, LC3_FLOAT *q_d_prev, LC3_INT32 spec_inv_idx, LC3_INT32 yLen, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_FLOAT *prev_gg, LC3_FLOAT *fac, LC3_INT32 *pc_nbLostCmpt ) { - LC3_FLOAT gg, mean_nrg_low, mean_nrg_high, ener_prev, ener_curr, fac_local; - LC3_INT32 i; - - ener_prev = 0; ener_curr = 0; mean_nrg_low = 0; mean_nrg_high = 0; - + LC3_FLOAT gg, mean_nrg_low, mean_nrg_high, ener_prev, ener_curr, fac_local; + LC3_INT32 i; + + ener_prev = 0; + ener_curr = 0; + mean_nrg_low = 0; + mean_nrg_high = 0; + *pc_nbLostCmpt = *pc_nbLostCmpt + 1; - - assert(spec_inv_idx > 1); - - gg = LC3_POW(10, (((LC3_FLOAT) (gg_idx + gg_idx_off)) / 28.0)); - for (i = 0; i < spec_inv_idx; i++) + assert( spec_inv_idx > 1 ); + + gg = LC3_POW( 10, ( ( (LC3_FLOAT) ( gg_idx + gg_idx_off ) ) / 28.0 ) ); + + for ( i = 0; i < spec_inv_idx; i++ ) { - mean_nrg_low += LC3_POW(q_d_prev[i], 2); + mean_nrg_low += LC3_POW( q_d_prev[i], 2 ); } - + mean_nrg_low /= (LC3_FLOAT) spec_inv_idx; - - if (spec_inv_idx < yLen) + + if ( spec_inv_idx < yLen ) { - for (i = spec_inv_idx; i < yLen; i++) + for ( i = spec_inv_idx; i < yLen; i++ ) { - mean_nrg_high += LC3_POW(q_d_prev[i], 2); + mean_nrg_high += LC3_POW( q_d_prev[i], 2 ); } } - - mean_nrg_high /= (LC3_FLOAT) (yLen - spec_inv_idx); - for (i = 0; i < spec_inv_idx; i++) + mean_nrg_high /= (LC3_FLOAT) ( yLen - spec_inv_idx ); + + for ( i = 0; i < spec_inv_idx; i++ ) { - ener_prev += LC3_POW(q_old_res[i], 2); - ener_curr += LC3_POW(q_res[i], 2); + ener_prev += LC3_POW( q_old_res[i], 2 ); + ener_curr += LC3_POW( q_res[i], 2 ); } *fac = 1; - if (ener_prev > 0) + if ( ener_prev > 0 ) { - *fac = LC3_SQRT(ener_curr / ener_prev); + *fac = LC3_SQRT( ener_curr / ener_prev ); } - + fac_local = *fac; - if (mean_nrg_low <= mean_nrg_high || ener_prev * LC3_POW(*prev_gg, 2) <= ener_curr * LC3_POW(gg, 2)) + if ( mean_nrg_low <= mean_nrg_high || ener_prev * LC3_POW( *prev_gg, 2 ) <= ener_curr * LC3_POW( gg, 2 ) ) { fac_local = *prev_gg / gg; } - - for (i = spec_inv_idx; i < yLen; i++) + + for ( i = spec_inv_idx; i < yLen; i++ ) { q_res[i] = q_old_res[i] * fac_local; - - if (LC3_FABS(q_res[i]) < (1 - 0.375)) + + if ( LC3_FABS( q_res[i] ) < ( 1 - 0.375 ) ) { q_res[i] = 0; } } } - diff --git a/lib_lc3plus/pc_classify.c b/lib_lc3plus/pc_classify.c index 71196edb89..22b228c9a2 100644 --- a/lib_lc3plus/pc_classify.c +++ b/lib_lc3plus/pc_classify.c @@ -1,55 +1,59 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -LC3_FLOAT pc_peak_detector(LC3_FLOAT *q_d_prev, LC3_INT32 yLen); +LC3_FLOAT pc_peak_detector( LC3_FLOAT *q_d_prev, LC3_INT32 yLen ); -void processPcClassify_fl(LC3_INT32 pitch_present, LC3_INT32 frame_dms, LC3_FLOAT *q_d_prev, LC3_FLOAT *q_old_res, LC3_INT32 yLen, LC3_INT32 spec_inv_idx, LC3_FLOAT stab_fac, LC3_INT32 *bfi) +void processPcClassify_fl( LC3_INT32 pitch_present, LC3_INT32 frame_dms, LC3_FLOAT *q_d_prev, LC3_FLOAT *q_old_res, LC3_INT32 yLen, LC3_INT32 spec_inv_idx, LC3_FLOAT stab_fac, LC3_INT32 *bfi ) { - LC3_INT32 maxPitchBin, xover, i; - LC3_FLOAT part_nrg, full_nrg; - - part_nrg = 0; full_nrg = 0; - - if (spec_inv_idx < (4 * frame_dms / 10)) + LC3_INT32 maxPitchBin, xover, i; + LC3_FLOAT part_nrg, full_nrg; + + part_nrg = 0; + full_nrg = 0; + + if ( spec_inv_idx < ( 4 * frame_dms / 10 ) ) { - if (stab_fac < 0.5) + if ( stab_fac < 0.5 ) { *bfi = 1; - } else if (pitch_present == 1) + } + else if ( pitch_present == 1 ) { maxPitchBin = 8; - if (frame_dms == 50) + if ( frame_dms == 50 ) { maxPitchBin = 4; } - xover = pc_peak_detector(q_d_prev, yLen); - if (spec_inv_idx < xover || spec_inv_idx < maxPitchBin) + xover = pc_peak_detector( q_d_prev, yLen ); + if ( spec_inv_idx < xover || spec_inv_idx < maxPitchBin ) { *bfi = 1; } - } else { - for (i = 0; i < spec_inv_idx; i++) + } + else + { + for ( i = 0; i < spec_inv_idx; i++ ) { - part_nrg += LC3_POW(q_old_res[i], 2); + part_nrg += LC3_POW( q_old_res[i], 2 ); } - - for (i = 0; i < yLen; i++) + + for ( i = 0; i < yLen; i++ ) { - full_nrg += LC3_POW(q_old_res[i], 2); + full_nrg += LC3_POW( q_old_res[i], 2 ); } - if (part_nrg < (0.3 * full_nrg)) + if ( part_nrg < ( 0.3 * full_nrg ) ) { *bfi = 1; } @@ -57,74 +61,74 @@ void processPcClassify_fl(LC3_INT32 pitch_present, LC3_INT32 frame_dms, LC3_FLOA } } -LC3_FLOAT pc_peak_detector(LC3_FLOAT *q_d_prev, LC3_INT32 yLen) +LC3_FLOAT pc_peak_detector( LC3_FLOAT *q_d_prev, LC3_INT32 yLen ) { - LC3_INT32 block_size, thresh1, i, peak, j, k; - LC3_FLOAT fac, mean_block_nrg, cur_max, block_cent, maxPeak, next_max, prev_max; - + LC3_INT32 block_size, thresh1, i, peak, j, k; + LC3_FLOAT fac, mean_block_nrg, cur_max, block_cent, maxPeak, next_max, prev_max; + mean_block_nrg = 0; - + block_size = 3; thresh1 = 8; fac = 0.3; - - for (i = 0; i < yLen; i++) + + for ( i = 0; i < yLen; i++ ) { - mean_block_nrg += LC3_POW(q_d_prev[i], 2); + mean_block_nrg += LC3_POW( q_d_prev[i], 2 ); } - + mean_block_nrg /= yLen; - + maxPeak = 0; peak = 0; - - if (LC3_FABS(q_d_prev[0]) > LC3_FABS(q_d_prev[1])) + + if ( LC3_FABS( q_d_prev[0] ) > LC3_FABS( q_d_prev[1] ) ) { - block_cent = LC3_POW(q_d_prev[0], 2) + LC3_POW(q_d_prev[1], 2); - - if ((block_cent / block_size) > (thresh1 * mean_block_nrg)) + block_cent = LC3_POW( q_d_prev[0], 2 ) + LC3_POW( q_d_prev[1], 2 ); + + if ( ( block_cent / block_size ) > ( thresh1 * mean_block_nrg ) ) { - cur_max = MAX(LC3_FABS(q_d_prev[0]), LC3_FABS(q_d_prev[1])); - next_max = array_max_abs(&q_d_prev[2], 3); - - if (cur_max > next_max) + cur_max = MAX( LC3_FABS( q_d_prev[0] ), LC3_FABS( q_d_prev[1] ) ); + next_max = array_max_abs( &q_d_prev[2], 3 ); + + if ( cur_max > next_max ) { maxPeak = block_cent; peak = 1; } } } - - for (i = 0; i < block_size; i++) + + for ( i = 0; i < block_size; i++ ) { - if ((LC3_FABS(q_d_prev[i + 1]) >= LC3_FABS(q_d_prev[i])) && LC3_FABS(q_d_prev[i + 1]) >= LC3_FABS(q_d_prev[i + 2])) + if ( ( LC3_FABS( q_d_prev[i + 1] ) >= LC3_FABS( q_d_prev[i] ) ) && LC3_FABS( q_d_prev[i + 1] ) >= LC3_FABS( q_d_prev[i + 2] ) ) { block_cent = 0; - for (j = i; j < i + block_size; j++) + for ( j = i; j < i + block_size; j++ ) { - block_cent += LC3_POW(q_d_prev[j], 2); + block_cent += LC3_POW( q_d_prev[j], 2 ); } - - if ((block_cent / block_size) > (thresh1 * mean_block_nrg)) + + if ( ( block_cent / block_size ) > ( thresh1 * mean_block_nrg ) ) { - cur_max = array_max_abs(&q_d_prev[i], block_size); + cur_max = array_max_abs( &q_d_prev[i], block_size ); prev_max = 0; - - for (k = i - block_size; k < i; k++) + + for ( k = i - block_size; k < i; k++ ) { - if (k > 0) + if ( k > 0 ) { - prev_max = MAX(LC3_FABS(q_d_prev[k]), prev_max); + prev_max = MAX( LC3_FABS( q_d_prev[k] ), prev_max ); } } - next_max = array_max_abs(&q_d_prev[i + block_size], block_size); - - if ((cur_max >= prev_max) && (cur_max > next_max)) + next_max = array_max_abs( &q_d_prev[i + block_size], block_size ); + + if ( ( cur_max >= prev_max ) && ( cur_max > next_max ) ) { - if (block_cent > (fac * maxPeak)) + if ( block_cent > ( fac * maxPeak ) ) { peak = i + block_size - 1; - if (block_cent >= maxPeak) + if ( block_cent >= maxPeak ) { maxPeak = block_cent; } @@ -133,29 +137,29 @@ LC3_FLOAT pc_peak_detector(LC3_FLOAT *q_d_prev, LC3_INT32 yLen) } } } - - for (i = block_size; i < yLen - (2 * block_size); i++) + + for ( i = block_size; i < yLen - ( 2 * block_size ); i++ ) { - if ((LC3_FABS(q_d_prev[i + 1]) >= LC3_FABS(q_d_prev[i])) && LC3_FABS(q_d_prev[i + 1]) >= LC3_FABS(q_d_prev[i + 2])) + if ( ( LC3_FABS( q_d_prev[i + 1] ) >= LC3_FABS( q_d_prev[i] ) ) && LC3_FABS( q_d_prev[i + 1] ) >= LC3_FABS( q_d_prev[i + 2] ) ) { block_cent = 0; - for (j = i; j < i + block_size; j++) + for ( j = i; j < i + block_size; j++ ) { - block_cent += LC3_POW(q_d_prev[j], 2); + block_cent += LC3_POW( q_d_prev[j], 2 ); } - - if ((block_cent / block_size) > (thresh1 * mean_block_nrg)) + + if ( ( block_cent / block_size ) > ( thresh1 * mean_block_nrg ) ) { - cur_max = array_max_abs(&q_d_prev[i], block_size); - prev_max = array_max_abs(&q_d_prev[i - block_size], block_size); - next_max = array_max_abs(&q_d_prev[i + block_size], block_size); - - if ((cur_max >= prev_max) && (cur_max > next_max)) + cur_max = array_max_abs( &q_d_prev[i], block_size ); + prev_max = array_max_abs( &q_d_prev[i - block_size], block_size ); + next_max = array_max_abs( &q_d_prev[i + block_size], block_size ); + + if ( ( cur_max >= prev_max ) && ( cur_max > next_max ) ) { - if (block_cent > (fac * maxPeak)) + if ( block_cent > ( fac * maxPeak ) ) { peak = i + block_size - 1; - if (block_cent >= maxPeak) + if ( block_cent >= maxPeak ) { maxPeak = block_cent; } @@ -164,7 +168,6 @@ LC3_FLOAT pc_peak_detector(LC3_FLOAT *q_d_prev, LC3_INT32 yLen) } } } - + return peak; } - diff --git a/lib_lc3plus/pc_main.c b/lib_lc3plus/pc_main.c index 268ee94d2a..891320e1af 100644 --- a/lib_lc3plus/pc_main.c +++ b/lib_lc3plus/pc_main.c @@ -1,43 +1,42 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -void processPcMain_fl(LC3_INT32 *bfi, LC3PLUS_Dec* decoder, LC3_FLOAT *sqQdec, DecSetup* h_DecSetup, LC3_INT32 pitch_present, LC3_FLOAT stab_fac, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_INT32 fac_ns_idx, pcState *statePC, LC3_INT32 spec_inv_idx, LC3_INT32 yLen) +void processPcMain_fl( LC3_INT32 *bfi, LC3PLUS_Dec *decoder, LC3_FLOAT *sqQdec, DecSetup *h_DecSetup, LC3_INT32 pitch_present, LC3_FLOAT stab_fac, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_INT32 fac_ns_idx, pcState *statePC, LC3_INT32 spec_inv_idx, LC3_INT32 yLen ) { - LC3_FLOAT fac; - + LC3_FLOAT fac; + /* PC Classifier */ - if (*bfi == 2) + if ( *bfi == 2 ) { - processPcClassify_fl(pitch_present, decoder->frame_dms, h_DecSetup->PlcSetup.q_d_prev, statePC->q_old_res, decoder->yLen, h_DecSetup->spec_inv_idx, stab_fac, bfi); + processPcClassify_fl( pitch_present, decoder->frame_dms, h_DecSetup->PlcSetup.q_d_prev, statePC->q_old_res, decoder->yLen, h_DecSetup->spec_inv_idx, stab_fac, bfi ); } /* PC Apply */ - if (*bfi == 2) + if ( *bfi == 2 ) { - processPcApply_fl(sqQdec, statePC->q_old_res, h_DecSetup->PlcSetup.q_d_prev, h_DecSetup->spec_inv_idx, decoder->yLen, gg_idx, gg_idx_off, &statePC->prev_gg, &fac, &statePC->ns_nbLostCmpt_pc); + processPcApply_fl( sqQdec, statePC->q_old_res, h_DecSetup->PlcSetup.q_d_prev, h_DecSetup->spec_inv_idx, decoder->yLen, gg_idx, gg_idx_off, &statePC->prev_gg, &fac, &statePC->ns_nbLostCmpt_pc ); } - + /* PC Update */ - if (*bfi != 1) + if ( *bfi != 1 ) { - processPcUpdate_fl(*bfi, sqQdec, gg_idx, gg_idx_off, decoder->rframe, &h_DecSetup->BW_cutoff_idx_nf, &h_DecSetup->prev_BW_cutoff_idx_nf, fac_ns_idx, &h_DecSetup->prev_fac_ns, &fac, statePC->q_old_res, &statePC->prev_gg, spec_inv_idx, yLen); + processPcUpdate_fl( *bfi, sqQdec, gg_idx, gg_idx_off, decoder->rframe, &h_DecSetup->BW_cutoff_idx_nf, &h_DecSetup->prev_BW_cutoff_idx_nf, fac_ns_idx, &h_DecSetup->prev_fac_ns, &fac, statePC->q_old_res, &statePC->prev_gg, spec_inv_idx, yLen ); } - + /* Reset counter */ - if (*bfi == 0) + if ( *bfi == 0 ) { statePC->ns_nbLostCmpt_pc = 0; } } - diff --git a/lib_lc3plus/pc_update.c b/lib_lc3plus/pc_update.c index 57539b5079..265f079d80 100644 --- a/lib_lc3plus/pc_update.c +++ b/lib_lc3plus/pc_update.c @@ -1,37 +1,35 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -void processPcUpdate_fl(LC3_INT32 bfi, LC3_FLOAT *q_res, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_INT32 rframe, LC3_INT32 *BW_cutoff_idx_nf, LC3_INT32 *prev_BW_cutoff_idx_nf, - LC3_INT32 fac_ns_idx, LC3_FLOAT *prev_fac_ns, LC3_FLOAT *fac, LC3_FLOAT *q_old_res, LC3_FLOAT *prev_gg, LC3_INT32 spec_inv_idx, LC3_INT32 yLen) +void processPcUpdate_fl( LC3_INT32 bfi, LC3_FLOAT *q_res, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_INT32 rframe, LC3_INT32 *BW_cutoff_idx_nf, LC3_INT32 *prev_BW_cutoff_idx_nf, LC3_INT32 fac_ns_idx, LC3_FLOAT *prev_fac_ns, LC3_FLOAT *fac, LC3_FLOAT *q_old_res, LC3_FLOAT *prev_gg, LC3_INT32 spec_inv_idx, LC3_INT32 yLen ) { - LC3_FLOAT gg; - - gg = LC3_POW(10.0, ((LC3_FLOAT) (gg_idx + gg_idx_off)) / 28.0); + LC3_FLOAT gg; + + gg = LC3_POW( 10.0, ( (LC3_FLOAT) ( gg_idx + gg_idx_off ) ) / 28.0 ); *prev_gg = gg; - move_float(q_old_res, q_res, yLen); - - if (rframe == 0) + move_float( q_old_res, q_res, yLen ); + + if ( rframe == 0 ) { *prev_BW_cutoff_idx_nf = *BW_cutoff_idx_nf; - *prev_fac_ns = (8.0 - (LC3_FLOAT) fac_ns_idx) / 16.0; - } else if ((bfi == 2) && (*BW_cutoff_idx_nf != *prev_BW_cutoff_idx_nf) && (spec_inv_idx < yLen)) + *prev_fac_ns = ( 8.0 - (LC3_FLOAT) fac_ns_idx ) / 16.0; + } + else if ( ( bfi == 2 ) && ( *BW_cutoff_idx_nf != *prev_BW_cutoff_idx_nf ) && ( spec_inv_idx < yLen ) ) { *BW_cutoff_idx_nf = *prev_BW_cutoff_idx_nf; - *prev_fac_ns = *prev_fac_ns * (*fac); - *prev_fac_ns = MAX(*prev_fac_ns, (8.0 - 7.0) / 16.0); - *prev_fac_ns = MIN(*prev_fac_ns, (8.0 - 0.0) / 16.0); + *prev_fac_ns = *prev_fac_ns * ( *fac ); + *prev_fac_ns = MAX( *prev_fac_ns, ( 8.0 - 7.0 ) / 16.0 ); + *prev_fac_ns = MIN( *prev_fac_ns, ( 8.0 - 0.0 ) / 16.0 ); } - } - diff --git a/lib_lc3plus/per_band_energy.c b/lib_lc3plus/per_band_energy.c index db1b5b2d0f..bc0f871d23 100644 --- a/lib_lc3plus/per_band_energy.c +++ b/lib_lc3plus/per_band_energy.c @@ -1,58 +1,61 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -void processPerBandEnergy_fl(LC3_INT bands_number, const LC3_INT* acc_coeff_per_band, LC3_INT16 hrmode, LC3_INT16 frame_dms, LC3_FLOAT* d2, LC3_FLOAT* d) +void processPerBandEnergy_fl( LC3_INT bands_number, const LC3_INT *acc_coeff_per_band, LC3_INT16 hrmode, LC3_INT16 frame_dms, LC3_FLOAT *d2, LC3_FLOAT *d ) { - LC3_INT i = 0, j = 0, start = 0, stop = 0, maxBwBin = 0; + LC3_INT i = 0, j = 0, start = 0, stop = 0, maxBwBin = 0; LC3_FLOAT sum = 0; -# ifdef ENABLE_HR_MODE_FL - if (hrmode) +#ifdef ENABLE_HR_MODE_FL + if ( hrmode ) { maxBwBin = MAX_BW_HR; } else -# else - UNUSED(hrmode); -# endif +#else + UNUSED( hrmode ); +#endif { maxBwBin = MAX_BW; } - switch (frame_dms) + switch ( frame_dms ) { -# ifdef ENABLE_2_5MS_MODE - case 25: - maxBwBin = maxBwBin >> 2; - break; -# endif -# ifdef ENABLE_5MS_MODE - case 50: - maxBwBin = maxBwBin >> 1; - break; -# endif +#ifdef ENABLE_2_5MS_MODE + case 25: + maxBwBin = maxBwBin >> 2; + break; +#endif +#ifdef ENABLE_5MS_MODE + case 50: + maxBwBin = maxBwBin >> 1; + break; +#endif } - for (i = 0; i < bands_number; i++) { - sum = 0; + for ( i = 0; i < bands_number; i++ ) + { + sum = 0; start = acc_coeff_per_band[i]; - stop = MIN(acc_coeff_per_band[i + 1], maxBwBin); + stop = MIN( acc_coeff_per_band[i + 1], maxBwBin ); - for (j = start; j < stop; j++) { + for ( j = start; j < stop; j++ ) + { sum += d[j] * d[j]; } - if (stop - start > 0) { - sum = sum / (LC3_FLOAT)(stop - start); + if ( stop - start > 0 ) + { + sum = sum / (LC3_FLOAT) ( stop - start ); } d2[i] = sum; } diff --git a/lib_lc3plus/plc_classify.c b/lib_lc3plus/plc_classify.c index 619a1f7419..7a93419f02 100644 --- a/lib_lc3plus/plc_classify.c +++ b/lib_lc3plus/plc_classify.c @@ -1,54 +1,50 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -static void plc_xcorr_lc(LC3_FLOAT *pcmbufHist, LC3_INT32 max_len_pcm_plc, LC3_INT32 pitch_int, LC3_INT32 framelength, LC3_INT32 frame_dms, LC3_INT32 fs, LC3_FLOAT *xcorr); -static void spectral_centroid_lc(LC3_FLOAT *gains, LC3_INT32 tilt, const LC3_INT *bands_offset, LC3_INT32 bands_number, LC3_INT32 framelength, LC3_INT32 fs, LC3_FLOAT *sc); +static void plc_xcorr_lc( LC3_FLOAT *pcmbufHist, LC3_INT32 max_len_pcm_plc, LC3_INT32 pitch_int, LC3_INT32 framelength, LC3_INT32 frame_dms, LC3_INT32 fs, LC3_FLOAT *xcorr ); +static void spectral_centroid_lc( LC3_FLOAT *gains, LC3_INT32 tilt, const LC3_INT *bands_offset, LC3_INT32 bands_number, LC3_INT32 framelength, LC3_INT32 fs, LC3_FLOAT *sc ); -void processPlcClassify_fl(LC3_INT plcMeth, LC3_INT *concealMethod, LC3_INT32 *nbLostCmpt, LC3_INT32 bfi, - LC3_FLOAT *xcorr, LC3_INT32 framelength, LC3_INT32 frame_dms, LC3_INT32 pitch_int, - LC3_INT32 fs, const LC3_INT *band_offsets, LC3_INT32 bands_number, LC3_INT32 tilt, PlcAdvSetup *plcAd - , LC3_INT32 hrmode -) +void processPlcClassify_fl( LC3_INT plcMeth, LC3_INT *concealMethod, LC3_INT32 *nbLostCmpt, LC3_INT32 bfi, LC3_FLOAT *xcorr, LC3_INT32 framelength, LC3_INT32 frame_dms, LC3_INT32 pitch_int, LC3_INT32 fs, const LC3_INT *band_offsets, LC3_INT32 bands_number, LC3_INT32 tilt, PlcAdvSetup *plcAd, LC3_INT32 hrmode ) { - LC3_FLOAT sc, class; - - if (plcAd) + LC3_FLOAT sc, class; + + if ( plcAd ) { *xcorr = 0; } - - if (bfi == 1) + + if ( bfi == 1 ) { *nbLostCmpt = *nbLostCmpt + 1; - + /* Use pitch correlation at ltpf integer lag if available */ - if (*nbLostCmpt == 1) + if ( *nbLostCmpt == 1 ) { *concealMethod = plcMeth; // this is a dangerous mapping! - + /* Advanced PLC */ - if (pitch_int > 0) + if ( pitch_int > 0 ) { *concealMethod = 3; /* Timedomain PLC assumed */ - plc_xcorr_lc(plcAd->pcmbufHist, plcAd->max_len_pcm_plc, pitch_int, framelength, frame_dms, fs, xcorr); + plc_xcorr_lc( plcAd->pcmbufHist, plcAd->max_len_pcm_plc, pitch_int, framelength, frame_dms, fs, xcorr ); - spectral_centroid_lc(plcAd->scf_q_old, tilt, band_offsets, bands_number, framelength, fs, &sc); - class = *xcorr * 7640.0/32768.0 - sc - 5112.0/32768.0; + spectral_centroid_lc( plcAd->scf_q_old, tilt, band_offsets, bands_number, framelength, fs, &sc ); + class = *xcorr * 7640.0 / 32768.0 - sc - 5112.0 / 32768.0; - if (class <= 0) + if ( class <= 0 ) { - if (frame_dms == 100 && hrmode == 0) + if ( frame_dms == 100 && hrmode == 0 ) { *concealMethod = 2; /* PhaseEcu selected */ } @@ -66,39 +62,39 @@ void processPlcClassify_fl(LC3_INT plcMeth, LC3_INT *concealMethod, LC3_INT32 *n } } -static void spectral_centroid_lc(LC3_FLOAT *gains, LC3_INT32 tilt, const LC3_INT *band_offsets, LC3_INT32 bands_number, LC3_INT32 framelength, LC3_INT32 fs, LC3_FLOAT *sc) +static void spectral_centroid_lc( LC3_FLOAT *gains, LC3_INT32 tilt, const LC3_INT *band_offsets, LC3_INT32 bands_number, LC3_INT32 framelength, LC3_INT32 fs, LC3_FLOAT *sc ) { - LC3_FLOAT gains_lin[M], gains_dee[M], numerator, denumerator; - LC3_INT32 i, j, sum, len, start, stop; - LC3_INT band_offsets_local[MAX_BANDS_NUMBER + 1]; - + LC3_FLOAT gains_lin[M], gains_dee[M], numerator, denumerator; + LC3_INT32 i, j, sum, len, start, stop; + LC3_INT band_offsets_local[MAX_BANDS_NUMBER + 1]; + numerator = 0; - for (i = 0; i < M; i++) + for ( i = 0; i < M; i++ ) { - gains_lin[i] = LC3_POW(2, gains[i]); + gains_lin[i] = LC3_POW( 2, gains[i] ); } - - for (i = 0; i < M; i++) + + for ( i = 0; i < M; i++ ) { - gains_dee[i] = gains_lin[i] / LC3_POW(10, i * (LC3_FLOAT) tilt / (LC3_FLOAT) (M - 1) / 10.0); + gains_dee[i] = gains_lin[i] / LC3_POW( 10, i * (LC3_FLOAT) tilt / (LC3_FLOAT) ( M - 1 ) / 10.0 ); } - - if (bands_number == 64) + + if ( bands_number == 64 ) { - memmove(band_offsets_local, band_offsets, (bands_number + 1) * sizeof(LC3_INT)); + memmove( band_offsets_local, band_offsets, ( bands_number + 1 ) * sizeof( LC3_INT ) ); } - if (bands_number < 32) + if ( bands_number < 32 ) { band_offsets_local[0] = 0; j = 32 - bands_number; - for (i = bands_number - 1; i >= j; i--) + for ( i = bands_number - 1; i >= j; i-- ) { - band_offsets_local[(i + j) * 2 + 1 + 1] = band_offsets[i + 1]; - band_offsets_local[(i + j) * 2 + 0 + 1] = band_offsets[i + 1]; + band_offsets_local[( i + j ) * 2 + 1 + 1] = band_offsets[i + 1]; + band_offsets_local[( i + j ) * 2 + 0 + 1] = band_offsets[i + 1]; } - for (i = j - 1; i >= 0; i--) + for ( i = j - 1; i >= 0; i-- ) { band_offsets_local[i * 4 + 3 + 1] = band_offsets[i + 1]; band_offsets_local[i * 4 + 2 + 1] = band_offsets[i + 1]; @@ -106,16 +102,15 @@ static void spectral_centroid_lc(LC3_FLOAT *gains, LC3_INT32 tilt, const LC3_INT band_offsets_local[i * 4 + 0 + 1] = band_offsets[i + 1]; } } - else - if (bands_number < 64) + else if ( bands_number < 64 ) { band_offsets_local[0] = 0; j = 64 - bands_number; - for (i = bands_number - 1; i >= j; i--) + for ( i = bands_number - 1; i >= j; i-- ) { band_offsets_local[i + j + 1] = band_offsets[i + 1]; } - for (i = j - 1; i >= 0; i--) + for ( i = j - 1; i >= 0; i-- ) { band_offsets_local[i * 2 + 1 + 1] = band_offsets[i + 1]; band_offsets_local[i * 2 + 0 + 1] = band_offsets[i + 1]; @@ -123,46 +118,48 @@ static void spectral_centroid_lc(LC3_FLOAT *gains, LC3_INT32 tilt, const LC3_INT } denumerator = 0.001; - - for (i = 0; i < M; i++) + + for ( i = 0; i < M; i++ ) { - sum = 0; len = 0; - start = band_offsets_local[i * 4] + 1; stop = band_offsets_local[i * 4 + 4]; - - for (j = stop; j >= start; j--) + sum = 0; + len = 0; + start = band_offsets_local[i * 4] + 1; + stop = band_offsets_local[i * 4 + 4]; + + for ( j = stop; j >= start; j-- ) { sum += j; len++; } - - numerator += gains_dee[i] * ((LC3_FLOAT) sum / (LC3_FLOAT) framelength); + + numerator += gains_dee[i] * ( (LC3_FLOAT) sum / (LC3_FLOAT) framelength ); denumerator += gains_dee[i] * len; } - + *sc = numerator / denumerator; *sc = *sc * (LC3_FLOAT) fs / 48000.0; /* scaling, because training is for 48kHz */ } -static void plc_xcorr_lc(LC3_FLOAT *pcmbufHist, LC3_INT32 max_len_pcm_plc, LC3_INT32 pitch_int, LC3_INT32 framelength, - LC3_INT32 frame_dms, LC3_INT32 fs, LC3_FLOAT *xcorr) +static void plc_xcorr_lc( LC3_FLOAT *pcmbufHist, LC3_INT32 max_len_pcm_plc, LC3_INT32 pitch_int, LC3_INT32 framelength, LC3_INT32 frame_dms, LC3_INT32 fs, LC3_FLOAT *xcorr ) { - LC3_INT32 max_corr_len, pitch_min, corr_len, min_corr_len, pcm_max_corr_len, range1Start, range2Start, i; - LC3_FLOAT norm_w, norm_w_t; - - norm_w_t = 0; norm_w = 0; - - assert(pitch_int >= 0); - assert(pitch_int <= MAX_LEN*100*MAX_PITCH_12K8/12800); - + LC3_INT32 max_corr_len, pitch_min, corr_len, min_corr_len, pcm_max_corr_len, range1Start, range2Start, i; + LC3_FLOAT norm_w, norm_w_t; + + norm_w_t = 0; + norm_w = 0; + + assert( pitch_int >= 0 ); + assert( pitch_int <= MAX_LEN * 100 * MAX_PITCH_12K8 / 12800 ); + *xcorr = 0; - if (pitch_int > 0) + if ( pitch_int > 0 ) { - pitch_min = fs * MIN_PITCH_12K8/12800; + pitch_min = fs * MIN_PITCH_12K8 / 12800; pcm_max_corr_len = max_len_pcm_plc - pitch_int; - min_corr_len = 2 * pitch_min; /* at least 5 ms (=2*pitchmin*) corr length */ - max_corr_len = framelength*100/frame_dms; /* maximum 10 ms */ + min_corr_len = 2 * pitch_min; /* at least 5 ms (=2*pitchmin*) corr length */ + max_corr_len = framelength * 100 / frame_dms; /* maximum 10 ms */ max_corr_len = MIN( max_corr_len, pcm_max_corr_len ); corr_len = MIN( max_corr_len, pitch_int ); /* pitch_int is prefered, but maximum 10ms or left pcm buf size */ @@ -175,25 +172,26 @@ static void plc_xcorr_lc(LC3_FLOAT *pcmbufHist, LC3_INT32 max_len_pcm_plc, LC3_I assert( corr_len <= max_corr_len ); assert( range2Start >= 0 ); - for (i = 0; i < corr_len; i++) + for ( i = 0; i < corr_len; i++ ) { norm_w += pcmbufHist[range1Start + i] * pcmbufHist[range1Start + i]; } - for (i = 0; i < corr_len; i++) + for ( i = 0; i < corr_len; i++ ) { norm_w_t += pcmbufHist[range2Start + i] * pcmbufHist[range2Start + i]; } - for (i = 0; i < corr_len; i++) + for ( i = 0; i < corr_len; i++ ) { *xcorr = *xcorr + pcmbufHist[range1Start + i] * pcmbufHist[range2Start + i]; } - *xcorr = *xcorr / sqrt(norm_w * norm_w_t + 0.1); - *xcorr = MAX(0, *xcorr); - } else { + *xcorr = *xcorr / sqrt( norm_w * norm_w_t + 0.1 ); + *xcorr = MAX( 0, *xcorr ); + } + else + { *xcorr = 0; } } - diff --git a/lib_lc3plus/plc_compute_stab_fac.c b/lib_lc3plus/plc_compute_stab_fac.c index 4a1111a2c7..04f2743684 100644 --- a/lib_lc3plus/plc_compute_stab_fac.c +++ b/lib_lc3plus/plc_compute_stab_fac.c @@ -1,64 +1,62 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -static void processPlcComputeStabFac_fl(LC3_FLOAT *scf_q, LC3_FLOAT *old_scf_q, LC3_INT32 prev_bfi, LC3_FLOAT *stab_fac); +static void processPlcComputeStabFac_fl( LC3_FLOAT *scf_q, LC3_FLOAT *old_scf_q, LC3_INT32 prev_bfi, LC3_FLOAT *stab_fac ); -void processPlcComputeStabFacMain_fl(LC3_FLOAT *scf_q, LC3_FLOAT *old_scf_q, LC3_FLOAT *old_old_scf_q, LC3_INT32 bfi, LC3_INT32 prev_bfi, - LC3_INT32 prev_prev_bfi, LC3_FLOAT *stab_fac) +void processPlcComputeStabFacMain_fl( LC3_FLOAT *scf_q, LC3_FLOAT *old_scf_q, LC3_FLOAT *old_old_scf_q, LC3_INT32 bfi, LC3_INT32 prev_bfi, LC3_INT32 prev_prev_bfi, LC3_FLOAT *stab_fac ) { - if (bfi == 1) + if ( bfi == 1 ) { - if (prev_bfi != 1) + if ( prev_bfi != 1 ) { - processPlcComputeStabFac_fl(old_scf_q, old_old_scf_q, prev_prev_bfi, stab_fac); + processPlcComputeStabFac_fl( old_scf_q, old_old_scf_q, prev_prev_bfi, stab_fac ); } } - else if (bfi == 2) + else if ( bfi == 2 ) { - processPlcComputeStabFac_fl(scf_q, old_scf_q, prev_bfi, stab_fac); + processPlcComputeStabFac_fl( scf_q, old_scf_q, prev_bfi, stab_fac ); } } -static void processPlcComputeStabFac_fl(LC3_FLOAT *scf_q, LC3_FLOAT *old_scf_q, LC3_INT32 prev_bfi, LC3_FLOAT *stab_fac) +static void processPlcComputeStabFac_fl( LC3_FLOAT *scf_q, LC3_FLOAT *old_scf_q, LC3_INT32 prev_bfi, LC3_FLOAT *stab_fac ) { - LC3_FLOAT tmp; - LC3_INT32 i; - + LC3_FLOAT tmp; + LC3_INT32 i; + tmp = 0; - - if (prev_bfi == 1) + + if ( prev_bfi == 1 ) { *stab_fac = 0.8; } else { - for (i = 0; i < M; i++) + for ( i = 0; i < M; i++ ) { - tmp += (scf_q[i] - old_scf_q[i]) * (scf_q[i] - old_scf_q[i]); + tmp += ( scf_q[i] - old_scf_q[i] ) * ( scf_q[i] - old_scf_q[i] ); } *stab_fac = 1.25 - tmp / 25.0; - if (*stab_fac > 1) + if ( *stab_fac > 1 ) { *stab_fac = 1; } - if (*stab_fac < 0) + if ( *stab_fac < 0 ) { *stab_fac = 0; } } } - diff --git a/lib_lc3plus/plc_damping_scrambling.c b/lib_lc3plus/plc_damping_scrambling.c index ecea32be5f..15fb5d7860 100644 --- a/lib_lc3plus/plc_damping_scrambling.c +++ b/lib_lc3plus/plc_damping_scrambling.c @@ -1,152 +1,172 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -void processPlcDampingScramblingMain_fl(LC3_INT32 *ns_seed, - LC3_INT32 *pc_seed, LC3_INT32 ns_nbLostCmpt_pc, - LC3_INT32 ns_nbLostCmpt, LC3_FLOAT *stabFac, LC3_FLOAT *cum_fading_slow, LC3_FLOAT *cum_fading_fast, - LC3_FLOAT *spec_prev, LC3_FLOAT *spec, LC3_INT32 spec_inv_idx, LC3_INT32 yLen, LC3_INT32 bfi, - LC3_INT32 frame_dms, LC3_INT32 concealMethod, LC3_INT32 pitch_present_bfi1, LC3_INT32 pitch_present_bfi2, - LC3_FLOAT *cum_fflcAtten) +void processPlcDampingScramblingMain_fl( LC3_INT32 *ns_seed, + LC3_INT32 *pc_seed, + LC3_INT32 ns_nbLostCmpt_pc, + LC3_INT32 ns_nbLostCmpt, + LC3_FLOAT *stabFac, + LC3_FLOAT *cum_fading_slow, + LC3_FLOAT *cum_fading_fast, + LC3_FLOAT *spec_prev, + LC3_FLOAT *spec, + LC3_INT32 spec_inv_idx, + LC3_INT32 yLen, + LC3_INT32 bfi, + LC3_INT32 frame_dms, + LC3_INT32 concealMethod, + LC3_INT32 pitch_present_bfi1, + LC3_INT32 pitch_present_bfi2, + LC3_FLOAT *cum_fflcAtten ) { - LC3_INT32 processDampScramb; + LC3_INT32 processDampScramb; processDampScramb = 0; - + if ( bfi != 0 ) { - if (concealMethod == 4 || bfi == 2) + if ( concealMethod == 4 || bfi == 2 ) { processDampScramb = 1; } if ( bfi == 1 ) { - processPlcDampingScrambling_fl(spec, yLen, ns_nbLostCmpt, stabFac, processDampScramb, cum_fflcAtten, - pitch_present_bfi1, frame_dms, cum_fading_slow, cum_fading_fast, ns_seed, 0); + processPlcDampingScrambling_fl( spec, yLen, ns_nbLostCmpt, stabFac, processDampScramb, cum_fflcAtten, + pitch_present_bfi1, frame_dms, cum_fading_slow, cum_fading_fast, ns_seed, 0 ); } else /* bfi == 2 */ { - processPlcDampingScrambling_fl(spec, yLen, ns_nbLostCmpt_pc, stabFac, processDampScramb, cum_fflcAtten, - pitch_present_bfi2, frame_dms, cum_fading_slow, cum_fading_fast, pc_seed, spec_inv_idx); - processPlcUpdateSpec_fl(spec_prev, spec, yLen); + processPlcDampingScrambling_fl( spec, yLen, ns_nbLostCmpt_pc, stabFac, processDampScramb, cum_fflcAtten, + pitch_present_bfi2, frame_dms, cum_fading_slow, cum_fading_fast, pc_seed, spec_inv_idx ); + processPlcUpdateSpec_fl( spec_prev, spec, yLen ); } } } -void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 nbLostCmpt, LC3_FLOAT *stabFac, LC3_INT32 processDampScramb, - LC3_FLOAT *cum_fflcAtten, LC3_INT32 pitch_present, LC3_INT32 frame_dms, LC3_FLOAT *cum_fading_slow, - LC3_FLOAT *cum_fading_fast, LC3_INT32 *seed, LC3_INT32 spec_inv_idx) +void processPlcDampingScrambling_fl( LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 nbLostCmpt, LC3_FLOAT *stabFac, LC3_INT32 processDampScramb, LC3_FLOAT *cum_fflcAtten, LC3_INT32 pitch_present, LC3_INT32 frame_dms, LC3_FLOAT *cum_fading_slow, LC3_FLOAT *cum_fading_fast, LC3_INT32 *seed, LC3_INT32 spec_inv_idx ) { LC3_INT32 plc_start_inFrames, plc_end_inFrames, plc_duration_inFrames, x, b, i, ad_ThreshFac_start; LC3_FLOAT slow, fast, linFuncStartStop, randThreshold, ad_ThreshFac_end, ad_threshFac, frame_energy, mean_energy, energThreshold, fac, m, n, fflcAtten, cum_fading_slow_local, cum_fading_fast_local; - + frame_energy = 0; /* Main process */ - if (nbLostCmpt == 1) + if ( nbLostCmpt == 1 ) { *cum_fading_slow = 1; *cum_fading_fast = 1; - *cum_fflcAtten = 1; + *cum_fflcAtten = 1; } - slow = 0.8 + 0.2 * (*stabFac); - fast = 0.3 + 0.2 * (*stabFac); + slow = 0.8 + 0.2 * ( *stabFac ); + fast = 0.3 + 0.2 * ( *stabFac ); - switch (frame_dms) + switch ( frame_dms ) { - case 25: - slow = LC3_SQRT(LC3_SQRT(slow)); - fast = LC3_SQRT(LC3_SQRT(fast)); - break; - case 50: - slow = LC3_SQRT(slow); - fast = LC3_SQRT(fast); - break; + case 25: + slow = LC3_SQRT( LC3_SQRT( slow ) ); + fast = LC3_SQRT( LC3_SQRT( fast ) ); + break; + case 50: + slow = LC3_SQRT( slow ); + fast = LC3_SQRT( fast ); + break; } *cum_fading_slow = *cum_fading_slow * slow; *cum_fading_fast = *cum_fading_fast * fast; - - if (processDampScramb == 1) + + if ( processDampScramb == 1 ) { fflcAtten = 1; cum_fading_slow_local = *cum_fading_slow; cum_fading_fast_local = *cum_fading_fast; - - if (spec_inv_idx == 0) + + if ( spec_inv_idx == 0 ) { - if (nbLostCmpt * frame_dms > PLC_FADEOUT_IN_MS * 10) + if ( nbLostCmpt * frame_dms > PLC_FADEOUT_IN_MS * 10 ) { fflcAtten = 0; *cum_fflcAtten = 0; } - else if (nbLostCmpt * frame_dms > 200) + else if ( nbLostCmpt * frame_dms > 200 ) { - switch(frame_dms) + switch ( frame_dms ) { - case 25: fflcAtten = PLC34_ATTEN_FAC_025; break; - case 50: fflcAtten = PLC34_ATTEN_FAC_050; break; - case 100: fflcAtten = PLC34_ATTEN_FAC_100; break; + case 25: + fflcAtten = PLC34_ATTEN_FAC_025; + break; + case 50: + fflcAtten = PLC34_ATTEN_FAC_050; + break; + case 100: + fflcAtten = PLC34_ATTEN_FAC_100; + break; } } - - - *cum_fflcAtten = *cum_fflcAtten * fflcAtten; + + + *cum_fflcAtten = *cum_fflcAtten * fflcAtten; cum_fading_slow_local = *cum_fading_slow * *cum_fflcAtten; cum_fading_fast_local = *cum_fading_fast * *cum_fflcAtten; } - if (pitch_present == 0) + if ( pitch_present == 0 ) { - plc_start_inFrames = 1; - } else { - plc_start_inFrames = floor(PLC4_TRANSIT_START_IN_MS / (frame_dms / 10.0)); + plc_start_inFrames = 1; + } + else + { + plc_start_inFrames = floor( PLC4_TRANSIT_START_IN_MS / ( frame_dms / 10.0 ) ); } - plc_end_inFrames = floor(PLC4_TRANSIT_END_IN_MS / (frame_dms / 10.0)); - plc_duration_inFrames = plc_end_inFrames - plc_start_inFrames; + plc_end_inFrames = floor( PLC4_TRANSIT_END_IN_MS / ( frame_dms / 10.0 ) ); + plc_duration_inFrames = plc_end_inFrames - plc_start_inFrames; - if (nbLostCmpt <= plc_start_inFrames) + if ( nbLostCmpt <= plc_start_inFrames ) { linFuncStartStop = 1; - } else if (nbLostCmpt >= plc_end_inFrames) + } + else if ( nbLostCmpt >= plc_end_inFrames ) { linFuncStartStop = 0; - } else { + } + else + { x = nbLostCmpt; m = -1.0 / plc_duration_inFrames; b = -plc_end_inFrames; - linFuncStartStop = m * (x + b); + linFuncStartStop = m * ( x + b ); } - + randThreshold = -32768 * linFuncStartStop; - - for (i = spec_inv_idx; i < yLen; i++) + + for ( i = spec_inv_idx; i < yLen; i++ ) { *seed = 16831 + *seed * 12821; - *seed = (LC3_INT16)(*seed); - if (*seed == 32768) + *seed = (LC3_INT16) ( *seed ); + if ( *seed == 32768 ) { *seed -= 32768; } - if (*seed < 0) + if ( *seed < 0 ) { - if (pitch_present == 0 || *seed < randThreshold) + if ( pitch_present == 0 || *seed < randThreshold ) { spec[i] = -spec[i]; } @@ -154,29 +174,29 @@ void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 n } ad_ThreshFac_start = 10; - ad_ThreshFac_end = 1.2; - ad_threshFac = (ad_ThreshFac_start - ad_ThreshFac_end) * linFuncStartStop + ad_ThreshFac_end; + ad_ThreshFac_end = 1.2; + ad_threshFac = ( ad_ThreshFac_start - ad_ThreshFac_end ) * linFuncStartStop + ad_ThreshFac_end; - if (spec_inv_idx < yLen) + if ( spec_inv_idx < yLen ) { - for (i = spec_inv_idx; i < yLen; i++) + for ( i = spec_inv_idx; i < yLen; i++ ) { - frame_energy = frame_energy + (spec[i] * spec[i]); + frame_energy = frame_energy + ( spec[i] * spec[i] ); } - mean_energy = frame_energy * 1 / (yLen - spec_inv_idx); + mean_energy = frame_energy * 1 / ( yLen - spec_inv_idx ); } else { mean_energy = 0; } - energThreshold = LC3_SQRT(ad_threshFac * mean_energy); - fac = (cum_fading_slow_local - cum_fading_fast_local) * energThreshold; + energThreshold = LC3_SQRT( ad_threshFac * mean_energy ); + fac = ( cum_fading_slow_local - cum_fading_fast_local ) * energThreshold; - for (i = spec_inv_idx; i < yLen; i++) + for ( i = spec_inv_idx; i < yLen; i++ ) { - if (LC3_FABS(spec[i]) < energThreshold) + if ( LC3_FABS( spec[i] ) < energThreshold ) { m = cum_fading_slow_local; n = 0; @@ -185,11 +205,11 @@ void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 n { m = cum_fading_fast_local; - if (spec[i] > 0) + if ( spec[i] > 0 ) { n = fac; } - else if (spec[i] == 0) + else if ( spec[i] == 0 ) { n = 0; } @@ -203,4 +223,3 @@ void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 n } } } - diff --git a/lib_lc3plus/plc_main.c b/lib_lc3plus/plc_main.c index df3fd184d9..27d3474ecc 100644 --- a/lib_lc3plus/plc_main.c +++ b/lib_lc3plus/plc_main.c @@ -1,38 +1,34 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -void processPlcMain_fl(LC3_FLOAT *q_d_fl_c, LC3_FLOAT *syntM_fl_c, LC3PLUS_Dec* decoder, DecSetup* h_DecSetup, LC3_INT bfi, - PlcAdvSetup *PlcAdvSetup, PlcSetup *PlcSetup, LC3_INT plcMeth, LC3_INT ltpf_pitch_int, LC3_INT ltpf_pitch_fr, - LC3_INT tilt, const LC3_INT *bands_offset, LC3_INT bands_number, const LC3_INT *bands_offsetPLC, - LC3_INT n_bandsPLC, LC3_INT16 hrmode, pcState *statePC -) +void processPlcMain_fl( LC3_FLOAT *q_d_fl_c, LC3_FLOAT *syntM_fl_c, LC3PLUS_Dec *decoder, DecSetup *h_DecSetup, LC3_INT bfi, PlcAdvSetup *PlcAdvSetup, PlcSetup *PlcSetup, LC3_INT plcMeth, LC3_INT ltpf_pitch_int, LC3_INT ltpf_pitch_fr, LC3_INT tilt, const LC3_INT *bands_offset, LC3_INT bands_number, const LC3_INT *bands_offsetPLC, LC3_INT n_bandsPLC, LC3_INT16 hrmode, pcState *statePC ) { LC3_FLOAT r[MAX_BANDS_NUMBER_PLC], A[M + 1], synth[MAX_LEN + MDCT_MEM_LEN_MAX], energies[MAX_BANDS_NUMBER_PLC]; LC3_INT32 pitch_classifier; LC3_FLOAT xcorr; LC3_INT32 yLen; LC3_INT16 prev_bfi_plc2; - LC3_FLOAT phEcu_env_stab_local[1]; - LC3_FLOAT phEcu_pfind_sens[1]; + LC3_FLOAT phEcu_env_stab_local[1]; + LC3_FLOAT phEcu_pfind_sens[1]; prev_bfi_plc2 = 1; - if (PlcSetup->nbLostCmpt == 0) + if ( PlcSetup->nbLostCmpt == 0 ) { prev_bfi_plc2 = 0; } - assert((h_DecSetup->PlcSetup.prevBfi == 1) == (prev_bfi_plc2 == 1)); + assert( ( h_DecSetup->PlcSetup.prevBfi == 1 ) == ( prev_bfi_plc2 == 1 ) ); - if (bfi == 1 && PlcAdvSetup) + if ( bfi == 1 && PlcAdvSetup ) { /* FFLC increases the PFLC counter */ statePC->ns_nbLostCmpt_pc = statePC->ns_nbLostCmpt_pc + 1; @@ -40,170 +36,161 @@ void processPlcMain_fl(LC3_FLOAT *q_d_fl_c, LC3_FLOAT *syntM_fl_c, LC3PLUS_Dec* pitch_classifier = ltpf_pitch_int; #ifdef NONBE_PLC_CLASSIFER_LAG_FIX - if (ltpf_pitch_fr > 2) + if ( ltpf_pitch_fr > 2 ) { pitch_classifier++; } #endif - processPlcClassify_fl(plcMeth, &h_DecSetup->concealMethod, &PlcSetup->nbLostCmpt, bfi, &xcorr, - decoder->frame_length, decoder->frame_dms, pitch_classifier, decoder->fs, - bands_offset, bands_number, tilt, PlcAdvSetup, hrmode - ); + processPlcClassify_fl( plcMeth, &h_DecSetup->concealMethod, &PlcSetup->nbLostCmpt, bfi, &xcorr, + decoder->frame_length, decoder->frame_dms, pitch_classifier, decoder->fs, + bands_offset, bands_number, tilt, PlcAdvSetup, hrmode ); - if (bfi == 1) + if ( bfi == 1 ) { - switch (h_DecSetup->concealMethod) - { - case 2: + switch ( h_DecSetup->concealMethod ) { - LC3_FLOAT pitch_fl_c; - - assert(decoder->fs_idx == floor(decoder->fs / 10000)); - // phaseECU supports only 10ms framing - assert(PlcSetup->nbLostCmpt != 0 || decoder->frame_dms == 100); - - if (decoder->frame_dms != 100) + case 2: { - // muting, if frame size changed during phaseECU concealment - memset(q_d_fl_c, 0, sizeof(LC3_FLOAT) * decoder->frame_length); - h_DecSetup->alpha = 0; - break; - } + LC3_FLOAT pitch_fl_c; - /* call phaseEcu */ - pitch_fl_c = (LC3_FLOAT)ltpf_pitch_int + (LC3_FLOAT)ltpf_pitch_fr / 4.0; /* use non-rounded pitch indeces */ + assert( decoder->fs_idx == floor( decoder->fs / 10000 ) ); + // phaseECU supports only 10ms framing + assert( PlcSetup->nbLostCmpt != 0 || decoder->frame_dms == 100 ); - - if (prev_bfi_plc2 == 0) - { - /* convert fractional pitch lag info at current fs to a normalized fractional bin-frequency */ - PlcAdvSetup->PlcPhEcuSetup.PhECU_f0hzLtpBin = plc_phEcuSetF0Hz(decoder->fs, &pitch_fl_c); - /* several buffers used in Cflt , a copy pcmbufHist, right before calling PhEcu in bad frames */ - assert(bfi == 1); - move_float(PlcAdvSetup->PlcPhEcuSetup.PhECU_xfp, - &(PlcAdvSetup->pcmbufHist[PlcAdvSetup->max_len_pcm_plc - PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot]), - PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot); - - /* a first bfi frame:: calc windowed 16 ms energy twice in a 26 ms buffer separated by 10 ms*/ + if ( decoder->frame_dms != 100 ) { - const LC3_FLOAT *w, *prev_xfp; - LC3_INT32 i, oold_start; + // muting, if frame size changed during phaseECU concealment + memset( q_d_fl_c, 0, sizeof( LC3_FLOAT ) * decoder->frame_length ); + h_DecSetup->alpha = 0; + break; + } + + /* call phaseEcu */ + pitch_fl_c = (LC3_FLOAT) ltpf_pitch_int + (LC3_FLOAT) ltpf_pitch_fr / 4.0; /* use non-rounded pitch indeces */ - oold_start = PlcAdvSetup->max_len_pcm_plc - (decoder->frame_length + PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot); - assert(oold_start > 0); - w = PhECU_whr16ms_wins[decoder->fs_idx]; /* hammrect table */ - prev_xfp = &(PlcAdvSetup->pcmbufHist[oold_start + 0]); - PlcAdvSetup->PlcPhEcuSetup.PhECU_L_oold_xfp_w_E = 0; - PlcAdvSetup->PlcPhEcuSetup.PhECU_L_old_xfp_w_E = 0; - for (i = 0; i < PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot; i++) + if ( prev_bfi_plc2 == 0 ) + { + /* convert fractional pitch lag info at current fs to a normalized fractional bin-frequency */ + PlcAdvSetup->PlcPhEcuSetup.PhECU_f0hzLtpBin = plc_phEcuSetF0Hz( decoder->fs, &pitch_fl_c ); + /* several buffers used in Cflt , a copy pcmbufHist, right before calling PhEcu in bad frames */ + assert( bfi == 1 ); + move_float( PlcAdvSetup->PlcPhEcuSetup.PhECU_xfp, + &( PlcAdvSetup->pcmbufHist[PlcAdvSetup->max_len_pcm_plc - PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot] ), + PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot ); + + /* a first bfi frame:: calc windowed 16 ms energy twice in a 26 ms buffer separated by 10 ms*/ { - PlcAdvSetup->PlcPhEcuSetup.PhECU_L_oold_xfp_w_E += sqrf(prev_xfp[i] * w[i]); - PlcAdvSetup->PlcPhEcuSetup.PhECU_L_old_xfp_w_E += sqrf(PlcAdvSetup->PlcPhEcuSetup.PhECU_xfp[i] * w[i]); + const LC3_FLOAT *w, *prev_xfp; + LC3_INT32 i, oold_start; + + oold_start = PlcAdvSetup->max_len_pcm_plc - ( decoder->frame_length + PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot ); + assert( oold_start > 0 ); + w = PhECU_whr16ms_wins[decoder->fs_idx]; /* hammrect table */ + prev_xfp = &( PlcAdvSetup->pcmbufHist[oold_start + 0] ); + + PlcAdvSetup->PlcPhEcuSetup.PhECU_L_oold_xfp_w_E = 0; + PlcAdvSetup->PlcPhEcuSetup.PhECU_L_old_xfp_w_E = 0; + for ( i = 0; i < PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot; i++ ) + { + PlcAdvSetup->PlcPhEcuSetup.PhECU_L_oold_xfp_w_E += sqrf( prev_xfp[i] * w[i] ); + PlcAdvSetup->PlcPhEcuSetup.PhECU_L_old_xfp_w_E += sqrf( PlcAdvSetup->PlcPhEcuSetup.PhECU_xfp[i] * w[i] ); + } } - } - - } /* (prev_bfi_plc2 == 0)*/ - else - { - /* overwrite last 3.75 ms of xfp with most recent pcmbufHist tail , right before calling PhEcu in bursts of bad frames */ - LC3_INT32 lenCopyOla = decoder->la_zeroes; /*copy_part + ola_part = 3.75 ms for 10 ms frame*/ - - assert(bfi == 1 && prev_bfi_plc2); - move_float(&(PlcAdvSetup->PlcPhEcuSetup.PhECU_xfp[PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot-lenCopyOla]), - &(PlcAdvSetup->pcmbufHist[PlcAdvSetup->max_len_pcm_plc - lenCopyOla]), lenCopyOla); - - } + } /* (prev_bfi_plc2 == 0)*/ + else + { + /* overwrite last 3.75 ms of xfp with most recent pcmbufHist tail , right before calling PhEcu in bursts of bad frames */ + LC3_INT32 lenCopyOla = decoder->la_zeroes; /*copy_part + ola_part = 3.75 ms for 10 ms frame*/ - { - LC3_FLOAT x_tda[MAX_LEN]; /* 960/2 */ - PlcAdvSetup->PlcPhEcuSetup.PhECU_norm_corr = xcorr; - phEcu_env_stab_local[0] = (LC3_FLOAT)PHECU_ENV_STAB_LOCAL; - phEcu_pfind_sens[0] = (LC3_FLOAT)PHECU_PFIND_SENS; - - plc_phEcu_hq_ecu(&(PlcAdvSetup->PlcPhEcuSetup.PhECU_f0hzLtpBin), - &(PlcAdvSetup->PlcPhEcuSetup.PhECU_norm_corr), - PlcAdvSetup->PlcPhEcuSetup.PhECU_xfp, - prev_bfi_plc2, - &(PlcAdvSetup->PlcPhEcuSetup.PhECU_short_flag_prev), - decoder->fs, - &(PlcAdvSetup->PlcPhEcuSetup.PhECU_time_offs), - PlcAdvSetup->PlcPhEcuSetup.PhECU_X_sav_m, /* Complex */ - &(PlcAdvSetup->PlcPhEcuSetup.PhECU_num_plocs), - PlcAdvSetup->PlcPhEcuSetup.PhECU_plocs, - PlcAdvSetup->PlcPhEcuSetup.PhECU_f0est, - MDCT_WINS_10ms[hrmode][decoder->fs_idx], - - phEcu_env_stab_local, - PHECU_DELTA_CORR, - phEcu_pfind_sens, - PHECU_LA, - PlcAdvSetup->PlcPhEcuSetup.PhECU_t_adv, - PhECU_whr16ms_wins[decoder->fs_idx], - PlcAdvSetup->PlcPhEcuSetup.PhECU_oold_grp_shape, - &(PlcAdvSetup->PlcPhEcuSetup.PhECU_L_oold_xfp_w_E), - PlcAdvSetup->PlcPhEcuSetup.PhECU_old_grp_shape, - &(PlcAdvSetup->PlcPhEcuSetup.PhECU_L_old_xfp_w_E), - &(PlcAdvSetup->PlcPhEcuSetup.PhECU_beta_mute), - PlcAdvSetup->PlcPhEcuSetup.PhECU_mag_chg_1st, - PlcAdvSetup->PlcPhEcuSetup.PhECU_Xavg, - decoder->la_zeroes, - x_tda, /* time domain aliased output */ - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL - , - &(PlcAdvSetup->PlcPhEcuSetup.PhEcu_Fft), - &(PlcAdvSetup->PlcPhEcuSetup.PhEcu_Ifft) - ); - - - ProcessingITDA_WIN_OLA_fl(x_tda, decoder->frame_length, decoder->imdct_win, decoder->imdct_winLen, decoder->imdct_laZeros, - h_DecSetup->imdct_mem, synth); - move_float(syntM_fl_c, synth, decoder->frame_length); - - + assert( bfi == 1 && prev_bfi_plc2 ); + move_float( &( PlcAdvSetup->PlcPhEcuSetup.PhECU_xfp[PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot - lenCopyOla] ), + &( PlcAdvSetup->pcmbufHist[PlcAdvSetup->max_len_pcm_plc - lenCopyOla] ), lenCopyOla ); + } + { + LC3_FLOAT x_tda[MAX_LEN]; /* 960/2 */ + PlcAdvSetup->PlcPhEcuSetup.PhECU_norm_corr = xcorr; + phEcu_env_stab_local[0] = (LC3_FLOAT) PHECU_ENV_STAB_LOCAL; + phEcu_pfind_sens[0] = (LC3_FLOAT) PHECU_PFIND_SENS; + + plc_phEcu_hq_ecu( &( PlcAdvSetup->PlcPhEcuSetup.PhECU_f0hzLtpBin ), + &( PlcAdvSetup->PlcPhEcuSetup.PhECU_norm_corr ), + PlcAdvSetup->PlcPhEcuSetup.PhECU_xfp, + prev_bfi_plc2, + &( PlcAdvSetup->PlcPhEcuSetup.PhECU_short_flag_prev ), + decoder->fs, + &( PlcAdvSetup->PlcPhEcuSetup.PhECU_time_offs ), + PlcAdvSetup->PlcPhEcuSetup.PhECU_X_sav_m, /* Complex */ + &( PlcAdvSetup->PlcPhEcuSetup.PhECU_num_plocs ), + PlcAdvSetup->PlcPhEcuSetup.PhECU_plocs, + PlcAdvSetup->PlcPhEcuSetup.PhECU_f0est, + MDCT_WINS_10ms[hrmode][decoder->fs_idx], + + phEcu_env_stab_local, + PHECU_DELTA_CORR, + phEcu_pfind_sens, + PHECU_LA, + PlcAdvSetup->PlcPhEcuSetup.PhECU_t_adv, + PhECU_whr16ms_wins[decoder->fs_idx], + PlcAdvSetup->PlcPhEcuSetup.PhECU_oold_grp_shape, + &( PlcAdvSetup->PlcPhEcuSetup.PhECU_L_oold_xfp_w_E ), + PlcAdvSetup->PlcPhEcuSetup.PhECU_old_grp_shape, + &( PlcAdvSetup->PlcPhEcuSetup.PhECU_L_old_xfp_w_E ), + &( PlcAdvSetup->PlcPhEcuSetup.PhECU_beta_mute ), + PlcAdvSetup->PlcPhEcuSetup.PhECU_mag_chg_1st, + PlcAdvSetup->PlcPhEcuSetup.PhECU_Xavg, + decoder->la_zeroes, + x_tda, /* time domain aliased output */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + &( PlcAdvSetup->PlcPhEcuSetup.PhEcu_Fft ), + &( PlcAdvSetup->PlcPhEcuSetup.PhEcu_Ifft ) ); + + + ProcessingITDA_WIN_OLA_fl( x_tda, decoder->frame_length, decoder->imdct_win, decoder->imdct_winLen, decoder->imdct_laZeros, + h_DecSetup->imdct_mem, synth ); + move_float( syntM_fl_c, synth, decoder->frame_length ); + } } - } - break; - case 3: - if (PlcSetup->nbLostCmpt == 1) - { - PlcAdvSetup->PlcTdcSetup.fract = ltpf_pitch_fr; - } - - processPerBandEnergy_fl(n_bandsPLC, bands_offsetPLC, hrmode, decoder->frame_dms, energies, PlcSetup->q_d_prev); - processTdcPreemphasis_fl(energies, &PlcAdvSetup->PlcTdcSetup.preemphFac, n_bandsPLC); - processTdcInverseOdft_fl(energies, n_bandsPLC, r, PlcAdvSetup->PlcTdcSetup.lpcorder); - processTdcLpcEstimation_fl(r, decoder->fs_idx, PlcAdvSetup->PlcTdcSetup.lpcorder + 1, A, decoder->frame_dms); - processTdcApply_fl(ltpf_pitch_int, &PlcAdvSetup->PlcTdcSetup.preemphFac, A, PlcAdvSetup->PlcTdcSetup.lpcorder, PlcAdvSetup->pcmbufHist, PlcAdvSetup->max_len_pcm_plc, decoder->frame_length, - decoder->frame_dms, decoder->fs, PlcSetup->nbLostCmpt, decoder->frame_length - decoder->la_zeroes, &PlcAdvSetup->stabFac, PlcAdvSetup->PlcTdcSetup.harmonicBuf, - PlcAdvSetup->PlcTdcSetup.synthHist, &PlcAdvSetup->PlcTdcSetup.fract, &PlcAdvSetup->PlcTdcSetup.seed, &PlcAdvSetup->PlcTdcSetup.gain_c, - &h_DecSetup->alpha, synth); - - processTdcTdac_fl(synth, decoder->imdct_win, decoder->frame_length, decoder->la_zeroes, h_DecSetup->imdct_mem); - memmove(syntM_fl_c, synth, sizeof(LC3_FLOAT) * decoder->frame_length); - break; - case 4: - processNoiseSubstitution_fl(q_d_fl_c, PlcSetup->q_d_prev, decoder->yLen); break; - default: - assert("Invalid PLC method!"); + case 3: + if ( PlcSetup->nbLostCmpt == 1 ) + { + PlcAdvSetup->PlcTdcSetup.fract = ltpf_pitch_fr; + } + + processPerBandEnergy_fl( n_bandsPLC, bands_offsetPLC, hrmode, decoder->frame_dms, energies, PlcSetup->q_d_prev ); + processTdcPreemphasis_fl( energies, &PlcAdvSetup->PlcTdcSetup.preemphFac, n_bandsPLC ); + processTdcInverseOdft_fl( energies, n_bandsPLC, r, PlcAdvSetup->PlcTdcSetup.lpcorder ); + processTdcLpcEstimation_fl( r, decoder->fs_idx, PlcAdvSetup->PlcTdcSetup.lpcorder + 1, A, decoder->frame_dms ); + processTdcApply_fl( ltpf_pitch_int, &PlcAdvSetup->PlcTdcSetup.preemphFac, A, PlcAdvSetup->PlcTdcSetup.lpcorder, PlcAdvSetup->pcmbufHist, PlcAdvSetup->max_len_pcm_plc, decoder->frame_length, + decoder->frame_dms, decoder->fs, PlcSetup->nbLostCmpt, decoder->frame_length - decoder->la_zeroes, &PlcAdvSetup->stabFac, PlcAdvSetup->PlcTdcSetup.harmonicBuf, + PlcAdvSetup->PlcTdcSetup.synthHist, &PlcAdvSetup->PlcTdcSetup.fract, &PlcAdvSetup->PlcTdcSetup.seed, &PlcAdvSetup->PlcTdcSetup.gain_c, + &h_DecSetup->alpha, synth ); + + processTdcTdac_fl( synth, decoder->imdct_win, decoder->frame_length, decoder->la_zeroes, h_DecSetup->imdct_mem ); + memmove( syntM_fl_c, synth, sizeof( LC3_FLOAT ) * decoder->frame_length ); + break; + case 4: + processNoiseSubstitution_fl( q_d_fl_c, PlcSetup->q_d_prev, decoder->yLen ); + break; + default: + assert( "Invalid PLC method!" ); } } - if (bfi == 0) + if ( bfi == 0 ) { - processPlcUpdateSpec_fl(PlcSetup->q_d_prev, q_d_fl_c, decoder->yLen); + processPlcUpdateSpec_fl( PlcSetup->q_d_prev, q_d_fl_c, decoder->yLen ); } - yLen = MIN(decoder->frame_length, MAX_PLC_LMEM); - if (PlcAdvSetup != NULL && (decoder->frame_dms == 100) && (hrmode == 0)) - { - /* BASOP processPLCspec2shape_fx(prev_bfi, bfi, q_old_d_fx, yLen, plcAd->PhECU_oold_grp_shape_fx, plcAd->PhECU_old_grp_shape_fx);*/ - plc_phEcu_processPLCspec2shape(prev_bfi_plc2, bfi, q_d_fl_c, yLen, - PlcAdvSetup->PlcPhEcuSetup.PhECU_oold_grp_shape, PlcAdvSetup->PlcPhEcuSetup.PhECU_old_grp_shape); - } + yLen = MIN( decoder->frame_length, MAX_PLC_LMEM ); + if ( PlcAdvSetup != NULL && ( decoder->frame_dms == 100 ) && ( hrmode == 0 ) ) + { + /* BASOP processPLCspec2shape_fx(prev_bfi, bfi, q_old_d_fx, yLen, plcAd->PhECU_oold_grp_shape_fx, plcAd->PhECU_old_grp_shape_fx);*/ + plc_phEcu_processPLCspec2shape( prev_bfi_plc2, bfi, q_d_fl_c, yLen, + PlcAdvSetup->PlcPhEcuSetup.PhECU_oold_grp_shape, PlcAdvSetup->PlcPhEcuSetup.PhECU_old_grp_shape ); + } } - diff --git a/lib_lc3plus/plc_noise_substitution.c b/lib_lc3plus/plc_noise_substitution.c index 4913ee53e5..ba63aaabe9 100644 --- a/lib_lc3plus/plc_noise_substitution.c +++ b/lib_lc3plus/plc_noise_substitution.c @@ -1,22 +1,21 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -void processNoiseSubstitution_fl(LC3_FLOAT* spec, LC3_FLOAT* spec_prev, LC3_INT32 yLen) +void processNoiseSubstitution_fl( LC3_FLOAT *spec, LC3_FLOAT *spec_prev, LC3_INT32 yLen ) { - memmove(spec, spec_prev, sizeof(LC3_FLOAT) * yLen); - + memmove( spec, spec_prev, sizeof( LC3_FLOAT ) * yLen ); + spec[0] *= 0.2; spec[1] *= 0.5; } - diff --git a/lib_lc3plus/plc_phecu_f0_refine_first.c b/lib_lc3plus/plc_phecu_f0_refine_first.c index 11ebf276b1..36cf39c23d 100644 --- a/lib_lc3plus/plc_phecu_f0_refine_first.c +++ b/lib_lc3plus/plc_phecu_f0_refine_first.c @@ -1,68 +1,78 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "defines.h" #include "functions.h" -void plc_phEcu_F0_refine_first( LC3_INT32 *plocs, /* i/o 0 ... Lprot/2 +1*/ +void plc_phEcu_F0_refine_first( LC3_INT32 *plocs, /* i/o 0 ... Lprot/2 +1*/ LC3_INT32 n_plocs, - LC3_FLOAT *f0est, /* i/o f0est */ + LC3_FLOAT *f0est, /* i/o f0est */ const LC3_INT32 Xabs_len, LC3_FLOAT *f0binPtr, /* i */ LC3_FLOAT *f0gainPtr, /* i */ - const LC3_INT32 nSubm - ) + const LC3_INT32 nSubm ) { - LC3_FLOAT sens; - LC3_INT32 i, j, high_idx, breakflag; - LC3_FLOAT f0est_lim[MAX_PLC_NPLOCS]; - LC3_FLOAT f0bin; - LC3_FLOAT f0gain; + LC3_FLOAT sens; + LC3_INT32 i, j, high_idx, breakflag; + LC3_FLOAT f0est_lim[MAX_PLC_NPLOCS]; + LC3_FLOAT f0bin; + LC3_FLOAT f0gain; + + f0bin = *f0binPtr; + f0gain = *f0gainPtr; - f0bin = *f0binPtr; - f0gain = *f0gainPtr; + if ( n_plocs > 0 && f0gain > 0.25 ) + { - if (n_plocs > 0 && f0gain > 0.25) { - sens = 0.5; - if (f0gain < 0.75) { + if ( f0gain < 0.75 ) + { sens = 0.25; } - + high_idx = -1; - for (i = 0; i < n_plocs; i++) { - if (plocs[i] <= 25) { /* 25 ~= 1550 Hz */ - high_idx = MAX(high_idx, i); - } else { + for ( i = 0; i < n_plocs; i++ ) + { + if ( plocs[i] <= 25 ) + { /* 25 ~= 1550 Hz */ + high_idx = MAX( high_idx, i ); + } + else + { /* Optimization, only works if plocs vector is sorted. Which it should be. */ break; } } - - if (high_idx != -1) { + + if ( high_idx != -1 ) + { high_idx++; - move_float(f0est_lim, f0est, high_idx); - + move_float( f0est_lim, f0est, high_idx ); + breakflag = 0; - for (i = 0; i < nSubm; i++) { - for (j = 0; j < high_idx; j++) { - if (LC3_FABS(f0est_lim[j] - (i+1) * f0bin) < sens) { - f0est[j] = (i+1)*f0bin; - plocs[j] = MIN(Xabs_len-1, MAX(1,(LC3_INT32) LC3_ROUND(f0est[j]))); + for ( i = 0; i < nSubm; i++ ) + { + for ( j = 0; j < high_idx; j++ ) + { + if ( LC3_FABS( f0est_lim[j] - ( i + 1 ) * f0bin ) < sens ) + { + f0est[j] = ( i + 1 ) * f0bin; + plocs[j] = MIN( Xabs_len - 1, MAX( 1, (LC3_INT32) LC3_ROUND( f0est[j] ) ) ); breakflag = 1; break; } } - if (breakflag) { + if ( breakflag ) + { break; } sens *= 0.875; @@ -70,6 +80,5 @@ void plc_phEcu_F0_refine_first( LC3_INT32 *plocs, /* i/o 0 ... Lprot } } - return; + return; } - diff --git a/lib_lc3plus/plc_phecu_fec_hq.c b/lib_lc3plus/plc_phecu_fec_hq.c index c25466c3e9..fd44ad604d 100644 --- a/lib_lc3plus/plc_phecu_fec_hq.c +++ b/lib_lc3plus/plc_phecu_fec_hq.c @@ -1,19 +1,20 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "defines.h" #include "functions.h" -LC3_FLOAT plc_phEcu_imax2_jacobsen_mag(const Complex *y, LC3_FLOAT *c_jacobPtr) { +LC3_FLOAT plc_phEcu_imax2_jacobsen_mag( const Complex *y, LC3_FLOAT *c_jacobPtr ) +{ LC3_FLOAT posi; const Complex *pY; @@ -23,12 +24,12 @@ LC3_FLOAT plc_phEcu_imax2_jacobsen_mag(const Complex *y, LC3_FLOAT *c_jacobPtr) LC3_FLOAT numer, denom; /* Jacobsen estimates peak offset relative y_0 using - * X_m1 - X_p1 - * d = REAL ( ------------------- ) * c_jacob - * 2*X_0 - X_m1 -Xp1 - * - * Where c_jacob is a window dependent constant - */ + * X_m1 - X_p1 + * d = REAL ( ------------------- ) * c_jacob + * 2*X_0 - X_m1 -Xp1 + * + * Where c_jacob is a window dependent constant + */ /* Get the parameters into variables */ pY = y; @@ -37,25 +38,28 @@ LC3_FLOAT plc_phEcu_imax2_jacobsen_mag(const Complex *y, LC3_FLOAT *c_jacobPtr) y_p1 = *pY++; /* prepare numerator real and imaginary parts*/ - N = csub(y_m1, y_p1); + N = csub( y_m1, y_p1 ); /* prepare denominator real and imaginary parts */ - D = cmul(cmplx(2.0, 0.0), y_0); - D = csub(D, y_m1); - D = csub(D, y_p1); + D = cmul( cmplx( 2.0, 0.0 ), y_0 ); + D = csub( D, y_m1 ); + D = csub( D, y_p1 ); /* REAL part of complex division */ - numer = N.r*D.r + N.i*D.i; - denom = D.r*D.r + D.i*D.i; + numer = N.r * D.r + N.i * D.i; + denom = D.r * D.r + D.i * D.i; - if (numer != 0 && denom != 0) { - posi = numer / denom * (*c_jacobPtr); - } else { + if ( numer != 0 && denom != 0 ) + { + posi = numer / denom * ( *c_jacobPtr ); + } + else + { posi = 0.0; /* flat top, division is not possible choose center freq */ } - posi = fclampf(-1.0, posi, 1.0); + posi = fclampf( -1.0, posi, 1.0 ); return posi; } @@ -65,47 +69,59 @@ LC3_FLOAT plc_phEcu_imax2_jacobsen_mag(const Complex *y, LC3_FLOAT *c_jacobPtr) * Get interpolated maximum position *-------------------------------------------------------------------*/ -LC3_FLOAT plc_phEcu_interp_max(const LC3_FLOAT *y, LC3_INT32 y_len) { +LC3_FLOAT plc_phEcu_interp_max( const LC3_FLOAT *y, LC3_INT32 y_len ) +{ LC3_FLOAT posi, y1, y2, y3, y3_y1, y2i; LC3_FLOAT ftmp_den1, ftmp_den2; /* Seek the extrema of the parabola P(x) defined by 3 consecutive points so that P([-1 0 1]) = [y1 y2 y3] */ y1 = y[0]; y2 = y[1]; - + /* If interp between two values only */ - if (y_len == 2) { - if (y1 < y2) { + if ( y_len == 2 ) + { + if ( y1 < y2 ) + { return 1.0; - } else { + } + else + { return 0.0; } } - + y3 = y[2]; - y3_y1 = y3-y1; - ftmp_den1 = (y1+y3-2*y2); - ftmp_den2 = (4*y2 - 2*y1 - 2*y3); - - if(ftmp_den2 == 0.0 || ftmp_den1 == 0.0) { - return 0.0; /* early exit with left-most value */ + y3_y1 = y3 - y1; + ftmp_den1 = ( y1 + y3 - 2 * y2 ); + ftmp_den2 = ( 4 * y2 - 2 * y1 - 2 * y3 ); + + if ( ftmp_den2 == 0.0 || ftmp_den1 == 0.0 ) + { + return 0.0; /* early exit with left-most value */ } - - y2i = ((LC3_FLOAT)-0.125) * sqrf(y3_y1) /(ftmp_den1) + y2; + + y2i = ( (LC3_FLOAT) -0.125 ) * sqrf( y3_y1 ) / ( ftmp_den1 ) + y2; /* their corresponding normalized locations */ - posi = y3_y1/(ftmp_den2); + posi = y3_y1 / ( ftmp_den2 ); /* Interpolated maxima if locations are not within [-1,1], calculated extrema are ignored */ - if (posi >= (LC3_FLOAT)1.0 || posi <= (LC3_FLOAT)-1.0) { - posi = y3 > y1 ? (LC3_FLOAT)1.0 : (LC3_FLOAT)-1.0; - } else { - if (y1 >= y2i) { - posi = (y1 > y3) ? (LC3_FLOAT)-1.0 :(LC3_FLOAT) 1.0; - } else if (y3 >= y2i) { - posi = (LC3_FLOAT)1.0; + if ( posi >= (LC3_FLOAT) 1.0 || posi <= (LC3_FLOAT) -1.0 ) + { + posi = y3 > y1 ? (LC3_FLOAT) 1.0 : (LC3_FLOAT) -1.0; + } + else + { + if ( y1 >= y2i ) + { + posi = ( y1 > y3 ) ? (LC3_FLOAT) -1.0 : (LC3_FLOAT) 1.0; + } + else if ( y3 >= y2i ) + { + posi = (LC3_FLOAT) 1.0; } } - - return posi + (LC3_FLOAT)1.0; + + return posi + (LC3_FLOAT) 1.0; } /*----------------------------------------------------------------------------- @@ -118,42 +134,49 @@ LC3_FLOAT plc_phEcu_interp_max(const LC3_FLOAT *y, LC3_INT32 y_len) { * abs = 0.84 max_abs + 0.561*min_abs * end * - + *----------------------------------------------------------------------------*/ -void plc_phEcu_fft_spec2_sqrt_approx(const Complex* x, LC3_INT32 x_len, LC3_FLOAT* x_abs) { +void plc_phEcu_fft_spec2_sqrt_approx( const Complex *x, LC3_INT32 x_len, LC3_FLOAT *x_abs ) +{ LC3_INT32 i; LC3_FLOAT max_abs, min_abs, re, im; - - for (i = 0; i < x_len; i++) { - re = LC3_FABS(x[i].r); - im = LC3_FABS(x[i].i); - max_abs = MAX(re, im); - min_abs = MIN(re, im); - - if (min_abs <= (LC3_FLOAT)0.4142135 * max_abs) { - x_abs[i] = (LC3_FLOAT)0.99*max_abs + (LC3_FLOAT)0.197*min_abs; - } else { - x_abs[i] = (LC3_FLOAT)0.84*max_abs + (LC3_FLOAT)0.561*min_abs; + + for ( i = 0; i < x_len; i++ ) + { + re = LC3_FABS( x[i].r ); + im = LC3_FABS( x[i].i ); + max_abs = MAX( re, im ); + min_abs = MIN( re, im ); + + if ( min_abs <= (LC3_FLOAT) 0.4142135 * max_abs ) + { + x_abs[i] = (LC3_FLOAT) 0.99 * max_abs + (LC3_FLOAT) 0.197 * min_abs; + } + else + { + x_abs[i] = (LC3_FLOAT) 0.84 * max_abs + (LC3_FLOAT) 0.561 * min_abs; } } - return; + return; } -LC3_INT32 plc_phEcu_pitch_in_plocs(LC3_INT32* plocs, LC3_INT32 n_plocs) { - +LC3_INT32 plc_phEcu_pitch_in_plocs( LC3_INT32 *plocs, LC3_INT32 n_plocs ) +{ + LC3_INT32 i; LC3_INT32 p_in_plocs; p_in_plocs = 0; - - for (i = 0; i < n_plocs; i++) { - if (plocs[i] > 0 && plocs[i] < 7) { + + for ( i = 0; i < n_plocs; i++ ) + { + if ( plocs[i] > 0 && plocs[i] < 7 ) + { p_in_plocs++; } } return p_in_plocs; } - diff --git a/lib_lc3plus/plc_phecu_hq_ecu.c b/lib_lc3plus/plc_phecu_hq_ecu.c index 5b1978bcab..53e8545ef6 100644 --- a/lib_lc3plus/plc_phecu_hq_ecu.c +++ b/lib_lc3plus/plc_phecu_hq_ecu.c @@ -1,12 +1,12 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "defines.h" @@ -14,103 +14,128 @@ void plc_phEcu_hq_ecu( - LC3_FLOAT *f0binPtr, LC3_FLOAT *f0ltpGainPtr, LC3_FLOAT *xfp, - LC3_INT16 prev_bfi, LC3_INT32 *short_flag_prev, LC3_INT32 fs, - LC3_INT32 *time_offs, Complex *X_sav_m, LC3_INT32 *n_plocs, LC3_INT32 *plocs, LC3_FLOAT *f0est, - const LC3_FLOAT *mdctWin, LC3_FLOAT *env_stabPtr, LC3_INT32 delta_corr, LC3_FLOAT *pfind_sensPtr, - LC3_INT32 PhECU_LA, LC3_INT32 t_adv, const LC3_FLOAT *winWhr, - LC3_FLOAT *oold_grp_shape, LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_grp_shape, LC3_FLOAT *old_EwPtr, - LC3_FLOAT *st_beta_mute, LC3_FLOAT *st_mag_chg_1st, LC3_FLOAT *st_Xavg, LC3_INT32 LA_ZEROS, LC3_FLOAT *x_tda, - LC3_FLOAT *xsubst_dbg, Complex *X_out_m_dbg, - LC3_INT32 *seed_dbg, LC3_FLOAT *mag_chg_dbg, LC3_INT32 *tr_dec_dbg, LC3_FLOAT *gpc_dbg, LC3_FLOAT *X_i_new_re_dbg, LC3_FLOAT *X_i_new_im_dbg, + LC3_FLOAT *f0binPtr, + LC3_FLOAT *f0ltpGainPtr, + LC3_FLOAT *xfp, + LC3_INT16 prev_bfi, + LC3_INT32 *short_flag_prev, + LC3_INT32 fs, + LC3_INT32 *time_offs, + Complex *X_sav_m, + LC3_INT32 *n_plocs, + LC3_INT32 *plocs, + LC3_FLOAT *f0est, + const LC3_FLOAT *mdctWin, + LC3_FLOAT *env_stabPtr, + LC3_INT32 delta_corr, + LC3_FLOAT *pfind_sensPtr, + LC3_INT32 PhECU_LA, + LC3_INT32 t_adv, + const LC3_FLOAT *winWhr, + LC3_FLOAT *oold_grp_shape, + LC3_FLOAT *oold_EwPtr, + LC3_FLOAT *old_grp_shape, + LC3_FLOAT *old_EwPtr, + LC3_FLOAT *st_beta_mute, + LC3_FLOAT *st_mag_chg_1st, + LC3_FLOAT *st_Xavg, + LC3_INT32 LA_ZEROS, + LC3_FLOAT *x_tda, + LC3_FLOAT *xsubst_dbg, + Complex *X_out_m_dbg, + LC3_INT32 *seed_dbg, + LC3_FLOAT *mag_chg_dbg, + LC3_INT32 *tr_dec_dbg, + LC3_FLOAT *gpc_dbg, + LC3_FLOAT *X_i_new_re_dbg, + LC3_FLOAT *X_i_new_im_dbg, LC3_FLOAT *corr_phase_dbg, - Fft *PhEcu_Fft, Fft *PhEcu_Ifft) + Fft *PhEcu_Fft, + Fft *PhEcu_Ifft ) { - LC3_INT32 i; - LC3_INT32 fs_idx, L, Lprot, n_grp, Lecu, LXsav, Lxfp_inuse; - LC3_FLOAT alpha[8]; - LC3_FLOAT beta[8]; - LC3_FLOAT mag_chg[8]; - LC3_FLOAT xfp_local_rnd[2*MAX_LEN]; - Complex X_out_m[2*MAX_LEN]; - LC3_INT32 seed; - LC3_INT32 burst_len; - - - fs_idx = (LC3_INT32)floor(fs / 10000.0); - L = (LC3_INT32)floor(0.01 * fs); - Lprot = (LC3_INT32)(1.6 * L); + LC3_INT32 i; + LC3_INT32 fs_idx, L, Lprot, n_grp, Lecu, LXsav, Lxfp_inuse; + LC3_FLOAT alpha[8]; + LC3_FLOAT beta[8]; + LC3_FLOAT mag_chg[8]; + LC3_FLOAT xfp_local_rnd[2 * MAX_LEN]; + Complex X_out_m[2 * MAX_LEN]; + LC3_INT32 seed; + LC3_INT32 burst_len; + + + fs_idx = (LC3_INT32) floor( fs / 10000.0 ); + L = (LC3_INT32) floor( 0.01 * fs ); + Lprot = (LC3_INT32) ( 1.6 * L ); n_grp = xavg_N_grp[fs_idx]; Lecu = 2 * L; - LXsav = Lprot / 2 + 1; /* 48 kHz may be optimized , to save only up to 20 kHz as in BASOP */ - Lxfp_inuse = Lprot ; - if (prev_bfi == 1){ - Lxfp_inuse = (LC3_INT32)(L*(3.75/10.0)); + LXsav = Lprot / 2 + 1; /* 48 kHz may be optimized , to save only up to 20 kHz as in BASOP */ + Lxfp_inuse = Lprot; + if ( prev_bfi == 1 ) + { + Lxfp_inuse = (LC3_INT32) ( L * ( 3.75 / 10.0 ) ); } - UNUSED(env_stabPtr); - UNUSED(xsubst_dbg); - UNUSED(X_out_m_dbg); - UNUSED(seed_dbg); - UNUSED(mag_chg_dbg); - UNUSED(tr_dec_dbg); - UNUSED(gpc_dbg); - UNUSED(X_i_new_re_dbg); - UNUSED(X_i_new_im_dbg); - UNUSED(corr_phase_dbg); - - - if (prev_bfi != 1) + UNUSED( env_stabPtr ); + UNUSED( xsubst_dbg ); + UNUSED( X_out_m_dbg ); + UNUSED( seed_dbg ); + UNUSED( mag_chg_dbg ); + UNUSED( tr_dec_dbg ); + UNUSED( gpc_dbg ); + UNUSED( X_i_new_re_dbg ); + UNUSED( X_i_new_im_dbg ); + UNUSED( corr_phase_dbg ); + + + if ( prev_bfi != 1 ) { - for (i = (Lprot-Lxfp_inuse); i < Lprot; i++) { - xfp_local_rnd[i] = xfp[i]; - /* hysteresis of low level input aligns float fft analysis and peak picking to BASOP performance for low level noisy signals */ - if (xfp[i] >= -0.5 && xfp[i] <= 0.5) { - xfp_local_rnd[i] = 0.0; - } - } - + for ( i = ( Lprot - Lxfp_inuse ); i < Lprot; i++ ) + { + xfp_local_rnd[i] = xfp[i]; + /* hysteresis of low level input aligns float fft analysis and peak picking to BASOP performance for low level noisy signals */ + if ( xfp[i] >= -0.5 && xfp[i] <= 0.5 ) + { + xfp_local_rnd[i] = 0.0; + } + } + *time_offs = 0; - burst_len = (*time_offs / L + 1); - plc_phEcu_trans_burst_ana_sub(fs_idx, burst_len, n_grp, oold_grp_shape, oold_EwPtr , old_grp_shape, old_EwPtr, st_beta_mute, - st_mag_chg_1st, st_Xavg, alpha, beta, mag_chg, NULL, NULL); - - plc_phEcu_spec_ana(xfp_local_rnd, Lprot, winWhr, pfind_sensPtr, plocs, n_plocs, f0est, X_sav_m, &LXsav, f0binPtr, f0ltpGainPtr, fs_idx, PhEcu_Fft); + burst_len = ( *time_offs / L + 1 ); + plc_phEcu_trans_burst_ana_sub( fs_idx, burst_len, n_grp, oold_grp_shape, oold_EwPtr, old_grp_shape, old_EwPtr, st_beta_mute, + st_mag_chg_1st, st_Xavg, alpha, beta, mag_chg, NULL, NULL ); + + plc_phEcu_spec_ana( xfp_local_rnd, Lprot, winWhr, pfind_sensPtr, plocs, n_plocs, f0est, X_sav_m, &LXsav, f0binPtr, f0ltpGainPtr, fs_idx, PhEcu_Fft ); } else { *time_offs = *time_offs + L; - *time_offs = imin(32767 ,*time_offs); /* limit to Word16 range as in BASOP ~= 70 10ms frames@48kHz */ - burst_len = ((*time_offs / L) + 1); - - plc_phEcu_trans_burst_ana_sub(fs_idx, burst_len, n_grp, oold_grp_shape, oold_EwPtr, old_grp_shape, old_EwPtr, st_beta_mute, - st_mag_chg_1st, st_Xavg, alpha, beta, mag_chg, NULL, NULL); + *time_offs = imin( 32767, *time_offs ); /* limit to Word16 range as in BASOP ~= 70 10ms frames@48kHz */ + burst_len = ( ( *time_offs / L ) + 1 ); + plc_phEcu_trans_burst_ana_sub( fs_idx, burst_len, n_grp, oold_grp_shape, oold_EwPtr, old_grp_shape, old_EwPtr, st_beta_mute, + st_mag_chg_1st, st_Xavg, alpha, beta, mag_chg, NULL, NULL ); } seed = *time_offs; - - if (*short_flag_prev != 0) + + if ( *short_flag_prev != 0 ) { *n_plocs = 0; } - move_cmplx( X_out_m, X_sav_m, LXsav); + move_cmplx( X_out_m, X_sav_m, LXsav ); /* inplace X_out_m update */ - plc_phEcu_subst_spec(plocs, *n_plocs, f0est, *time_offs, X_out_m, LXsav, mag_chg, &seed, alpha, beta, st_Xavg, t_adv, Lprot, delta_corr, - NULL, NULL, NULL); - + plc_phEcu_subst_spec( plocs, *n_plocs, f0est, *time_offs, X_out_m, LXsav, mag_chg, &seed, alpha, beta, st_Xavg, t_adv, Lprot, delta_corr, + NULL, NULL, NULL ); - - plc_phEcu_rec_frame(X_out_m, L, Lecu, winWhr, mdctWin, Lprot, - xfp, /* last 3.75ms of non-rounded xfp used here */ - *time_offs, - x_tda /* output */, - NULL, NULL, NULL, - LA_ZEROS, PhECU_LA, PhEcu_Ifft); - + plc_phEcu_rec_frame( X_out_m, L, Lecu, winWhr, mdctWin, Lprot, + xfp, /* last 3.75ms of non-rounded xfp used here */ + *time_offs, + x_tda /* output */, + NULL, NULL, NULL, + LA_ZEROS, PhECU_LA, PhEcu_Ifft ); } - diff --git a/lib_lc3plus/plc_phecu_lf_peak_analysis.c b/lib_lc3plus/plc_phecu_lf_peak_analysis.c index 0bcc98d7a4..2eb3108924 100644 --- a/lib_lc3plus/plc_phecu_lf_peak_analysis.c +++ b/lib_lc3plus/plc_phecu_lf_peak_analysis.c @@ -1,26 +1,25 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "defines.h" #include "functions.h" -void plc_phEcu_LF_peak_analysis(LC3_INT32 *plocs, /* i/o 0 ... Lprot/2 +1*/ - LC3_INT32 *n_plocs, /* i/o 0.. MAX_PLOCS */ - LC3_FLOAT *f0est, /* i/o Q16*/ - const LC3_FLOAT *Xabs, - LC3_FLOAT *f0binPtr, - LC3_FLOAT *f0gainPtr, - const LC3_INT32 nSubm -) +void plc_phEcu_LF_peak_analysis( LC3_INT32 *plocs, /* i/o 0 ... Lprot/2 +1*/ + LC3_INT32 *n_plocs, /* i/o 0.. MAX_PLOCS */ + LC3_FLOAT *f0est, /* i/o Q16*/ + const LC3_FLOAT *Xabs, + LC3_FLOAT *f0binPtr, + LC3_FLOAT *f0gainPtr, + const LC3_INT32 nSubm ) { LC3_INT32 i, j, fin, f_ind, prel_low, prel_high, start; LC3_FLOAT f0est_prel[3]; @@ -29,84 +28,97 @@ void plc_phEcu_LF_peak_analysis(LC3_INT32 *plocs, /* i/o 0 ... Lprot/2 + LC3_FLOAT f0est_old[MAX_PLC_NPLOCS]; LC3_INT32 plocs_old[MAX_PLC_NPLOCS]; LC3_FLOAT peakLF_Xval, f; - LC3_FLOAT f0bin ; - LC3_FLOAT f0gain ; - - f0bin = *f0binPtr; + LC3_FLOAT f0bin; + LC3_FLOAT f0gain; + + f0bin = *f0binPtr; f0gain = *f0gainPtr; - if (*n_plocs > 0 && f0gain > 0.25 && f0bin < 2.75) { + if ( *n_plocs > 0 && f0gain > 0.25 && f0bin < 2.75 ) + { /* Assumes sorted plocs */ - if (plocs[0] < 3) { - fin = MIN(3, *n_plocs); + if ( plocs[0] < 3 ) + { + fin = MIN( 3, *n_plocs ); peakLF_Xval = Xabs[plocs[0]]; - for (i = 1; i < fin; i++) { - peakLF_Xval = MAX(peakLF_Xval, Xabs[plocs[i]]); + for ( i = 1; i < fin; i++ ) + { + peakLF_Xval = MAX( peakLF_Xval, Xabs[plocs[i]] ); } n_prel = 0; - for (i = 0; i < nSubm; i++) { - f = (i+1)*f0bin; - f_ind = (LC3_INT32)LC3_ROUND(f); - if (f*PHECU_FRES <= 400 && Xabs[f_ind] > peakLF_Xval*0.375) { + for ( i = 0; i < nSubm; i++ ) + { + f = ( i + 1 ) * f0bin; + f_ind = (LC3_INT32) LC3_ROUND( f ); + if ( f * PHECU_FRES <= 400 && Xabs[f_ind] > peakLF_Xval * 0.375 ) + { f0est_prel[n_prel] = f; plocs_prel[n_prel] = f_ind; n_prel++; } } - if (n_prel > 0) { + if ( n_prel > 0 ) + { prel_low = plocs_prel[0]; - prel_high = plocs_prel[n_prel-1]; - - /* initial assumption:: all original peaks (1 or 2 of them) are positioned below prel_low */ - start = (*n_plocs); /* at this point 'start' is the location_c where to add any harmonics peaks */ - for (i = (*n_plocs)-1; i >= 0; i--) { - if (plocs[i] >= prel_low) { + prel_high = plocs_prel[n_prel - 1]; + + /* initial assumption:: all original peaks (1 or 2 of them) are positioned below prel_low */ + start = ( *n_plocs ); /* at this point 'start' is the location_c where to add any harmonics peaks */ + for ( i = ( *n_plocs ) - 1; i >= 0; i-- ) + { + if ( plocs[i] >= prel_low ) + { start = i; } } /* found position_c where to start adding */ - start = (start-1 ); /* one step lower, now start is of original LF peaks to keep */ - start = MAX(start, -1); /* limit for loop */ + start = ( start - 1 ); /* one step lower, now start is of original LF peaks to keep */ + start = MAX( start, -1 ); /* limit for loop */ - if (prel_high < plocs[0]) { + if ( prel_high < plocs[0] ) + { fin = 0; - } else { - fin = (*n_plocs)+1; - for (i = 0; i < *n_plocs; i++) { - if (plocs[i] <= prel_high) { + } + else + { + fin = ( *n_plocs ) + 1; + for ( i = 0; i < *n_plocs; i++ ) + { + if ( plocs[i] <= prel_high ) + { fin = i; } } fin++; } - move_int(plocs_old, plocs, *n_plocs); - move_float(f0est_old, f0est, *n_plocs); + move_int( plocs_old, plocs, *n_plocs ); + move_float( f0est_old, f0est, *n_plocs ); - j = (start+1); /* [0..(j-1)] of original LF peaks will be kept */ - /* j now points to first location_c where to add peaks */ + j = ( start + 1 ); /* [0..(j-1)] of original LF peaks will be kept */ + /* j now points to first location_c where to add peaks */ - for (i = 0; i < n_prel; i++) { - plocs[j] = plocs_prel[i]; - f0est[j] = f0est_prel[i]; - j++; - } - for (i = fin; i < *n_plocs; i++) { - plocs[j] = plocs_old[i]; - f0est[j] = f0est_old[i]; - j++; - } + for ( i = 0; i < n_prel; i++ ) + { + plocs[j] = plocs_prel[i]; + f0est[j] = f0est_prel[i]; + j++; + } + for ( i = fin; i < *n_plocs; i++ ) + { + plocs[j] = plocs_old[i]; + f0est[j] = f0est_old[i]; + j++; + } *n_plocs = j; - } } } return; } - diff --git a/lib_lc3plus/plc_phecu_rec_frame.c b/lib_lc3plus/plc_phecu_rec_frame.c index 0e6570743a..db472f3405 100644 --- a/lib_lc3plus/plc_phecu_rec_frame.c +++ b/lib_lc3plus/plc_phecu_rec_frame.c @@ -1,147 +1,148 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "defines.h" #include "functions.h" -void plc_phEcu_rec_frame(Complex *X_in, - LC3_INT32 L, - LC3_INT32 Lecu, - const LC3_FLOAT *whr, - const LC3_FLOAT *winMDCT, - LC3_INT32 Lprot, - LC3_FLOAT *xfp, - LC3_INT32 time_offs, - LC3_FLOAT *x_out, - Complex *full_spec_dbg, - LC3_FLOAT* ifft_out_dbg, - LC3_FLOAT* xsubst_dbg, - LC3_INT32 LA_ZEROS, - LC3_INT32 LA, - Fft* PhEcu_ifft -) +void plc_phEcu_rec_frame( Complex *X_in, + LC3_INT32 L, + LC3_INT32 Lecu, + const LC3_FLOAT *whr, + const LC3_FLOAT *winMDCT, + LC3_INT32 Lprot, + LC3_FLOAT *xfp, + LC3_INT32 time_offs, + LC3_FLOAT *x_out, + Complex *full_spec_dbg, + LC3_FLOAT *ifft_out_dbg, + LC3_FLOAT *xsubst_dbg, + LC3_INT32 LA_ZEROS, + LC3_INT32 LA, + Fft *PhEcu_ifft ) { - LC3_INT32 i; - - LC3_FLOAT xrec[2*MAX_LEN]; - LC3_FLOAT xsubst[2*MAX_LEN]; - LC3_FLOAT xsubst_LL[2*MAX_LEN]; - LC3_FLOAT *pXsubst_LL; - - LC3_INT32 fs_idx; - - LC3_FLOAT *pXfp, *pOlaXsubst, *pXOut; - LC3_INT32 work_part, copy_part, ola_part; + LC3_INT32 i; - const LC3_FLOAT *hannOla; - const LC3_FLOAT *pHannOla; + LC3_FLOAT xrec[2 * MAX_LEN]; + LC3_FLOAT xsubst[2 * MAX_LEN]; + LC3_FLOAT xsubst_LL[2 * MAX_LEN]; + LC3_FLOAT *pXsubst_LL; - UNUSED(time_offs); - UNUSED(full_spec_dbg); - UNUSED(ifft_out_dbg); - UNUSED(xsubst_dbg); - UNUSED(xsubst_LL); - fs_idx = FRAME2FS_IDX(L); - hannOla = hannOla_wins[fs_idx]; + LC3_INT32 fs_idx; - X_in[0].i = X_in[Lprot / 2].r; /* move fs/2 real to imag part of X_in[0]*/ + LC3_FLOAT *pXfp, *pOlaXsubst, *pXOut; + LC3_INT32 work_part, copy_part, ola_part; - real_fft_apply(PhEcu_ifft, (LC3_FLOAT*)X_in, xrec); + const LC3_FLOAT *hannOla; + const LC3_FLOAT *pHannOla; - move_float(xsubst, xrec, Lprot); + UNUSED( time_offs ); + UNUSED( full_spec_dbg ); + UNUSED( ifft_out_dbg ); + UNUSED( xsubst_dbg ); + UNUSED( xsubst_LL ); + fs_idx = FRAME2FS_IDX( L ); + hannOla = hannOla_wins[fs_idx]; + X_in[0].i = X_in[Lprot / 2].r; /* move fs/2 real to imag part of X_in[0]*/ + real_fft_apply( PhEcu_ifft, (LC3_FLOAT *) X_in, xrec ); + move_float( xsubst, xrec, Lprot ); - { - for (i = 0; i < Lprot; i++) { - if (whr[i] != 0) { - xsubst[i] = xsubst[i] / whr[i]; /* inverse stored in BASOP */ - } + { + for ( i = 0; i < Lprot; i++ ) + { - } + if ( whr[i] != 0 ) + { + xsubst[i] = xsubst[i] / whr[i]; /* inverse stored in BASOP */ + } + } - assert(xsubst_LL != NULL); - zero_float(xsubst_LL, (Lecu-Lprot)/2); /* initial 2ms */ - zero_float(&(xsubst_LL[ Lecu- (Lecu-Lprot)/2]), (Lecu-Lprot)/2); /* tail 2ms */ - { - /* position reconstruction properly */ - /* pXsubst_LL = &xsubst_LL[Lecu - Lprot - (Lecu - Lprot) / 2]; */ - pXsubst_LL = &xsubst_LL[(Lecu - Lprot) / 2]; - for (i = 0; i < Lprot ; i++) { - *pXsubst_LL++ = xsubst[i]; /* copy required 14.25 ms into center */ - } - } + assert( xsubst_LL != NULL ); + zero_float( xsubst_LL, ( Lecu - Lprot ) / 2 ); /* initial 2ms */ + zero_float( &( xsubst_LL[Lecu - ( Lecu - Lprot ) / 2] ), ( Lecu - Lprot ) / 2 ); /* tail 2ms */ + { + /* position reconstruction properly */ + /* pXsubst_LL = &xsubst_LL[Lecu - Lprot - (Lecu - Lprot) / 2]; */ + pXsubst_LL = &xsubst_LL[( Lecu - Lprot ) / 2]; + for ( i = 0; i < Lprot; i++ ) + { + *pXsubst_LL++ = xsubst[i]; /* copy required 14.25 ms into center */ + } + } + } - } + work_part = LA_ZEROS + LA; + copy_part = ( Lecu - Lprot ) / 2; + ola_part = work_part - copy_part; + pXfp = &xfp[Lprot - work_part]; + for ( i = 0; i < copy_part; i++ ) + { + xsubst_LL[i] = *pXfp++; + } - work_part = LA_ZEROS + LA; - copy_part = (Lecu - Lprot) / 2; - ola_part = work_part - copy_part; + assert( xsubst_LL != NULL ); + pOlaXsubst = &( xsubst_LL[copy_part] ); + pHannOla = hannOla; + for ( i = 0; i < ola_part; i++ ) + { + *pOlaXsubst = *pOlaXsubst * *pHannOla++; + pOlaXsubst++; + } - pXfp = &xfp[Lprot - work_part]; - for (i = 0; i < copy_part; i++) { - xsubst_LL[i] = *pXfp++; - } + pOlaXsubst = &( xsubst_LL[copy_part] ); + for ( i = 0; i < ola_part; i++ ) + { + *pOlaXsubst = *pOlaXsubst + *pXfp++ * *pHannOla--; + pOlaXsubst++; + } - assert(xsubst_LL != NULL); - pOlaXsubst = &(xsubst_LL[copy_part]); - pHannOla = hannOla; - for (i = 0; i < ola_part; i++) { - *pOlaXsubst = *pOlaXsubst * *pHannOla++; - pOlaXsubst++; - } - pOlaXsubst = &(xsubst_LL[copy_part]); - for (i = 0; i < ola_part; i++) { - *pOlaXsubst = *pOlaXsubst + *pXfp++ * *pHannOla--; - pOlaXsubst++; - } + /* clear x_out to start with */ + assert( x_out != NULL ); + zero_float( x_out, L ); - /* clear x_out to start with */ - assert(x_out != NULL); - zero_float(x_out, L); + for ( i = 0; i < ( Lecu - LA_ZEROS ); i++ ) + { + xsubst_LL[i] = xsubst_LL[i] * winMDCT[i]; /* xsubstLL windowing up to 16.25 ms i.e not last 3.75 ms */ + } + zero_float( &( xsubst_LL[Lecu - LA_ZEROS] ), LA_ZEROS ); /* tail 3.75ms always zero */ - for (i = 0; i < (Lecu - LA_ZEROS); i++) { - - xsubst_LL[i] = xsubst_LL[i] * winMDCT[i]; /* xsubstLL windowing up to 16.25 ms i.e not last 3.75 ms */ - - } - zero_float(&(xsubst_LL[Lecu - LA_ZEROS]), LA_ZEROS); /* tail 3.75ms always zero */ - - /* perform tda */ + /* perform tda */ /* first half */ - pXsubst_LL = &xsubst_LL[3 * Lecu / 4]; - pXfp = &xsubst_LL[(3 * Lecu / 4) - 1]; - - pXOut = x_out; - for (i = 0; i < Lecu / 4; i++) { - *pXOut++ = -*pXsubst_LL++ - *pXfp--; /* 3.75 ms mults with 0 . may be skipped, see BASOP */ - } - - /* second half */ - /* */ - - pXsubst_LL = &(xsubst_LL[0]); - pXfp = &xsubst_LL[(Lecu / 2) - 1]; - for (i = 0; i < Lecu / 4; i++) { - *pXOut++ = *pXsubst_LL++ - *pXfp--; - } + pXsubst_LL = &xsubst_LL[3 * Lecu / 4]; + pXfp = &xsubst_LL[( 3 * Lecu / 4 ) - 1]; + + pXOut = x_out; + for ( i = 0; i < Lecu / 4; i++ ) + { + *pXOut++ = -*pXsubst_LL++ - *pXfp--; /* 3.75 ms mults with 0 . may be skipped, see BASOP */ + } + + /* second half */ + /* */ + + pXsubst_LL = &( xsubst_LL[0] ); + pXfp = &xsubst_LL[( Lecu / 2 ) - 1]; + for ( i = 0; i < Lecu / 4; i++ ) + { + *pXOut++ = *pXsubst_LL++ - *pXfp--; + } } - diff --git a/lib_lc3plus/plc_phecu_setf0hz.c b/lib_lc3plus/plc_phecu_setf0hz.c index b14327e2b2..716d0bd3fc 100644 --- a/lib_lc3plus/plc_phecu_setf0hz.c +++ b/lib_lc3plus/plc_phecu_setf0hz.c @@ -1,28 +1,27 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "defines.h" #include "functions.h" -LC3_FLOAT plc_phEcuSetF0Hz(LC3_INT32 fs, LC3_FLOAT * old_pitchPtr) +LC3_FLOAT plc_phEcuSetF0Hz( LC3_INT32 fs, LC3_FLOAT *old_pitchPtr ) { LC3_FLOAT result; result = 0; - if (*old_pitchPtr != 0) + if ( *old_pitchPtr != 0 ) { - result = LC3_ROUND(fs/(*old_pitchPtr)/PHECU_FRES * 128.0) / 128.0; + result = LC3_ROUND( fs / ( *old_pitchPtr ) / PHECU_FRES * 128.0 ) / 128.0; } return result; } - diff --git a/lib_lc3plus/plc_phecu_spec_ana.c b/lib_lc3plus/plc_phecu_spec_ana.c index b496900305..bec60147db 100644 --- a/lib_lc3plus/plc_phecu_spec_ana.c +++ b/lib_lc3plus/plc_phecu_spec_ana.c @@ -1,65 +1,64 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "defines.h" #include "functions.h" -#define PEAK_LOCATOR_RES_FX 1 /* fixed point resolution minimum value */ +#define PEAK_LOCATOR_RES_FX 1 /* fixed point resolution minimum value */ -static LC3_INT16 plc_phEcu_find_ind_fx( /* o : output maximum indx 0.. len-1 */ - const LC3_INT16 *inp, /* i : vector */ - const LC3_INT16 len, /* i : length */ - const LC3_INT16 val /* i : value to find */ +static LC3_INT16 plc_phEcu_find_ind_fx( /* o : output maximum indx 0.. len-1 */ + const LC3_INT16 *inp, /* i : vector */ + const LC3_INT16 len, /* i : length */ + const LC3_INT16 val /* i : value to find */ ); -static void plc_phEcu_peak_locator_fxlike(const LC3_INT16 *inp, /* i: vector with values >=0 ,Qx */ - const LC3_INT16 inp_len, /* i: length of inp */ - LC3_INT16 * int_plocs, /* o: array of filtered integer plocs Q0 */ - LC3_INT16 * n_fsc, /* o: total_ number of filtered located highs Q0 */ - const LC3_INT16 sens, /* i sensitivity, Qx */ - const LC3_INT16 inp_high, /* i global high , Qx */ - const LC3_INT16 inp_low /* i: global low, Qx */ +static void plc_phEcu_peak_locator_fxlike( const LC3_INT16 *inp, /* i: vector with values >=0 ,Qx */ + const LC3_INT16 inp_len, /* i: length of inp */ + LC3_INT16 *int_plocs, /* o: array of filtered integer plocs Q0 */ + LC3_INT16 *n_fsc, /* o: total_ number of filtered located highs Q0 */ + const LC3_INT16 sens, /* i sensitivity, Qx */ + const LC3_INT16 inp_high, /* i global high , Qx */ + const LC3_INT16 inp_low /* i: global low, Qx */ ); -void plc_phEcu_spec_ana(LC3_FLOAT* xfp, - LC3_INT32 xfp_len, - const LC3_FLOAT* whr, - LC3_FLOAT *pfind_sensPtr, - LC3_INT32* plocs, - LC3_INT32* n_plocs, - LC3_FLOAT* f0est, - Complex* x, - LC3_INT32* x_len, - LC3_FLOAT * f0hzLtpBinPtr, - LC3_FLOAT * f0gainLtpPtr, - LC3_INT32 bw_idx, - Fft* PhEcu_fft -) +void plc_phEcu_spec_ana( LC3_FLOAT *xfp, + LC3_INT32 xfp_len, + const LC3_FLOAT *whr, + LC3_FLOAT *pfind_sensPtr, + LC3_INT32 *plocs, + LC3_INT32 *n_plocs, + LC3_FLOAT *f0est, + Complex *x, + LC3_INT32 *x_len, + LC3_FLOAT *f0hzLtpBinPtr, + LC3_FLOAT *f0gainLtpPtr, + LC3_INT32 bw_idx, + Fft *PhEcu_fft ) { - LC3_INT32 i, peak_range_1, curr; - LC3_FLOAT xfp_w[MAX_PLC_LPROT]; - - LC3_FLOAT Xabs[MAX_LEN] = {0}; - LC3_FLOAT inp_high, inp_low, sens; - LC3_FLOAT interPos; - Complex Xana_p[3]; - LC3_INT32 P_in_plocs; - LC3_INT32 nSubs; - LC3_INT32 n_plocs_in; - LC3_FLOAT phEcu_c_jacob[1]; + LC3_INT32 i, peak_range_1, curr; + LC3_FLOAT xfp_w[MAX_PLC_LPROT]; + + LC3_FLOAT Xabs[MAX_LEN] = { 0 }; + LC3_FLOAT inp_high, inp_low, sens; + LC3_FLOAT interPos; + Complex Xana_p[3]; + LC3_INT32 P_in_plocs; + LC3_INT32 nSubs; + LC3_INT32 n_plocs_in; + LC3_FLOAT phEcu_c_jacob[1]; LC3_FLOAT fx_fft_scale; LC3_FLOAT fft_fs_scale; @@ -68,472 +67,495 @@ void plc_phEcu_spec_ana(LC3_FLOAT* xfp, LC3_FLOAT PLC2_Q_flt; LC3_FLOAT Q_scale_flt; - LC3_INT16 Xabs_fx[MAX_LEN]; - LC3_INT16 plocs_fx[MAX_LEN]; + LC3_INT16 Xabs_fx[MAX_LEN]; + LC3_INT16 plocs_fx[MAX_LEN]; + + LC3_INT16 sens_fx; + LC3_INT16 inp_high_fx; + LC3_INT16 inp_low_fx; + LC3_INT16 n_plocs_fx; - LC3_INT16 sens_fx; - LC3_INT16 inp_high_fx; - LC3_INT16 inp_low_fx; - LC3_INT16 n_plocs_fx; + LC3_FLOAT pfind_sens; + LC3_FLOAT f0hzLtpBin; + LC3_FLOAT f0gainLtp; - LC3_FLOAT pfind_sens ; - LC3_FLOAT f0hzLtpBin ; - LC3_FLOAT f0gainLtp ; - - pfind_sens = *pfind_sensPtr; - f0hzLtpBin = *f0hzLtpBinPtr; - f0gainLtp = *f0gainLtpPtr; + pfind_sens = *pfind_sensPtr; + f0hzLtpBin = *f0hzLtpBinPtr; + f0gainLtp = *f0gainLtpPtr; - for (i = 0; i < xfp_len; i++) + for ( i = 0; i < xfp_len; i++ ) { - xfp_w[i] = xfp[i] * whr[i]; /* whr windowing may be split into three segments , two loops, and possibly inplace */ + xfp_w[i] = xfp[i] * whr[i]; /* whr windowing may be split into three segments , two loops, and possibly inplace */ } - real_fft_apply(PhEcu_fft, xfp_w, (LC3_FLOAT *)x); - - x[xfp_len/2].r = x[0].i; /* move the real Fs/2 value to end */ - x[xfp_len/2].i = 0; /* safety clear imaginary Fs/2 value at end */ - x[0].i = 0.0; /* safety, make DC value only real */ - - - *x_len = xfp_len/2 + 1; - - i =(LC3_INT32) LC3_FLOOR(20000.0/PHECU_FRES)+1; - zero_cmplx( &(x[i]), *x_len - i); - - peak_range_1 = (LC3_INT32) MIN(*x_len, (40000.0 / 100 * 1.6) / 2 + 1); - - plc_phEcu_fft_spec2_sqrt_approx(x, peak_range_1, Xabs); - - zero_float(&(Xabs[peak_range_1]), *x_len - peak_range_1); - + real_fft_apply( PhEcu_fft, xfp_w, (LC3_FLOAT *) x ); + + x[xfp_len / 2].r = x[0].i; /* move the real Fs/2 value to end */ + x[xfp_len / 2].i = 0; /* safety clear imaginary Fs/2 value at end */ + x[0].i = 0.0; /* safety, make DC value only real */ + + + *x_len = xfp_len / 2 + 1; + + i = (LC3_INT32) LC3_FLOOR( 20000.0 / PHECU_FRES ) + 1; + zero_cmplx( &( x[i] ), *x_len - i ); + + peak_range_1 = (LC3_INT32) MIN( *x_len, ( 40000.0 / 100 * 1.6 ) / 2 + 1 ); + + plc_phEcu_fft_spec2_sqrt_approx( x, peak_range_1, Xabs ); + + zero_float( &( Xabs[peak_range_1] ), *x_len - peak_range_1 ); + inp_high = Xabs[0]; inp_low = Xabs[0]; - - for (i = 1; i < peak_range_1; i++) { - inp_high = MAX(inp_high, Xabs[i]); - inp_low = MIN(inp_low, Xabs[i]); + + for ( i = 1; i < peak_range_1; i++ ) + { + inp_high = MAX( inp_high, Xabs[i] ); + inp_low = MIN( inp_low, Xabs[i] ); } - - sens = (inp_high-inp_low)*(1-pfind_sens); - - if (inp_high > ((LC3_FLOAT) PEAK_LOCATOR_RES_FX)/2.0) - { - { - /* from ROM constants.c */ - LC3_FLOAT fx_fft_scales[5] = { 6, 7, 7, 8, 8 }; /*NB,WB, sSWB, SWB, FB*/ - fx_fft_scale = LC3_POW(2.0, fx_fft_scales[bw_idx]); /*% scaling due to up / dn pre shifts in fx FFT */ - } - { /* from ROM constants.c */ - LC3_FLOAT fx_fs_scales[5] = { 1.0, 1.0, 1.5, 1.0, 1.5 }; /*NB,WB, sSWB, SWB, FB*/ - fft_fs_scale = fx_fs_scales[bw_idx]; - } - - - max_xfp_abs = (LC3_FLOAT) LC3_FABS(xfp[0]); - for (i = 1; i < xfp_len; i++) { - max_xfp_abs = (LC3_FLOAT) MAX(max_xfp_abs, LC3_FABS(xfp[i])); - } - - if (max_xfp_abs >= 0.5) - { - PLC2_Q_flt = (LC3_FLOAT)LC3_FLOOR(LC3_LOGTWO(32768 / 2 / 2 / max_xfp_abs)); - Q_scale_flt = LC3_POW(2.0, PLC2_Q_flt) / fx_fft_scale / fft_fs_scale; /* basop way using xfp scale */ - - /* C-Float additional safety limit/verification of the integer xfp based scaling using the available C-float Xabs max value inp_high as well */ - { - LC3_FLOAT tmp_scale; - tmp_scale = LC3_POW(2.0, LC3_FLOOR(LC3_LOGTWO(32768 / 2 / 2 / inp_high))); - if (Q_scale_flt > tmp_scale) { - Q_scale_flt = tmp_scale; - } - } - /* Round sens, inp_high, inp_low according to BASOP fix-point scaling */ - - for (i = 0; i < peak_range_1; i++) { - Xabs_fx[i] = (LC3_INT16) LC3_ROUND(Xabs[i] * Q_scale_flt) ; - } - sens_fx = (LC3_INT16) LC3_ROUND(sens * Q_scale_flt) ; - inp_high_fx = (LC3_INT16) LC3_ROUND(inp_high * Q_scale_flt) ; - inp_low_fx = (LC3_INT16) LC3_ROUND(inp_low * Q_scale_flt) ; - plc_phEcu_peak_locator_fxlike(Xabs_fx, peak_range_1, plocs_fx, &n_plocs_fx, sens_fx, inp_high_fx, inp_low_fx); - - *n_plocs = (LC3_INT32)n_plocs_fx; - for (i = 0; i < *n_plocs; i++) { - plocs[i] = (LC3_INT32)plocs_fx[i]; /* short Word16 values now stored/saved as Word32 */ - } - } - else + + sens = ( inp_high - inp_low ) * ( 1 - pfind_sens ); + + if ( inp_high > ( (LC3_FLOAT) PEAK_LOCATOR_RES_FX ) / 2.0 ) + { + { + /* from ROM constants.c */ + LC3_FLOAT fx_fft_scales[5] = { 6, 7, 7, 8, 8 }; /*NB,WB, sSWB, SWB, FB*/ + fx_fft_scale = LC3_POW( 2.0, fx_fft_scales[bw_idx] ); /*% scaling due to up / dn pre shifts in fx FFT */ + } + { /* from ROM constants.c */ + LC3_FLOAT fx_fs_scales[5] = { 1.0, 1.0, 1.5, 1.0, 1.5 }; /*NB,WB, sSWB, SWB, FB*/ + fft_fs_scale = fx_fs_scales[bw_idx]; + } + + + max_xfp_abs = (LC3_FLOAT) LC3_FABS( xfp[0] ); + for ( i = 1; i < xfp_len; i++ ) { - *n_plocs = 0; /* time domain xfp level near zero */ + max_xfp_abs = (LC3_FLOAT) MAX( max_xfp_abs, LC3_FABS( xfp[i] ) ); + } + + if ( max_xfp_abs >= 0.5 ) + { + PLC2_Q_flt = (LC3_FLOAT) LC3_FLOOR( LC3_LOGTWO( 32768 / 2 / 2 / max_xfp_abs ) ); + Q_scale_flt = LC3_POW( 2.0, PLC2_Q_flt ) / fx_fft_scale / fft_fs_scale; /* basop way using xfp scale */ + + /* C-Float additional safety limit/verification of the integer xfp based scaling using the available C-float Xabs max value inp_high as well */ + { + LC3_FLOAT tmp_scale; + tmp_scale = LC3_POW( 2.0, LC3_FLOOR( LC3_LOGTWO( 32768 / 2 / 2 / inp_high ) ) ); + if ( Q_scale_flt > tmp_scale ) + { + Q_scale_flt = tmp_scale; + } + } + /* Round sens, inp_high, inp_low according to BASOP fix-point scaling */ + + for ( i = 0; i < peak_range_1; i++ ) + { + Xabs_fx[i] = (LC3_INT16) LC3_ROUND( Xabs[i] * Q_scale_flt ); + } + sens_fx = (LC3_INT16) LC3_ROUND( sens * Q_scale_flt ); + inp_high_fx = (LC3_INT16) LC3_ROUND( inp_high * Q_scale_flt ); + inp_low_fx = (LC3_INT16) LC3_ROUND( inp_low * Q_scale_flt ); + plc_phEcu_peak_locator_fxlike( Xabs_fx, peak_range_1, plocs_fx, &n_plocs_fx, sens_fx, inp_high_fx, inp_low_fx ); + + *n_plocs = (LC3_INT32) n_plocs_fx; + for ( i = 0; i < *n_plocs; i++ ) + { + plocs[i] = (LC3_INT32) plocs_fx[i]; /* short Word16 values now stored/saved as Word32 */ + } + } + else + { + *n_plocs = 0; /* time domain xfp level near zero */ } } else { *n_plocs = 0; /* Freq domain Xabs max level near zero */ } - - for (i = 0; i < *n_plocs; i++) { - curr = plocs[i]; - if (curr == 0) { - interPos = plc_phEcu_interp_max(Xabs, 3); /* returns 0.0 ... 2.0 */ - if (interPos == 2) { - /* integer peak was at DC, restrict to one of coeffs at [DC or DC+1] */ - interPos = plc_phEcu_interp_max(Xabs, 2); /* returns 0.0 or 1.0 */ + + for ( i = 0; i < *n_plocs; i++ ) + { + curr = plocs[i]; + if ( curr == 0 ) + { + interPos = plc_phEcu_interp_max( Xabs, 3 ); /* returns 0.0 ... 2.0 */ + if ( interPos == 2 ) + { + /* integer peak was at DC, restrict to one of coeffs at [DC or DC+1] */ + interPos = plc_phEcu_interp_max( Xabs, 2 ); /* returns 0.0 or 1.0 */ } interPos += plocs[i]; - } else if (curr == 1) { - interPos = plc_phEcu_interp_max(Xabs, 3); + } + else if ( curr == 1 ) + { + interPos = plc_phEcu_interp_max( Xabs, 3 ); interPos += plocs[i] - 1; - } else if (curr == *x_len - 2) { - interPos = plc_phEcu_interp_max(&Xabs[*x_len - 3], 3); + } + else if ( curr == *x_len - 2 ) + { + interPos = plc_phEcu_interp_max( &Xabs[*x_len - 3], 3 ); interPos += plocs[i] - 1; - } else if (curr == *x_len - 1) { - /* integer curr at Fs/2, a real coeff */ - interPos = plc_phEcu_interp_max(&Xabs[*x_len - 3], 3); /* returns 0.0 ... 2.0 */ - interPos += plocs[i] - 2; /* valid for range ]... 1.0 ... 2.0] , where 1 is fs/2-1 and 2.0 is Fs/2 */ - if (interPos == 0) { - /* restrict to one of coeffs at [fs/2-1, fs/2 ] */ - interPos = plc_phEcu_interp_max(&Xabs[*x_len - 2], 2); /* returns 0.0 or 1.0 */ + } + else if ( curr == *x_len - 1 ) + { + /* integer curr at Fs/2, a real coeff */ + interPos = plc_phEcu_interp_max( &Xabs[*x_len - 3], 3 ); /* returns 0.0 ... 2.0 */ + interPos += plocs[i] - 2; /* valid for range ]... 1.0 ... 2.0] , where 1 is fs/2-1 and 2.0 is Fs/2 */ + if ( interPos == 0 ) + { + /* restrict to one of coeffs at [fs/2-1, fs/2 ] */ + interPos = plc_phEcu_interp_max( &Xabs[*x_len - 2], 2 ); /* returns 0.0 or 1.0 */ interPos += plocs[i] - 1; - } + } - if (interPos > (*x_len - 1) ) { /* interPos only defined up to Fs/2 */ - interPos = (LC3_FLOAT)(*x_len - 1); + if ( interPos > ( *x_len - 1 ) ) + { /* interPos only defined up to Fs/2 */ + interPos = (LC3_FLOAT) ( *x_len - 1 ); } - } else { - Xana_p[0] = x[plocs[i]-1]; + } + else + { + Xana_p[0] = x[plocs[i] - 1]; Xana_p[1] = x[plocs[i]]; - Xana_p[2] = x[plocs[i]+1]; - phEcu_c_jacob[0] = (LC3_FLOAT)PHECU_C_JACOB; - interPos = plc_phEcu_imax2_jacobsen_mag(Xana_p, phEcu_c_jacob ); + Xana_p[2] = x[plocs[i] + 1]; + phEcu_c_jacob[0] = (LC3_FLOAT) PHECU_C_JACOB; + interPos = plc_phEcu_imax2_jacobsen_mag( Xana_p, phEcu_c_jacob ); interPos += (LC3_FLOAT) plocs[i]; - } + } f0est[i] = interPos; } - - if (*n_plocs >= 2 && plocs[0] == 0 && - f0est[0] > f0est[1] && plocs[1] <= 2 && Xabs[0] < Xabs[plocs[1]+1]) - { + + if ( *n_plocs >= 2 && plocs[0] == 0 && + f0est[0] > f0est[1] && plocs[1] <= 2 && Xabs[0] < Xabs[plocs[1] + 1] ) + { f0est[0] = f0est[1]; } - - P_in_plocs = plc_phEcu_pitch_in_plocs(plocs, *n_plocs); - - if (f0hzLtpBin > 0.0 && P_in_plocs > 0) { + + P_in_plocs = plc_phEcu_pitch_in_plocs( plocs, *n_plocs ); + + if ( f0hzLtpBin > 0.0 && P_in_plocs > 0 ) + { nSubs = 2; n_plocs_in = *n_plocs; - plc_phEcu_LF_peak_analysis(plocs, n_plocs, f0est, Xabs, &f0hzLtpBin, &f0gainLtp, nSubs); - - if (n_plocs_in == *n_plocs) { + plc_phEcu_LF_peak_analysis( plocs, n_plocs, f0est, Xabs, &f0hzLtpBin, &f0gainLtp, nSubs ); + + if ( n_plocs_in == *n_plocs ) + { nSubs = 3; - plc_phEcu_F0_refine_first(plocs, *n_plocs, f0est, *x_len, &f0hzLtpBin, &f0gainLtp, nSubs); + plc_phEcu_F0_refine_first( plocs, *n_plocs, f0est, *x_len, &f0hzLtpBin, &f0gainLtp, nSubs ); } } - - if (f0gainLtp > 0.0 && f0gainLtp < 0.5 && *n_plocs > 14) { - if (P_in_plocs > 0) { + + if ( f0gainLtp > 0.0 && f0gainLtp < 0.5 && *n_plocs > 14 ) + { + if ( P_in_plocs > 0 ) + { *n_plocs = 0; } } - return; + return; } -#define sub(a,b) (a - b) -#define add(a,b) (a + b) -#define s_xor(a,b) (a ^ b) +#define sub( a, b ) ( a - b ) +#define add( a, b ) ( a + b ) +#define s_xor( a, b ) ( a ^ b ) /* in case a value (e.g max or min) is already known , find the first corresponding array index */ -static LC3_INT16 plc_phEcu_find_ind_fx( /* o : output maximum indx 0.. len-1 */ - const LC3_INT16 *inp, /* i : vector */ - const LC3_INT16 len, /* i : length */ - const LC3_INT16 val /* i : value to find */ +static LC3_INT16 plc_phEcu_find_ind_fx( /* o : output maximum indx 0.. len-1 */ + const LC3_INT16 *inp, /* i : vector */ + const LC3_INT16 len, /* i : length */ + const LC3_INT16 val /* i : value to find */ ) { - LC3_INT16 val_ind; + LC3_INT16 val_ind; LC3_INT16 pos; - val_ind = -1; + val_ind = -1; - for(pos = 0; pos < len; pos++) + for ( pos = 0; pos < len; pos++ ) { - if (sub(inp[pos], val) == 0) + if ( sub( inp[pos], val ) == 0 ) { val_ind = pos; } } - return val_ind; + return val_ind; } - /* BASOP function adapted to compile in float/integer environment */ /*----------------------------------------------------------------------------- * plc_phEcu_peak_locator_fxlike() *----------------------------------------------------------------------------*/ -static void plc_phEcu_peak_locator_fxlike(const LC3_INT16 *inp, /* i: vector with values >=0 ,Qx */ - const LC3_INT16 inp_len, /* i: length of inp */ - LC3_INT16 * int_plocs, /* o: array of filtered integer plocs Q0 */ - LC3_INT16 * n_fsc, /* o: total_ number of filtered located highs Q0 */ - const LC3_INT16 sens, /* i sensitivity, Qx */ - const LC3_INT16 inp_high, /* i global high , Qx */ - const LC3_INT16 inp_low /* i: global low, Qx */ +static void plc_phEcu_peak_locator_fxlike( const LC3_INT16 *inp, /* i: vector with values >=0 ,Qx */ + const LC3_INT16 inp_len, /* i: length of inp */ + LC3_INT16 *int_plocs, /* o: array of filtered integer plocs Q0 */ + LC3_INT16 *n_fsc, /* o: total_ number of filtered located highs Q0 */ + const LC3_INT16 sens, /* i sensitivity, Qx */ + const LC3_INT16 inp_high, /* i global high , Qx */ + const LC3_INT16 inp_low /* i: global low, Qx */ ) { - LC3_INT16 j, k, n, idx_high, idx_low; - LC3_INT16 inp_len_minus1; - LC3_INT16 pairs_start, pairs_end; - LC3_INT16 *p_tmp; - LC3_INT16 prev_delta, curr_delta; - LC3_INT16 delta_predc, delta_fin; - LC3_INT16 add_dc_flag, add_fin_flag; - LC3_INT16 low_val_cand_pairs, val_range; - LC3_INT16 num_pairs, n_tail_values; - LC3_INT16 cand_phase_start, cand_idx, prev_low_plus_sens, tmp; - LC3_INT16 cand_high, prev_low; - LC3_INT16 *cand_pairs; /* actually [DC ] + pairs + [FS/2] */ - - LC3_INT16 sc_idx[1 + 368 + 1]; - LC3_INT16 cand_pairs_buf[1 + 1 + 368 + 1]; - LC3_INT16 fsc_idx[1 + 368 / 2 + 1]; - - - inp_len_minus1 = sub(inp_len, 1); /* size of delta=derivative array ,and last index in inp */ - - cand_pairs = &cand_pairs_buf[1]; /* ptr init , make space for storing a lowest amplitude value in location -1 */ + LC3_INT16 j, k, n, idx_high, idx_low; + LC3_INT16 inp_len_minus1; + LC3_INT16 pairs_start, pairs_end; + LC3_INT16 *p_tmp; + LC3_INT16 prev_delta, curr_delta; + LC3_INT16 delta_predc, delta_fin; + LC3_INT16 add_dc_flag, add_fin_flag; + LC3_INT16 low_val_cand_pairs, val_range; + LC3_INT16 num_pairs, n_tail_values; + LC3_INT16 cand_phase_start, cand_idx, prev_low_plus_sens, tmp; + LC3_INT16 cand_high, prev_low; + LC3_INT16 *cand_pairs; /* actually [DC ] + pairs + [FS/2] */ + + LC3_INT16 sc_idx[1 + 368 + 1]; + LC3_INT16 cand_pairs_buf[1 + 1 + 368 + 1]; + LC3_INT16 fsc_idx[1 + 368 / 2 + 1]; + + + inp_len_minus1 = sub( inp_len, 1 ); /* size of delta=derivative array ,and last index in inp */ + + cand_pairs = &cand_pairs_buf[1]; /* ptr init , make space for storing a lowest amplitude value in location -1 */ pairs_start = 1; /* adjusted to zero or 1 or 2 when/if, DC is injected as sc_idx[0], or initial plateau skipped */ - p_tmp = &(sc_idx[pairs_start]); /* ptr init */ + p_tmp = &( sc_idx[pairs_start] ); /* ptr init */ /* xor high/low pairs of delta_inp and save sign changes */ - prev_delta = sub(inp[1], inp[0]); /* precompute very first delta */ + prev_delta = sub( inp[1], inp[0] ); /* precompute very first delta */ - for(n = 1; n < inp_len_minus1; n++) - { /* sign change analysis */ - curr_delta = sub(inp[n + 1], inp[n]); /* n+1 ,n , are loop ptrs */ - if (s_xor(prev_delta, curr_delta) < 0) /* a "0" delta treated as a positive sign */ + for ( n = 1; n < inp_len_minus1; n++ ) + { /* sign change analysis */ + curr_delta = sub( inp[n + 1], inp[n] ); /* n+1 ,n , are loop ptrs */ + if ( s_xor( prev_delta, curr_delta ) < 0 ) /* a "0" delta treated as a positive sign */ { - *p_tmp++ = n; /* store sign change bin locations , location n in the inp[] signal */ + *p_tmp++ = n; /* store sign change bin locations , location n in the inp[] signal */ } - prev_delta = curr_delta; + prev_delta = curr_delta; } - k = (LC3_INT16)(p_tmp - &(sc_idx[pairs_start])); + k = (LC3_INT16) ( p_tmp - &( sc_idx[pairs_start] ) ); /* copy sign change location values to a pairs array */ /* leave one initial sc_idx location open for a potential initial DC value */ - for(j = 0; j < k; j++){ - cand_pairs[j + pairs_start] = inp[sc_idx[j + pairs_start]]; + for ( j = 0; j < k; j++ ) + { + cand_pairs[j + pairs_start] = inp[sc_idx[j + pairs_start]]; } /* filter away a potential single initial/trailing plateau to enable correct analysis for adding DC or fs/2 bins */ - - if((sub(k, 2) >= 0) && - (sub(cand_pairs[pairs_start], cand_pairs[pairs_start + 1]) == 0)){ - pairs_start = add(pairs_start, 1); - k = sub(k, 1); + + if ( ( sub( k, 2 ) >= 0 ) && + ( sub( cand_pairs[pairs_start], cand_pairs[pairs_start + 1] ) == 0 ) ) + { + pairs_start = add( pairs_start, 1 ); + k = sub( k, 1 ); } /* filter away potential single trailing plateu */ - pairs_end = sub(add(pairs_start, k), 1); /* point to last established sign change element */ - - if ((sub(k, 2) >= 0) && - (sub(cand_pairs[sub(pairs_end, 1)], cand_pairs[pairs_end]) == 0)){ - k = sub(k, 1); + pairs_end = sub( add( pairs_start, k ), 1 ); /* point to last established sign change element */ + + if ( ( sub( k, 2 ) >= 0 ) && + ( sub( cand_pairs[sub( pairs_end, 1 )], cand_pairs[pairs_end] ) == 0 ) ) + { + k = sub( k, 1 ); } - pairs_end = sub(add(pairs_start, k), 1); /* recalc ptr to last element */ + pairs_end = sub( add( pairs_start, k ), 1 ); /* recalc ptr to last element */ /* conditionally add high/lows on both sides of input (pre_dc or fin) as candidates */ - add_dc_flag = 0; - add_fin_flag = 0; + add_dc_flag = 0; + add_fin_flag = 0; - if(sub(k, 1) == 0) /* one single sign change found special case */ + if ( sub( k, 1 ) == 0 ) /* one single sign change found special case */ { - if (sub(inp[0], cand_pairs[pairs_start]) != 0) + if ( sub( inp[0], cand_pairs[pairs_start] ) != 0 ) { - add_dc_flag = 1; /* not plateau */ + add_dc_flag = 1; /* not plateau */ } - if (sub(cand_pairs[pairs_end], inp[inp_len_minus1]) != 0) + if ( sub( cand_pairs[pairs_end], inp[inp_len_minus1] ) != 0 ) { - add_fin_flag = 1; /* not plateau */ + add_fin_flag = 1; /* not plateau */ } } - if(sub(k, 2) >= 0) + if ( sub( k, 2 ) >= 0 ) { - delta_predc = sub(cand_pairs[pairs_start + 1], cand_pairs[pairs_start]); - delta_fin = sub(cand_pairs[pairs_end], cand_pairs[pairs_end - 1]); + delta_predc = sub( cand_pairs[pairs_start + 1], cand_pairs[pairs_start] ); + delta_fin = sub( cand_pairs[pairs_end], cand_pairs[pairs_end - 1] ); /* plateaus are allowed to be detected by xor sign change, but still not allowed at the start nor at the end */ - add_dc_flag = 1; - if (sub(inp[0], cand_pairs[pairs_start]) == 0) + add_dc_flag = 1; + if ( sub( inp[0], cand_pairs[pairs_start] ) == 0 ) { - add_dc_flag = 0; /* plateau down or , plateaus up., --> do not add DC */ + add_dc_flag = 0; /* plateau down or , plateaus up., --> do not add DC */ } - - if ((sub(inp[0], cand_pairs[pairs_start]) < 0) && (delta_predc > 0)) + + if ( ( sub( inp[0], cand_pairs[pairs_start] ) < 0 ) && ( delta_predc > 0 ) ) { - add_dc_flag = -1; /*UP - up ... replace */ + add_dc_flag = -1; /*UP - up ... replace */ } - - if ((sub(inp[0], cand_pairs[pairs_start]) > 0) && (delta_predc < 0)) + + if ( ( sub( inp[0], cand_pairs[pairs_start] ) > 0 ) && ( delta_predc < 0 ) ) { - add_dc_flag = -1; /* DOWN - down ... % replace */ + add_dc_flag = -1; /* DOWN - down ... % replace */ } - add_fin_flag = 1; - if (sub(cand_pairs[pairs_end], inp[inp_len_minus1]) == 0) + add_fin_flag = 1; + if ( sub( cand_pairs[pairs_end], inp[inp_len_minus1] ) == 0 ) { - add_fin_flag = 0; /* up - plateau ... */ + add_fin_flag = 0; /* up - plateau ... */ } - - if ((delta_fin > 0) && (sub(cand_pairs[pairs_end], inp[inp_len_minus1]) < 0)) + + if ( ( delta_fin > 0 ) && ( sub( cand_pairs[pairs_end], inp[inp_len_minus1] ) < 0 ) ) { - add_fin_flag = -1; /* up - UP ... % replace , hard to hit */ + add_fin_flag = -1; /* up - UP ... % replace , hard to hit */ } - - if ((delta_fin < 0) && (sub(cand_pairs[pairs_end], inp[inp_len_minus1]) > 0)) + + if ( ( delta_fin < 0 ) && ( sub( cand_pairs[pairs_end], inp[inp_len_minus1] ) > 0 ) ) { - add_fin_flag = -1; /*down - DOWN ... % replace */ + add_fin_flag = -1; /*down - DOWN ... % replace */ } - } - if(add_dc_flag > 0) - { /* add DC */ - pairs_start = sub(pairs_start, 1); - cand_pairs[pairs_start] = inp[0]; - sc_idx[pairs_start] = 0; - k = add(k, 1); + if ( add_dc_flag > 0 ) + { /* add DC */ + pairs_start = sub( pairs_start, 1 ); + cand_pairs[pairs_start] = inp[0]; + sc_idx[pairs_start] = 0; + k = add( k, 1 ); } - if(add_dc_flag < 0) + if ( add_dc_flag < 0 ) { /* -1 --> replace with DC*/ - cand_pairs[pairs_start] = inp[0]; - sc_idx[pairs_start] = 0; + cand_pairs[pairs_start] = inp[0]; + sc_idx[pairs_start] = 0; } - if(add_fin_flag > 0) - { /* add FS/2 */ - pairs_end = add(pairs_end, 1); - cand_pairs[pairs_end] = inp[inp_len_minus1]; - sc_idx[pairs_end] = inp_len_minus1; - k = add(k, 1); + if ( add_fin_flag > 0 ) + { /* add FS/2 */ + pairs_end = add( pairs_end, 1 ); + cand_pairs[pairs_end] = inp[inp_len_minus1]; + sc_idx[pairs_end] = inp_len_minus1; + k = add( k, 1 ); } - if(add_fin_flag < 0) - { /* -1, replace tail with FS/2*/ - cand_pairs[pairs_end] = inp[inp_len_minus1]; - sc_idx[pairs_end] = inp_len_minus1; + if ( add_fin_flag < 0 ) + { /* -1, replace tail with FS/2*/ + cand_pairs[pairs_end] = inp[inp_len_minus1]; + sc_idx[pairs_end] = inp_len_minus1; } /* preliminary cand_pairs now only have highs , lows , no initial/trailing plateaus */ /* we allow the DC/FsBy2 lows to be used as the candidatelLow */ - low_val_cand_pairs = inp_low; - val_range = sub(inp_high, low_val_cand_pairs); /* used to determine if search is useful at all */ + low_val_cand_pairs = inp_low; + val_range = sub( inp_high, low_val_cand_pairs ); /* used to determine if search is useful at all */ + - - if ((sub(val_range, PEAK_LOCATOR_RES_FX) < 0) || - (sub(inp_high, sens) < 0)) + if ( ( sub( val_range, PEAK_LOCATOR_RES_FX ) < 0 ) || + ( sub( inp_high, sens ) < 0 ) ) { - k = 0; + k = 0; } - - if ((k == 0) && (sub(val_range, sens) >= 0)) + + if ( ( k == 0 ) && ( sub( val_range, sens ) >= 0 ) ) { - k = 1; + k = 1; } - if(sub(k, 2) > 0) + if ( sub( k, 2 ) > 0 ) { /* low, high, low, ... or high, low, high, ...*/ - cand_phase_start = pairs_start; /*assume first candidate is a high */ - if (sub(cand_pairs[pairs_start], cand_pairs[pairs_start + 1]) < 0) + cand_phase_start = pairs_start; /*assume first candidate is a high */ + if ( sub( cand_pairs[pairs_start], cand_pairs[pairs_start + 1] ) < 0 ) { - cand_phase_start = add(pairs_start, 1); /* first is a low, --> skip to next higher cand */ + cand_phase_start = add( pairs_start, 1 ); /* first is a low, --> skip to next higher cand */ } /* high, low, high, ... */ - tmp = k; - if (sub(cand_phase_start, pairs_start) != 0) + tmp = k; + if ( sub( cand_phase_start, pairs_start ) != 0 ) { - tmp = sub(tmp, 1); + tmp = sub( tmp, 1 ); } - num_pairs = tmp / 2; // shr(tmp, 1); - n_tail_values = sub(tmp, num_pairs * 2); // shl(num_pairs, 1)); + num_pairs = tmp / 2; // shr(tmp, 1); + n_tail_values = sub( tmp, num_pairs * 2 ); // shl(num_pairs, 1)); /* filter preliminary sign changes into sensitivity filtered sign changes */ - *n_fsc = 0; /* counter of filtered fsc_idx */ - cand_high = low_val_cand_pairs; - cand_idx = -1; /* sentinel location for no high cand found yet. */ - cand_pairs[-1] = low_val_cand_pairs; + *n_fsc = 0; /* counter of filtered fsc_idx */ + cand_high = low_val_cand_pairs; + cand_idx = -1; /* sentinel location for no high cand found yet. */ + cand_pairs[-1] = low_val_cand_pairs; - prev_low = low_val_cand_pairs; - prev_low_plus_sens = add(prev_low, sens); + prev_low = low_val_cand_pairs; + prev_low_plus_sens = add( prev_low, sens ); /* filter loop for high - low sign change pairs */ /* idx_high, idx_low are raw pointers into the cand_pairs and sc_idx arrays */ - for(idx_high = cand_phase_start; idx_high < (cand_phase_start + 2 * num_pairs); idx_high += 2) + for ( idx_high = cand_phase_start; idx_high < ( cand_phase_start + 2 * num_pairs ); idx_high += 2 ) { - idx_low = idx_high + 1; /* loop ptr increase */ + idx_low = idx_high + 1; /* loop ptr increase */ /* new high candidate larger than previous candidate and */ /* sensitivity still larger than the the previous low */ - tmp = MAX(cand_high, prev_low_plus_sens); - if (sub(cand_pairs[idx_high], tmp) > 0) + tmp = MAX( cand_high, prev_low_plus_sens ); + if ( sub( cand_pairs[idx_high], tmp ) > 0 ) { - cand_idx = idx_high; /* enable or shift candidate position fwd */ + cand_idx = idx_high; /* enable or shift candidate position fwd */ } - cand_high = cand_pairs[cand_idx]; /* NB, cand_pairs[-1] , has the low_val_cand_pairs value stored */ + cand_high = cand_pairs[cand_idx]; /* NB, cand_pairs[-1] , has the low_val_cand_pairs value stored */ /* now check the fwd idx_low of the current {high,low} pair */ - prev_low = MIN(cand_pairs[idx_low], prev_low); + prev_low = MIN( cand_pairs[idx_low], prev_low ); - tmp = sub(cand_high, sens); - if(sub(tmp, cand_pairs[idx_low]) > 0) + tmp = sub( cand_high, sens ); + if ( sub( tmp, cand_pairs[idx_low] ) > 0 ) { /* this low point is now low enough to fix a previous high candidate */ - fsc_idx[*n_fsc] = cand_idx; /*% add cand high idx -> output idx list*/ - *n_fsc = add(*n_fsc, 1); + fsc_idx[*n_fsc] = cand_idx; /*% add cand high idx -> output idx list*/ + *n_fsc = add( *n_fsc, 1 ); - prev_low = cand_pairs[idx_low]; /* use this value as new low estimate */ - cand_idx = -1; /* no candidate until next pair or tail bin, and pt to lowVal */ - cand_high = low_val_cand_pairs; /* enable next candidate to be selected immediately */ + prev_low = cand_pairs[idx_low]; /* use this value as new low estimate */ + cand_idx = -1; /* no candidate until next pair or tail bin, and pt to lowVal */ + cand_high = low_val_cand_pairs; /* enable next candidate to be selected immediately */ } - prev_low_plus_sens = add(prev_low, sens); + prev_low_plus_sens = add( prev_low, sens ); } /* { high, low} for loop */ - - if((n_tail_values == 0) && (cand_idx >= 0)) + + if ( ( n_tail_values == 0 ) && ( cand_idx >= 0 ) ) { /* no tail low or high value to analyze still may need to lock a non-locked but qualified candidate */ - fsc_idx[*n_fsc] = cand_idx; - *n_fsc = add(*n_fsc, 1); + fsc_idx[*n_fsc] = cand_idx; + *n_fsc = add( *n_fsc, 1 ); } /* cand_pairs vector may have a last orphan value */ - if(n_tail_values > 0) + if ( n_tail_values > 0 ) { /* cand_pairs vector may have a last orphan tail value */ /* @@ -548,52 +570,49 @@ static void plc_phEcu_peak_locator_fxlike(const LC3_INT16 *inp, /* i: vector wit tmp=a||b */ - tmp = MAX(cand_high, prev_low_plus_sens); - tmp = sub(cand_pairs[pairs_end], tmp); - if(tmp > 0) + tmp = MAX( cand_high, prev_low_plus_sens ); + tmp = sub( cand_pairs[pairs_end], tmp ); + if ( tmp > 0 ) { - fsc_idx[*n_fsc] = pairs_end; - *n_fsc = add(*n_fsc, 1); + fsc_idx[*n_fsc] = pairs_end; + *n_fsc = add( *n_fsc, 1 ); } else { - if(cand_idx >= 0) - { /* we have a previously established high candidate */ - fsc_idx[*n_fsc] = cand_idx; - *n_fsc = add(*n_fsc, 1); - } - + if ( cand_idx >= 0 ) + { /* we have a previously established high candidate */ + fsc_idx[*n_fsc] = cand_idx; + *n_fsc = add( *n_fsc, 1 ); + } } } /* move high locations info from fsc_idx , to output */ - for(j = 0; j < *n_fsc; j++) - { - int_plocs[j] = sc_idx[fsc_idx[j]]; - + for ( j = 0; j < *n_fsc; j++ ) + { + int_plocs[j] = sc_idx[fsc_idx[j]]; } } /* end of pairs + [tail] section filtering */ else { /* constant/single rise or constant decay or very low overall values, cases */ - *n_fsc = 0; - - tmp = sub(inp_high, sens); - if((k != 0) && (sub(tmp, low_val_cand_pairs) > 0)) + *n_fsc = 0; + + tmp = sub( inp_high, sens ); + if ( ( k != 0 ) && ( sub( tmp, low_val_cand_pairs ) > 0 ) ) { /* low,high */ /* high,low */ - tmp = plc_phEcu_find_ind_fx(inp, inp_len, inp_high); - int_plocs[0] = tmp; /* simply locate the high peak*/ - *n_fsc = 1; - if (tmp < 0) - { /*safety in case max value index was not found */ - *n_fsc = 0; + tmp = plc_phEcu_find_ind_fx( inp, inp_len, inp_high ); + int_plocs[0] = tmp; /* simply locate the high peak*/ + *n_fsc = 1; + if ( tmp < 0 ) + { /*safety in case max value index was not found */ + *n_fsc = 0; } - } + } } return; } - diff --git a/lib_lc3plus/plc_phecu_subst_spec.c b/lib_lc3plus/plc_phecu_subst_spec.c index 43f806339b..4c838ab2ff 100644 --- a/lib_lc3plus/plc_phecu_subst_spec.c +++ b/lib_lc3plus/plc_phecu_subst_spec.c @@ -1,12 +1,12 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "defines.h" @@ -14,234 +14,258 @@ #include "constants.h" -static LC3_INT32 own_rand(LC3_INT32 seed); -static Complex valley_magnitude_adj(Complex X_i_in, LC3_INT32 uni_seed, LC3_FLOAT cos_F); -static LC3_INT32 rand_phase(LC3_INT32 seed_in, LC3_FLOAT* cos_F); +static LC3_INT32 own_rand( LC3_INT32 seed ); +static Complex valley_magnitude_adj( Complex X_i_in, LC3_INT32 uni_seed, LC3_FLOAT cos_F ); +static LC3_INT32 rand_phase( LC3_INT32 seed_in, LC3_FLOAT *cos_F ); + +void plc_phEcu_subst_spec( LC3_INT32 *plocs, LC3_INT32 n_plocs, LC3_FLOAT *f0est, LC3_INT32 time_offs, Complex *X, LC3_INT32 X_len, LC3_FLOAT *mag_chg_gr, LC3_INT32 *seed, LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *Xavg, LC3_INT32 t_adv_in, LC3_INT32 Lprot, LC3_INT32 delta_corr, LC3_FLOAT *corr_phase_dbg, LC3_FLOAT *X_i_new_re_dbg, LC3_FLOAT *X_i_new_im_dbg ) +{ -void plc_phEcu_subst_spec(LC3_INT32* plocs, LC3_INT32 n_plocs, LC3_FLOAT* f0est, LC3_INT32 time_offs, Complex* X, LC3_INT32 X_len, - LC3_FLOAT* mag_chg_gr, LC3_INT32 *seed, LC3_FLOAT* alpha, LC3_FLOAT* beta, LC3_FLOAT* Xavg, - LC3_INT32 t_adv_in, LC3_INT32 Lprot, LC3_INT32 delta_corr, LC3_FLOAT *corr_phase_dbg, - LC3_FLOAT *X_i_new_re_dbg, LC3_FLOAT *X_i_new_im_dbg) { - LC3_INT32 i, i2, lprotBy2Minus1, one_peak_flag_mask, noise_mag_scale; LC3_INT32 t_adv; - LC3_FLOAT corr_phase[MAX_PLC_NPLOCS] = {0}; - LC3_FLOAT cos_F, mag_chg_local, alpha_local, beta_local, tmp; + LC3_FLOAT corr_phase[MAX_PLC_NPLOCS] = { 0 }; + LC3_FLOAT cos_F, mag_chg_local, alpha_local, beta_local, tmp; Complex X_i, X_i_new; LC3_INT32 segmentLen, e; LC3_FLOAT Xph; LC3_FLOAT seed_local; LC3_INT32 binCounter, subInd; - - UNUSED(corr_phase_dbg); - UNUSED(X_i_new_re_dbg); - UNUSED(X_i_new_im_dbg); + + UNUSED( corr_phase_dbg ); + UNUSED( X_i_new_re_dbg ); + UNUSED( X_i_new_im_dbg ); seed_local = (LC3_FLOAT) *seed; - - - lprotBy2Minus1 = imin(320, Lprot/2 - 1); /* limit to 20 KHz */ - - + + + lprotBy2Minus1 = imin( 320, Lprot / 2 - 1 ); /* limit to 20 KHz */ + + t_adv = t_adv_in + time_offs; - - for (i = 0; i < n_plocs; i++) { - corr_phase[i] = (LC3_FLOAT)2.0 * (LC3_FLOAT)M_PI * (f0est[i]/Lprot)*(LC3_FLOAT)t_adv; + + for ( i = 0; i < n_plocs; i++ ) + { + corr_phase[i] = (LC3_FLOAT) 2.0 * (LC3_FLOAT) M_PI * ( f0est[i] / Lprot ) * (LC3_FLOAT) t_adv; } // EVOLVE PHASE ----------------- binCounter = 1; subInd = 0; - + one_peak_flag_mask = -1; - if (n_plocs < 3 && n_plocs > 0) { + if ( n_plocs < 3 && n_plocs > 0 ) + { one_peak_flag_mask = 0; } - + noise_mag_scale = 0; - if (n_plocs == 0 || time_offs != 0) { + if ( n_plocs == 0 || time_offs != 0 ) + { noise_mag_scale = 1; } - - if (n_plocs == 0) { - X[0] = realtoc(0); - X[X_len-1] = realtoc(0); - } - - if (n_plocs != 0) { - for (i = 0; i < n_plocs; i++) { - LC3_INT32 delta_corr_dn = delta_corr; - LC3_INT32 delta_corr_up = delta_corr; - - if (i > 0) { - delta_corr_dn = imin( ((plocs[i] - plocs[i - 1] - 1) / 2), delta_corr_dn); - } - - if (i < n_plocs - 1) { - delta_corr_up = imin( ((plocs[i + 1] - plocs[i] - 1) / 2), delta_corr_up); - } - - segmentLen = (plocs[i] - delta_corr_dn) - binCounter; - - for (i2 = 0; i2 < segmentLen; i2++) { - seed_local = (LC3_FLOAT)rand_phase((LC3_INT32)seed_local, &cos_F); - - X_i = X[binCounter]; - X_i_new = cmul(X_i, cexpi((LC3_FLOAT)M_PI*seed_local / (LC3_FLOAT)32768.0)); - - - seed_local = (LC3_FLOAT)own_rand((LC3_INT32)seed_local); + if ( n_plocs == 0 ) + { + X[0] = realtoc( 0 ); + X[X_len - 1] = realtoc( 0 ); + } - if (noise_mag_scale != 0) { - X_i = valley_magnitude_adj(X_i_new,(LC3_INT32) seed_local, cos_F); - X_i_new = X_i; - } - mag_chg_local = mag_chg_gr[subInd]; - alpha_local = alpha[subInd]; + if ( n_plocs != 0 ) + { + for ( i = 0; i < n_plocs; i++ ) + { + LC3_INT32 delta_corr_dn = delta_corr; + LC3_INT32 delta_corr_up = delta_corr; - if (beta[subInd] != 0) { - tmp = beta[subInd] * Xavg[subInd]; - if (one_peak_flag_mask == 0) { - tmp = 0; - X_i_new = realtoc(0); - } - X[binCounter] = cadd(cmul(realtoc(alpha_local), X_i_new), cmul(realtoc(tmp), cexpi((LC3_FLOAT)M_PI*seed_local / (LC3_FLOAT)32768.0))); + if ( i > 0 ) + { + delta_corr_dn = imin( ( ( plocs[i] - plocs[i - 1] - 1 ) / 2 ), delta_corr_dn ); } - else { - if (one_peak_flag_mask == 0) { - X_i_new = realtoc(0); - } - X[binCounter] = cmul(realtoc(mag_chg_local), X_i_new); + if ( i < n_plocs - 1 ) + { + delta_corr_up = imin( ( ( plocs[i + 1] - plocs[i] - 1 ) / 2 ), delta_corr_up ); } - binCounter++; + segmentLen = ( plocs[i] - delta_corr_dn ) - binCounter; - if (binCounter >= gwlpr[subInd + 1]) { - subInd++; + for ( i2 = 0; i2 < segmentLen; i2++ ) + { + seed_local = (LC3_FLOAT) rand_phase( (LC3_INT32) seed_local, &cos_F ); + + X_i = X[binCounter]; + X_i_new = cmul( X_i, cexpi( (LC3_FLOAT) M_PI * seed_local / (LC3_FLOAT) 32768.0 ) ); + + + seed_local = (LC3_FLOAT) own_rand( (LC3_INT32) seed_local ); + + if ( noise_mag_scale != 0 ) + { + X_i = valley_magnitude_adj( X_i_new, (LC3_INT32) seed_local, cos_F ); + X_i_new = X_i; + } + + mag_chg_local = mag_chg_gr[subInd]; + alpha_local = alpha[subInd]; + + if ( beta[subInd] != 0 ) + { + tmp = beta[subInd] * Xavg[subInd]; + if ( one_peak_flag_mask == 0 ) + { + tmp = 0; + X_i_new = realtoc( 0 ); + } + X[binCounter] = cadd( cmul( realtoc( alpha_local ), X_i_new ), cmul( realtoc( tmp ), cexpi( (LC3_FLOAT) M_PI * seed_local / (LC3_FLOAT) 32768.0 ) ) ); + } + else + { + if ( one_peak_flag_mask == 0 ) + { + X_i_new = realtoc( 0 ); + } + + X[binCounter] = cmul( realtoc( mag_chg_local ), X_i_new ); + } + + binCounter++; + + if ( binCounter >= gwlpr[subInd + 1] ) + { + subInd++; + } } - } - + e = plocs[i] + delta_corr_up; - if (e > lprotBy2Minus1) { + if ( e > lprotBy2Minus1 ) + { e = lprotBy2Minus1; } - + Xph = corr_phase[i]; - - segmentLen = e - (binCounter - 1); - for (i2 = 0; i2 < segmentLen; i2++) - { - seed_local = (LC3_FLOAT)own_rand((LC3_INT32)seed_local); - X_i = X[binCounter]; + segmentLen = e - ( binCounter - 1 ); + for ( i2 = 0; i2 < segmentLen; i2++ ) { - LC3_INT32 nrep =(LC3_INT32) LC3_FLOOR(Xph / (2.0f*(LC3_FLOAT)M_PI)); + seed_local = (LC3_FLOAT) own_rand( (LC3_INT32) seed_local ); + X_i = X[binCounter]; - X_i_new = cmul(X_i, cexpi(Xph - (2.0f*(LC3_FLOAT)M_PI*(LC3_FLOAT)nrep))); - } + { + LC3_INT32 nrep = (LC3_INT32) LC3_FLOOR( Xph / ( 2.0f * (LC3_FLOAT) M_PI ) ); + X_i_new = cmul( X_i, cexpi( Xph - ( 2.0f * (LC3_FLOAT) M_PI * (LC3_FLOAT) nrep ) ) ); + } - seed_local = (LC3_FLOAT)own_rand((LC3_INT32)seed_local); - mag_chg_local = mag_chg_gr[subInd]; - alpha_local = alpha[subInd]; - beta_local = beta[subInd]; - if (beta_local != 0) { + seed_local = (LC3_FLOAT) own_rand( (LC3_INT32) seed_local ); - assert(alpha_local == mag_chg_local); - tmp = beta_local * Xavg[subInd]; + mag_chg_local = mag_chg_gr[subInd]; + alpha_local = alpha[subInd]; + beta_local = beta[subInd]; + if ( beta_local != 0 ) + { - X[binCounter] = cadd(cmul(realtoc(alpha_local), X_i_new), cmul(realtoc(tmp), cexpi((LC3_FLOAT)M_PI*seed_local / (LC3_FLOAT)32768.0))); - } - else - { - X[binCounter] = cmul(realtoc(mag_chg_local), X_i_new); - } + assert( alpha_local == mag_chg_local ); + tmp = beta_local * Xavg[subInd]; - binCounter++; + X[binCounter] = cadd( cmul( realtoc( alpha_local ), X_i_new ), cmul( realtoc( tmp ), cexpi( (LC3_FLOAT) M_PI * seed_local / (LC3_FLOAT) 32768.0 ) ) ); + } + else + { + X[binCounter] = cmul( realtoc( mag_chg_local ), X_i_new ); + } - if (binCounter >= gwlpr[subInd + 1]) { - subInd++; + binCounter++; + + if ( binCounter >= gwlpr[subInd + 1] ) + { + subInd++; + } } - } - } - } + } + } - segmentLen = lprotBy2Minus1 - (binCounter - 1); + segmentLen = lprotBy2Minus1 - ( binCounter - 1 ); + + for ( i = 0; i < segmentLen; i++ ) + { + seed_local = (LC3_FLOAT) rand_phase( (LC3_INT32) seed_local, &cos_F ); - for (i = 0; i < segmentLen; i++) { - seed_local = (LC3_FLOAT)rand_phase((LC3_INT32)seed_local, &cos_F); - X_i = X[binCounter]; - X_i_new = cmul(X_i, cexpi((LC3_FLOAT)M_PI*seed_local/(LC3_FLOAT)32768.0)); + X_i_new = cmul( X_i, cexpi( (LC3_FLOAT) M_PI * seed_local / (LC3_FLOAT) 32768.0 ) ); + + seed_local = (LC3_FLOAT) own_rand( (LC3_INT32) seed_local ); - seed_local = (LC3_FLOAT)own_rand((LC3_INT32)seed_local); - - if (noise_mag_scale != 0) { - X_i = valley_magnitude_adj(X_i_new, (LC3_INT32)seed_local, cos_F); + if ( noise_mag_scale != 0 ) + { + X_i = valley_magnitude_adj( X_i_new, (LC3_INT32) seed_local, cos_F ); X_i_new = X_i; } - - if (one_peak_flag_mask == 0) { - X_i_new = realtoc(0); + + if ( one_peak_flag_mask == 0 ) + { + X_i_new = realtoc( 0 ); } - + alpha_local = alpha[subInd]; mag_chg_local = mag_chg_gr[subInd]; - - if (beta[subInd] != 0) { - assert(alpha_local == mag_chg_local); - tmp = beta[subInd]*Xavg[subInd]; - - if (one_peak_flag_mask == 0) { + + if ( beta[subInd] != 0 ) + { + assert( alpha_local == mag_chg_local ); + tmp = beta[subInd] * Xavg[subInd]; + + if ( one_peak_flag_mask == 0 ) + { tmp = 0; } - - X[binCounter] = cadd(cmul(realtoc(alpha_local), X_i_new), cmul(realtoc(tmp), cexpi((LC3_FLOAT)M_PI*seed_local/(LC3_FLOAT)32768.0))); - } - else - { - X[binCounter] = cmul(realtoc(mag_chg_local), X_i_new); + + X[binCounter] = cadd( cmul( realtoc( alpha_local ), X_i_new ), cmul( realtoc( tmp ), cexpi( (LC3_FLOAT) M_PI * seed_local / (LC3_FLOAT) 32768.0 ) ) ); + } + else + { + X[binCounter] = cmul( realtoc( mag_chg_local ), X_i_new ); } - + binCounter++; - - if (binCounter >= gwlpr[subInd + 1]) { + + if ( binCounter >= gwlpr[subInd + 1] ) + { subInd++; } } - - *seed = (LC3_INT32)seed_local; + + *seed = (LC3_INT32) seed_local; } -static LC3_INT32 own_rand(LC3_INT32 seed) { - LC3_INT32 retSeed; - assert(seed <= 32767 && seed >= -32768); - retSeed = (13849 + (seed + 32768) * 31821) & 65535; - retSeed -= 32768; - assert(retSeed <= 32767 && retSeed >= -32768); +static LC3_INT32 own_rand( LC3_INT32 seed ) +{ + LC3_INT32 retSeed; + assert( seed <= 32767 && seed >= -32768 ); + retSeed = ( 13849 + ( seed + 32768 ) * 31821 ) & 65535; + retSeed -= 32768; + assert( retSeed <= 32767 && retSeed >= -32768 ); return retSeed; } -static Complex valley_magnitude_adj(Complex X_i_in, LC3_INT32 uni_seed, LC3_FLOAT cos_F) { - LC3_FLOAT scale = ((LC3_FLOAT)0.5*(LC3_FLOAT)uni_seed/(LC3_FLOAT)32768.0) + (LC3_FLOAT)0.5*cos_F; - scale = (LC3_FLOAT)1.0 + (LC3_FLOAT)0.25*scale; - - assert(scale <= (LC3_FLOAT)1.25); - assert(scale >= (LC3_FLOAT)0.75); - - return cmul(X_i_in, realtoc(scale)); +static Complex valley_magnitude_adj( Complex X_i_in, LC3_INT32 uni_seed, LC3_FLOAT cos_F ) +{ + LC3_FLOAT scale = ( (LC3_FLOAT) 0.5 * (LC3_FLOAT) uni_seed / (LC3_FLOAT) 32768.0 ) + (LC3_FLOAT) 0.5 * cos_F; + scale = (LC3_FLOAT) 1.0 + (LC3_FLOAT) 0.25 * scale; + + assert( scale <= (LC3_FLOAT) 1.25 ); + assert( scale >= (LC3_FLOAT) 0.75 ); + + return cmul( X_i_in, realtoc( scale ) ); } -static LC3_INT32 rand_phase(LC3_INT32 seed_in, LC3_FLOAT* cos_F) { - LC3_FLOAT seed = (LC3_FLOAT)own_rand(seed_in); - *cos_F = LC3_COS((LC3_FLOAT)M_PI*seed/(LC3_FLOAT)32768.0); +static LC3_INT32 rand_phase( LC3_INT32 seed_in, LC3_FLOAT *cos_F ) +{ + LC3_FLOAT seed = (LC3_FLOAT) own_rand( seed_in ); + *cos_F = LC3_COS( (LC3_FLOAT) M_PI * seed / (LC3_FLOAT) 32768.0 ); return (LC3_INT32) seed; } - diff --git a/lib_lc3plus/plc_phecu_tba_per_band_gain.c b/lib_lc3plus/plc_phecu_tba_per_band_gain.c index 9f585f28dd..fae3b227cf 100644 --- a/lib_lc3plus/plc_phecu_tba_per_band_gain.c +++ b/lib_lc3plus/plc_phecu_tba_per_band_gain.c @@ -1,11 +1,11 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ #include "options.h" @@ -13,32 +13,31 @@ #include "functions.h" -void plc_phEcu_tba_per_band_gain(LC3_INT32 n_grp, LC3_FLOAT *gr_pow_left, LC3_FLOAT *gr_pow_right, LC3_FLOAT *trans, LC3_FLOAT *grp_pow_change) +void plc_phEcu_tba_per_band_gain( LC3_INT32 n_grp, LC3_FLOAT *gr_pow_left, LC3_FLOAT *gr_pow_right, LC3_FLOAT *trans, LC3_FLOAT *grp_pow_change ) { LC3_INT32 i; /* per band gain */ - for (i = 0; i < n_grp; i++) { - if (gr_pow_left[i] > 0) + for ( i = 0; i < n_grp; i++ ) + { + if ( gr_pow_left[i] > 0 ) { trans[i] = gr_pow_right[i] / gr_pow_left[i]; } else { /* handle division by zero case */ - if (gr_pow_right[i] > 0) + if ( gr_pow_right[i] > 0 ) { - trans[i] = 10.0; /* positive/0 transient */ + trans[i] = 10.0; /* positive/0 transient */ } else { - trans[i] = 1.0; /* 0/0 no transient , no power change */ + trans[i] = 1.0; /* 0/0 no transient , no power change */ } } - grp_pow_change[i] = (LC3_FLOAT) 10.0 * LC3_LOGTEN(trans[i]); - + grp_pow_change[i] = (LC3_FLOAT) 10.0 * LC3_LOGTEN( trans[i] ); } return; } - diff --git a/lib_lc3plus/plc_phecu_tba_spect_Xavg.c b/lib_lc3plus/plc_phecu_tba_spect_Xavg.c index 600b9714e4..3527caa991 100644 --- a/lib_lc3plus/plc_phecu_tba_spect_Xavg.c +++ b/lib_lc3plus/plc_phecu_tba_spect_Xavg.c @@ -1,45 +1,43 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "defines.h" #include "functions.h" -void plc_phEcu_tba_spect_Xavg(LC3_INT32 fs_idx, LC3_INT32 n_grp, LC3_FLOAT *oold_spec_shape, - LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_spec_shape, - LC3_FLOAT *old_EwPtr, LC3_FLOAT *gr_pow_left, LC3_FLOAT *gr_pow_right, LC3_FLOAT *Xavg) +void plc_phEcu_tba_spect_Xavg( LC3_INT32 fs_idx, LC3_INT32 n_grp, LC3_FLOAT *oold_spec_shape, LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_spec_shape, LC3_FLOAT *old_EwPtr, LC3_FLOAT *gr_pow_left, LC3_FLOAT *gr_pow_right, LC3_FLOAT *Xavg ) { - LC3_INT32 i; - LC3_FLOAT XavgEn[MAX_LGW]; - LC3_FLOAT xfp_w_scale, oold_Escale, old_Escale; + LC3_INT32 i; + LC3_FLOAT XavgEn[MAX_LGW]; + LC3_FLOAT xfp_w_scale, oold_Escale, old_Escale; /* 8k 16k 24k 32k 48k */ LC3_FLOAT flt_xfp_wE_MDCT2FFT_target[5] = { (LC3_FLOAT) 1.9906, (LC3_FLOAT) 4.0445, (LC3_FLOAT) 6.0980, (LC3_FLOAT) 8.1533, (LC3_FLOAT) 12.2603 }; - LC3_INT32 gw_0[10] = { 1, 3, 5, 9, 17, 33, 49, 65, 81, 97 }; - + LC3_INT32 gw_0[10] = { 1, 3, 5, 9, 17, 33, 49, 65, 81, 97 }; + /* prepare scale factor */ - xfp_w_scale = LC3_ROUND(flt_xfp_wE_MDCT2FFT_target[fs_idx]/(LC3_FLOAT)16.0*(LC3_FLOAT) 32768.0) / (LC3_FLOAT) LC3_POW(2,11); + xfp_w_scale = LC3_ROUND( flt_xfp_wE_MDCT2FFT_target[fs_idx] / (LC3_FLOAT) 16.0 * (LC3_FLOAT) 32768.0 ) / (LC3_FLOAT) LC3_POW( 2, 11 ); /* prepare left and right subband energies */ - oold_Escale = (*oold_EwPtr) * xfp_w_scale; - old_Escale = (*old_EwPtr) * xfp_w_scale; - for (i = 0;i < n_grp;i++) { + oold_Escale = ( *oold_EwPtr ) * xfp_w_scale; + old_Escale = ( *old_EwPtr ) * xfp_w_scale; + for ( i = 0; i < n_grp; i++ ) + { gr_pow_left[i] = oold_spec_shape[i] * oold_Escale; gr_pow_right[i] = old_spec_shape[i] * old_Escale; - XavgEn[i] = ((LC3_FLOAT) 0.5) * (gr_pow_left[i] + gr_pow_right[i]) / (gw_0[i + 1] - gw_0[i]); - Xavg[i] = LC3_SQRT(XavgEn[i]); + XavgEn[i] = ( (LC3_FLOAT) 0.5 ) * ( gr_pow_left[i] + gr_pow_right[i] ) / ( gw_0[i + 1] - gw_0[i] ); + Xavg[i] = LC3_SQRT( XavgEn[i] ); } return; } - diff --git a/lib_lc3plus/plc_phecu_tba_trans_dect_gains.c b/lib_lc3plus/plc_phecu_tba_trans_dect_gains.c index e5f0d3caae..d0f8d75935 100644 --- a/lib_lc3plus/plc_phecu_tba_trans_dect_gains.c +++ b/lib_lc3plus/plc_phecu_tba_trans_dect_gains.c @@ -1,24 +1,23 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "defines.h" #include "functions.h" -#define BETA_MUTE_FAC 0.5 /* % attenuation factor per additional bad frame, FX uses 0.5 (shift right with 1 bit) */ +#define BETA_MUTE_FAC 0.5 /* % attenuation factor per additional bad frame, FX uses 0.5 (shift right with 1 bit) */ #define BETA_MUTE_FAC_INI 0.5 -#define OFF_FRAMES_LIMIT 30 /* 300 ms for LC3 10 ms */ - +#define OFF_FRAMES_LIMIT 30 /* 300 ms for LC3 10 ms */ #define LGW32k 7 @@ -29,120 +28,127 @@ /* Tables are in Q15 */ /* 0.3 dB attenuation per frame for 16 frames, then 6 dB attenuation per frame */ const LC3_INT32 POW_ATT_TABLE1[OFF_FRAMES_LIMIT + 1] = { 32767, 31656, 30581, 29543, 28540, 27571, 26635, 25731, 24857, 24013, - 23198, 22410, 21650, 20915, 20205, 19519, 9759, 4880, 2440, 1220, - 610, 305, 152, 76, 38, 19, 10, 5, 2, 1, - 0 }; + 23198, 22410, 21650, 20915, 20205, 19519, 9759, 4880, 2440, 1220, + 610, 305, 152, 76, 38, 19, 10, 5, 2, 1, + 0 }; /* % 0.4 dB attenuation per frame for 16 frames, then 6 dB attenuation per frame */ const LC3_INT32 POW_ATT_TABLE0[OFF_FRAMES_LIMIT + 1] = { 32767, 31293, 29885, 28540, 27255, 26029, 24857, 23738, 22670, 21650, - 20675, 19745, 18856, 18007, 17197, 16423, 8211, 4106, 2053, 1026, - 513, 257, 128, 64, 32, 16, 8, 4, 2, 1, - 0 }; + 20675, 19745, 18856, 18007, 17197, 16423, 8211, 4106, 2053, 1026, + 513, 257, 128, 64, 32, 16, 8, 4, 2, 1, + 0 }; -#ifdef PLC2_FADEOUT_IN_MS +#ifdef PLC2_FADEOUT_IN_MS #if PLC2_FADEOUT_IN_MS == 0 /* default setting only requieres two tables */ -const Word16* const POW_ATT_TABLES[1 + 2] = -{ NULL, POW_ATT_TABLE1/*1 0.3dB steps */ , POW_ATT_TABLE0/*2 0.4 dB steps*/, +const Word16 *const POW_ATT_TABLES[1 + 2] = { + NULL, + POW_ATT_TABLE1 /*1 0.3dB steps */, + POW_ATT_TABLE0 /*2 0.4 dB steps*/, }; -#else +#else const LC3_INT32 POW_ATT_TABLE_p3x8_6[] = { - 32767, 31656, 30581, 29543, 28540, 27571, 26635, 25731, 12865, 6433, - 3216, 1608, 804, 402, 201, 101, 50, 25, 13, 6, - 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0 }; -const LC3_INT32 POW_ATT_TABLE_p4x8_6[OFF_FRAMES_LIMIT + 1] = { - 32767, 31293, 29885, 28540, 27255, 26029, 24857, 23738, 11869, 5935, - 2967, 1484, 742, 371, 185, 93, 46, 23, 12, 6, - 3, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 }; - -const LC3_INT32 POW_ATT_TABLE_p3x4_6[OFF_FRAMES_LIMIT + 1] = { - 32767, 31656, 30581, 29543, 14772, 7386, 3693, 1847, 923, 462, - 231, 115, 58, 29, 14, 7, 4, 2, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -const LC3_INT32 POW_ATT_TABLE_p4x4_6[OFF_FRAMES_LIMIT + 1] = { - 32767, 31293, 29885, 28540, 14270, 7135, 3568, 1784, 892, 446, - 223, 111, 56, 28, 14, 7, 3, 2, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - -const LC3_INT32 POW_ATT_TABLE_p3x2_6[OFF_FRAMES_LIMIT + 1] = { - 32767, 31656, 15828, 7914, 3957, 1979, 989, 495, 247, 124, - 62, 31, 15, 8, 4, 2, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -const LC3_INT32 POW_ATT_TABLE_p4x2_6[OFF_FRAMES_LIMIT + 1] = { - 32767, 31293, 15647, 7823, 3912, 1956, 978, 489, 244, 122, - 61, 31, 15, 8, 4, 2, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - -const LC3_INT32 POW_ATT_TABLE_p3x1_6[OFF_FRAMES_LIMIT + 1] = { - 32767, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, - 32, 16, 8, 4, 2, 1, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -const LC3_INT32 POW_ATT_TABLE_p4x1_6[OFF_FRAMES_LIMIT + 1] = { - 32767, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, - 32, 16, 8, 4, 2, 1, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - - -const LC3_INT32* const POW_ATT_TABLES[1 + 10] = -{ NULL, - POW_ATT_TABLE1 , POW_ATT_TABLE0, /* .3dB x16,16 6dB steps */ /* .4dB x16, 16 6dB steps */ /*original/default */ - POW_ATT_TABLE_p3x8_6, POW_ATT_TABLE_p4x8_6, /* .3dB x8, 24 6dB steps */ /* .4dB x8, 24 6dB steps */ - POW_ATT_TABLE_p3x4_6, POW_ATT_TABLE_p4x4_6, /* .3dB x4, 28 6dB steps */ /* .4dB x4, 28 6dB steps */ - POW_ATT_TABLE_p3x2_6, POW_ATT_TABLE_p4x2_6, /* .3dB x2, 30 6dB steps */ /* .4dB x2, 30 6dB steps */ - POW_ATT_TABLE_p3x1_6, POW_ATT_TABLE_p4x1_6 /* .3dB x1, 30 6dB steps */ /* .4dB x1, 30 6dB steps */ + 32767, 31656, 30581, 29543, 28540, 27571, 26635, 25731, 12865, 6433, + 3216, 1608, 804, 402, 201, 101, 50, 25, 13, 6, + 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0 +}; +const LC3_INT32 POW_ATT_TABLE_p4x8_6[OFF_FRAMES_LIMIT + 1] = { + 32767, 31293, 29885, 28540, 27255, 26029, 24857, 23738, 11869, 5935, + 2967, 1484, 742, 371, 185, 93, 46, 23, 12, 6, + 3, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +const LC3_INT32 POW_ATT_TABLE_p3x4_6[OFF_FRAMES_LIMIT + 1] = { + 32767, 31656, 30581, 29543, 14772, 7386, 3693, 1847, 923, 462, + 231, 115, 58, 29, 14, 7, 4, 2, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; +const LC3_INT32 POW_ATT_TABLE_p4x4_6[OFF_FRAMES_LIMIT + 1] = { + 32767, 31293, 29885, 28540, 14270, 7135, 3568, 1784, 892, 446, + 223, 111, 56, 28, 14, 7, 3, 2, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +const LC3_INT32 POW_ATT_TABLE_p3x2_6[OFF_FRAMES_LIMIT + 1] = { + 32767, 31656, 15828, 7914, 3957, 1979, 989, 495, 247, 124, + 62, 31, 15, 8, 4, 2, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; +const LC3_INT32 POW_ATT_TABLE_p4x2_6[OFF_FRAMES_LIMIT + 1] = { + 32767, 31293, 15647, 7823, 3912, 1956, 978, 489, 244, 122, + 61, 31, 15, 8, 4, 2, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +const LC3_INT32 POW_ATT_TABLE_p3x1_6[OFF_FRAMES_LIMIT + 1] = { + 32767, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, + 32, 16, 8, 4, 2, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; +const LC3_INT32 POW_ATT_TABLE_p4x1_6[OFF_FRAMES_LIMIT + 1] = { + 32767, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, + 32, 16, 8, 4, 2, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + + +const LC3_INT32 *const POW_ATT_TABLES[1 + 10] = { + NULL, + POW_ATT_TABLE1, POW_ATT_TABLE0, /* .3dB x16,16 6dB steps */ /* .4dB x16, 16 6dB steps */ /*original/default */ + POW_ATT_TABLE_p3x8_6, POW_ATT_TABLE_p4x8_6, /* .3dB x8, 24 6dB steps */ /* .4dB x8, 24 6dB steps */ + POW_ATT_TABLE_p3x4_6, POW_ATT_TABLE_p4x4_6, /* .3dB x4, 28 6dB steps */ /* .4dB x4, 28 6dB steps */ + POW_ATT_TABLE_p3x2_6, POW_ATT_TABLE_p4x2_6, /* .3dB x2, 30 6dB steps */ /* .4dB x2, 30 6dB steps */ + POW_ATT_TABLE_p3x1_6, POW_ATT_TABLE_p4x1_6 /* .3dB x1, 30 6dB steps */ /* .4dB x1, 30 6dB steps */ }; #endif #endif -void plc_phEcu_tba_trans_dect_gains(LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FLOAT *grp_pow_change, - LC3_FLOAT *stPhECU_beta_mute, LC3_FLOAT *stPhECU_mag_chg_1st, - LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *mag_chg, LC3_FLOAT *ph_dith, LC3_INT32 *tr_dec, - LC3_FLOAT *att_val, LC3_INT32 *attDegreeFrames_dbg, LC3_FLOAT *thresh_dbg) +void plc_phEcu_tba_trans_dect_gains( LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FLOAT *grp_pow_change, LC3_FLOAT *stPhECU_beta_mute, LC3_FLOAT *stPhECU_mag_chg_1st, LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *mag_chg, LC3_FLOAT *ph_dith, LC3_INT32 *tr_dec, LC3_FLOAT *att_val, LC3_INT32 *attDegreeFrames_dbg, LC3_FLOAT *thresh_dbg ) { LC3_INT32 i; - LC3_FLOAT thresh_tr_dB, max_increase_grp_pow; + LC3_FLOAT thresh_tr_dB, max_increase_grp_pow; LC3_FLOAT max_increase_grp_pow_lin; LC3_FLOAT grp_pow_change_lin[MAX_LGW]; LC3_FLOAT XavgFadeinFactor; LC3_INT32 burst_att_thresh; LC3_INT32 att_per_frame_idx; - LC3_INT32 att_always, attDegreeFrames; + LC3_INT32 att_always, attDegreeFrames; LC3_INT32 FADEOUT_IN_MS, PLC_P800_SPEECH_FADEOUT_IN_FRAMES, PLC2_FADEOUT_IN_FRAMES, BURST_ATT_THRESH_PRE; const LC3_INT32 *TABLEQ15; - LC3_INT32 BURST_ATT_THRESH; /* start attenuate with losses in a row, also starts FADE2AVG actions */ - LC3_INT32 ATT_PER_FRAME; /* initial msuic attenuation table ptr, actually implemented in table lookup! */ - LC3_INT32 BETA_MUTE_THR; /* time threshold in 10 ms frames to start beta - noise attenuation */ - - UNUSED(attDegreeFrames_dbg); + LC3_INT32 BURST_ATT_THRESH; /* start attenuate with losses in a row, also starts FADE2AVG actions */ + LC3_INT32 ATT_PER_FRAME; /* initial msuic attenuation table ptr, actually implemented in table lookup! */ + LC3_INT32 BETA_MUTE_THR; /* time threshold in 10 ms frames to start beta - noise attenuation */ + + UNUSED( attDegreeFrames_dbg ); /* constants setup */ - att_always = 0; + att_always = 0; XavgFadeinFactor = -1.0; - if (PLC2_FADEOUT_IN_MS != 0) + if ( PLC2_FADEOUT_IN_MS != 0 ) { - if (PLC2_FADEOUT_IN_MS < 0) + if ( PLC2_FADEOUT_IN_MS < 0 ) { - FADEOUT_IN_MS = PLC_FADEOUT_IN_MS; /* % use TDC - SETTING as input */ + FADEOUT_IN_MS = PLC_FADEOUT_IN_MS; /* % use TDC - SETTING as input */ } else { FADEOUT_IN_MS = PLC2_FADEOUT_IN_MS; /* % use a PLC2 individual settinsg */ } - PLC_P800_SPEECH_FADEOUT_IN_FRAMES = (LC3_INT32) LC3_FLOOR((LC3_FLOAT)FADEOUT_IN_MS / (LC3_FLOAT)10.0); /* % nominal svaleu for speech */ + PLC_P800_SPEECH_FADEOUT_IN_FRAMES = (LC3_INT32) LC3_FLOOR( (LC3_FLOAT) FADEOUT_IN_MS / (LC3_FLOAT) 10.0 ); /* % nominal svaleu for speech */ - PLC2_FADEOUT_IN_FRAMES = MIN(OFF_FRAMES_LIMIT, MAX(6, 3 * PLC_P800_SPEECH_FADEOUT_IN_FRAMES)); /* for PLC2 we typically maintain energy 3x longer */ + PLC2_FADEOUT_IN_FRAMES = MIN( OFF_FRAMES_LIMIT, MAX( 6, 3 * PLC_P800_SPEECH_FADEOUT_IN_FRAMES ) ); /* for PLC2 we typically maintain energy 3x longer */ - BURST_ATT_THRESH_PRE = MIN(5, MAX(1, (1 * PLC2_FADEOUT_IN_FRAMES) / 6)); /* nominal 20-40 ms to start actual muting, will be thresh +1 fot assumed music */ + BURST_ATT_THRESH_PRE = MIN( 5, MAX( 1, ( 1 * PLC2_FADEOUT_IN_FRAMES ) / 6 ) ); /* nominal 20-40 ms to start actual muting, will be thresh +1 fot assumed music */ - ATT_PER_FRAME = MIN(10, MAX(2, 2 * (6 - BURST_ATT_THRESH_PRE))); /* % we let the BURST_ATT_thresh control the initial table selection */ - BURST_ATT_THRESH = MIN(BURST_ATT_THRESH_PRE, 4); - BETA_MUTE_THR = MIN(4 + (OFF_FRAMES_LIMIT / 2) + 1, MAX(4, BURST_ATT_THRESH + 1 + (LC3_INT32)LC3_POW((LC3_FLOAT)2.0,BURST_ATT_THRESH_PRE - (LC3_FLOAT)1))); /* nominal time to start mandatory decrease of Xavg */ + ATT_PER_FRAME = MIN( 10, MAX( 2, 2 * ( 6 - BURST_ATT_THRESH_PRE ) ) ); /* % we let the BURST_ATT_thresh control the initial table selection */ + BURST_ATT_THRESH = MIN( BURST_ATT_THRESH_PRE, 4 ); + BETA_MUTE_THR = MIN( 4 + ( OFF_FRAMES_LIMIT / 2 ) + 1, MAX( 4, BURST_ATT_THRESH + 1 + (LC3_INT32) LC3_POW( (LC3_FLOAT) 2.0, BURST_ATT_THRESH_PRE - (LC3_FLOAT) 1 ) ) ); /* nominal time to start mandatory decrease of Xavg */ } @@ -152,19 +158,19 @@ void plc_phEcu_tba_trans_dect_gains(LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FL /* 10ms constants */ - thresh_tr_dB = 10.0; /* dB threshold kept same as for 20ms, even though transient analysis frame size was shortened */ - max_increase_grp_pow = 0; /* maximum amplification(dB) in case of onset transients, offset always deacy */ + thresh_tr_dB = 10.0; /* dB threshold kept same as for 20ms, even though transient analysis frame size was shortened */ + max_increase_grp_pow = 0; /* maximum amplification(dB) in case of onset transients, offset always deacy */ - max_increase_grp_pow_lin = (LC3_FLOAT)1.0*LC3_POW((LC3_FLOAT)10.0, max_increase_grp_pow / (LC3_FLOAT)10.0)*(LC3_FLOAT)(32767.0 / 32768.0); + max_increase_grp_pow_lin = (LC3_FLOAT) 1.0 * LC3_POW( (LC3_FLOAT) 10.0, max_increase_grp_pow / (LC3_FLOAT) 10.0 ) * (LC3_FLOAT) ( 32767.0 / 32768.0 ); /* envelope setting */ burst_att_thresh = BURST_ATT_THRESH + 1; att_per_frame_idx = ATT_PER_FRAME - 1; - + attDegreeFrames = 0; - if (burst_len > burst_att_thresh) + if ( burst_len > burst_att_thresh ) { att_always = 1; @@ -172,91 +178,92 @@ void plc_phEcu_tba_trans_dect_gains(LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FL /* Limit attDegreeFrames to OFF_FRAMES_LIMIT */ attDegreeFrames = burst_len - burst_att_thresh; - if (attDegreeFrames > OFF_FRAMES_LIMIT) + if ( attDegreeFrames > OFF_FRAMES_LIMIT ) { attDegreeFrames = OFF_FRAMES_LIMIT; } } - set_vec(1.0 * (32767.0/32768.0), mag_chg, n_grp); - set_vec(0.0, ph_dith, n_grp); + set_vec( 1.0 * ( 32767.0 / 32768.0 ), mag_chg, n_grp ); + set_vec( 0.0, ph_dith, n_grp ); - set_vec(1.0 * (32767.0/32768.0), alpha, n_grp); - set_vec(0.0, beta, n_grp); - set_vec_int(0, tr_dec, n_grp); + set_vec( 1.0 * ( 32767.0 / 32768.0 ), alpha, n_grp ); + set_vec( 0.0, beta, n_grp ); + set_vec_int( 0, tr_dec, n_grp ); - set_vec(1.0 * (32767.0/32768.0), att_val, n_grp); + set_vec( 1.0 * ( 32767.0 / 32768.0 ), att_val, n_grp ); - /* transient detection per band */ - for (i = 0;i < n_grp; i++) { - if(burst_len == 1) + for ( i = 0; i < n_grp; i++ ) + { + if ( burst_len == 1 ) { /* first bad frame */ - grp_pow_change_lin[i] = LC3_POW((LC3_FLOAT)10.0, grp_pow_change[i]/(LC3_FLOAT)10.0); + grp_pow_change_lin[i] = LC3_POW( (LC3_FLOAT) 10.0, grp_pow_change[i] / (LC3_FLOAT) 10.0 ); *stPhECU_beta_mute = BETA_MUTE_FAC_INI; - *stPhECU_beta_mute = *stPhECU_beta_mute / (LC3_FLOAT)2.0; - + *stPhECU_beta_mute = *stPhECU_beta_mute / (LC3_FLOAT) 2.0; + /* transient processing */ /* transients may be both rise and decay transients !! */ - if(LC3_FABS(grp_pow_change[i]) >= thresh_tr_dB) + if ( LC3_FABS( grp_pow_change[i] ) >= thresh_tr_dB ) { - + tr_dec[i] = 1; } /* magnitude modification */ att_val[i] = 0.0f; - if(tr_dec[i] || att_always) { + if ( tr_dec[i] || att_always ) + { - att_val[i] = MIN(max_increase_grp_pow_lin, grp_pow_change_lin[i]); /* % linear values !! */ - att_val[i] = LC3_SQRT(att_val[i]); + att_val[i] = MIN( max_increase_grp_pow_lin, grp_pow_change_lin[i] ); /* % linear values !! */ + att_val[i] = LC3_SQRT( att_val[i] ); mag_chg[i] = att_val[i]; stPhECU_mag_chg_1st[i] = att_val[i]; } else { - mag_chg[i] = 1.0 * (LC3_FLOAT)(32767.0/32768.0); - stPhECU_mag_chg_1st[i] = (LC3_FLOAT)1.0; + mag_chg[i] = 1.0 * (LC3_FLOAT) ( 32767.0 / 32768.0 ); + stPhECU_mag_chg_1st[i] = (LC3_FLOAT) 1.0; } } else { /* burst handling based on states */ - assert(burst_len >= 2); /* states used here */ + assert( burst_len >= 2 ); /* states used here */ tr_dec[i] = 0; - if (PLC_FADEOUT_IN_MS > 0) + if ( PLC_FADEOUT_IN_MS > 0 ) { - assert(att_per_frame_idx >= 1 && att_per_frame_idx <= 10); - TABLEQ15 = POW_ATT_TABLES[att_per_frame_idx]; - att_val[i] = (LC3_FLOAT)1.0 * ( (LC3_FLOAT) TABLEQ15[MIN(OFF_FRAMES_LIMIT, attDegreeFrames )] / (LC3_FLOAT)32768.0); /* Table idx 0...N-1 therefore no + 1 */ + assert( att_per_frame_idx >= 1 && att_per_frame_idx <= 10 ); + TABLEQ15 = POW_ATT_TABLES[att_per_frame_idx]; + att_val[i] = (LC3_FLOAT) 1.0 * ( (LC3_FLOAT) TABLEQ15[MIN( OFF_FRAMES_LIMIT, attDegreeFrames )] / (LC3_FLOAT) 32768.0 ); /* Table idx 0...N-1 therefore no + 1 */ att_val[i] = att_val[i]; } else { - if (att_per_frame_idx == ATT_PER_FRAME) + if ( att_per_frame_idx == ATT_PER_FRAME ) { - att_val[i] = (LC3_FLOAT)1.0 * ( (LC3_FLOAT)POW_ATT_TABLE0[MIN(OFF_FRAMES_LIMIT, attDegreeFrames)] / (LC3_FLOAT)32768.0); + att_val[i] = (LC3_FLOAT) 1.0 * ( (LC3_FLOAT) POW_ATT_TABLE0[MIN( OFF_FRAMES_LIMIT, attDegreeFrames )] / (LC3_FLOAT) 32768.0 ); } else { - att_val[i] = (LC3_FLOAT)1.0 * ( (LC3_FLOAT)POW_ATT_TABLE1[MIN(OFF_FRAMES_LIMIT, attDegreeFrames)] / (LC3_FLOAT)32768.0); + att_val[i] = (LC3_FLOAT) 1.0 * ( (LC3_FLOAT) POW_ATT_TABLE1[MIN( OFF_FRAMES_LIMIT, attDegreeFrames )] / (LC3_FLOAT) 32768.0 ); } } - - - if ( (att_val[i] != 0) && (att_val[i] * (LC3_FLOAT)32768.0 < (LC3_FLOAT)0.5) ) + + + if ( ( att_val[i] != 0 ) && ( att_val[i] * (LC3_FLOAT) 32768.0 < (LC3_FLOAT) 0.5 ) ) { - att_val[i] = 0.0; /* for SNR measurments match in float lowest possible level to BASOP representation */ + att_val[i] = 0.0; /* for SNR measurments match in float lowest possible level to BASOP representation */ } /* Apply attenuation */ @@ -264,57 +271,55 @@ void plc_phEcu_tba_trans_dect_gains(LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FL mag_chg[i] = mag_chg[i] * att_val[i]; /* add additional attenuation from burst attenation logic */ - if ((mag_chg[i] != 0) && (mag_chg[i] * (LC3_FLOAT)32768.0 < (LC3_FLOAT)0.5)) + if ( ( mag_chg[i] != 0 ) && ( mag_chg[i] * (LC3_FLOAT) 32768.0 < (LC3_FLOAT) 0.5 ) ) { - mag_chg[i] = 0; /* for SNR measurments match in float lowest possible level to BASOP representation */ + mag_chg[i] = 0; /* for SNR measurments match in float lowest possible level to BASOP representation */ } - - if(burst_len > BETA_MUTE_THR) + if ( burst_len > BETA_MUTE_THR ) { - *stPhECU_beta_mute = *stPhECU_beta_mute * (LC3_FLOAT)BETA_MUTE_FAC; + *stPhECU_beta_mute = *stPhECU_beta_mute * (LC3_FLOAT) BETA_MUTE_FAC; } alpha[i] = mag_chg[i]; - if (alpha[i] >= (LC3_FLOAT)(32766.0 / 32768.0)) + if ( alpha[i] >= (LC3_FLOAT) ( 32766.0 / 32768.0 ) ) { - beta[i] = 0; /* align to BASOP more efficent use of beta */ + beta[i] = 0; /* align to BASOP more efficent use of beta */ } else { - beta[i] = LC3_SQRT((LC3_FLOAT)1.0 - alpha[i]* alpha[i]) * *stPhECU_beta_mute; + beta[i] = LC3_SQRT( (LC3_FLOAT) 1.0 - alpha[i] * alpha[i] ) * *stPhECU_beta_mute; } - if ( i >= LGW32k-1) { - beta[i] = beta[i] * (LC3_FLOAT)0.1; + if ( i >= LGW32k - 1 ) + { + beta[i] = beta[i] * (LC3_FLOAT) 0.1; } - else if( i >= LGW16k-1) + else if ( i >= LGW16k - 1 ) { - beta[i] = beta[i] * (LC3_FLOAT)0.5; + beta[i] = beta[i] * (LC3_FLOAT) 0.5; } /* limit Xavg noise contribution further in case of offset / tr_decay */ - if ((burst_len <= burst_att_thresh) && (stPhECU_mag_chg_1st[i] < (LC3_FLOAT)(32767.0 / 32768.0))) + if ( ( burst_len <= burst_att_thresh ) && ( stPhECU_mag_chg_1st[i] < (LC3_FLOAT) ( 32767.0 / 32768.0 ) ) ) { - XavgFadeinFactor = (LC3_FLOAT)(burst_len - (LC3_FLOAT)1.0) / burst_att_thresh; - - XavgFadeinFactor = MIN((LC3_FLOAT)1.0, XavgFadeinFactor); + XavgFadeinFactor = (LC3_FLOAT) ( burst_len - (LC3_FLOAT) 1.0 ) / burst_att_thresh; + + XavgFadeinFactor = MIN( (LC3_FLOAT) 1.0, XavgFadeinFactor ); - beta[i] = beta[i] * XavgFadeinFactor; - + beta[i] = beta[i] * XavgFadeinFactor; } } } - if (thresh_dbg != NULL) + if ( thresh_dbg != NULL ) { *thresh_dbg = XavgFadeinFactor; } - return; + return; } - diff --git a/lib_lc3plus/plc_phecu_trans_burst_ana_sub.c b/lib_lc3plus/plc_phecu_trans_burst_ana_sub.c index c860cd6ce3..a6adff0dc8 100644 --- a/lib_lc3plus/plc_phecu_trans_burst_ana_sub.c +++ b/lib_lc3plus/plc_phecu_trans_burst_ana_sub.c @@ -1,11 +1,11 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ #include "options.h" @@ -13,36 +13,31 @@ #include "functions.h" -void plc_phEcu_trans_burst_ana_sub(LC3_INT32 fs_idx, LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FLOAT *oold_spect_shape, - LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_spect_shape, - LC3_FLOAT *old_EwPtr, LC3_FLOAT *stPhECU_beta_mute, - LC3_FLOAT *stPhECU_mag_chg_1st, LC3_FLOAT *stPhECU_Xavg, LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *mag_chg, LC3_INT32 *tr_dec_dbg, LC3_FLOAT *gpc_dbg) +void plc_phEcu_trans_burst_ana_sub( LC3_INT32 fs_idx, LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FLOAT *oold_spect_shape, LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_spect_shape, LC3_FLOAT *old_EwPtr, LC3_FLOAT *stPhECU_beta_mute, LC3_FLOAT *stPhECU_mag_chg_1st, LC3_FLOAT *stPhECU_Xavg, LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *mag_chg, LC3_INT32 *tr_dec_dbg, LC3_FLOAT *gpc_dbg ) { - LC3_FLOAT gr_pow_left[MAX_LGW]; - LC3_FLOAT gr_pow_right[MAX_LGW]; - LC3_FLOAT trans[MAX_LGW]; - LC3_FLOAT grp_pow_change[MAX_LGW]; - LC3_FLOAT ph_dith[MAX_LGW]; - LC3_FLOAT att_val[MAX_LGW]; - LC3_INT32 tr_dec[MAX_LGW]; + LC3_FLOAT gr_pow_left[MAX_LGW]; + LC3_FLOAT gr_pow_right[MAX_LGW]; + LC3_FLOAT trans[MAX_LGW]; + LC3_FLOAT grp_pow_change[MAX_LGW]; + LC3_FLOAT ph_dith[MAX_LGW]; + LC3_FLOAT att_val[MAX_LGW]; + LC3_INT32 tr_dec[MAX_LGW]; - LC3_INT32 attDegreeFrames; - LC3_FLOAT thresh_dbg; + LC3_INT32 attDegreeFrames; + LC3_FLOAT thresh_dbg; - UNUSED(tr_dec_dbg); - UNUSED(gpc_dbg); + UNUSED( tr_dec_dbg ); + UNUSED( gpc_dbg ); - if (burst_len <= 1) + if ( burst_len <= 1 ) { - plc_phEcu_tba_spect_Xavg(fs_idx, n_grp, oold_spect_shape, oold_EwPtr, old_spect_shape, old_EwPtr, gr_pow_left, gr_pow_right, stPhECU_Xavg); - - plc_phEcu_tba_per_band_gain(n_grp, gr_pow_left, gr_pow_right, trans, grp_pow_change); + plc_phEcu_tba_spect_Xavg( fs_idx, n_grp, oold_spect_shape, oold_EwPtr, old_spect_shape, old_EwPtr, gr_pow_left, gr_pow_right, stPhECU_Xavg ); + plc_phEcu_tba_per_band_gain( n_grp, gr_pow_left, gr_pow_right, trans, grp_pow_change ); } - plc_phEcu_tba_trans_dect_gains(burst_len, n_grp, grp_pow_change, stPhECU_beta_mute, stPhECU_mag_chg_1st, alpha, beta, mag_chg, ph_dith, tr_dec, att_val, &attDegreeFrames, &thresh_dbg); + plc_phEcu_tba_trans_dect_gains( burst_len, n_grp, grp_pow_change, stPhECU_beta_mute, stPhECU_mag_chg_1st, alpha, beta, mag_chg, ph_dith, tr_dec, att_val, &attDegreeFrames, &thresh_dbg ); return; } - diff --git a/lib_lc3plus/plc_tdc.c b/lib_lc3plus/plc_tdc.c index 1a1a408f4d..ff7f84abbc 100644 --- a/lib_lc3plus/plc_tdc.c +++ b/lib_lc3plus/plc_tdc.c @@ -1,12 +1,12 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" /***************************************************************************\ @@ -17,461 +17,478 @@ #include "functions.h" -static LC3_INT16 TDC_random_short(LC3_INT16 *seed); -static LC3_FLOAT TDC_get_gainp(const LC3_FLOAT x[], const LC3_FLOAT y[], LC3_INT32 n); -static LC3_FLOAT TDC_get_gainc(const LC3_FLOAT x[], const LC3_FLOAT y[], const LC3_FLOAT *gain_p, const LC3_INT32 n, const LC3_INT32 frame_dms); -static void TDC_LPC_synthesis(const LC3_FLOAT a[], LC3_FLOAT x[], LC3_FLOAT y[], LC3_INT32 l, const LC3_FLOAT mem[], LC3_INT32 lpcorder, LC3_FLOAT *buf); -static void TDC_LPC_residu(const LC3_FLOAT *a, LC3_FLOAT *x, LC3_FLOAT *y, LC3_INT32 l, LC3_INT32 lpcorder); -static void TDC_highPassFiltering(const LC3_INT32 L_buffer, LC3_FLOAT exc2[], const LC3_FLOAT hp_filt[], const LC3_INT32 l_fir_fer); -static void TDC_f_preemph(LC3_FLOAT *signal, const LC3_FLOAT *mu, LC3_INT32 L, LC3_FLOAT *mem); -static void TDC_deemph(LC3_FLOAT *signal, const LC3_FLOAT *mu, LC3_INT32 L, const LC3_FLOAT *mem); -const LC3_FLOAT TDC_high_16[TDC_L_FIR_HP] = { 0.f, -0.0205f, -0.0651f, -0.1256f, -0.1792f, 0.8028f, -0.1792f, -0.1256f, -0.0651f, -0.0205f, 0.f }; -const LC3_FLOAT TDC_high_32[TDC_L_FIR_HP] = {-0.0517f, -0.0587f, -0.0820f, -0.1024f, -0.1164f, 0.8786f, -0.1164f, -0.1024f, -0.0820f, -0.0587f, -0.0517f}; -const LC3_FLOAT TDC_high_16_harm[TDC_L_FIR_HP] = { 0.0053f, 0.0000f, -0.0440f, 0.0000f, 0.2637f, 0.5500f, 0.2637f, 0.0000f, -0.0440f, 0.0000f, 0.0053f}; -const LC3_FLOAT TDC_high_32_harm[TDC_L_FIR_HP] = {-0.0053f, -0.0037f, -0.0140f, 0.0180f, 0.2668f, 0.4991f, 0.2668f, 0.0180f, -0.0140f, -0.0037f, -0.0053f}; -static void TDC_levinson(LC3_FLOAT *acf, LC3_INT32 len, LC3_FLOAT *out); -static void TDC_copyFLOAT(const LC3_FLOAT * X, LC3_FLOAT * Z, LC3_INT32 n); -static LC3_FLOAT TDC_dotFLOAT(const LC3_FLOAT * X, const LC3_FLOAT * Y, LC3_INT32 n); - -const LC3_INT32 beforeNextIncArray[4][4] = {{0,0,0,1}, - {0,1,0,1}, - {0,1,1,1}, - {1,1,1,1}}; -const LC3_INT32 nextIncArray[4][4] = {{1,0,0,0}, - {1,0,1,0}, - {1,0,1,1}, - {1,1,1,1}}; - -void processTdcApply_fl(const LC3_INT32 pitch_int, - const LC3_FLOAT *preemphFac, - const LC3_FLOAT* A, - const LC3_INT32 lpc_order, - const LC3_FLOAT* pcmbufHist, - const LC3_INT32 max_len_pcm_plc, - const LC3_INT32 N, - const LC3_INT32 frame_dms, - const LC3_INT32 SampRate, - const LC3_INT32 nbLostFramesInRow, - const LC3_INT32 overlap, - const LC3_FLOAT *stabFac, - LC3_FLOAT harmonicBuf[MAX_PITCH], - LC3_FLOAT synthHist[M], - LC3_INT32* fract, - LC3_INT16* seed, - LC3_FLOAT* gain_c, - LC3_FLOAT* alpha, - LC3_FLOAT* synth - ) -{ - LC3_FLOAT step, step_n; - LC3_INT32 i, len, Tc, nbLostCmpt_loc, nextInc, beforeNextInc; - LC3_FLOAT gain_h, tmp, gain_p; - LC3_FLOAT *exc2, *exc_buf, *exc, *x_pre, *buf, *pt_exc, *pt1_exc, *synthMemPtr; - LC3_FLOAT *harmonicBufPtr; - LC3_FLOAT synth_mem[M]; - const LC3_FLOAT *hp_filt, *high_harm; - LC3_FLOAT gainInov; - LC3_FLOAT hpBlendFac; - char *scratchSpace1st, *scratchSpaceTmp; - char scratchSpace[(MAX_LEN_PCM_PLC + MDCT_MEM_LEN_MAX + MAX_LEN_PCM_PLC + 1 + M) * sizeof(LC3_FLOAT)]; - LC3_FLOAT alphaPrev; - LC3_FLOAT throttle; - LC3_INT32 frame_dms_idx, nbLostFramesInRow_mod; - - memset(synth_mem, 0, M * sizeof(LC3_FLOAT)); - memset(scratchSpace, 0, (MAX_LEN_PCM_PLC + MDCT_MEM_LEN_MAX + MAX_LEN_PCM_PLC + 1 + M) * sizeof(LC3_FLOAT)); - - /* len of synthesized signal */ - len = N + overlap; - - nbLostCmpt_loc = floor(frame_dms/100.0 * (nbLostFramesInRow - 1) + 1); - frame_dms_idx = frame_dms / 25 - 1; /* 0,1,2,3 */ - nbLostFramesInRow_mod = (nbLostFramesInRow - 1) % 4; - - beforeNextInc = beforeNextIncArray[frame_dms_idx][nbLostFramesInRow_mod]; - nextInc = nextIncArray [frame_dms_idx][nbLostFramesInRow_mod]; - - if (nbLostCmpt_loc > PLC_FADEOUT_IN_MS/10) - { - gain_p = 0; - *gain_c = 0; - *alpha = 0; - memset(synth, 0, len * sizeof(LC3_FLOAT)); - return; - } - - Tc = pitch_int; - if (*fract > 0) { - Tc++; - } - - /*---------------------------------------------------------------- - * Buffer Initialization for timeDomainConcealment_Apply - * - * 1st - * |--exc_buf--|--x_pre--| - * | |--exc2--| - * | |--buf (LPC Syn)--| - * - *---------------------------------------------------------------*/ - - scratchSpace1st = scratchSpace; - exc_buf = (LC3_FLOAT*)scratchSpace1st; scratchSpace1st += (LC3_INT32)sizeof(LC3_FLOAT) * (Tc + N/2 + len); - exc = exc_buf + (Tc + N/2); - - scratchSpaceTmp = scratchSpace1st; - x_pre = (LC3_FLOAT*)scratchSpaceTmp; scratchSpaceTmp += (LC3_INT32)sizeof(LC3_FLOAT) * (lpc_order + Tc + N/2 + 1); - - /*---------------------------------------------------------------* - * LPC Residual * - *---------------------------------------------------------------*/ - if (nbLostFramesInRow == 1) - { - /* copy buffer to pre-emphasis buffer */ - TDC_copyFLOAT(&(pcmbufHist[max_len_pcm_plc-(lpc_order+Tc+N/2+1)]), &(x_pre[0]), lpc_order+Tc+N/2+1); - - /* apply pre-emphasis to the signal */ - TDC_f_preemph(&(x_pre[1]), preemphFac, lpc_order+Tc+N/2, &x_pre[0]); - - /* copy memory for LPC synth */ - TDC_copyFLOAT(&(x_pre[Tc+N/2+1]), synth_mem, lpc_order); - - /* LPC Residual */ - TDC_LPC_residu(A, &(x_pre[lpc_order+1]), &(exc[-(Tc+N/2)]), Tc+N/2, lpc_order); - } - - /*---------------------------------------------------------------* - * Calculate gains * - *---------------------------------------------------------------*/ - if (nbLostFramesInRow == 1) - { - if (pitch_int == Tc) - { - gain_p = TDC_get_gainp( &(x_pre[lpc_order+Tc+1]), &(x_pre[lpc_order+1]), N/2 ); +static LC3_INT16 TDC_random_short( LC3_INT16 *seed ); +static LC3_FLOAT TDC_get_gainp( const LC3_FLOAT x[], const LC3_FLOAT y[], LC3_INT32 n ); +static LC3_FLOAT TDC_get_gainc( const LC3_FLOAT x[], const LC3_FLOAT y[], const LC3_FLOAT *gain_p, const LC3_INT32 n, const LC3_INT32 frame_dms ); +static void TDC_LPC_synthesis( const LC3_FLOAT a[], LC3_FLOAT x[], LC3_FLOAT y[], LC3_INT32 l, const LC3_FLOAT mem[], LC3_INT32 lpcorder, LC3_FLOAT *buf ); +static void TDC_LPC_residu( const LC3_FLOAT *a, LC3_FLOAT *x, LC3_FLOAT *y, LC3_INT32 l, LC3_INT32 lpcorder ); +static void TDC_highPassFiltering( const LC3_INT32 L_buffer, LC3_FLOAT exc2[], const LC3_FLOAT hp_filt[], const LC3_INT32 l_fir_fer ); +static void TDC_f_preemph( LC3_FLOAT *signal, const LC3_FLOAT *mu, LC3_INT32 L, LC3_FLOAT *mem ); +static void TDC_deemph( LC3_FLOAT *signal, const LC3_FLOAT *mu, LC3_INT32 L, const LC3_FLOAT *mem ); +const LC3_FLOAT TDC_high_16[TDC_L_FIR_HP] = { 0.f, -0.0205f, -0.0651f, -0.1256f, -0.1792f, 0.8028f, -0.1792f, -0.1256f, -0.0651f, -0.0205f, 0.f }; +const LC3_FLOAT TDC_high_32[TDC_L_FIR_HP] = { -0.0517f, -0.0587f, -0.0820f, -0.1024f, -0.1164f, 0.8786f, -0.1164f, -0.1024f, -0.0820f, -0.0587f, -0.0517f }; +const LC3_FLOAT TDC_high_16_harm[TDC_L_FIR_HP] = { 0.0053f, 0.0000f, -0.0440f, 0.0000f, 0.2637f, 0.5500f, 0.2637f, 0.0000f, -0.0440f, 0.0000f, 0.0053f }; +const LC3_FLOAT TDC_high_32_harm[TDC_L_FIR_HP] = { -0.0053f, -0.0037f, -0.0140f, 0.0180f, 0.2668f, 0.4991f, 0.2668f, 0.0180f, -0.0140f, -0.0037f, -0.0053f }; +static void TDC_levinson( LC3_FLOAT *acf, LC3_INT32 len, LC3_FLOAT *out ); +static void TDC_copyFLOAT( const LC3_FLOAT *X, LC3_FLOAT *Z, LC3_INT32 n ); +static LC3_FLOAT TDC_dotFLOAT( const LC3_FLOAT *X, const LC3_FLOAT *Y, LC3_INT32 n ); + +const LC3_INT32 beforeNextIncArray[4][4] = { { 0, 0, 0, 1 }, + { 0, 1, 0, 1 }, + { 0, 1, 1, 1 }, + { 1, 1, 1, 1 } }; +const LC3_INT32 nextIncArray[4][4] = { { 1, 0, 0, 0 }, + { 1, 0, 1, 0 }, + { 1, 0, 1, 1 }, + { 1, 1, 1, 1 } }; + +void processTdcApply_fl( const LC3_INT32 pitch_int, + const LC3_FLOAT *preemphFac, + const LC3_FLOAT *A, + const LC3_INT32 lpc_order, + const LC3_FLOAT *pcmbufHist, + const LC3_INT32 max_len_pcm_plc, + const LC3_INT32 N, + const LC3_INT32 frame_dms, + const LC3_INT32 SampRate, + const LC3_INT32 nbLostFramesInRow, + const LC3_INT32 overlap, + const LC3_FLOAT *stabFac, + LC3_FLOAT harmonicBuf[MAX_PITCH], + LC3_FLOAT synthHist[M], + LC3_INT32 *fract, + LC3_INT16 *seed, + LC3_FLOAT *gain_c, + LC3_FLOAT *alpha, + LC3_FLOAT *synth ) +{ + LC3_FLOAT step, step_n; + LC3_INT32 i, len, Tc, nbLostCmpt_loc, nextInc, beforeNextInc; + LC3_FLOAT gain_h, tmp, gain_p; + LC3_FLOAT *exc2, *exc_buf, *exc, *x_pre, *buf, *pt_exc, *pt1_exc, *synthMemPtr; + LC3_FLOAT *harmonicBufPtr; + LC3_FLOAT synth_mem[M]; + const LC3_FLOAT *hp_filt, *high_harm; + LC3_FLOAT gainInov; + LC3_FLOAT hpBlendFac; + char *scratchSpace1st, *scratchSpaceTmp; + char scratchSpace[( MAX_LEN_PCM_PLC + MDCT_MEM_LEN_MAX + MAX_LEN_PCM_PLC + 1 + M ) * sizeof( LC3_FLOAT )]; + LC3_FLOAT alphaPrev; + LC3_FLOAT throttle; + LC3_INT32 frame_dms_idx, nbLostFramesInRow_mod; + + memset( synth_mem, 0, M * sizeof( LC3_FLOAT ) ); + memset( scratchSpace, 0, ( MAX_LEN_PCM_PLC + MDCT_MEM_LEN_MAX + MAX_LEN_PCM_PLC + 1 + M ) * sizeof( LC3_FLOAT ) ); + + /* len of synthesized signal */ + len = N + overlap; + + nbLostCmpt_loc = floor( frame_dms / 100.0 * ( nbLostFramesInRow - 1 ) + 1 ); + frame_dms_idx = frame_dms / 25 - 1; /* 0,1,2,3 */ + nbLostFramesInRow_mod = ( nbLostFramesInRow - 1 ) % 4; + + beforeNextInc = beforeNextIncArray[frame_dms_idx][nbLostFramesInRow_mod]; + nextInc = nextIncArray[frame_dms_idx][nbLostFramesInRow_mod]; + + if ( nbLostCmpt_loc > PLC_FADEOUT_IN_MS / 10 ) + { + gain_p = 0; + *gain_c = 0; + *alpha = 0; + memset( synth, 0, len * sizeof( LC3_FLOAT ) ); + return; + } + + Tc = pitch_int; + if ( *fract > 0 ) + { + Tc++; + } + + /*---------------------------------------------------------------- + * Buffer Initialization for timeDomainConcealment_Apply + * + * 1st + * |--exc_buf--|--x_pre--| + * | |--exc2--| + * | |--buf (LPC Syn)--| + * + *---------------------------------------------------------------*/ + + scratchSpace1st = scratchSpace; + exc_buf = (LC3_FLOAT *) scratchSpace1st; + scratchSpace1st += (LC3_INT32) sizeof( LC3_FLOAT ) * ( Tc + N / 2 + len ); + exc = exc_buf + ( Tc + N / 2 ); + + scratchSpaceTmp = scratchSpace1st; + x_pre = (LC3_FLOAT *) scratchSpaceTmp; + scratchSpaceTmp += (LC3_INT32) sizeof( LC3_FLOAT ) * ( lpc_order + Tc + N / 2 + 1 ); + + /*---------------------------------------------------------------* + * LPC Residual * + *---------------------------------------------------------------*/ + if ( nbLostFramesInRow == 1 ) + { + /* copy buffer to pre-emphasis buffer */ + TDC_copyFLOAT( &( pcmbufHist[max_len_pcm_plc - ( lpc_order + Tc + N / 2 + 1 )] ), &( x_pre[0] ), lpc_order + Tc + N / 2 + 1 ); + + /* apply pre-emphasis to the signal */ + TDC_f_preemph( &( x_pre[1] ), preemphFac, lpc_order + Tc + N / 2, &x_pre[0] ); + + /* copy memory for LPC synth */ + TDC_copyFLOAT( &( x_pre[Tc + N / 2 + 1] ), synth_mem, lpc_order ); + + /* LPC Residual */ + TDC_LPC_residu( A, &( x_pre[lpc_order + 1] ), &( exc[-( Tc + N / 2 )] ), Tc + N / 2, lpc_order ); + } + + /*---------------------------------------------------------------* + * Calculate gains * + *---------------------------------------------------------------*/ + if ( nbLostFramesInRow == 1 ) + { + if ( pitch_int == Tc ) + { + gain_p = TDC_get_gainp( &( x_pre[lpc_order + Tc + 1] ), &( x_pre[lpc_order + 1] ), N / 2 ); + } + else + { + tmp = TDC_get_gainp( &( x_pre[lpc_order + Tc + 1] ), &( x_pre[lpc_order + 2] ), N / 2 ); + gain_p = TDC_get_gainp( &( x_pre[lpc_order + Tc + 1] ), &( x_pre[lpc_order + 1] ), N / 2 ); + + if ( tmp > gain_p ) + { + Tc = pitch_int; + gain_p = tmp; + *fract = 0; + } + } + + if ( gain_p < 0.0f ) + { + gain_p = 0.0f; + } + + if ( gain_p > 1.0f ) + { + gain_p = 1.0f; + } + + *gain_c = 0.0f; + + if ( pitch_int == Tc ) + { + *gain_c = TDC_get_gainc( &( exc[-1] ), &( exc[-1 - Tc] ), &gain_p, N / 2, frame_dms ); + } + else + { + tmp = TDC_get_gainc( &( exc[-1] ), &( exc[-1 - pitch_int] ), &gain_p, N / 2, frame_dms ); + *gain_c = TDC_get_gainc( &( exc[-1] ), &( exc[-1 - Tc] ), &gain_p, N / 2, frame_dms ); + *gain_c = MIN( *gain_c, tmp ); + } } else { - tmp = TDC_get_gainp( &(x_pre[lpc_order+Tc+1]), &(x_pre[lpc_order+2]), N/2 ); - gain_p = TDC_get_gainp( &(x_pre[lpc_order+Tc+1]), &(x_pre[lpc_order+1]), N/2 ); + gain_p = *alpha; + } + + /*---------------------------------------------------------------* + * Damping factor * + *---------------------------------------------------------------*/ + + alphaPrev = 1; + if ( nbLostFramesInRow > 1 ) + { + alphaPrev = *alpha; + } + + if ( nextInc != 0 ) + { + switch ( nbLostCmpt_loc ) + { + case 1: + *alpha = (LC3_FLOAT) sqrt( gain_p ); + if ( *alpha > 0.98f ) + { + *alpha = 0.98f; + } + else if ( *alpha < 0.925f ) + { + *alpha = 0.925f; + } + break; + case 2: + *alpha = ( 0.63f + 0.35f * ( *stabFac ) ) * gain_p; + if ( *alpha < 0.919f ) + { + *alpha = 0.919f; + } + break; + default: + *alpha = ( 0.652f + 0.328f * ( *stabFac ) ) * gain_p; + } + } + + if ( nbLostCmpt_loc > 3 ) + { + switch ( frame_dms ) + { + case 25: + *alpha *= PLC34_ATTEN_FAC_025; + break; + case 50: + *alpha *= PLC34_ATTEN_FAC_050; + break; + case 100: + *alpha *= PLC34_ATTEN_FAC_100; + break; + } + } - if (tmp > gain_p) { - Tc = pitch_int; - gain_p = tmp; - *fract = 0; - } + if ( nbLostCmpt_loc > 5 ) + { + gain_p = *alpha; } - if(gain_p < 0.0f) + /*---------------------------------------------------------------* + * Construct the harmonic part * + * Last pitch cycle of the previous frame is repeatedly copied. * + *---------------------------------------------------------------*/ + + pt_exc = harmonicBuf; + pt1_exc = exc - Tc; + + if ( nbLostFramesInRow == 1 ) { - gain_p = 0.0f; + if ( *stabFac >= 1 ) + { + TDC_copyFLOAT( pt1_exc, pt_exc, Tc ); + } + else + { + /* These values are necessary for the last five filtered samples */ + TDC_copyFLOAT( &exc[-Tc], exc, ( TDC_L_FIR_HP - 1 ) / 2 ); + + high_harm = TDC_high_32_harm; + if ( SampRate <= 16000 ) + { + high_harm = TDC_high_16_harm; + } + + for ( i = 0; i < Tc; i++ ) + { + pt_exc[i] = TDC_dotFLOAT( &pt1_exc[i - ( TDC_L_FIR_HP - 1 ) / 2], high_harm, TDC_L_FIR_HP ); + } + } } - if(gain_p > 1.0f) + /*---------------------------------------------------------------* + * Construct the random part of excitation * + *---------------------------------------------------------------*/ + scratchSpaceTmp = scratchSpace1st; + exc2 = (LC3_FLOAT *) scratchSpaceTmp; + scratchSpaceTmp += (LC3_INT32) sizeof( LC3_FLOAT ) * ( len + TDC_L_FIR_HP - 1 ); + + for ( i = 0; i < len + TDC_L_FIR_HP - 1; i++ ) { - gain_p = 1.0f; + exc2[i] = (LC3_FLOAT) TDC_random_short( seed ); } - *gain_c = 0.0f; + /* high pass noise */ + if ( SampRate <= 16000 ) + { + hp_filt = TDC_high_16; + } + else + { + hp_filt = TDC_high_32; + } - if (pitch_int == Tc) + if ( nbLostFramesInRow == 1 ) { - *gain_c = TDC_get_gainc( &(exc[-1]), &(exc[-1-Tc]), &gain_p, N/2, frame_dms ); + TDC_highPassFiltering( len, exc2, hp_filt, TDC_L_FIR_HP ); } else { - tmp = TDC_get_gainc( &(exc[-1]), &(exc[-1-pitch_int]), &gain_p, N/2, frame_dms ); - *gain_c = TDC_get_gainc( &(exc[-1]), &(exc[-1-Tc]) , &gain_p, N/2, frame_dms ); - *gain_c = MIN(*gain_c, tmp); - } - } - else - { - gain_p = *alpha; - } - - /*---------------------------------------------------------------* - * Damping factor * - *---------------------------------------------------------------*/ - - alphaPrev = 1; - if (nbLostFramesInRow > 1) - { - alphaPrev = *alpha; - } - - if (nextInc != 0) - { - switch (nbLostCmpt_loc) - { - case 1: - *alpha = (LC3_FLOAT)sqrt(gain_p); - if ( *alpha > 0.98f ) - { - *alpha = 0.98f; - } - else if ( *alpha < 0.925f ) - { - *alpha = 0.925f; - } - break; - case 2: - *alpha = (0.63f + 0.35f * (*stabFac)) * gain_p; - if ( *alpha < 0.919f ) - { - *alpha = 0.919f; - } - break; - default: - *alpha = (0.652f + 0.328f * (*stabFac)) * gain_p; - } - } - - if (nbLostCmpt_loc > 3) - { - switch (frame_dms) - { - case 25: *alpha *= PLC34_ATTEN_FAC_025; break; - case 50: *alpha *= PLC34_ATTEN_FAC_050; break; - case 100: *alpha *= PLC34_ATTEN_FAC_100; break; - } - } - - if (nbLostCmpt_loc > 5) - { - gain_p = *alpha; - } - - /*---------------------------------------------------------------* - * Construct the harmonic part * - * Last pitch cycle of the previous frame is repeatedly copied. * - *---------------------------------------------------------------*/ - - pt_exc = harmonicBuf; - pt1_exc = exc - Tc; - - if( nbLostFramesInRow == 1 ) - { - if (*stabFac >= 1) - { - TDC_copyFLOAT(pt1_exc, pt_exc, Tc); - } - else - { - /* These values are necessary for the last five filtered samples */ - TDC_copyFLOAT(&exc[-Tc], exc, (TDC_L_FIR_HP-1)/2); - - high_harm = TDC_high_32_harm; - if (SampRate <= 16000) - { - high_harm = TDC_high_16_harm; - } - - for( i = 0; i < Tc; i++ ) - { - pt_exc[i] = TDC_dotFLOAT(&pt1_exc[i-(TDC_L_FIR_HP-1)/2], high_harm, TDC_L_FIR_HP); - } - } - } - - /*---------------------------------------------------------------* - * Construct the random part of excitation * - *---------------------------------------------------------------*/ - scratchSpaceTmp = scratchSpace1st; - exc2 = (LC3_FLOAT*)scratchSpaceTmp; scratchSpaceTmp += (LC3_INT32)sizeof(LC3_FLOAT) * (len + TDC_L_FIR_HP - 1); - - for (i = 0; i < len + TDC_L_FIR_HP - 1; i++) { - exc2[i] = (LC3_FLOAT)TDC_random_short(seed); - } - - /* high pass noise */ - if (SampRate <= 16000 ) - { - hp_filt = TDC_high_16; - } else { - hp_filt = TDC_high_32; - } - - if ( nbLostFramesInRow == 1 ) - { - TDC_highPassFiltering(len, exc2, hp_filt, TDC_L_FIR_HP); - } - else - { - /* moves from 0 to 1, speed is defined by PLC3_HPBLENDTHROTTLE */ - throttle = (LC3_FLOAT)nbLostCmpt_loc / (nbLostCmpt_loc + PLC3_HPBLENDTHROTTLE); - hpBlendFac = (1 - *alpha) * throttle; - - for (i = 0; i < len; i++) - { - exc2[i] = hpBlendFac * exc2[i+TDC_L_FIR_HP/2] + (1 - hpBlendFac) * TDC_dotFLOAT(&exc2[i], hp_filt, TDC_L_FIR_HP ); - } - } - - /* normalize energy */ - gainInov = 1.0f / (LC3_FLOAT)sqrt(TDC_dotFLOAT( exc2, exc2, N ) / (LC3_FLOAT)N + 0.01f ); - gainInov *= (1.1f - 0.75* gain_p); - - /* gains */ - gain_h = alphaPrev; - tmp = *gain_c * *alpha / alphaPrev; - - /* update steps */ - step = (1.0f/(LC3_FLOAT)N) * (gain_h - *alpha); - step_n = (1.0f/(LC3_FLOAT)N) * (*gain_c - tmp); - - /*---------------------------------------------------------------* - * Construct the total excitation * - *---------------------------------------------------------------*/ - harmonicBufPtr = harmonicBuf + ((nbLostFramesInRow - 1) * N) % Tc; - - for ( i = 0; i < len; i++ ) { - /* harmonic */ - if (harmonicBufPtr - harmonicBuf >= Tc) { - harmonicBufPtr = harmonicBuf; - } - exc[i] = *harmonicBufPtr++; - exc[i] *= gain_h; - - /* random */ - exc2[i] *= *gain_c * gainInov; - - /* total */ - exc[i] = exc[i] + exc2[i]; - - /* update */ - gain_h -= step; - gain_h = MAX(gain_h, 0); - *gain_c -= step_n; - *gain_c = MAX(*gain_c, 0); - } - - *gain_c = tmp; - - /*----------------------------------------------------------* - * Compute the synthesis speech * - *----------------------------------------------------------*/ - buf = (LC3_FLOAT*)scratchSpace1st; scratchSpace1st += (LC3_INT32)sizeof(LC3_FLOAT) * (len + lpc_order); - synthMemPtr = synth_mem; - if (nbLostFramesInRow != 1) - { - synthMemPtr = synthHist; - } - - TDC_LPC_synthesis(A, - &exc[0], - synth, - len, - synthMemPtr, - lpc_order, - buf); - - TDC_copyFLOAT(&synth[N-lpc_order], synthHist, lpc_order); - - /*----------------------------------------------------------* - * Deemphasis * - *----------------------------------------------------------*/ - TDC_deemph( synth, preemphFac, len, &pcmbufHist[max_len_pcm_plc-1] ); - - /*----------------------------------------------------------* - * Fade to zero * - *----------------------------------------------------------*/ - if (beforeNextInc != 0) - { - if (nbLostCmpt_loc == PLC_FADEOUT_IN_MS/10) - { - gain_h = 1; - step = 1.0f/(LC3_FLOAT)N; - for ( i = 0; i < N; i++ ) { - synth[i] *= gain_h; + /* moves from 0 to 1, speed is defined by PLC3_HPBLENDTHROTTLE */ + throttle = (LC3_FLOAT) nbLostCmpt_loc / ( nbLostCmpt_loc + PLC3_HPBLENDTHROTTLE ); + hpBlendFac = ( 1 - *alpha ) * throttle; + + for ( i = 0; i < len; i++ ) + { + exc2[i] = hpBlendFac * exc2[i + TDC_L_FIR_HP / 2] + ( 1 - hpBlendFac ) * TDC_dotFLOAT( &exc2[i], hp_filt, TDC_L_FIR_HP ); + } + } + + /* normalize energy */ + gainInov = 1.0f / (LC3_FLOAT) sqrt( TDC_dotFLOAT( exc2, exc2, N ) / (LC3_FLOAT) N + 0.01f ); + gainInov *= ( 1.1f - 0.75 * gain_p ); + + /* gains */ + gain_h = alphaPrev; + tmp = *gain_c * *alpha / alphaPrev; + + /* update steps */ + step = ( 1.0f / (LC3_FLOAT) N ) * ( gain_h - *alpha ); + step_n = ( 1.0f / (LC3_FLOAT) N ) * ( *gain_c - tmp ); + + /*---------------------------------------------------------------* + * Construct the total excitation * + *---------------------------------------------------------------*/ + harmonicBufPtr = harmonicBuf + ( ( nbLostFramesInRow - 1 ) * N ) % Tc; + + for ( i = 0; i < len; i++ ) + { + /* harmonic */ + if ( harmonicBufPtr - harmonicBuf >= Tc ) + { + harmonicBufPtr = harmonicBuf; + } + exc[i] = *harmonicBufPtr++; + exc[i] *= gain_h; + + /* random */ + exc2[i] *= *gain_c * gainInov; + + /* total */ + exc[i] = exc[i] + exc2[i]; + + /* update */ gain_h -= step; - } - memset(&synth[N], 0, overlap * sizeof(LC3_FLOAT)); + gain_h = MAX( gain_h, 0 ); + *gain_c -= step_n; + *gain_c = MAX( *gain_c, 0 ); + } + + *gain_c = tmp; + + /*----------------------------------------------------------* + * Compute the synthesis speech * + *----------------------------------------------------------*/ + buf = (LC3_FLOAT *) scratchSpace1st; + scratchSpace1st += (LC3_INT32) sizeof( LC3_FLOAT ) * ( len + lpc_order ); + synthMemPtr = synth_mem; + if ( nbLostFramesInRow != 1 ) + { + synthMemPtr = synthHist; + } + + TDC_LPC_synthesis( A, + &exc[0], + synth, + len, + synthMemPtr, + lpc_order, + buf ); + + TDC_copyFLOAT( &synth[N - lpc_order], synthHist, lpc_order ); + + /*----------------------------------------------------------* + * Deemphasis * + *----------------------------------------------------------*/ + TDC_deemph( synth, preemphFac, len, &pcmbufHist[max_len_pcm_plc - 1] ); + + /*----------------------------------------------------------* + * Fade to zero * + *----------------------------------------------------------*/ + if ( beforeNextInc != 0 ) + { + if ( nbLostCmpt_loc == PLC_FADEOUT_IN_MS / 10 ) + { + gain_h = 1; + step = 1.0f / (LC3_FLOAT) N; + for ( i = 0; i < N; i++ ) + { + synth[i] *= gain_h; + gain_h -= step; + } + memset( &synth[N], 0, overlap * sizeof( LC3_FLOAT ) ); + } } - } } /* Take only real part */ -void processTdcInverseOdft_fl(LC3_FLOAT *in, LC3_INT32 n_bands, LC3_FLOAT *out, LC3_INT32 lpc_order) +void processTdcInverseOdft_fl( LC3_FLOAT *in, LC3_INT32 n_bands, LC3_FLOAT *out, LC3_INT32 lpc_order ) { - LC3_INT32 i, j, k; - LC3_FLOAT buf[2*MAX_BANDS_NUMBER_PLC]; - Complex sum; - Complex res; + LC3_INT32 i, j, k; + LC3_FLOAT buf[2 * MAX_BANDS_NUMBER_PLC]; + Complex sum; + Complex res; /* Buffer for ifft */ j = 0; - for (i = 0; i < n_bands - 1; i += 2) + for ( i = 0; i < n_bands - 1; i += 2 ) { buf[j] = in[i]; j++; } - for (i = n_bands - 1; i > 0; i -= 2) + for ( i = n_bands - 1; i > 0; i -= 2 ) { buf[j] = in[i]; j++; } - for (i = 0; i < n_bands; i++) + for ( i = 0; i < n_bands; i++ ) { buf[j] = in[i]; j++; } /* ifft */ - for (j = 0; j < n_bands; j++) + for ( j = 0; j < n_bands; j++ ) { sum.r = 0, sum.i = 0; res.r = 0, res.i = 0; - for (k = 0; k < n_bands; k++) + for ( k = 0; k < n_bands; k++ ) { - res = cexpi((2 * M_PI * (LC3_FLOAT) (j * k)) / (LC3_FLOAT) n_bands); + res = cexpi( ( 2 * M_PI * (LC3_FLOAT) ( j * k ) ) / (LC3_FLOAT) n_bands ); res.r = res.r * buf[k]; res.i = res.i * buf[k]; - sum = cadd(sum, res); + sum = cadd( sum, res ); } - res = cexpi((LC3_FLOAT) j * M_PI / (2.0 * (LC3_FLOAT) n_bands)); - out[j] = (sum.r * res.r - sum.i * res.i); + res = cexpi( (LC3_FLOAT) j * M_PI / ( 2.0 * (LC3_FLOAT) n_bands ) ); + out[j] = ( sum.r * res.r - sum.i * res.i ); } out[0] = out[0] * 1.0001; - if (out[0] == 0) + if ( out[0] == 0 ) { out[0] = 1; - zero_float(&out[1], lpc_order); + zero_float( &out[1], lpc_order ); } } -void processTdcPreemphasis_fl(LC3_FLOAT *in, LC3_FLOAT *pre_emph_factor, LC3_INT32 n_bands) +void processTdcPreemphasis_fl( LC3_FLOAT *in, LC3_FLOAT *pre_emph_factor, LC3_INT32 n_bands ) { - LC3_INT32 i; + LC3_INT32 i; - for (i = 0; i < n_bands; i++) + for ( i = 0; i < n_bands; i++ ) { - in[i] = in[i] * (1.0 - 2.0 * (*pre_emph_factor) * LC3_COS(2.0 * M_PI * (0.5 + (LC3_FLOAT) i) / (2.0 * (LC3_FLOAT) n_bands)) + (*pre_emph_factor) * (*pre_emph_factor)); + in[i] = in[i] * ( 1.0 - 2.0 * ( *pre_emph_factor ) * LC3_COS( 2.0 * M_PI * ( 0.5 + (LC3_FLOAT) i ) / ( 2.0 * (LC3_FLOAT) n_bands ) ) + ( *pre_emph_factor ) * ( *pre_emph_factor ) ); } } -void processTdcLpcEstimation_fl(LC3_FLOAT *r, LC3_INT32 fs_idx, LC3_INT32 len, LC3_FLOAT *A, LC3_INT32 frame_dms) +void processTdcLpcEstimation_fl( LC3_FLOAT *r, LC3_INT32 fs_idx, LC3_INT32 len, LC3_FLOAT *A, LC3_INT32 frame_dms ) { - LC3_INT32 i; - const LC3_FLOAT *lpc_array; - + LC3_INT32 i; + const LC3_FLOAT *lpc_array; + lpc_array = plc_tdc_lpc_all[fs_idx]; - - if (fs_idx == 0 && frame_dms == 25) + + if ( fs_idx == 0 && frame_dms == 25 ) { lpc_array = plc_tdc_lpc_8_25ms; } - + /* r[0] = r[0] * 1 */ - for (i = 1; i < len; i++) + for ( i = 1; i < len; i++ ) { r[i] = r[i] * lpc_array[i]; } - TDC_levinson(r, len - 1, A); + TDC_levinson( r, len - 1, A ); } /** random @@ -485,109 +502,111 @@ void processTdcLpcEstimation_fl(LC3_FLOAT *r, LC3_INT32 fs_idx, LC3_INT32 len, L * Returns: * random number */ -static LC3_INT16 TDC_random_short(LC3_INT16 *seed) +static LC3_INT16 TDC_random_short( LC3_INT16 *seed ) { - *seed = (LC3_INT16) (*seed * 12821L + 16831L); - return(*seed); + *seed = (LC3_INT16) ( *seed * 12821L + 16831L ); + return ( *seed ); } -static LC3_FLOAT TDC_get_gainp( /* output: gain of pitch */ - const LC3_FLOAT x[], /* input : input signal */ - const LC3_FLOAT y[], /* input : shifted input signal */ - LC3_INT32 n /* input : vector length */ +static LC3_FLOAT TDC_get_gainp( /* output: gain of pitch */ + const LC3_FLOAT x[], /* input : input signal */ + const LC3_FLOAT y[], /* input : shifted input signal */ + LC3_INT32 n /* input : vector length */ ) { - LC3_FLOAT corr, ener; - LC3_INT16 i; - - corr = 0; ener = 1e-6f; + LC3_FLOAT corr, ener; + LC3_INT16 i; - for (i = 0; i < n; i++) + corr = 0; + ener = 1e-6f; + + for ( i = 0; i < n; i++ ) { - corr += x[i]*y[i]; - ener += y[i]*y[i]; + corr += x[i] * y[i]; + ener += y[i] * y[i]; } - return(corr/ener); + return ( corr / ener ); } -static LC3_FLOAT TDC_get_gainc( /* output: gain of code */ - const LC3_FLOAT x[], /* input : input signal */ - const LC3_FLOAT y[], /* input : shifted input signal */ - const LC3_FLOAT *gain_p, /* input : gain of pitch */ - const LC3_INT32 n, /* input : vector length */ - const LC3_INT32 frame_dms /* input : frame length in dms */ +static LC3_FLOAT TDC_get_gainc( /* output: gain of code */ + const LC3_FLOAT x[], /* input : input signal */ + const LC3_FLOAT y[], /* input : shifted input signal */ + const LC3_FLOAT *gain_p, /* input : gain of pitch */ + const LC3_INT32 n, /* input : vector length */ + const LC3_INT32 frame_dms /* input : frame length in dms */ ) { - LC3_FLOAT gain_c; - LC3_FLOAT gain_c_max; - LC3_INT16 i; - - gain_c = 0; gain_c_max = 0; + LC3_FLOAT gain_c; + LC3_FLOAT gain_c_max; + LC3_INT16 i; + + gain_c = 0; + gain_c_max = 0; - for (i = 0; i < n; i++) + for ( i = 0; i < n; i++ ) { - gain_c += ( x[-i] - *gain_p * y[-i] ) * ( x[-i] - *gain_p * y[-i] ); + gain_c += ( x[-i] - *gain_p * y[-i] ) * ( x[-i] - *gain_p * y[-i] ); } - if (frame_dms < 100) + if ( frame_dms < 100 ) { - for (i = 0; i < n; i++) + for ( i = 0; i < n; i++ ) { - gain_c_max += (x[-i] * x[-i]); + gain_c_max += ( x[-i] * x[-i] ); } - gain_c = MIN(gain_c, gain_c_max); + gain_c = MIN( gain_c, gain_c_max ); } - gain_c = (LC3_FLOAT)sqrt(gain_c / n ); + gain_c = (LC3_FLOAT) sqrt( gain_c / n ); return gain_c; } -static void TDC_highPassFiltering(const LC3_INT32 L_buffer, /* i: buffer length */ - LC3_FLOAT exc2[], /* i/o: unvoiced excitation before the high pass filtering */ - const LC3_FLOAT hp_filt[], /* i: high pass filter coefficients */ - const LC3_INT32 l_fir_fer) /* i: high pass filter length */ +static void TDC_highPassFiltering( const LC3_INT32 L_buffer, /* i: buffer length */ + LC3_FLOAT exc2[], /* i/o: unvoiced excitation before the high pass filtering */ + const LC3_FLOAT hp_filt[], /* i: high pass filter coefficients */ + const LC3_INT32 l_fir_fer ) /* i: high pass filter length */ { - LC3_INT32 i; - - for( i=0 ; i< L_buffer; i++ ) { - exc2[i] = TDC_dotFLOAT(&exc2[i], hp_filt, l_fir_fer); - } + LC3_INT32 i; + + for ( i = 0; i < L_buffer; i++ ) + { + exc2[i] = TDC_dotFLOAT( &exc2[i], hp_filt, l_fir_fer ); + } } static void TDC_LPC_synthesis( - const LC3_FLOAT a[], - LC3_FLOAT x[], - LC3_FLOAT y[], - LC3_INT32 l, - const LC3_FLOAT mem[], - LC3_INT32 lpcorder, - LC3_FLOAT *buf - ) + const LC3_FLOAT a[], + LC3_FLOAT x[], + LC3_FLOAT y[], + LC3_INT32 l, + const LC3_FLOAT mem[], + LC3_INT32 lpcorder, + LC3_FLOAT *buf ) { - LC3_FLOAT s, *yy; - LC3_INT32 i, j; - - /* copy initial filter states into synthesis buffer */ - for (i=0; i < lpcorder; i++) - { - buf[i] = mem[i]; - } - yy = &buf[i]; - - for (i = 0; i < l; i++) - { - s = x[i]; - for (j = 1; j <= lpcorder; j++) - { - s -= a[j] * yy[i- j]; - } - y[i] = s; - yy[i] = y[i]; - } - - return; + LC3_FLOAT s, *yy; + LC3_INT32 i, j; + + /* copy initial filter states into synthesis buffer */ + for ( i = 0; i < lpcorder; i++ ) + { + buf[i] = mem[i]; + } + yy = &buf[i]; + + for ( i = 0; i < l; i++ ) + { + s = x[i]; + for ( j = 1; j <= lpcorder; j++ ) + { + s -= a[j] * yy[i - j]; + } + y[i] = s; + yy[i] = y[i]; + } + + return; } @@ -606,22 +625,22 @@ static void TDC_LPC_synthesis( * Returns: * void */ -static void TDC_LPC_residu(const LC3_FLOAT *a, LC3_FLOAT *x, LC3_FLOAT *y, LC3_INT32 l, LC3_INT32 lpcorder) +static void TDC_LPC_residu( const LC3_FLOAT *a, LC3_FLOAT *x, LC3_FLOAT *y, LC3_INT32 l, LC3_INT32 lpcorder ) { - LC3_FLOAT s; - LC3_INT32 i, j; - - for (i = 0; i < l; i++) - { - s = x[i]; - for (j = 1; j <= lpcorder; j++) - { - s += a[j] * x[i - j]; - } - y[i] = s; - } - - return; + LC3_FLOAT s; + LC3_INT32 i, j; + + for ( i = 0; i < l; i++ ) + { + s = x[i]; + for ( j = 1; j <= lpcorder; j++ ) + { + s += a[j] * x[i - j]; + } + y[i] = s; + } + + return; } @@ -641,18 +660,18 @@ static void TDC_LPC_residu(const LC3_FLOAT *a, LC3_FLOAT *x, LC3_FLOAT *y, LC3_I * void */ -static void TDC_f_preemph(LC3_FLOAT *signal, const LC3_FLOAT *mu, LC3_INT32 L, LC3_FLOAT *mem) +static void TDC_f_preemph( LC3_FLOAT *signal, const LC3_FLOAT *mu, LC3_INT32 L, LC3_FLOAT *mem ) { - LC3_INT32 i; + LC3_INT32 i; - for (i = L - 1; i > 0; i--) - { - signal[i] = signal[i] - *mu * signal[i - 1]; - } + for ( i = L - 1; i > 0; i-- ) + { + signal[i] = signal[i] - *mu * signal[i - 1]; + } - signal[0] -= *mu * (*mem); + signal[0] -= *mu * ( *mem ); - return; + return; } /* @@ -671,93 +690,99 @@ static void TDC_f_preemph(LC3_FLOAT *signal, const LC3_FLOAT *mu, LC3_INT32 L, L * Returns: * void */ -static void TDC_deemph(LC3_FLOAT *signal, const LC3_FLOAT *mu, LC3_INT32 L, const LC3_FLOAT *mem) +static void TDC_deemph( LC3_FLOAT *signal, const LC3_FLOAT *mu, LC3_INT32 L, const LC3_FLOAT *mem ) { - LC3_INT32 i; + LC3_INT32 i; - signal[0] = signal[0] + *mu * (*mem); + signal[0] = signal[0] + *mu * ( *mem ); - for (i = 1; i < L; i++) - { - signal[i] = signal[i] + *mu * signal[i - 1]; - } + for ( i = 1; i < L; i++ ) + { + signal[i] = signal[i] + *mu * signal[i - 1]; + } - return; + return; } -static void TDC_copyFLOAT(const LC3_FLOAT * X, LC3_FLOAT * Z, LC3_INT32 n) +static void TDC_copyFLOAT( const LC3_FLOAT *X, LC3_FLOAT *Z, LC3_INT32 n ) { - /* no values to copy */ - if ( (n < 1) || (X == Z) ){ - return; - } - /* If overlapping */ - if ( ( (Z > X) && (Z < X+n) ) || ( (Z < X) && (X < Z+n) ) ) { - memmove(Z, X, sizeof(LC3_FLOAT)*n); - } - else{ - memcpy(Z, X, sizeof(LC3_FLOAT)*n); - } + /* no values to copy */ + if ( ( n < 1 ) || ( X == Z ) ) + { + return; + } + /* If overlapping */ + if ( ( ( Z > X ) && ( Z < X + n ) ) || ( ( Z < X ) && ( X < Z + n ) ) ) + { + memmove( Z, X, sizeof( LC3_FLOAT ) * n ); + } + else + { + memcpy( Z, X, sizeof( LC3_FLOAT ) * n ); + } } -static LC3_FLOAT TDC_dotFLOAT(const LC3_FLOAT * X, const LC3_FLOAT * Y, LC3_INT32 n) +static LC3_FLOAT TDC_dotFLOAT( const LC3_FLOAT *X, const LC3_FLOAT *Y, LC3_INT32 n ) { - LC3_FLOAT acc; - LC3_INT32 i; + LC3_FLOAT acc; + LC3_INT32 i; + + acc = 0; + if ( n ) + { + acc = X[0] * Y[0]; + } - acc = 0; - if (n) { - acc = X[0]*Y[0]; - } + for ( i = 1; i < n; i++ ) + acc += X[i] * Y[i]; - for (i=1; i= 0; i--) + for ( i = t - 1; i >= 0; i-- ) { out[j] = buf[k] - g * buf2[i]; - j++; k++; + j++; + k++; } - v = v * (1.0 - g * g); + v = v * ( 1.0 - g * g ); } - move_float(buf, out, len); + move_float( buf, out, len ); out[0] = 1; j = 1; - for (i = len - 1; i >= 0; i--) + for ( i = len - 1; i >= 0; i-- ) { out[j] = -buf[i]; j++; } } - diff --git a/lib_lc3plus/plc_tdc_tdac.c b/lib_lc3plus/plc_tdc_tdac.c index 329361b14c..6d66eb6513 100644 --- a/lib_lc3plus/plc_tdc_tdac.c +++ b/lib_lc3plus/plc_tdc_tdac.c @@ -1,31 +1,31 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -void processTdcTdac_fl(const LC3_FLOAT *synth_inp, const LC3_FLOAT *win, LC3_INT32 frame_length, LC3_INT32 la_zeroes, LC3_FLOAT *ola_mem) +void processTdcTdac_fl( const LC3_FLOAT *synth_inp, const LC3_FLOAT *win, LC3_INT32 frame_length, LC3_INT32 la_zeroes, LC3_FLOAT *ola_mem ) { - LC3_INT32 i, L, LD2, NZ, synth_len; - LC3_FLOAT synth[(MAX_LEN + MDCT_MEM_LEN_MAX)], *synth1, *synth2, *ola_mem1, *ola_mem2, sz; - const LC3_FLOAT *win1, *win2, *win3, *win4; + LC3_INT32 i, L, LD2, NZ, synth_len; + LC3_FLOAT synth[( MAX_LEN + MDCT_MEM_LEN_MAX )], *synth1, *synth2, *ola_mem1, *ola_mem2, sz; + const LC3_FLOAT *win1, *win2, *win3, *win4; - assert(la_zeroes <= frame_length / 2); + assert( la_zeroes <= frame_length / 2 ); - L = frame_length; - LD2 = L/2; - NZ = LD2 - la_zeroes; - synth_len = 2*L - la_zeroes; + L = frame_length; + LD2 = L / 2; + NZ = LD2 - la_zeroes; + synth_len = 2 * L - la_zeroes; - move_float(synth, synth_inp, synth_len); + move_float( synth, synth_inp, synth_len ); /* calculate x_ov[L+la_zeroes] ... x_ov[2*L-1] */ win1 = &win[L + LD2 - 1]; @@ -40,7 +40,7 @@ void processTdcTdac_fl(const LC3_FLOAT *synth_inp, const LC3_FLOAT *win, LC3_INT ola_mem1 = &ola_mem[LD2 - la_zeroes]; ola_mem2 = &ola_mem[LD2 - la_zeroes - 1]; - for (i = 0; i < NZ; i++) + for ( i = 0; i < NZ; i++ ) { /* analysis windowing + 2N -> N */ sz = *synth1 * *win1 + *synth2 * *win2; @@ -60,7 +60,7 @@ void processTdcTdac_fl(const LC3_FLOAT *synth_inp, const LC3_FLOAT *win, LC3_INT ola_mem2--; } - for (; i < LD2; i++) + for ( ; i < LD2; i++ ) { /* analysis windowing + 2N -> N */ sz = *synth1 * *win1; @@ -77,4 +77,3 @@ void processTdcTdac_fl(const LC3_FLOAT *synth_inp, const LC3_FLOAT *win, LC3_INT ola_mem1++; } } - diff --git a/lib_lc3plus/plc_update.c b/lib_lc3plus/plc_update.c index a151420eb7..ed24a1f3a0 100644 --- a/lib_lc3plus/plc_update.c +++ b/lib_lc3plus/plc_update.c @@ -1,125 +1,129 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ #include "functions.h" #include "options.h" -void processPlcUpdate_fl(PlcAdvSetup *PlcAdvSetup, LC3_INT32 frame_length, LC3_FLOAT *syntM, LC3_FLOAT *scf_q, - LC3_INT32 *nbLostCmpt, LC3_FLOAT *cum_alpha, LC3_INT32 bfi, LC3_INT32 *prevBfi, LC3_INT32 *prevprevBfi) +void processPlcUpdate_fl( PlcAdvSetup *PlcAdvSetup, LC3_INT32 frame_length, LC3_FLOAT *syntM, LC3_FLOAT *scf_q, LC3_INT32 *nbLostCmpt, LC3_FLOAT *cum_alpha, LC3_INT32 bfi, LC3_INT32 *prevBfi, LC3_INT32 *prevprevBfi ) { LC3_FLOAT tmp[MAX_LEN_PCM_PLC]; - - move_float(tmp, &PlcAdvSetup->pcmbufHist[frame_length], PlcAdvSetup->max_len_pcm_plc - frame_length); - move_float(&PlcAdvSetup->pcmbufHist[0], tmp, PlcAdvSetup->max_len_pcm_plc - frame_length); - move_float(&PlcAdvSetup->pcmbufHist[PlcAdvSetup->max_len_pcm_plc - frame_length], syntM, frame_length); - - if (bfi != 1) - { + + move_float( tmp, &PlcAdvSetup->pcmbufHist[frame_length], PlcAdvSetup->max_len_pcm_plc - frame_length ); + move_float( &PlcAdvSetup->pcmbufHist[0], tmp, PlcAdvSetup->max_len_pcm_plc - frame_length ); + move_float( &PlcAdvSetup->pcmbufHist[PlcAdvSetup->max_len_pcm_plc - frame_length], syntM, frame_length ); + + if ( bfi != 1 ) + { *nbLostCmpt = 0; *cum_alpha = 1; - - if (PlcAdvSetup) + + if ( PlcAdvSetup ) { - move_float(PlcAdvSetup->scf_q_old_old, PlcAdvSetup->scf_q_old, M); - move_float(PlcAdvSetup->scf_q_old, scf_q, M); - /* PLC fullband transient detector setting for non-bfi frames */ - PlcAdvSetup->PlcPhEcuSetup.PhECU_short_flag_prev = 0; /* fullband transient not active */ + move_float( PlcAdvSetup->scf_q_old_old, PlcAdvSetup->scf_q_old, M ); + move_float( PlcAdvSetup->scf_q_old, scf_q, M ); + /* PLC fullband transient detector setting for non-bfi frames */ + PlcAdvSetup->PlcPhEcuSetup.PhECU_short_flag_prev = 0; /* fullband transient not active */ } } - + *prevprevBfi = *prevBfi; *prevBfi = bfi; } -void plc_phEcu_processPLCspec2shape(LC3_INT16 prev_bfi, LC3_INT16 bfi, LC3_FLOAT q_d[], LC3_INT32 yLen, - LC3_FLOAT *stPhECU_oold_grp_shape, LC3_FLOAT *stPhECU_old_grp_shape) +void plc_phEcu_processPLCspec2shape( LC3_INT16 prev_bfi, LC3_INT16 bfi, LC3_FLOAT q_d[], LC3_INT32 yLen, LC3_FLOAT *stPhECU_oold_grp_shape, LC3_FLOAT *stPhECU_old_grp_shape ) { - LC3_INT32 i, j, N_grp; - LC3_INT32 local_prev_bfi; - LC3_INT32 fs_idx; - LC3_FLOAT E_tot = 0.0; - LC3_INT32 l_grp; - LC3_FLOAT *pX; - - if (bfi != 1) /* compute only for bfi== 0 or 2 */ - { - fs_idx = (LC3_INT32)floor(yLen / 100); - assert(fs_idx < 5); - N_grp = xavg_N_grp[fs_idx]; - - local_prev_bfi = prev_bfi; - if (local_prev_bfi == 2) { - local_prev_bfi = 0; - } - - - /* Copy old to oold grp shape */ - for (i = 0; i < MAX_LGW; i++) - { - stPhECU_oold_grp_shape[i] = stPhECU_old_grp_shape[i]; - } - - /* Accumulate DC-coupled bins to total */ - E_tot = 0; - pX = q_d; /* ptr setup */ - for (i = 0; i < mdct_grp_bins[0]; i++) - { - E_tot += sqrf( *pX ); - pX++; - } - - /* Accumulate middle grps and add to total */ - for (i = 0; i < (N_grp - 1); i++) - { - l_grp = mdct_grp_bins[i + 1] - mdct_grp_bins[i]; ; - stPhECU_old_grp_shape[i] = 0.0; - for (j = 0; j < l_grp; j++) { - stPhECU_old_grp_shape[i] += sqrf( *pX ); + LC3_INT32 i, j, N_grp; + LC3_INT32 local_prev_bfi; + LC3_INT32 fs_idx; + LC3_FLOAT E_tot = 0.0; + LC3_INT32 l_grp; + LC3_FLOAT *pX; + + if ( bfi != 1 ) /* compute only for bfi== 0 or 2 */ + { + fs_idx = (LC3_INT32) floor( yLen / 100 ); + assert( fs_idx < 5 ); + N_grp = xavg_N_grp[fs_idx]; + + local_prev_bfi = prev_bfi; + if ( local_prev_bfi == 2 ) + { + local_prev_bfi = 0; + } + + + /* Copy old to oold grp shape */ + for ( i = 0; i < MAX_LGW; i++ ) + { + stPhECU_oold_grp_shape[i] = stPhECU_old_grp_shape[i]; + } + + /* Accumulate DC-coupled bins to total */ + E_tot = 0; + pX = q_d; /* ptr setup */ + for ( i = 0; i < mdct_grp_bins[0]; i++ ) + { + E_tot += sqrf( *pX ); pX++; - } - E_tot += stPhECU_old_grp_shape[i]; - } - - /* Accumulate last subbband and add to total */ - stPhECU_old_grp_shape[(N_grp - 1)] = 0.0; - l_grp = mdct_grp_bins[N_grp] - mdct_grp_bins[N_grp - 1] - mdct_grp_bins[0]; - assert( (mdct_grp_bins[N_grp] - mdct_grp_bins[0]) <= yLen); - for (j = 0; j < l_grp; j++) - { - stPhECU_old_grp_shape[(N_grp - 1)] += sqrf( *pX ); - pX++; - } - E_tot += stPhECU_old_grp_shape[(N_grp - 1)]; - - - /* Normalize shape */ - for (i = 0; i < (N_grp); i++) { - if (E_tot > 0.0) { - stPhECU_old_grp_shape[i] /= E_tot; - } - else - { + } + + /* Accumulate middle grps and add to total */ + for ( i = 0; i < ( N_grp - 1 ); i++ ) + { + l_grp = mdct_grp_bins[i + 1] - mdct_grp_bins[i]; + ; stPhECU_old_grp_shape[i] = 0.0; - } - } - if (local_prev_bfi == 1) { - for (i = 0; i < MAX_LGW; i++) { - stPhECU_oold_grp_shape[i] = stPhECU_old_grp_shape[i]; - } - } - }/*bfi*/ - return; + for ( j = 0; j < l_grp; j++ ) + { + stPhECU_old_grp_shape[i] += sqrf( *pX ); + pX++; + } + E_tot += stPhECU_old_grp_shape[i]; + } + + /* Accumulate last subbband and add to total */ + stPhECU_old_grp_shape[( N_grp - 1 )] = 0.0; + l_grp = mdct_grp_bins[N_grp] - mdct_grp_bins[N_grp - 1] - mdct_grp_bins[0]; + assert( ( mdct_grp_bins[N_grp] - mdct_grp_bins[0] ) <= yLen ); + for ( j = 0; j < l_grp; j++ ) + { + stPhECU_old_grp_shape[( N_grp - 1 )] += sqrf( *pX ); + pX++; + } + E_tot += stPhECU_old_grp_shape[( N_grp - 1 )]; + + + /* Normalize shape */ + for ( i = 0; i < ( N_grp ); i++ ) + { + if ( E_tot > 0.0 ) + { + stPhECU_old_grp_shape[i] /= E_tot; + } + else + { + stPhECU_old_grp_shape[i] = 0.0; + } + } + if ( local_prev_bfi == 1 ) + { + for ( i = 0; i < MAX_LGW; i++ ) + { + stPhECU_oold_grp_shape[i] = stPhECU_old_grp_shape[i]; + } + } + } /*bfi*/ + return; } -void processPlcUpdateSpec_fl(LC3_FLOAT *q_d_prev, LC3_FLOAT *q_d_fl_c, LC3_INT32 yLen) +void processPlcUpdateSpec_fl( LC3_FLOAT *q_d_prev, LC3_FLOAT *q_d_fl_c, LC3_INT32 yLen ) { - move_float(q_d_prev, q_d_fl_c, yLen); + move_float( q_d_prev, q_d_fl_c, yLen ); } - diff --git a/lib_lc3plus/quantize_spec.c b/lib_lc3plus/quantize_spec.c index 7886b4586d..3a7b051cb4 100644 --- a/lib_lc3plus/quantize_spec.c +++ b/lib_lc3plus/quantize_spec.c @@ -1,194 +1,228 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -static LC3_INT sign(LC3_FLOAT x); +static LC3_INT sign( LC3_FLOAT x ); -LC3_INT sign(LC3_FLOAT x) +LC3_INT sign( LC3_FLOAT x ) { - if (x > 0) + if ( x > 0 ) return 1; - if (x < 0) + if ( x < 0 ) return -1; return 0; } -void processQuantizeSpec_fl(LC3_FLOAT x[], LC3_FLOAT gain, LC3_INT xq[], LC3_INT nt, LC3_INT totalBits, LC3_INT* nbits, LC3_INT* nbits2, LC3_INT fs, - LC3_INT* lastnzout, LC3_INT* codingdata, LC3_INT* lsbMode, LC3_INT mode, LC3_INT target, LC3_INT hrmode) +void processQuantizeSpec_fl( LC3_FLOAT x[], LC3_FLOAT gain, LC3_INT xq[], LC3_INT nt, LC3_INT totalBits, LC3_INT *nbits, LC3_INT *nbits2, LC3_INT fs, LC3_INT *lastnzout, LC3_INT *codingdata, LC3_INT *lsbMode, LC3_INT mode, LC3_INT target, LC3_INT hrmode ) { LC3_INT rateFlag = 0, i = 0, lastnz2 = 0, m = 0, maxlev = 0, k = 0; LC3_INT nbits_lsb = 0; - LC3_INT c = 0; + LC3_INT c = 0; LC3_INT a = 0, b = 0, lev1 = 0, sym = 0, t = 0, pki = 0; LC3_INT a1_msb = 0, b1_msb = 0; LC3_INT lastnz = 1; LC3_FLOAT offset = 0.375; - if (hrmode) + if ( hrmode ) { offset = 0.5; } /* Quantization */ - for (i = 0; i < nt; i++) { - xq[i] = trunc(x[i] / gain + offset * sign(x[i])); - if (hrmode == 0) { - assert(xq[i] <= 32767 && xq[i] >= -32768); + for ( i = 0; i < nt; i++ ) + { + xq[i] = trunc( x[i] / gain + offset * sign( x[i] ) ); + if ( hrmode == 0 ) + { + assert( xq[i] <= 32767 && xq[i] >= -32768 ); } } /* Rate flag */ - if ((fs < 48000 && totalBits > 320 + (fs / 8000 - 2) * 160) || (fs == 48000 && totalBits > 800)) { + if ( ( fs < 48000 && totalBits > 320 + ( fs / 8000 - 2 ) * 160 ) || ( fs == 48000 && totalBits > 800 ) ) + { rateFlag = 512; } /* Init */ - if (mode == 0 && ((fs < 48000 && totalBits >= 640 + (fs / 8000 - 2) * 160) || (fs == 48000 && totalBits >= 1120))) { + if ( mode == 0 && ( ( fs < 48000 && totalBits >= 640 + ( fs / 8000 - 2 ) * 160 ) || ( fs == 48000 && totalBits >= 1120 ) ) ) + { mode = 1; } /* Last non-zero 2-tuple */ - for (i = nt - 2; i >= 2; i = i - 2) { - if (xq[i + 1] != 0 || xq[i] != 0) { + for ( i = nt - 2; i >= 2; i = i - 2 ) + { + if ( xq[i + 1] != 0 || xq[i] != 0 ) + { lastnz = i + 1; break; } } - if (mode < 0) { + if ( mode < 0 ) + { lastnz2 = lastnz + 1; - } else { + } + else + { lastnz2 = 2; } - *nbits = 0; + *nbits = 0; *nbits2 = 0; /* Calculate number of estimated bits */ - for (k = 0; k < lastnz; k = k + 2) { + for ( k = 0; k < lastnz; k = k + 2 ) + { t = c + rateFlag; - if (k > nt / 2) { + if ( k > nt / 2 ) + { t += 256; } codingdata[0] = t; - a = abs(xq[k]); - b = abs(xq[k + 1]); - m = MAX(a, b); + a = abs( xq[k] ); + b = abs( xq[k + 1] ); + m = MAX( a, b ); - if (m == 0) { + if ( m == 0 ) + { maxlev = -1; - } else { - maxlev = 29 - (clz_func(MAX(m, 3)) - 1); + } + else + { + maxlev = 29 - ( clz_func( MAX( m, 3 ) ) - 1 ); } codingdata[1] = maxlev; - if (mode <= 0) { - *nbits = *nbits + MIN(a, 1) * 2048; - *nbits = *nbits + MIN(b, 1) * 2048; + if ( mode <= 0 ) + { + *nbits = *nbits + MIN( a, 1 ) * 2048; + *nbits = *nbits + MIN( b, 1 ) * 2048; } lev1 = 0; - while (MAX(a, b) >= 4) { - pki = ari_spec_lookup_fl[t + lev1 * 1024]; + while ( MAX( a, b ) >= 4 ) + { + pki = ari_spec_lookup_fl[t + lev1 * 1024]; *nbits = *nbits + ari_spec_bits_fl[pki][16]; - if (lev1 == 0 && mode > 0) { + if ( lev1 == 0 && mode > 0 ) + { nbits_lsb += 2; - } else { + } + else + { *nbits = *nbits + 2 * 2048; } - a = a >> 1; - b = b >> 1; - lev1 = MIN(lev1 + 1, 3); + a = a >> 1; + b = b >> 1; + lev1 = MIN( lev1 + 1, 3 ); } - pki = ari_spec_lookup_fl[t + lev1 * 1024]; - sym = a + 4 * b; + pki = ari_spec_lookup_fl[t + lev1 * 1024]; + sym = a + 4 * b; codingdata[2] = sym; codingdata += 3; *nbits = *nbits + ari_spec_bits_fl[pki][sym]; - if (mode > 0) { - a1_msb = abs(xq[k]); - b1_msb = abs(xq[k + 1]); + if ( mode > 0 ) + { + a1_msb = abs( xq[k] ); + b1_msb = abs( xq[k + 1] ); - if (lev1 > 0) { + if ( lev1 > 0 ) + { a1_msb = a1_msb >> 1; b1_msb = b1_msb >> 1; - if (a1_msb == 0 && xq[k] != 0) { + if ( a1_msb == 0 && xq[k] != 0 ) + { nbits_lsb++; } - if (b1_msb == 0 && xq[k + 1] != 0) { + if ( b1_msb == 0 && xq[k + 1] != 0 ) + { nbits_lsb++; } } - *nbits = *nbits + MIN(a1_msb, 1) * 2048; - *nbits = *nbits + MIN(b1_msb, 1) * 2048; + *nbits = *nbits + MIN( a1_msb, 1 ) * 2048; + *nbits = *nbits + MIN( b1_msb, 1 ) * 2048; } - if (mode >= 0 && (abs(xq[k]) != 0 || abs(xq[k + 1]) != 0) && *nbits <= target * 2048) { + if ( mode >= 0 && ( abs( xq[k] ) != 0 || abs( xq[k + 1] ) != 0 ) && *nbits <= target * 2048 ) + { lastnz2 = k + 2; *nbits2 = *nbits; } lev1 = lev1 - 1; - if (lev1 <= 0) { - t = 1 + (a + b) * (lev1 + 2); - } else { + if ( lev1 <= 0 ) + { + t = 1 + ( a + b ) * ( lev1 + 2 ); + } + else + { t = 13 + lev1; } - c = (c & 15) * 16 + t; + c = ( c & 15 ) * 16 + t; } /* Number of bits */ - *nbits = ceil((LC3_FLOAT)*nbits / 2048.0); + *nbits = ceil( (LC3_FLOAT) *nbits / 2048.0 ); - if (mode >= 0) { - *nbits2 = ceil((LC3_FLOAT)*nbits2 / 2048.0); - } else { + if ( mode >= 0 ) + { + *nbits2 = ceil( (LC3_FLOAT) *nbits2 / 2048.0 ); + } + else + { *nbits2 = *nbits; } - if (mode > 0) { + if ( mode > 0 ) + { *nbits += nbits_lsb; *nbits2 += nbits_lsb; } /* Truncation of high-frequency coefficients */ - for (i = lastnz2; i <= lastnz; i++) { + for ( i = lastnz2; i <= lastnz; i++ ) + { xq[i] = 0; } /* Truncation of LSBs */ - if (mode > 0 && *nbits > target) { + if ( mode > 0 && *nbits > target ) + { *lsbMode = 1; - } else { + } + else + { *lsbMode = 0; } diff --git a/lib_lc3plus/reorder_bitstream.c b/lib_lc3plus/reorder_bitstream.c index 77b50d7a13..a5f3205ff3 100644 --- a/lib_lc3plus/reorder_bitstream.c +++ b/lib_lc3plus/reorder_bitstream.c @@ -1,41 +1,40 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -void processReorderBitstream_fl(LC3_UINT8* bytes, LC3_INT32 n_pccw, LC3_INT32 n_pc, LC3_INT32 b_left, LC3_INT32 len) +void processReorderBitstream_fl( LC3_UINT8 *bytes, LC3_INT32 n_pccw, LC3_INT32 n_pc, LC3_INT32 b_left, LC3_INT32 len ) { LC3_UINT8 bytes_local[MAX_NBYTES2]; LC3_INT32 i, block_bytes; - - assert(b_left > 0); - - memcpy(bytes_local, bytes, len * sizeof(LC3_UINT8)); - - if (n_pccw == 0) + + assert( b_left > 0 ); + + memcpy( bytes_local, bytes, len * sizeof( LC3_UINT8 ) ); + + if ( n_pccw == 0 ) { return; } - - block_bytes = ceil((LC3_FLOAT) n_pc / 2.0); - - for (i = 0; i < block_bytes; i++) + + block_bytes = ceil( (LC3_FLOAT) n_pc / 2.0 ); + + for ( i = 0; i < block_bytes; i++ ) { bytes[i] = bytes_local[b_left + i]; } - - for (i = 0; i < b_left; i++) + + for ( i = 0; i < b_left; i++ ) { bytes[block_bytes + i] = bytes_local[i]; } } - diff --git a/lib_lc3plus/resamp12k8.c b/lib_lc3plus/resamp12k8.c index 0cab5daae9..3c40b20082 100644 --- a/lib_lc3plus/resamp12k8.c +++ b/lib_lc3plus/resamp12k8.c @@ -1,23 +1,22 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -void process_resamp12k8_fl(LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC3_INT mem_in_len, LC3_FLOAT mem_50[], LC3_FLOAT mem_out[], - LC3_INT mem_out_len, LC3_FLOAT y[], LC3_INT* y_len, LC3_INT fs_idx, LC3_INT frame_dms, LC3_INT fs) +void process_resamp12k8_fl( LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC3_INT mem_in_len, LC3_FLOAT mem_50[], LC3_FLOAT mem_out[], LC3_INT mem_out_len, LC3_FLOAT y[], LC3_INT *y_len, LC3_INT fs_idx, LC3_INT frame_dms, LC3_INT fs ) { - - LC3_INT len_12k8 = 0, N12k8 = 0, i = 0, k = 0; - LC3_FLOAT mac = 0, buf_out[120 + MAX_LEN] = {0}, bufdown[128] = {0}, buf[120 + MAX_LEN] = {0}; + + LC3_INT len_12k8 = 0, N12k8 = 0, i = 0, k = 0; + LC3_FLOAT mac = 0, buf_out[120 + MAX_LEN] = { 0 }, bufdown[128] = { 0 }, buf[120 + MAX_LEN] = { 0 }; LC3_INT32 index_int, index_frac, resamp_upfac, resamp_delay, resamp_off_int, resamp_off_frac; LC3_FLOAT u_11, u_21, u_1, u_2; @@ -25,7 +24,7 @@ void process_resamp12k8_fl(LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC3 const LC3_FLOAT *filt_input, *filt_coeff; - switch (frame_dms) + switch ( frame_dms ) { case 25: len_12k8 = LEN_12K8 / 4; @@ -39,42 +38,42 @@ void process_resamp12k8_fl(LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC3 } *y_len = len_12k8; - N12k8 = x_len * 12800 / fs; + N12k8 = x_len * 12800 / fs; /* Init Input Buffer */ - memmove(buf, mem_in, mem_in_len * sizeof(LC3_FLOAT)); - memmove(&buf[mem_in_len], x, x_len * sizeof(LC3_FLOAT)); - memmove(mem_in, &buf[x_len], mem_in_len * sizeof(LC3_FLOAT)); - + memmove( buf, mem_in, mem_in_len * sizeof( LC3_FLOAT ) ); + memmove( &buf[mem_in_len], x, x_len * sizeof( LC3_FLOAT ) ); + memmove( mem_in, &buf[x_len], mem_in_len * sizeof( LC3_FLOAT ) ); filter = lp_filter[fs_idx]; /* Upsampling & Low-pass Filtering & Downsampling */ - index_int = 1; + index_int = 1; index_frac = 0; - resamp_upfac = resamp_params[fs_idx][0]; - resamp_delay = resamp_params[fs_idx][1]; - resamp_off_int = resamp_params[fs_idx][2]; + resamp_upfac = resamp_params[fs_idx][0]; + resamp_delay = resamp_params[fs_idx][1]; + resamp_off_int = resamp_params[fs_idx][2]; resamp_off_frac = resamp_params[fs_idx][3]; k = 0; - for (i = 0; i < N12k8; i++) { + for ( i = 0; i < N12k8; i++ ) + { filt_input = &buf[index_int]; filt_coeff = &filter[index_frac * resamp_delay * 2]; - mac = mac_loop(filt_input, filt_coeff, (2 * resamp_delay)); - + mac = mac_loop( filt_input, filt_coeff, ( 2 * resamp_delay ) ); + bufdown[k++] = mac; - - index_int = index_int + resamp_off_int; + + index_int = index_int + resamp_off_int; index_frac = index_frac + resamp_off_frac; - - if ((resamp_upfac - index_frac) <= 0) + + if ( ( resamp_upfac - index_frac ) <= 0 ) { - index_int = index_int + 1; + index_int = index_int + 1; index_frac = index_frac - resamp_upfac; } } @@ -84,24 +83,25 @@ void process_resamp12k8_fl(LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC3 u_11 = mem_50[0]; u_21 = mem_50[1]; - for (i = 0; i < len_12k8; i++) { - LC3_FLOAT y1 = (highpass50_filt_b[0] * bufdown[i] + u_11); - u_1 = (highpass50_filt_b[1] * bufdown[i] + u_21) - highpass50_filt_a[1] * y1; - u_2 = highpass50_filt_b[2] * bufdown[i] - highpass50_filt_a[2] * y1; - u_11 = u_1; - u_21 = u_2; - bufdown[i] = (LC3_FLOAT)y1; + for ( i = 0; i < len_12k8; i++ ) + { + LC3_FLOAT y1 = ( highpass50_filt_b[0] * bufdown[i] + u_11 ); + u_1 = ( highpass50_filt_b[1] * bufdown[i] + u_21 ) - highpass50_filt_a[1] * y1; + u_2 = highpass50_filt_b[2] * bufdown[i] - highpass50_filt_a[2] * y1; + u_11 = u_1; + u_21 = u_2; + bufdown[i] = (LC3_FLOAT) y1; } - mem_50[0] = (LC3_FLOAT)u_11; - mem_50[1] = (LC3_FLOAT)u_21; + mem_50[0] = (LC3_FLOAT) u_11; + mem_50[1] = (LC3_FLOAT) u_21; /* Output Buffer */ - memmove(buf_out, mem_out, mem_out_len * sizeof(LC3_FLOAT)); + memmove( buf_out, mem_out, mem_out_len * sizeof( LC3_FLOAT ) ); - memmove(&buf_out[mem_out_len], bufdown, len_12k8 * sizeof(LC3_FLOAT)); + memmove( &buf_out[mem_out_len], bufdown, len_12k8 * sizeof( LC3_FLOAT ) ); - memmove(y, buf_out, (*y_len + 1) * sizeof(LC3_FLOAT)); + memmove( y, buf_out, ( *y_len + 1 ) * sizeof( LC3_FLOAT ) ); - memmove(mem_out, &buf_out[N12k8], mem_out_len * sizeof(LC3_FLOAT)); + memmove( mem_out, &buf_out[N12k8], mem_out_len * sizeof( LC3_FLOAT ) ); } diff --git a/lib_lc3plus/residual_coding.c b/lib_lc3plus/residual_coding.c index 42094d275f..844057cf8f 100644 --- a/lib_lc3plus/residual_coding.c +++ b/lib_lc3plus/residual_coding.c @@ -1,74 +1,71 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -void processResidualCoding_fl(LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gain, LC3_INT L_spec, LC3_INT targetBits, LC3_INT nBits, uint8_t* resBits, LC3_INT* numResBits - , LC3_INT hrmode -) +void processResidualCoding_fl( LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gain, LC3_INT L_spec, LC3_INT targetBits, LC3_INT nBits, uint8_t *resBits, LC3_INT *numResBits, LC3_INT hrmode ) { LC3_INT n = 0, m = 0, k = 0; - LC3_INT iter=0; + LC3_INT iter = 0; LC3_FLOAT offset; LC3_INT iter_max = 1; - LC3_INT nz_idx[MAX_LEN] = {0}; + LC3_INT nz_idx[MAX_LEN] = { 0 }; LC3_INT N_nz = 0, idx = 0; - memset(resBits, 0, MAX_RESBITS_LEN); + memset( resBits, 0, MAX_RESBITS_LEN ); m = targetBits - nBits + 4; - if (hrmode) + if ( hrmode ) { m += 10; } - assert(m <= MAX_RESBITS); + assert( m <= MAX_RESBITS ); offset = .25; - if (hrmode) + if ( hrmode ) { iter_max = EXT_RES_ITER_MAX; - } - for (k = 0; k < L_spec; k ++) + for ( k = 0; k < L_spec; k++ ) { - if (xq[k]) + if ( xq[k] ) { - nz_idx[N_nz ++] = k; + nz_idx[N_nz++] = k; } } - while (iter < iter_max && n < m) + while ( iter < iter_max && n < m ) { k = 0; - while (k < N_nz && n < m) + while ( k < N_nz && n < m ) { idx = nz_idx[k]; - - if (x[idx] >= (LC3_FLOAT)xq[idx] * gain) + + if ( x[idx] >= (LC3_FLOAT) xq[idx] * gain ) { - resBits[n >> 3] |= 1 << (n & 7); + resBits[n >> 3] |= 1 << ( n & 7 ); x[idx] -= gain * offset; } else { - resBits[n >> 3] &= ~(1 << (n & 7)); + resBits[n >> 3] &= ~( 1 << ( n & 7 ) ); x[idx] += gain * offset; } - + n++; - + k++; } - iter ++; + iter++; offset *= .5; } diff --git a/lib_lc3plus/residual_decoding.c b/lib_lc3plus/residual_decoding.c index 97fd94afc3..05f257e645 100644 --- a/lib_lc3plus/residual_decoding.c +++ b/lib_lc3plus/residual_decoding.c @@ -1,29 +1,27 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -void processResidualDecoding_fl(LC3_INT* bitsRead, LC3_FLOAT x[], LC3_INT L_spec, uint8_t prm[], LC3_INT resQBits - , LC3_INT hrmode -) +void processResidualDecoding_fl( LC3_INT *bitsRead, LC3_FLOAT x[], LC3_INT L_spec, uint8_t prm[], LC3_INT resQBits, LC3_INT hrmode ) { LC3_INT k = 0, n = 0; LC3_FLOAT offset1 = 0, offset2 = 0; LC3_FLOAT offset = 0; - LC3_INT nz_idx[MAX_LEN] = {0}; + LC3_INT nz_idx[MAX_LEN] = { 0 }; LC3_INT N_nz = 0, idx = 0; LC3_INT iter = 0, iter_max = 1; - if (hrmode) + if ( hrmode ) { iter_max = EXT_RES_ITER_MAX; offset = offset1 = offset2 = 0.25; @@ -34,62 +32,72 @@ void processResidualDecoding_fl(LC3_INT* bitsRead, LC3_FLOAT x[], LC3_INT L_spec offset2 = 0.3125; } - if (hrmode) + if ( hrmode ) { /* enumerat non-zero coefficients */ - for (k = 0; k < L_spec; k ++) + for ( k = 0; k < L_spec; k++ ) { - if (x[k]) + if ( x[k] ) { - nz_idx[N_nz ++] = k; + nz_idx[N_nz++] = k; } } /* apply residual corrections */ - while (n < resQBits && iter < iter_max) + while ( n < resQBits && iter < iter_max ) { - for (k = 0; k < N_nz; k ++) + for ( k = 0; k < N_nz; k++ ) { idx = nz_idx[k]; - - if ((prm[n >> 3] & 1 << (n & 7)) == 0) + + if ( ( prm[n >> 3] & 1 << ( n & 7 ) ) == 0 ) { x[idx] -= offset; } else { - + x[idx] += offset; } - if (++n >= resQBits) + if ( ++n >= resQBits ) { break; } } offset /= 2; - iter ++; + iter++; } } else { - while (k < L_spec && n < resQBits) { - if (x[k] != 0) { - if ((prm[n >> 3] & 1 << (n & 7)) == 0) + while ( k < L_spec && n < resQBits ) + { + if ( x[k] != 0 ) + { + if ( ( prm[n >> 3] & 1 << ( n & 7 ) ) == 0 ) { - if (x[k] > 0) { + if ( x[k] > 0 ) + { x[k] -= offset1; - } else { + } + else + { x[k] -= offset2; } - } else { - if (x[k] > 0) { + } + else + { + if ( x[k] > 0 ) + { x[k] += offset2; - } else { + } + else + { x[k] += offset1; } } n++; } - + k++; } } diff --git a/lib_lc3plus/setup_com_lc3.c b/lib_lc3plus/setup_com_lc3.c index 17054d1ffc..95c6271dcf 100644 --- a/lib_lc3plus/setup_com_lc3.c +++ b/lib_lc3plus/setup_com_lc3.c @@ -1,30 +1,29 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "functions.h" #include "options.h" -LC3_FLOAT array_max_abs(LC3_FLOAT *in, LC3_INT32 len) +LC3_FLOAT array_max_abs( LC3_FLOAT *in, LC3_INT32 len ) { - LC3_FLOAT max; - LC3_INT32 i; - - max = LC3_FABS(in[0]); - - for (i = 0; i < len; i++) + LC3_FLOAT max; + LC3_INT32 i; + + max = LC3_FABS( in[0] ); + + for ( i = 0; i < len; i++ ) { - if (LC3_FABS(in[i]) > LC3_FABS(max)) + if ( LC3_FABS( in[i] ) > LC3_FABS( max ) ) { - max = LC3_FABS(in[i]); + max = LC3_FABS( in[i] ); } } - + return max; } - diff --git a/lib_lc3plus/setup_dec_lc3.c b/lib_lc3plus/setup_dec_lc3.c index c14309720e..310e8f530d 100644 --- a/lib_lc3plus/setup_dec_lc3.c +++ b/lib_lc3plus/setup_dec_lc3.c @@ -1,12 +1,12 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "setup_dec_lc3.h" @@ -15,52 +15,54 @@ #include /* if decoder is null only size is reported */ -# include "fft/iis_fft.h" +#include "fft/iis_fft.h" -int alloc_decoder(LC3PLUS_Dec* decoder, int samplerate, int channels) +int alloc_decoder( LC3PLUS_Dec *decoder, int samplerate, int channels ) { - int ch = 0; - size_t size = sizeof(LC3PLUS_Dec); - size_t frame_len = DYN_MAX_LEN_EXT(samplerate); - - void *PlcAdvSetup = NULL; - LC3_FLOAT *pcmbufHist, *harmonicBuf; - LC3_FLOAT *PhECU_oold_grp_shape, *PhECU_old_grp_shape; - LC3_FLOAT *PhECU_xfp; - Complex *PhECU_X_sav_m; - LC3_INT32 *PhECU_plocs; - LC3_FLOAT *PhECU_f0est, *PhECU_mag_chg_1st, *PhECU_Xavg; - LC3_FLOAT *sine_table1_phecu, *sine_table2_phecu; - HANDLE_IIS_FFT handle_fft_phaseecu; - HANDLE_IIS_FFT handle_ifft_phaseecu; - LC3_FLOAT *q_old_res; - - for (ch = 0; ch < channels; ch++) { - DecSetup* setup = balloc(decoder, &size, sizeof(DecSetup)); - - size_t max_pitch = ceilf(228.0 * CODEC_FS(samplerate) / 12800.0); - size_t pcm_plc_len = max_pitch + frame_len; - pcmbufHist = balloc(decoder, &size, sizeof(LC3_FLOAT) * pcm_plc_len); - harmonicBuf = balloc(decoder, &size, sizeof(LC3_FLOAT) * max_pitch); - PlcAdvSetup = balloc(decoder, &size, sizeof(*setup->PlcAdvSetup)); - PhECU_oold_grp_shape = balloc(decoder, &size, sizeof(LC3_FLOAT) *MAX_LGW); /* BASOP Word16 PhECU_oold_grp_shape_fx[MAX_LGW]; */ - PhECU_old_grp_shape = balloc(decoder, &size, sizeof(LC3_FLOAT) *MAX_LGW); /* BASOP Word16 PhECU_old_grp_shape_fx[MAX_LGW] ; */ - PhECU_xfp = balloc(decoder, &size, sizeof(LC3_FLOAT) *(frame_len * 16 / 10)); - PhECU_X_sav_m = balloc(decoder, &size, sizeof(Complex) *(((frame_len * 16 / 10) / 2) + 1));/*MAX_PLC_LMSPEC*/ - PhECU_plocs = balloc(decoder, &size, sizeof(LC3_INT32) * (((frame_len * 16 / 10) / 4) + 1 + 1)); /* BASOP Word16 *PhECU_plocs; */ - - handle_fft_phaseecu = balloc(decoder, &size, sizeof(IIS_FFT) * 1); - handle_ifft_phaseecu = balloc(decoder, &size, sizeof(IIS_FFT) * 1); - PhECU_f0est = balloc(decoder, &size, sizeof(LC3_FLOAT) * (((frame_len * 16 / 10) / 4) + 1)); /*BASOP Word32 *PhECU_f0est;*/ - PhECU_mag_chg_1st = balloc(decoder, &size, sizeof(LC3_FLOAT) *MAX_LGW); /* BASOP Word16 PhECU_mag_chg_1st[MAX_LGW];*/ - PhECU_Xavg = balloc(decoder, &size, sizeof(LC3_FLOAT) * MAX_LGW); /* BASOP Word16 PhECU_Xavg[MAX_LGW] ; */ - - sine_table1_phecu = balloc(decoder, &size, sizeof(LC3_FLOAT) * (((CODEC_FS(samplerate) * 16) / 1000) / 2 + 1)); - sine_table2_phecu = balloc(decoder, &size, sizeof(LC3_FLOAT) * (((CODEC_FS(samplerate) * 16) / 1000) / 2 + 1)); - - q_old_res = balloc(decoder, &size, sizeof(LC3_FLOAT) * frame_len); - - if (decoder) { + int ch = 0; + size_t size = sizeof( LC3PLUS_Dec ); + size_t frame_len = DYN_MAX_LEN_EXT( samplerate ); + + void *PlcAdvSetup = NULL; + LC3_FLOAT *pcmbufHist, *harmonicBuf; + LC3_FLOAT *PhECU_oold_grp_shape, *PhECU_old_grp_shape; + LC3_FLOAT *PhECU_xfp; + Complex *PhECU_X_sav_m; + LC3_INT32 *PhECU_plocs; + LC3_FLOAT *PhECU_f0est, *PhECU_mag_chg_1st, *PhECU_Xavg; + LC3_FLOAT *sine_table1_phecu, *sine_table2_phecu; + HANDLE_IIS_FFT handle_fft_phaseecu; + HANDLE_IIS_FFT handle_ifft_phaseecu; + LC3_FLOAT *q_old_res; + + for ( ch = 0; ch < channels; ch++ ) + { + DecSetup *setup = balloc( decoder, &size, sizeof( DecSetup ) ); + + size_t max_pitch = ceilf( 228.0 * CODEC_FS( samplerate ) / 12800.0 ); + size_t pcm_plc_len = max_pitch + frame_len; + pcmbufHist = balloc( decoder, &size, sizeof( LC3_FLOAT ) * pcm_plc_len ); + harmonicBuf = balloc( decoder, &size, sizeof( LC3_FLOAT ) * max_pitch ); + PlcAdvSetup = balloc( decoder, &size, sizeof( *setup->PlcAdvSetup ) ); + PhECU_oold_grp_shape = balloc( decoder, &size, sizeof( LC3_FLOAT ) * MAX_LGW ); /* BASOP Word16 PhECU_oold_grp_shape_fx[MAX_LGW]; */ + PhECU_old_grp_shape = balloc( decoder, &size, sizeof( LC3_FLOAT ) * MAX_LGW ); /* BASOP Word16 PhECU_old_grp_shape_fx[MAX_LGW] ; */ + PhECU_xfp = balloc( decoder, &size, sizeof( LC3_FLOAT ) * ( frame_len * 16 / 10 ) ); + PhECU_X_sav_m = balloc( decoder, &size, sizeof( Complex ) * ( ( ( frame_len * 16 / 10 ) / 2 ) + 1 ) ); /*MAX_PLC_LMSPEC*/ + PhECU_plocs = balloc( decoder, &size, sizeof( LC3_INT32 ) * ( ( ( frame_len * 16 / 10 ) / 4 ) + 1 + 1 ) ); /* BASOP Word16 *PhECU_plocs; */ + + handle_fft_phaseecu = balloc( decoder, &size, sizeof( IIS_FFT ) * 1 ); + handle_ifft_phaseecu = balloc( decoder, &size, sizeof( IIS_FFT ) * 1 ); + PhECU_f0est = balloc( decoder, &size, sizeof( LC3_FLOAT ) * ( ( ( frame_len * 16 / 10 ) / 4 ) + 1 ) ); /*BASOP Word32 *PhECU_f0est;*/ + PhECU_mag_chg_1st = balloc( decoder, &size, sizeof( LC3_FLOAT ) * MAX_LGW ); /* BASOP Word16 PhECU_mag_chg_1st[MAX_LGW];*/ + PhECU_Xavg = balloc( decoder, &size, sizeof( LC3_FLOAT ) * MAX_LGW ); /* BASOP Word16 PhECU_Xavg[MAX_LGW] ; */ + + sine_table1_phecu = balloc( decoder, &size, sizeof( LC3_FLOAT ) * ( ( ( CODEC_FS( samplerate ) * 16 ) / 1000 ) / 2 + 1 ) ); + sine_table2_phecu = balloc( decoder, &size, sizeof( LC3_FLOAT ) * ( ( ( CODEC_FS( samplerate ) * 16 ) / 1000 ) / 2 + 1 ) ); + + q_old_res = balloc( decoder, &size, sizeof( LC3_FLOAT ) * frame_len ); + + if ( decoder ) + { decoder->channel_setup[ch] = setup; setup->PlcAdvSetup = PlcAdvSetup; @@ -77,117 +79,126 @@ int alloc_decoder(LC3PLUS_Dec* decoder, int samplerate, int channels) setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Xavg = PhECU_Xavg; setup->PlcAdvSetup->PlcPhEcuSetup.handle_fft_phaseecu = handle_fft_phaseecu; setup->PlcAdvSetup->PlcPhEcuSetup.handle_ifft_phaseecu = handle_ifft_phaseecu; - + setup->PlcAdvSetup->PlcPhEcuSetup.handle_fft_phaseecu->sine_table = sine_table1_phecu; setup->PlcAdvSetup->PlcPhEcuSetup.handle_ifft_phaseecu->sine_table = sine_table2_phecu; - - setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot = (CODEC_FS(samplerate) * 16) / 1000; - real_fft_init(&(setup->PlcAdvSetup->PlcPhEcuSetup.PhEcu_Fft), setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot, &(setup->PlcAdvSetup->PlcPhEcuSetup.handle_fft_phaseecu)); - real_ifft_init(&(setup->PlcAdvSetup->PlcPhEcuSetup.PhEcu_Ifft), setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot, &(setup->PlcAdvSetup->PlcPhEcuSetup.handle_ifft_phaseecu)); + + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot = ( CODEC_FS( samplerate ) * 16 ) / 1000; + real_fft_init( &( setup->PlcAdvSetup->PlcPhEcuSetup.PhEcu_Fft ), setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot, &( setup->PlcAdvSetup->PlcPhEcuSetup.handle_fft_phaseecu ) ); + real_ifft_init( &( setup->PlcAdvSetup->PlcPhEcuSetup.PhEcu_Ifft ), setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot, &( setup->PlcAdvSetup->PlcPhEcuSetup.handle_ifft_phaseecu ) ); setup->statePC.q_old_res = q_old_res; } } - return (int)size; + return (int) size; } -LC3PLUS_Error FillDecSetup(LC3PLUS_Dec* decoder, int samplerate, int channels, LC3PLUS_PlcMode plc_mode - , int hrmode -) +LC3PLUS_Error FillDecSetup( LC3PLUS_Dec *decoder, int samplerate, int channels, LC3PLUS_PlcMode plc_mode, int hrmode ) { - memset(decoder, 0, lc3plus_dec_get_size(samplerate, channels)); - alloc_decoder(decoder, samplerate, channels); + memset( decoder, 0, lc3plus_dec_get_size( samplerate, channels ) ); + alloc_decoder( decoder, samplerate, channels ); - decoder->fs = CODEC_FS(samplerate); + decoder->fs = CODEC_FS( samplerate ); decoder->fs_out = samplerate; - decoder->fs_idx = FS2FS_IDX(decoder->fs); + decoder->fs_idx = FS2FS_IDX( decoder->fs ); decoder->plcMeth = plc_mode; - + decoder->hrmode = hrmode != 0; - - if (decoder->fs_idx > 4) { + + if ( decoder->fs_idx > 4 ) + { decoder->fs_idx = 5; } - decoder->channels = channels; - decoder->frame_ms = 10; - decoder->frame_dms = 100; + decoder->channels = channels; + decoder->frame_ms = 10; + decoder->frame_dms = 100; decoder->BW_cutoff_bits = BW_cutoff_bits_all[decoder->fs_idx]; - - if (decoder->fs == 8000) { + + if ( decoder->fs == 8000 ) + { decoder->tilt = 14; - } else if (decoder->fs == 16000) { + } + else if ( decoder->fs == 16000 ) + { decoder->tilt = 18; - } else if (decoder->fs == 24000) { + } + else if ( decoder->fs == 24000 ) + { decoder->tilt = 22; - } else if (decoder->fs == 32000) { + } + else if ( decoder->fs == 32000 ) + { decoder->tilt = 26; - } else if (decoder->fs == 48000) { + } + else if ( decoder->fs == 48000 ) + { decoder->tilt = 30; } - else if (decoder->fs == 96000) { + else if ( decoder->fs == 96000 ) + { decoder->tilt = 34; } - set_dec_frame_params(decoder); + set_dec_frame_params( decoder ); + + lc3plus_dec_set_ep_enabled( decoder, 0 ); - lc3plus_dec_set_ep_enabled(decoder, 0); - return LC3PLUS_OK; } /* set frame config params */ -void set_dec_frame_params(LC3PLUS_Dec* decoder) +void set_dec_frame_params( LC3PLUS_Dec *decoder ) { int ch = 0; - - if (decoder->fs_idx == 5) + + if ( decoder->fs_idx == 5 ) { decoder->hrmode = 1; } - decoder->frame_length = ceil(decoder->fs * 10 / 1000); /* fs * 0.01*2^6 */ - if (decoder->hrmode == 1) + decoder->frame_length = ceil( decoder->fs * 10 / 1000 ); /* fs * 0.01*2^6 */ + if ( decoder->hrmode == 1 ) { decoder->yLen = decoder->frame_length; } else { - decoder->yLen = MIN(MAX_BW, decoder->frame_length); + decoder->yLen = MIN( MAX_BW, decoder->frame_length ); } decoder->bands_number = 64; - if (decoder->frame_ms == 2.5) + if ( decoder->frame_ms == 2.5 ) { decoder->frame_length = decoder->frame_length >> 2; decoder->yLen /= 4; - if (decoder->hrmode) + if ( decoder->hrmode ) { decoder->bands_number = bands_number_2_5ms_HR[decoder->fs_idx]; - } + } else { decoder->bands_number = bands_number_2_5ms[decoder->fs_idx]; } } - if (decoder->frame_ms == 5) + if ( decoder->frame_ms == 5 ) { decoder->frame_length = decoder->frame_length >> 1; decoder->yLen /= 2; decoder->bands_number = bands_number_5ms[decoder->fs_idx]; } - if (decoder->hrmode) + if ( decoder->hrmode ) { - decoder->BW_cutoff_bits = 0; + decoder->BW_cutoff_bits = 0; } else { - decoder->BW_cutoff_bits = BW_cutoff_bits_all[decoder->fs_idx]; + decoder->BW_cutoff_bits = BW_cutoff_bits_all[decoder->fs_idx]; } - if (decoder->frame_ms == 10) + if ( decoder->frame_ms == 10 ) { - if (decoder->hrmode) + if ( decoder->hrmode ) { decoder->bands_offset = ACC_COEFF_PER_BAND_HR[decoder->fs_idx]; } @@ -195,11 +206,11 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder) { decoder->bands_offset = ACC_COEFF_PER_BAND[decoder->fs_idx]; } - decoder->cutoffBins = BW_cutoff_bin_all; + decoder->cutoffBins = BW_cutoff_bin_all; } - else if (decoder->frame_ms == 2.5) + else if ( decoder->frame_ms == 2.5 ) { - if (decoder->hrmode) + if ( decoder->hrmode ) { decoder->bands_offset = ACC_COEFF_PER_BAND_2_5ms_HR[decoder->fs_idx]; } @@ -207,11 +218,11 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder) { decoder->bands_offset = ACC_COEFF_PER_BAND_2_5ms[decoder->fs_idx]; } - decoder->cutoffBins = BW_cutoff_bin_all_2_5ms; + decoder->cutoffBins = BW_cutoff_bin_all_2_5ms; } - else if (decoder->frame_ms == 5) + else if ( decoder->frame_ms == 5 ) { - if (decoder->hrmode) + if ( decoder->hrmode ) { decoder->bands_offset = ACC_COEFF_PER_BAND_5ms_HR[decoder->fs_idx]; } @@ -219,86 +230,94 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder) { decoder->bands_offset = ACC_COEFF_PER_BAND_5ms[decoder->fs_idx]; } - decoder->cutoffBins = BW_cutoff_bin_all_5ms; + decoder->cutoffBins = BW_cutoff_bin_all_5ms; } - - decoder->n_bandsPLC = MIN(decoder->frame_length, 80); - - if (decoder->frame_ms == 10) + + decoder->n_bandsPLC = MIN( decoder->frame_length, 80 ); + + if ( decoder->frame_ms == 10 ) { decoder->bands_offsetPLC = ACC_COEFF_PER_BAND_PLC[decoder->fs_idx]; } - else if (decoder->frame_ms == 5) + else if ( decoder->frame_ms == 5 ) { decoder->bands_offsetPLC = ACC_COEFF_PER_BAND_PLC_5ms[decoder->fs_idx]; - if (decoder->fs == 24000) + if ( decoder->fs == 24000 ) { decoder->n_bandsPLC = 40; } } - else if (decoder->frame_ms == 2.5) + else if ( decoder->frame_ms == 2.5 ) { decoder->bands_offsetPLC = ACC_COEFF_PER_BAND_PLC_2_5ms[decoder->fs_idx]; - if (decoder->fs == 48000) + if ( decoder->fs == 48000 ) { decoder->n_bandsPLC = 60; } } - assert(decoder->bands_offsetPLC); + assert( decoder->bands_offsetPLC ); - if (decoder->frame_ms == 10) { - decoder->imdct_win = MDCT_WINS_10ms[decoder->hrmode][decoder->fs_idx]; + if ( decoder->frame_ms == 10 ) + { + decoder->imdct_win = MDCT_WINS_10ms[decoder->hrmode][decoder->fs_idx]; decoder->imdct_laZeros = MDCT_la_zeroes[decoder->fs_idx]; - decoder->imdct_winLen = MDCT_WINDOWS_LENGTHS_10ms[decoder->fs_idx]; + decoder->imdct_winLen = MDCT_WINDOWS_LENGTHS_10ms[decoder->fs_idx]; } - else if (decoder->frame_ms == 2.5) { - decoder->imdct_win = MDCT_WINS_2_5ms[decoder->hrmode][decoder->fs_idx]; + else if ( decoder->frame_ms == 2.5 ) + { + decoder->imdct_win = MDCT_WINS_2_5ms[decoder->hrmode][decoder->fs_idx]; decoder->imdct_laZeros = MDCT_la_zeroes_2_5ms[decoder->fs_idx]; - decoder->imdct_winLen = MDCT_WINDOWS_LENGTHS_2_5ms[decoder->fs_idx]; + decoder->imdct_winLen = MDCT_WINDOWS_LENGTHS_2_5ms[decoder->fs_idx]; } - else if (decoder->frame_ms == 5) { - decoder->imdct_win = MDCT_WINS_5ms[decoder->hrmode][decoder->fs_idx]; + else if ( decoder->frame_ms == 5 ) + { + decoder->imdct_win = MDCT_WINS_5ms[decoder->hrmode][decoder->fs_idx]; decoder->imdct_laZeros = MDCT_la_zeroes_5ms[decoder->fs_idx]; - decoder->imdct_winLen = MDCT_WINDOWS_LENGTHS_5ms[decoder->fs_idx]; + decoder->imdct_winLen = MDCT_WINDOWS_LENGTHS_5ms[decoder->fs_idx]; } decoder->la_zeroes = decoder->imdct_laZeros; decoder->imdct_memLen = decoder->frame_length - decoder->imdct_laZeros; - for (ch = 0; ch < decoder->channels; ch++) { - DecSetup* setup = decoder->channel_setup[ch]; - + for ( ch = 0; ch < decoder->channels; ch++ ) + { + DecSetup *setup = decoder->channel_setup[ch]; + setup->ltpf_mem_beta_idx = -1; - + setup->statePC.seed = 24607; - if (decoder) { + if ( decoder ) + { /* Init DCT4 structs */ - if (setup->dct4structImdct.length != 0) { - dct4_free(&setup->dct4structImdct); - dct4_init(&setup->dct4structImdct, decoder->frame_length); - } else { - dct4_init(&setup->dct4structImdct, decoder->frame_length); + if ( setup->dct4structImdct.length != 0 ) + { + dct4_free( &setup->dct4structImdct ); + dct4_init( &setup->dct4structImdct, decoder->frame_length ); + } + else + { + dct4_init( &setup->dct4structImdct, decoder->frame_length ); } - + setup->PlcNsSetup.cum_alpha = 1; setup->PlcNsSetup.seed = 24607; setup->alpha = 1; - if (setup->PlcAdvSetup) + if ( setup->PlcAdvSetup ) { - LC3_INT32 pitch_max = 0, pitch_ana_len = 0, tdc_synt_len = 0; - pitch_max = ceil(228.0 * (LC3_FLOAT) decoder->fs / 12800.0); + LC3_INT32 pitch_max = 0, pitch_ana_len = 0, tdc_synt_len = 0; + pitch_max = ceil( 228.0 * (LC3_FLOAT) decoder->fs / 12800.0 ); pitch_ana_len = pitch_max + decoder->frame_length * (LC3_FLOAT) 100 / decoder->frame_dms; - tdc_synt_len = 16 + 1 + pitch_max + ceil(decoder->frame_length / 2); - setup->PlcAdvSetup->max_len_pcm_plc = MAX(pitch_ana_len, tdc_synt_len); + tdc_synt_len = 16 + 1 + pitch_max + ceil( decoder->frame_length / 2 ); + setup->PlcAdvSetup->max_len_pcm_plc = MAX( pitch_ana_len, tdc_synt_len ); setup->PlcAdvSetup->PlcTdcSetup.preemphFac = plc_preemph_fac[decoder->fs_idx]; setup->PlcAdvSetup->PlcTdcSetup.seed = 24607; setup->PlcAdvSetup->PlcTdcSetup.lpcorder = 16; - if (decoder->fs_idx == 0 && decoder->frame_dms == 25) + if ( decoder->fs_idx == 0 && decoder->frame_dms == 25 ) { setup->PlcAdvSetup->PlcTdcSetup.lpcorder = 8; } @@ -308,66 +327,63 @@ void set_dec_frame_params(LC3PLUS_Dec* decoder) setup->PlcAdvSetup->cum_fading_slow = 1; setup->PlcAdvSetup->cum_fflcAtten = 1; - if (decoder->fs_idx <= 4 && decoder->frame_dms == 100) + if ( decoder->fs_idx <= 4 && decoder->frame_dms == 100 ) { - setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot = (decoder->fs * 16) / 1000; /* 16 ms of samples at fs*/ + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot = ( decoder->fs * 16 ) / 1000; /* 16 ms of samples at fs*/ - setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_f0hzLtpBin = 0; - setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_norm_corr = 0; + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_f0hzLtpBin = 0; + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_norm_corr = 0; - set_vec(PHECU_GRP_SHAPE_INIT, setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_oold_grp_shape, MAX_LGW); - set_vec(PHECU_GRP_SHAPE_INIT, setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_old_grp_shape, MAX_LGW); + set_vec( PHECU_GRP_SHAPE_INIT, setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_oold_grp_shape, MAX_LGW ); + set_vec( PHECU_GRP_SHAPE_INIT, setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_old_grp_shape, MAX_LGW ); - setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_L_oold_xfp_w_E = (LC3_FLOAT)PHECU_LTOT_MIN_MAN * LC3_POW(2.0, PHECU_LTOT_MIN_EXP - 31); - setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_L_old_xfp_w_E = (LC3_FLOAT)PHECU_LTOT_MIN_MAN * LC3_POW(2.0, PHECU_LTOT_MIN_EXP - 31); + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_L_oold_xfp_w_E = (LC3_FLOAT) PHECU_LTOT_MIN_MAN * LC3_POW( 2.0, PHECU_LTOT_MIN_EXP - 31 ); + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_L_old_xfp_w_E = (LC3_FLOAT) PHECU_LTOT_MIN_MAN * LC3_POW( 2.0, PHECU_LTOT_MIN_EXP - 31 ); - /* CFL uses separate buffers for pcmHist, xfp and Xsav and q_d , BASOP uses an optimized joint buffer*/ - zero_float(setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_xfp, setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot); - zero_cmplx(setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_X_sav_m, (setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot/2 + 1)); + /* CFL uses separate buffers for pcmHist, xfp and Xsav and q_d , BASOP uses an optimized joint buffer*/ + zero_float( setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_xfp, setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot ); + zero_cmplx( setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_X_sav_m, ( setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot / 2 + 1 ) ); - set_vec(POS_ONE_Q15, setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_mag_chg_1st, MAX_LGW); + set_vec( POS_ONE_Q15, setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_mag_chg_1st, MAX_LGW ); - setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_beta_mute = (16384.0/32768.0); - setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_seed = 21845; + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_beta_mute = ( 16384.0 / 32768.0 ); + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_seed = 21845; - assert(decoder->frame_dms == 100); - setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_LDWIN_OLAP = (decoder->frame_length / 4 ); /* 2.5 ms for regular 10 ms MDCT */ + assert( decoder->frame_dms == 100 ); + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_LDWIN_OLAP = ( decoder->frame_length / 4 ); /* 2.5 ms for regular 10 ms MDCT */ - setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_t_adv = ( - decoder->frame_length - + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot - + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_LDWIN_OLAP )/ 2; + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_t_adv = ( decoder->frame_length + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_LDWIN_OLAP ) / 2; } - setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_short_flag_prev = 0; /* fullband transient */ + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_short_flag_prev = 0; /* fullband transient */ setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_num_plocs = 0; } } } } -LC3PLUS_Error update_dec_bitrate(LC3PLUS_Dec* decoder, int ch, int nBytes) +LC3PLUS_Error update_dec_bitrate( LC3PLUS_Dec *decoder, int ch, int nBytes ) { int totalBits = 0, bitsTmp = 0, channel_bytes = 0, maxBytes = 0, minBytes = 0; - DecSetup* setup; + DecSetup *setup; - if (decoder->hrmode) + if ( decoder->hrmode ) { - switch (decoder->frame_dms) + switch ( decoder->frame_dms ) { - case 25: - maxBytes = 210; - minBytes = MIN_NBYTES; - break; - case 50: - maxBytes = 375; - minBytes = MIN_NBYTES; - break; - case 100: - maxBytes = 625; - minBytes = MIN_NBYTES; - break; - default: - return LC3PLUS_HRMODE_ERROR; + case 25: + maxBytes = 210; + minBytes = MIN_NBYTES; + break; + case 50: + maxBytes = 375; + minBytes = MIN_NBYTES; + break; + case 100: + maxBytes = 625; + minBytes = MIN_NBYTES; + break; + default: + return LC3PLUS_HRMODE_ERROR; } } else @@ -378,67 +394,82 @@ LC3PLUS_Error update_dec_bitrate(LC3PLUS_Dec* decoder, int ch, int nBytes) channel_bytes = nBytes; - setup = decoder->channel_setup[ch]; + setup = decoder->channel_setup[ch]; - if (channel_bytes < minBytes || channel_bytes > maxBytes) - { - return LC3PLUS_NUMBYTES_ERROR; - } - - setup->targetBytes = channel_bytes; - setup->total_bits = setup->targetBytes << 3; - setup->enable_lpc_weighting = (setup->total_bits < 480); - setup->quantizedGainOff = - -(MIN(115, setup->total_bits / (10 * (decoder->fs_idx + 1))) + 105 + 5 * (decoder->fs_idx + 1)); - - if (decoder->hrmode && decoder->fs_idx == 5) - { - setup->quantizedGainOff = MAX(setup->quantizedGainOff, -181); - } + if ( channel_bytes < minBytes || channel_bytes > maxBytes ) + { + return LC3PLUS_NUMBYTES_ERROR; + } - totalBits = setup->total_bits; - - if (decoder->frame_ms == 2.5) { - setup->enable_lpc_weighting = setup->total_bits < 120; - totalBits = setup->total_bits * 4.0 * (1.0 - 0.4); - } - if (decoder->frame_ms == 5) { - setup->enable_lpc_weighting = (setup->total_bits < 240); - totalBits = setup->total_bits * 2 - 160; - } - - if (decoder->frame_length > 40 * ((LC3_FLOAT) (decoder->frame_dms) / 10.0)) { - setup->N_red_tns = 40 * ((LC3_FLOAT) (decoder->frame_dms) / 10.0); - setup->fs_red_tns = 40000; - } else { - setup->N_red_tns = decoder->frame_length; - setup->fs_red_tns = decoder->fs; - } + setup->targetBytes = channel_bytes; + setup->total_bits = setup->targetBytes << 3; + setup->enable_lpc_weighting = ( setup->total_bits < 480 ); + setup->quantizedGainOff = + -( MIN( 115, setup->total_bits / ( 10 * ( decoder->fs_idx + 1 ) ) ) + 105 + 5 * ( decoder->fs_idx + 1 ) ); - bitsTmp = totalBits; - - if (bitsTmp < 400 + (decoder->fs_idx - 1) * 80) { - setup->ltpf_conf_beta = 0.4; - setup->ltpf_conf_beta_idx = 0; - } else if (bitsTmp < 480 + (decoder->fs_idx - 1) * 80) { - setup->ltpf_conf_beta = 0.35; - setup->ltpf_conf_beta_idx = 1; - } else if (bitsTmp < 560 + (decoder->fs_idx - 1) * 80) { - setup->ltpf_conf_beta = 0.3; - setup->ltpf_conf_beta_idx = 2; - } else if (bitsTmp < 640 + (decoder->fs_idx - 1) * 80) { - setup->ltpf_conf_beta = 0.25; - setup->ltpf_conf_beta_idx = 3; - } else { - setup->ltpf_conf_beta = 0; - setup->ltpf_conf_beta_idx = -1; - } + if ( decoder->hrmode && decoder->fs_idx == 5 ) + { + setup->quantizedGainOff = MAX( setup->quantizedGainOff, -181 ); + } + + totalBits = setup->total_bits; + + if ( decoder->frame_ms == 2.5 ) + { + setup->enable_lpc_weighting = setup->total_bits < 120; + totalBits = setup->total_bits * 4.0 * ( 1.0 - 0.4 ); + } + if ( decoder->frame_ms == 5 ) + { + setup->enable_lpc_weighting = ( setup->total_bits < 240 ); + totalBits = setup->total_bits * 2 - 160; + } + + if ( decoder->frame_length > 40 * ( (LC3_FLOAT) ( decoder->frame_dms ) / 10.0 ) ) + { + setup->N_red_tns = 40 * ( (LC3_FLOAT) ( decoder->frame_dms ) / 10.0 ); + setup->fs_red_tns = 40000; + } + else + { + setup->N_red_tns = decoder->frame_length; + setup->fs_red_tns = decoder->fs; + } + + bitsTmp = totalBits; + + if ( bitsTmp < 400 + ( decoder->fs_idx - 1 ) * 80 ) + { + setup->ltpf_conf_beta = 0.4; + setup->ltpf_conf_beta_idx = 0; + } + else if ( bitsTmp < 480 + ( decoder->fs_idx - 1 ) * 80 ) + { + setup->ltpf_conf_beta = 0.35; + setup->ltpf_conf_beta_idx = 1; + } + else if ( bitsTmp < 560 + ( decoder->fs_idx - 1 ) * 80 ) + { + setup->ltpf_conf_beta = 0.3; + setup->ltpf_conf_beta_idx = 2; + } + else if ( bitsTmp < 640 + ( decoder->fs_idx - 1 ) * 80 ) + { + setup->ltpf_conf_beta = 0.25; + setup->ltpf_conf_beta_idx = 3; + } + else + { + setup->ltpf_conf_beta = 0; + setup->ltpf_conf_beta_idx = -1; + } + + /* No LTPF in hrmode */ + if ( decoder->hrmode == 1 ) + { + setup->ltpf_conf_beta = 0; + setup->ltpf_conf_beta_idx = -1; + } - /* No LTPF in hrmode */ - if (decoder->hrmode == 1) { - setup->ltpf_conf_beta = 0; - setup->ltpf_conf_beta_idx = -1; - } - return LC3PLUS_OK; } diff --git a/lib_lc3plus/setup_dec_lc3.h b/lib_lc3plus/setup_dec_lc3.h index 6ed0f438ea..8052e38987 100644 --- a/lib_lc3plus/setup_dec_lc3.h +++ b/lib_lc3plus/setup_dec_lc3.h @@ -1,12 +1,12 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #ifndef SETUP_DEC_LC3_FL_H #define SETUP_DEC_LC3_FL_H @@ -14,29 +14,30 @@ #include "constants.h" /* Channel state and bitrate-derived values go in this struct */ -typedef struct { - LC3_INT* stDec_ola_mem_fx; /* MDCT_MEM_LEN_MAX */ - LC3_INT total_bits; - LC3_INT enable_lpc_weighting; - LC3_INT targetBytes; - LC3_INT quantizedGainOff; - LC3_INT ltpf_param[3]; - LC3_INT ltpf_param_mem[3]; - LC3_INT ltpf_mem_pitch; - LC3_INT ltpf_mem_active; - LC3_INT ltpf_mem_pitch_fr; - LC3_INT ltpf_mem_beta_idx; - LC3_INT ltpf_conf_beta_idx; - LC3_INT spec_inv_idx; - LC3_INT concealMethod; - LC3_INT last_size; - LC3_INT BW_cutoff_idx_nf; - LC3_INT prev_BW_cutoff_idx_nf; - LC3_INT fs_red_tns; - LC3_INT N_red_tns; - LC3_INT scf_idx[SCF_MAX_PARAM]; - uint8_t resBits[MAX_RESBITS_LEN]; - LC3_INT tns_idx[TNS_NUMFILTERS_MAX * MAXLAG]; +typedef struct +{ + LC3_INT *stDec_ola_mem_fx; /* MDCT_MEM_LEN_MAX */ + LC3_INT total_bits; + LC3_INT enable_lpc_weighting; + LC3_INT targetBytes; + LC3_INT quantizedGainOff; + LC3_INT ltpf_param[3]; + LC3_INT ltpf_param_mem[3]; + LC3_INT ltpf_mem_pitch; + LC3_INT ltpf_mem_active; + LC3_INT ltpf_mem_pitch_fr; + LC3_INT ltpf_mem_beta_idx; + LC3_INT ltpf_conf_beta_idx; + LC3_INT spec_inv_idx; + LC3_INT concealMethod; + LC3_INT last_size; + LC3_INT BW_cutoff_idx_nf; + LC3_INT prev_BW_cutoff_idx_nf; + LC3_INT fs_red_tns; + LC3_INT N_red_tns; + LC3_INT scf_idx[SCF_MAX_PARAM]; + uint8_t resBits[MAX_RESBITS_LEN]; + LC3_INT tns_idx[TNS_NUMFILTERS_MAX * MAXLAG]; LC3_FLOAT prev_fac_ns; LC3_FLOAT ltpf_mem_x[3 * MAX_LEN]; @@ -51,20 +52,21 @@ typedef struct { LC3_FLOAT alpha; Dct4 dct4structImdct; - - PlcSetup PlcSetup; - PlcNsSetup PlcNsSetup; - + + PlcSetup PlcSetup; + PlcNsSetup PlcNsSetup; + pcState statePC; - PlcAdvSetup* PlcAdvSetup; + PlcAdvSetup *PlcAdvSetup; } DecSetup; /* Constants and sampling rate derived values go in this struct */ -struct LC3PLUS_Dec { - DecSetup* channel_setup[MAX_CHANNELS]; - const LC3_INT* W_fx; - const LC3_INT* bands_offset; - const LC3_INT* cutoffBins; +struct LC3PLUS_Dec +{ + DecSetup *channel_setup[MAX_CHANNELS]; + const LC3_INT *W_fx; + const LC3_INT *bands_offset; + const LC3_INT *cutoffBins; LC3_INT fs; /* sampling rate, 44.1 maps to 48 */ LC3_INT fs_out; /* output sampling rate */ @@ -77,10 +79,10 @@ struct LC3PLUS_Dec { LC3_INT ep_enabled; /* error protection enabled */ LC3_INT error_report; /* corrected errors in last frame or -1 on error */ - LC3_INT imdct_memLen; - LC3_INT imdct_winLen; - LC3_INT imdct_laZeros; - const LC3_FLOAT* imdct_win; + LC3_INT imdct_memLen; + LC3_INT imdct_winLen; + LC3_INT imdct_laZeros; + const LC3_FLOAT *imdct_win; LC3_INT yLen; LC3_INT W_size; @@ -90,23 +92,23 @@ struct LC3PLUS_Dec { LC3_INT ltpf_mem_y_len; LC3_INT BW_cutoff_bits; LC3_INT tilt; - + LC3_INT hrmode; LC3_INT specflip; - - const LC3_INT* bands_offsetPLC; + + const LC3_INT *bands_offsetPLC; LC3_INT n_bandsPLC; - - LC3_INT32 rframe; - int plcMeth; /* PLC method for all channels */ + + LC3_INT32 rframe; + int plcMeth; /* PLC method for all channels */ LC3_INT16 n_pccw; LC3_INT16 be_bp_left; LC3_INT16 be_bp_right; LC3_INT16 n_pc; LC3_INT16 m_fec; - int epmr; - LC3_INT16 combined_channel_coding; - int last_error; + int epmr; + LC3_INT16 combined_channel_coding; + int last_error; }; #endif diff --git a/lib_lc3plus/setup_enc_lc3.c b/lib_lc3plus/setup_enc_lc3.c index 986b43d608..85baa05741 100644 --- a/lib_lc3plus/setup_enc_lc3.c +++ b/lib_lc3plus/setup_enc_lc3.c @@ -1,12 +1,12 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "setup_enc_lc3.h" @@ -14,108 +14,118 @@ #include /* if encoder is null only size is reported */ -int alloc_encoder(LC3PLUS_Enc* encoder, int channels) +int alloc_encoder( LC3PLUS_Enc *encoder, int channels ) { - int ch = 0; - size_t size = sizeof(LC3PLUS_Enc); + int ch = 0; + size_t size = sizeof( LC3PLUS_Enc ); - for (ch = 0; ch < channels; ch++) { - EncSetup* setup = balloc(encoder, &size, sizeof(EncSetup)); - if (encoder) { + for ( ch = 0; ch < channels; ch++ ) + { + EncSetup *setup = balloc( encoder, &size, sizeof( EncSetup ) ); + if ( encoder ) + { encoder->channel_setup[ch] = setup; } } - return (int)size; + return (int) size; } -LC3PLUS_Error FillEncSetup(LC3PLUS_Enc* encoder, int samplerate, int channels - , int hrmode - , int32_t lfe_channel_array[] -) +LC3PLUS_Error FillEncSetup( LC3PLUS_Enc *encoder, int samplerate, int channels, int hrmode, int32_t lfe_channel_array[] ) { int ch = 0; - memset(encoder, 0, lc3plus_enc_get_size(samplerate, channels)); - alloc_encoder(encoder, channels); + memset( encoder, 0, lc3plus_enc_get_size( samplerate, channels ) ); + alloc_encoder( encoder, channels ); - encoder->fs = CODEC_FS(samplerate); - encoder->fs_in = samplerate; - encoder->fs_idx = FS2FS_IDX(encoder->fs); + encoder->fs = CODEC_FS( samplerate ); + encoder->fs_in = samplerate; + encoder->fs_idx = FS2FS_IDX( encoder->fs ); encoder->frame_dms = 100; - if (encoder->fs_idx > 4) { + if ( encoder->fs_idx > 4 ) + { encoder->fs_idx = 5; } encoder->hrmode = hrmode != 0; - encoder->channels = channels; - encoder->frame_ms = 10; - encoder->envelope_bits = 38; - encoder->global_gain_bits = 8; - encoder->noise_fac_bits = 3; - encoder->BW_cutoff_bits = BW_cutoff_bits_all[encoder->fs_idx]; + encoder->channels = channels; + encoder->frame_ms = 10; + encoder->envelope_bits = 38; + encoder->global_gain_bits = 8; + encoder->noise_fac_bits = 3; + encoder->BW_cutoff_bits = BW_cutoff_bits_all[encoder->fs_idx]; - encoder->r12k8_mem_in_len = 2 * 8 * encoder->fs / 12800; + encoder->r12k8_mem_in_len = 2 * 8 * encoder->fs / 12800; encoder->r12k8_mem_out_len = 24; - for (ch = 0; ch < encoder->channels; ch++) + for ( ch = 0; ch < encoder->channels; ch++ ) { encoder->channel_setup[ch]->lfe = lfe_channel_array[ch] != 0; } - encoder->bw_ctrl_active = 0; - encoder->bandwidth = encoder->fs / 2; + encoder->bw_ctrl_active = 0; + encoder->bandwidth = encoder->fs / 2; encoder->bandwidth_preset = encoder->fs / 2; - if (encoder->fs == 8000) { + if ( encoder->fs == 8000 ) + { encoder->tilt = 14; - } else if (encoder->fs == 16000) { + } + else if ( encoder->fs == 16000 ) + { encoder->tilt = 18; - } else if (encoder->fs == 24000) { + } + else if ( encoder->fs == 24000 ) + { encoder->tilt = 22; - } else if (encoder->fs == 32000) { + } + else if ( encoder->fs == 32000 ) + { encoder->tilt = 26; - } else if (encoder->fs == 48000) { + } + else if ( encoder->fs == 48000 ) + { encoder->tilt = 30; } - else if (encoder->fs == 96000) { + else if ( encoder->fs == 96000 ) + { encoder->tilt = 34; } - set_enc_frame_params(encoder); + set_enc_frame_params( encoder ); return LC3PLUS_OK; } /* set frame config params */ -void set_enc_frame_params(LC3PLUS_Enc* encoder) +void set_enc_frame_params( LC3PLUS_Enc *encoder ) { - int ch = 0; - EncSetup* setup; + int ch = 0; + EncSetup *setup; - encoder->frame_length = ceil(encoder->fs * 10 / 1000); /* fs * 0.01*2^6 */ - if (encoder->hrmode == 1) + encoder->frame_length = ceil( encoder->fs * 10 / 1000 ); /* fs * 0.01*2^6 */ + if ( encoder->hrmode == 1 ) { encoder->yLen = encoder->frame_length; } else { - encoder->yLen = MIN(MAX_BW, encoder->frame_length); + encoder->yLen = MIN( MAX_BW, encoder->frame_length ); encoder->sns_damping = 0.85; } encoder->stEnc_mdct_mem_len = encoder->frame_length - encoder->la_zeroes; - encoder->bands_number = 64; - encoder->nSubdivisions = 3; + encoder->bands_number = 64; + encoder->nSubdivisions = 3; encoder->near_nyquist_index = encoder->bands_number - 2; - encoder->near_nyquist_flag = 0; - encoder->ltpf_mem_in_len = LTPF_MEMIN_LEN; - - if (encoder->fs_idx == 5) + encoder->near_nyquist_flag = 0; + encoder->ltpf_mem_in_len = LTPF_MEMIN_LEN; + + if ( encoder->fs_idx == 5 ) { encoder->hrmode = 1; } - if (encoder->hrmode) + if ( encoder->hrmode ) { encoder->BW_cutoff_bits = 0; } @@ -124,9 +134,10 @@ void set_enc_frame_params(LC3PLUS_Enc* encoder) encoder->BW_cutoff_bits = BW_cutoff_bits_all[encoder->fs_idx]; } - if (encoder->frame_ms == 10) { + if ( encoder->frame_ms == 10 ) + { encoder->la_zeroes = MDCT_la_zeroes[encoder->fs_idx]; - if (encoder->hrmode) + if ( encoder->hrmode ) { encoder->bands_offset = ACC_COEFF_PER_BAND_HR[encoder->fs_idx]; } @@ -134,15 +145,16 @@ void set_enc_frame_params(LC3PLUS_Enc* encoder) { encoder->bands_offset = ACC_COEFF_PER_BAND[encoder->fs_idx]; } - encoder->cutoffBins = BW_cutoff_bin_all; - - encoder->attdec_nblocks = 4; - encoder->attdec_damping = 0.5; + encoder->cutoffBins = BW_cutoff_bin_all; + + encoder->attdec_nblocks = 4; + encoder->attdec_damping = 0.5; encoder->attdec_hangover_thresh = 2; } - else if (encoder->frame_ms == 2.5) { + else if ( encoder->frame_ms == 2.5 ) + { encoder->la_zeroes = MDCT_la_zeroes_2_5ms[encoder->fs_idx]; - if (encoder->hrmode) + if ( encoder->hrmode ) { encoder->bands_offset = ACC_COEFF_PER_BAND_2_5ms_HR[encoder->fs_idx]; } @@ -150,11 +162,12 @@ void set_enc_frame_params(LC3PLUS_Enc* encoder) { encoder->bands_offset = ACC_COEFF_PER_BAND_2_5ms[encoder->fs_idx]; } - encoder->cutoffBins = BW_cutoff_bin_all_2_5ms; + encoder->cutoffBins = BW_cutoff_bin_all_2_5ms; } - else if (encoder->frame_ms == 5) { + else if ( encoder->frame_ms == 5 ) + { encoder->la_zeroes = MDCT_la_zeroes_5ms[encoder->fs_idx]; - if (encoder->hrmode) + if ( encoder->hrmode ) { encoder->bands_offset = ACC_COEFF_PER_BAND_5ms_HR[encoder->fs_idx]; } @@ -162,203 +175,250 @@ void set_enc_frame_params(LC3PLUS_Enc* encoder) { encoder->bands_offset = ACC_COEFF_PER_BAND_5ms[encoder->fs_idx]; } - encoder->cutoffBins = BW_cutoff_bin_all_5ms; + encoder->cutoffBins = BW_cutoff_bin_all_5ms; } - if (encoder->frame_ms == 2.5) { + if ( encoder->frame_ms == 2.5 ) + { encoder->frame_length = encoder->frame_length >> 2; encoder->yLen /= 4; encoder->stEnc_mdct_mem_len = encoder->frame_length - encoder->la_zeroes; - if (encoder->hrmode) + if ( encoder->hrmode ) { - encoder->bands_number = bands_number_2_5ms_HR[encoder->fs_idx]; + encoder->bands_number = bands_number_2_5ms_HR[encoder->fs_idx]; } else { - encoder->bands_number = bands_number_2_5ms[encoder->fs_idx]; + encoder->bands_number = bands_number_2_5ms[encoder->fs_idx]; } - encoder->nSubdivisions = 2; + encoder->nSubdivisions = 2; encoder->near_nyquist_index = encoder->bands_number - 2; - encoder->ltpf_mem_in_len = LTPF_MEMIN_LEN + (LEN_12K8 >> 2); + encoder->ltpf_mem_in_len = LTPF_MEMIN_LEN + ( LEN_12K8 >> 2 ); } - - - if (encoder->frame_ms == 5) { + + + if ( encoder->frame_ms == 5 ) + { encoder->frame_length = encoder->frame_length >> 1; encoder->yLen /= 2; encoder->stEnc_mdct_mem_len = encoder->frame_length - encoder->la_zeroes; - encoder->bands_number = bands_number_5ms[encoder->fs_idx]; - encoder->nSubdivisions = 2; + encoder->bands_number = bands_number_5ms[encoder->fs_idx]; + encoder->nSubdivisions = 2; encoder->near_nyquist_index = encoder->bands_number - 3; } - for (ch = 0; ch < encoder->channels; ch++) { + for ( ch = 0; ch < encoder->channels; ch++ ) + { setup = encoder->channel_setup[ch]; setup->olpa_mem_pitch = 17; - - if (setup->mdctStruct.mem != NULL) { - mdct_free(&setup->mdctStruct); - mdct_init(&setup->mdctStruct, encoder->frame_length, encoder->frame_dms, encoder->fs_idx, encoder->hrmode); - dct2_free(&setup->dct2StructSNS); - dct2_init(&setup->dct2StructSNS, M); + if ( setup->mdctStruct.mem != NULL ) + { + mdct_free( &setup->mdctStruct ); + mdct_init( &setup->mdctStruct, encoder->frame_length, encoder->frame_dms, encoder->fs_idx, encoder->hrmode ); + + dct2_free( &setup->dct2StructSNS ); + dct2_init( &setup->dct2StructSNS, M ); } else { - mdct_init(&setup->mdctStruct, encoder->frame_length, encoder->frame_dms, encoder->fs_idx, encoder->hrmode); - dct2_init(&setup->dct2StructSNS, M); + mdct_init( &setup->mdctStruct, encoder->frame_length, encoder->frame_dms, encoder->fs_idx, encoder->hrmode ); + dct2_init( &setup->dct2StructSNS, M ); } } } /* change encoder bitrate */ -LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate) +LC3PLUS_Error update_enc_bitrate( LC3PLUS_Enc *encoder, int bitrate ) { int ch = 0, bitsTmp = 0, minBR = 0, maxBR = 0, totalBytes = 0; LC3_INT channel_bytes = 0, max_bytes = 0; - if (encoder->hrmode) + if ( encoder->hrmode ) { #ifdef ENABLE_HR_MODE_FL - switch (encoder->frame_dms) - { - case 25: - maxBR = 672000; - if (encoder->fs == 48000) {minBR = MIN_BR_25MS_48KHZ_HR;} - else if (encoder->fs == 96000) {minBR = MIN_BR_25MS_96KHZ_HR;} - else { return LC3PLUS_HRMODE_ERROR;} - break; - case 50: - maxBR = 600000; - if (encoder->fs == 48000) {minBR = MIN_BR_50MS_48KHZ_HR;} - else if (encoder->fs == 96000) {minBR = MIN_BR_50MS_96KHZ_HR;} - else { return LC3PLUS_HRMODE_ERROR;} - break; - case 100: - maxBR = 500000; - if (encoder->fs == 48000) {minBR = MIN_BR_100MS_48KHZ_HR;} - else if (encoder->fs == 96000) {minBR = MIN_BR_100MS_96KHZ_HR;} - else { return LC3PLUS_HRMODE_ERROR;} - break; - default: - return LC3PLUS_HRMODE_ERROR; + switch ( encoder->frame_dms ) + { + case 25: + maxBR = 672000; + if ( encoder->fs == 48000 ) + { + minBR = MIN_BR_25MS_48KHZ_HR; + } + else if ( encoder->fs == 96000 ) + { + minBR = MIN_BR_25MS_96KHZ_HR; + } + else + { + return LC3PLUS_HRMODE_ERROR; + } + break; + case 50: + maxBR = 600000; + if ( encoder->fs == 48000 ) + { + minBR = MIN_BR_50MS_48KHZ_HR; + } + else if ( encoder->fs == 96000 ) + { + minBR = MIN_BR_50MS_96KHZ_HR; + } + else + { + return LC3PLUS_HRMODE_ERROR; + } + break; + case 100: + maxBR = 500000; + if ( encoder->fs == 48000 ) + { + minBR = MIN_BR_100MS_48KHZ_HR; + } + else if ( encoder->fs == 96000 ) + { + minBR = MIN_BR_100MS_96KHZ_HR; + } + else + { + return LC3PLUS_HRMODE_ERROR; + } + break; + default: + return LC3PLUS_HRMODE_ERROR; } #endif } else { - minBR = (MIN_NBYTES << 3); + minBR = ( MIN_NBYTES << 3 ); maxBR = MAX_BR; - switch (encoder->frame_dms) - { - case 25: - minBR = MIN_BR_025DMS; - maxBR = MAX_BR; - break; - case 50: - minBR = MIN_BR_050DMS; - maxBR = MAX_BR; - /* have additional limitations for 5.0ms */ - switch (encoder->fs_in) - { - case 8000: maxBR = MAX_BR_050DMS_NB; break; - default: break; - } - break; - case 100: - /* have additional limitations for 10ms */ - minBR = MIN_BR_100DMS; - maxBR = MAX_BR; - switch (encoder->fs_in) - { - case 8000: maxBR = MAX_BR_100DMS_NB ; break; - case 16000: maxBR = MAX_BR_100DMS_WB ; break; - case 24000: maxBR = MAX_BR_100DMS_SSWB; break; - default: maxBR = MAX_BR; break; - } - break; - default: return LC3PLUS_FRAMEMS_ERROR; + switch ( encoder->frame_dms ) + { + case 25: + minBR = MIN_BR_025DMS; + maxBR = MAX_BR; + break; + case 50: + minBR = MIN_BR_050DMS; + maxBR = MAX_BR; + /* have additional limitations for 5.0ms */ + switch ( encoder->fs_in ) + { + case 8000: + maxBR = MAX_BR_050DMS_NB; + break; + default: + break; + } + break; + case 100: + /* have additional limitations for 10ms */ + minBR = MIN_BR_100DMS; + maxBR = MAX_BR; + switch ( encoder->fs_in ) + { + case 8000: + maxBR = MAX_BR_100DMS_NB; + break; + case 16000: + maxBR = MAX_BR_100DMS_WB; + break; + case 24000: + maxBR = MAX_BR_100DMS_SSWB; + break; + default: + maxBR = MAX_BR; + break; + } + break; + default: + return LC3PLUS_FRAMEMS_ERROR; } - maxBR *= (encoder->fs_in == 44100 ? 441. / 480 : 1); + maxBR *= ( encoder->fs_in == 44100 ? 441. / 480 : 1 ); } minBR *= encoder->channels; maxBR *= encoder->channels; - + encoder->combined_channel_coding = 0; - - if (encoder->channels > 1 && encoder->epmode) + + if ( encoder->channels > 1 && encoder->epmode ) { - if (encoder->bitrate * encoder->frame_length / (8 * encoder->fs_in) <= 160) + if ( encoder->bitrate * encoder->frame_length / ( 8 * encoder->fs_in ) <= 160 ) { encoder->combined_channel_coding = 1; } } - if (encoder->epmode > 0) + if ( encoder->epmode > 0 ) { - max_bytes = bitrate * encoder->frame_length / (8 * encoder->fs_in * encoder->channels); - if (max_bytes < FEC_SLOT_BYTES_MIN || max_bytes > FEC_SLOT_BYTES_MAX) + max_bytes = bitrate * encoder->frame_length / ( 8 * encoder->fs_in * encoder->channels ); + if ( max_bytes < FEC_SLOT_BYTES_MIN || max_bytes > FEC_SLOT_BYTES_MAX ) { encoder->lc3_br_set = 0; return LC3PLUS_BITRATE_ERROR; } } - if (encoder->combined_channel_coding) + if ( encoder->combined_channel_coding ) { - totalBytes = fec_get_data_size(encoder->epmode, encoder->combined_channel_coding, - bitrate * encoder->frame_length / (8 * encoder->fs_in)); + totalBytes = fec_get_data_size( encoder->epmode, encoder->combined_channel_coding, + bitrate * encoder->frame_length / ( 8 * encoder->fs_in ) ); encoder->channel_setup[0]->n_pccw = - fec_get_n_pccw(bitrate * encoder->frame_length / (8 * encoder->fs_in), encoder->epmode, - encoder->combined_channel_coding); + fec_get_n_pccw( bitrate * encoder->frame_length / ( 8 * encoder->fs_in ), encoder->epmode, + encoder->combined_channel_coding ); - encoder->channel_setup[0]->n_pc = fec_get_n_pc(encoder->epmode, encoder->channel_setup[0]->n_pccw, - bitrate * encoder->frame_length / (8 * encoder->fs_in)); + encoder->channel_setup[0]->n_pc = fec_get_n_pc( encoder->epmode, encoder->channel_setup[0]->n_pccw, + bitrate * encoder->frame_length / ( 8 * encoder->fs_in ) ); } else { - totalBytes = bitrate * encoder->frame_length / (8 * encoder->fs_in); + totalBytes = bitrate * encoder->frame_length / ( 8 * encoder->fs_in ); } - - if (encoder->frame_dms <= 50) + + if ( encoder->frame_dms <= 50 ) { encoder->tnsMaxOrder = 4; - } else { + } + else + { encoder->tnsMaxOrder = 8; } - if (bitrate < minBR || bitrate > maxBR) { + if ( bitrate < minBR || bitrate > maxBR ) + { return LC3PLUS_BITRATE_ERROR; } - + encoder->lc3_br_set = 1; - for (ch = 0; ch < encoder->channels; ch++) { + for ( ch = 0; ch < encoder->channels; ch++ ) + { - EncSetup* setup = encoder->channel_setup[ch]; - - setup->targetBytes = totalBytes / encoder->channels + (ch < (totalBytes % encoder->channels)); - channel_bytes = totalBytes / encoder->channels + (ch < (totalBytes % encoder->channels)); + EncSetup *setup = encoder->channel_setup[ch]; - if (encoder->combined_channel_coding) + setup->targetBytes = totalBytes / encoder->channels + ( ch < ( totalBytes % encoder->channels ) ); + channel_bytes = totalBytes / encoder->channels + ( ch < ( totalBytes % encoder->channels ) ); + + if ( encoder->combined_channel_coding ) { setup->targetBytes = channel_bytes; } else { - setup->targetBytes = fec_get_data_size(encoder->epmode, encoder->combined_channel_coding, channel_bytes); - setup->n_pccw = fec_get_n_pccw(channel_bytes, encoder->epmode, encoder->combined_channel_coding); - setup->n_pc = fec_get_n_pc(encoder->epmode, setup->n_pccw, channel_bytes); + setup->targetBytes = fec_get_data_size( encoder->epmode, encoder->combined_channel_coding, channel_bytes ); + setup->n_pccw = fec_get_n_pccw( channel_bytes, encoder->epmode, encoder->combined_channel_coding ); + setup->n_pc = fec_get_n_pc( encoder->epmode, setup->n_pccw, channel_bytes ); } // reduce bandwith to 12kHz if bitrate is low - if (encoder->frame_dms == 100 && - ((setup->targetBytes < 40 && encoder->fs == 48000) || - (setup->targetBytes < 36 && encoder->fs == 32000))) + if ( encoder->frame_dms == 100 && + ( ( setup->targetBytes < 40 && encoder->fs == 48000 ) || + ( setup->targetBytes < 36 && encoder->fs == 32000 ) ) ) { - encoder->bandwidth = MIN(12000, encoder->bandwidth_preset); + encoder->bandwidth = MIN( 12000, encoder->bandwidth_preset ); } else { @@ -367,49 +427,51 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate) encoder->bandwidth = encoder->bandwidth_preset; } encoder->bw_ctrl_cutoff_bin = encoder->bandwidth * encoder->frame_dms / 5000; - encoder->bw_index = (encoder->bandwidth / 4000) - 1; - setup->total_bits = setup->targetBytes << 3; + encoder->bw_index = ( encoder->bandwidth / 4000 ) - 1; + setup->total_bits = setup->targetBytes << 3; setup->targetBitsInit = setup->total_bits - encoder->envelope_bits - encoder->global_gain_bits - encoder->noise_fac_bits - encoder->BW_cutoff_bits - - ceil(LC3_LOGTWO(encoder->frame_length / 2)) - 2 - 1; + ceil( LC3_LOGTWO( encoder->frame_length / 2 ) ) - 2 - 1; - if (setup->total_bits > 1280) { + if ( setup->total_bits > 1280 ) + { setup->targetBitsInit = setup->targetBitsInit - 1; } - if (setup->total_bits > 2560) { + if ( setup->total_bits > 2560 ) + { setup->targetBitsInit = setup->targetBitsInit - 1; } - if (encoder->hrmode) + if ( encoder->hrmode ) { setup->targetBitsInit -= 1; } - setup->targetBitsAri = setup->total_bits; + setup->targetBitsAri = setup->total_bits; setup->enable_lpc_weighting = setup->total_bits < 480; - if (encoder->frame_ms == 5) { + if ( encoder->frame_ms == 5 ) + { setup->enable_lpc_weighting = setup->total_bits < 240; } - if (encoder->frame_ms == 2.5) { + if ( encoder->frame_ms == 2.5 ) + { setup->enable_lpc_weighting = setup->total_bits < 120; } setup->quantizedGainOff = - -(MIN(115, setup->total_bits / (10 * (encoder->fs_idx + 1))) + 105 + 5 * (encoder->fs_idx + 1)); + -( MIN( 115, setup->total_bits / ( 10 * ( encoder->fs_idx + 1 ) ) ) + 105 + 5 * ( encoder->fs_idx + 1 ) ); - if (encoder->hrmode && encoder->fs_idx == 5) + if ( encoder->hrmode && encoder->fs_idx == 5 ) { - setup->quantizedGainOff = MAX(setup->quantizedGainOff, -181); + setup->quantizedGainOff = MAX( setup->quantizedGainOff, -181 ); } - if (encoder->frame_ms == 10 && ((encoder->fs_in >= 44100 && setup->targetBytes >= 100) || - (encoder->fs_in == 32000 && setup->targetBytes >= 81)) && setup->targetBytes < 340 && encoder->hrmode == 0) { + if ( encoder->frame_ms == 10 && ( ( encoder->fs_in >= 44100 && setup->targetBytes >= 100 ) || ( encoder->fs_in == 32000 && setup->targetBytes >= 81 ) ) && setup->targetBytes < 340 && encoder->hrmode == 0 ) + { setup->attack_handling = 1; - - } - else if (encoder->frame_dms == 75 && ((encoder->fs_in >= 44100 && setup->targetBytes >= 75) || - (encoder->fs_in == 32000 && setup->targetBytes >= 61)) && setup->targetBytes < 150 && encoder->hrmode == 0) + } + else if ( encoder->frame_dms == 75 && ( ( encoder->fs_in >= 44100 && setup->targetBytes >= 75 ) || ( encoder->fs_in == 32000 && setup->targetBytes >= 61 ) ) && setup->targetBytes < 150 && encoder->hrmode == 0 ) { setup->attack_handling = 1; } @@ -421,97 +483,116 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate) setup->attdec_filter_mem[0] = 0; setup->attdec_filter_mem[1] = 0; - setup->attdec_detected = 0; - setup->attdec_position = 0; + setup->attdec_detected = 0; + setup->attdec_position = 0; setup->attdec_acc_energy = 0; } bitsTmp = setup->total_bits; - if (encoder->frame_ms == 2.5) { - bitsTmp = bitsTmp * 4.0 * (1.0 - 0.4); + if ( encoder->frame_ms == 2.5 ) + { + bitsTmp = bitsTmp * 4.0 * ( 1.0 - 0.4 ); } - if (encoder->frame_ms == 5) { + if ( encoder->frame_ms == 5 ) + { bitsTmp = bitsTmp * 2 - 160; } - if (bitsTmp < 400 + (encoder->fs_idx - 1) * 80) { + if ( bitsTmp < 400 + ( encoder->fs_idx - 1 ) * 80 ) + { setup->ltpf_enable = 1; - } else if (bitsTmp < 480 + (encoder->fs_idx - 1) * 80) { + } + else if ( bitsTmp < 480 + ( encoder->fs_idx - 1 ) * 80 ) + { setup->ltpf_enable = 1; - } else if (bitsTmp < 560 + (encoder->fs_idx - 1) * 80) { + } + else if ( bitsTmp < 560 + ( encoder->fs_idx - 1 ) * 80 ) + { setup->ltpf_enable = 1; - } else if (bitsTmp < 640 + (encoder->fs_idx - 1) * 80) { + } + else if ( bitsTmp < 640 + ( encoder->fs_idx - 1 ) * 80 ) + { setup->ltpf_enable = 1; - } else { + } + else + { setup->ltpf_enable = 0; } - if (encoder->hrmode) { + if ( encoder->hrmode ) + { setup->ltpf_enable = 0; } /* turn down SNS shaping for higher rates */ - if (encoder->hrmode == 0) { + if ( encoder->hrmode == 0 ) + { encoder->sns_damping = 0.85; - } else { + } + else + { encoder->sns_damping = 0.6; - if (encoder->fs_idx >= 4) { - if (encoder->frame_ms == 10) + if ( encoder->fs_idx >= 4 ) + { + if ( encoder->frame_ms == 10 ) { - if (setup->total_bits > 4400) { - encoder->sns_damping = 6881.0/32768.0; + if ( setup->total_bits > 4400 ) + { + encoder->sns_damping = 6881.0 / 32768.0; } } - if (encoder->frame_ms == 5) + if ( encoder->frame_ms == 5 ) { - if (setup->total_bits > 4600/2) { - encoder->sns_damping = 4915.0/32768.0; + if ( setup->total_bits > 4600 / 2 ) + { + encoder->sns_damping = 4915.0 / 32768.0; } } - if (encoder->frame_ms == 2.5) + if ( encoder->frame_ms == 2.5 ) { - if (setup->total_bits > 4600/4) { - encoder->sns_damping = 4915.0/32768.0; + if ( setup->total_bits > 4600 / 4 ) + { + encoder->sns_damping = 4915.0 / 32768.0; } } } } - if (encoder->hrmode && encoder->fs_idx >= 4) + if ( encoder->hrmode && encoder->fs_idx >= 4 ) { int real_rate = setup->targetBytes * 8000 / encoder->frame_ms; setup->regBits = real_rate / 12500; - if (encoder->fs_idx == 5) + if ( encoder->fs_idx == 5 ) { - if (encoder->frame_ms == 10) + if ( encoder->frame_ms == 10 ) { - setup->regBits +=2; + setup->regBits += 2; } - if (encoder->frame_ms == 2.5) + if ( encoder->frame_ms == 2.5 ) { setup->regBits -= 6; } } else { - if (encoder->frame_ms == 2.5) + if ( encoder->frame_ms == 2.5 ) { setup->regBits -= 6; } - else if (encoder->frame_ms == 5) + else if ( encoder->frame_ms == 5 ) { setup->regBits += 0; } - if (encoder->frame_ms == 10) + if ( encoder->frame_ms == 10 ) { setup->regBits += 5; } } - if (setup->regBits < 6) + if ( setup->regBits < 6 ) { setup->regBits = 6; } - if (setup->regBits > 23) + if ( setup->regBits > 23 ) { setup->regBits = 23; } @@ -527,18 +608,20 @@ LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate) return LC3PLUS_OK; } -void update_enc_bandwidth(LC3PLUS_Enc* encoder, int bandwidth) +void update_enc_bandwidth( LC3PLUS_Enc *encoder, int bandwidth ) { int index = 0; - if (bandwidth >= encoder->fs_in) { + if ( bandwidth >= encoder->fs_in ) + { encoder->bandwidth = 0; } else { encoder->bandwidth = bandwidth; - index = FS2FS_IDX(bandwidth); - if (index > 4) { + index = FS2FS_IDX( bandwidth ); + if ( index > 4 ) + { index = 5; } encoder->bw_ctrl_cutoff_bin = encoder->cutoffBins[index]; diff --git a/lib_lc3plus/setup_enc_lc3.h b/lib_lc3plus/setup_enc_lc3.h index 31f0cbeb50..c5570c4636 100644 --- a/lib_lc3plus/setup_enc_lc3.h +++ b/lib_lc3plus/setup_enc_lc3.h @@ -1,12 +1,12 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #ifndef SETUP_ENC_LC3_FL_H #define SETUP_ENC_LC3_FL_H @@ -14,7 +14,8 @@ #include "constants.h" /* Channel state and bitrate-derived values go in this struct */ -typedef struct { +typedef struct +{ LC3_FLOAT targetBitsOff; LC3_FLOAT ltpf_mem_normcorr; LC3_FLOAT ltpf_mem_mem_normcorr; @@ -55,7 +56,7 @@ typedef struct { LC3_INT codingdata[3 * MAX_LEN]; uint8_t resBits[MAX_RESBITS_LEN]; LC3_INT regBits; - + LC3_INT16 n_pc; LC3_INT16 n_pccw; LC3_INT16 be_bp_left; @@ -68,11 +69,12 @@ typedef struct { } EncSetup; /* Constants and sampling rate derived values go in this struct */ -struct LC3PLUS_Enc { - EncSetup* channel_setup[MAX_CHANNELS]; - const LC3_INT* W_fx; - const LC3_INT* bands_offset; - const LC3_INT* cutoffBins; +struct LC3PLUS_Enc +{ + EncSetup *channel_setup[MAX_CHANNELS]; + const LC3_INT *W_fx; + const LC3_INT *bands_offset; + const LC3_INT *cutoffBins; LC3_INT fs; /* encoder sampling rate 44.1 -> 48 */ LC3_INT fs_in; /* input sampling rate */ @@ -103,15 +105,15 @@ struct LC3PLUS_Enc { LC3_INT tnsMaxOrder; LC3_INT hrmode; LC3_INT bandwidth; - LC3_INT bandwidth_preset; - LC3_INT bw_ctrl_active; + LC3_INT bandwidth_preset; + LC3_INT bw_ctrl_active; LC3_INT bw_ctrl_cutoff_bin; LC3_INT bw_index; LC3_FLOAT sns_damping; LC3_INT attdec_nblocks; LC3_FLOAT attdec_damping; LC3_INT attdec_hangover_thresh; - + LC3_INT16 combined_channel_coding; LC3_INT16 epmr; }; diff --git a/lib_lc3plus/sns_compute_scf.c b/lib_lc3plus/sns_compute_scf.c index 5cb041925b..78a4089a16 100644 --- a/lib_lc3plus/sns_compute_scf.c +++ b/lib_lc3plus/sns_compute_scf.c @@ -1,47 +1,50 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -void processSnsComputeScf_fl(LC3_FLOAT* x, LC3_INT tilt, LC3_INT xLen, LC3_FLOAT* gains, LC3_INT smooth, LC3_FLOAT sns_damping, LC3_FLOAT attdec_damping_factor) +void processSnsComputeScf_fl( LC3_FLOAT *x, LC3_INT tilt, LC3_INT xLen, LC3_FLOAT *gains, LC3_INT smooth, LC3_FLOAT sns_damping, LC3_FLOAT attdec_damping_factor ) { - LC3_INT bands_number = 0, d = 0, i = 0, j = 0, n = 0, n2 = 0, n4 = 0, mapping[64] = {0}; - LC3_FLOAT tmp[64] = {0}, x_tmp1[MAX_LEN] = {0}, x_tmp2[MAX_LEN] = {0}, sum = 0, mean = 0, xl4[16] = {0}, nf = 0, xl[64] = {0}, gains_smooth[M] = {0}, ratio = 0; - LC3_FLOAT W[6] = {1.0 / 12.0, 2.0 / 12.0, 3.0 / 12.0, 3.0 / 12.0, 2.0 / 12.0, 1.0 / 12.0}; + LC3_INT bands_number = 0, d = 0, i = 0, j = 0, n = 0, n2 = 0, n4 = 0, mapping[64] = { 0 }; + LC3_FLOAT tmp[64] = { 0 }, x_tmp1[MAX_LEN] = { 0 }, x_tmp2[MAX_LEN] = { 0 }, sum = 0, mean = 0, xl4[16] = { 0 }, nf = 0, xl[64] = { 0 }, gains_smooth[M] = { 0 }, ratio = 0; + LC3_FLOAT W[6] = { 1.0 / 12.0, 2.0 / 12.0, 3.0 / 12.0, 3.0 / 12.0, 2.0 / 12.0, 1.0 / 12.0 }; bands_number = xLen; - assert(bands_number <= 64); + assert( bands_number <= 64 ); /* 5 ms */ - if (bands_number < 64) { + if ( bands_number < 64 ) + { d = 64 - bands_number; - if (d < xLen) + if ( d < xLen ) { j = 0; - for (i = 0; i < 2 * d; i = i + 2) { - tmp[i] = x[j]; + for ( i = 0; i < 2 * d; i = i + 2 ) + { + tmp[i] = x[j]; tmp[i + 1] = x[j]; j++; } - move_float(&tmp[2 * d], &x[d], 64 - 2 * d); - } else if (ceil(64.0 / (LC3_FLOAT) xLen) == 4) + move_float( &tmp[2 * d], &x[d], 64 - 2 * d ); + } + else if ( ceil( 64.0 / (LC3_FLOAT) xLen ) == 4 ) { - ratio = LC3_FABS((LC3_FLOAT) (1.0 - 32.0 / (LC3_FLOAT) xLen)); - n4 = round(ratio * xLen); + ratio = LC3_FABS( (LC3_FLOAT) ( 1.0 - 32.0 / (LC3_FLOAT) xLen ) ); + n4 = round( ratio * xLen ); n2 = xLen - n4; - + j = 0; - for(i = 1; i <= n4; i++) + for ( i = 1; i <= n4; i++ ) { mapping[j] = i; mapping[j + 1] = i; @@ -49,27 +52,29 @@ void processSnsComputeScf_fl(LC3_FLOAT* x, LC3_INT tilt, LC3_INT xLen, LC3_FLOAT mapping[j + 3] = i; j += 4; } - - for (i = n4 + 1; i <= n4 + n2; i++) + + for ( i = n4 + 1; i <= n4 + n2; i++ ) { mapping[j] = i; mapping[j + 1] = i; j += 2; } - - - for (i = 0; i < 64; i++) + + + for ( i = 0; i < 64; i++ ) { tmp[i] = x[mapping[i] - 1]; } - } else { - assert(0 && "Unsupported number of bands!"); + } + else + { + assert( 0 && "Unsupported number of bands!" ); } - move_float(x, tmp, 64); + move_float( x, tmp, 64 ); bands_number = 64; - xLen = bands_number; + xLen = bands_number; } @@ -77,60 +82,71 @@ void processSnsComputeScf_fl(LC3_FLOAT* x, LC3_INT tilt, LC3_INT xLen, LC3_FLOAT x_tmp1[0] = x[0]; - move_float(&x_tmp1[1], &x[0], xLen - 1); + move_float( &x_tmp1[1], &x[0], xLen - 1 ); - move_float(&x_tmp2[0], &x[1], xLen - 1); + move_float( &x_tmp2[0], &x[1], xLen - 1 ); x_tmp2[xLen - 1] = x[xLen - 1]; - for (i = 0; i < xLen; i++) { - x[i] = 0.5 * x[i] + 0.25 * (x_tmp1[i] + x_tmp2[i]); + for ( i = 0; i < xLen; i++ ) + { + x[i] = 0.5 * x[i] + 0.25 * ( x_tmp1[i] + x_tmp2[i] ); } /* Pre-emphasis */ - for (i = 0; i < xLen; i++) { - x[i] = x[i] * LC3_POW(10.0, (LC3_FLOAT)i * (LC3_FLOAT)tilt / ((LC3_FLOAT)bands_number - 1.0) / 10.0); + for ( i = 0; i < xLen; i++ ) + { + x[i] = x[i] * LC3_POW( 10.0, (LC3_FLOAT) i * (LC3_FLOAT) tilt / ( (LC3_FLOAT) bands_number - 1.0 ) / 10.0 ); } /* Noise floor at -40dB */ - for (i = 0; i < 64; i++) { + for ( i = 0; i < 64; i++ ) + { sum += x[i]; } - mean = sum / (LC3_FLOAT)xLen; + mean = sum / (LC3_FLOAT) xLen; - nf = mean * LC3_POW(10.0, -40.0 / 10.0); - nf = MAX(nf, LC3_POW(2.0, -32.0)); + nf = mean * LC3_POW( 10.0, -40.0 / 10.0 ); + nf = MAX( nf, LC3_POW( 2.0, -32.0 ) ); - for (i = 0; i < 64; i++) { - if (x[i] < nf) { + for ( i = 0; i < 64; i++ ) + { + if ( x[i] < nf ) + { x[i] = nf; } } /* Log-domain */ - for (i = 0; i < 64; i++) { - xl[i] = LC3_LOGTWO(x[i]) / 2.0; + for ( i = 0; i < 64; i++ ) + { + xl[i] = LC3_LOGTWO( x[i] ) / 2.0; } /* Downsampling */ - for (n = 0; n < bands_number / 4; n++) { - if (n == 0) { + for ( n = 0; n < bands_number / 4; n++ ) + { + if ( n == 0 ) + { tmp[0] = xl[0]; - move_float(&tmp[1], &xl[0], 5); - - } else if (n == (bands_number / 4 - 1)) { - move_float(tmp, &xl[59], 5); + move_float( &tmp[1], &xl[0], 5 ); + } + else if ( n == ( bands_number / 4 - 1 ) ) + { + move_float( tmp, &xl[59], 5 ); tmp[5] = xl[63]; - - } else { - move_float(tmp, &xl[n * 4 - 1], ((n * 4 + 5 - 1) - (n * 4 - 1) + 1)); + } + else + { + move_float( tmp, &xl[n * 4 - 1], ( ( n * 4 + 5 - 1 ) - ( n * 4 - 1 ) + 1 ) ); } sum = 0; - for (i = 0; i < 6; i++) { + for ( i = 0; i < 6; i++ ) + { sum += tmp[i] * W[i]; } @@ -141,37 +157,43 @@ void processSnsComputeScf_fl(LC3_FLOAT* x, LC3_INT tilt, LC3_INT xLen, LC3_FLOAT /* Remove mean and scaling */ sum = 0; - for (i = 0; i < bands_number / 4; i++) { + for ( i = 0; i < bands_number / 4; i++ ) + { sum += xl4[i]; } - mean = sum / ((LC3_FLOAT)bands_number / 4.0); + mean = sum / ( (LC3_FLOAT) bands_number / 4.0 ); - for (i = 0; i < bands_number / 4; i++) { - gains[i] = sns_damping * (xl4[i] - mean); + for ( i = 0; i < bands_number / 4; i++ ) + { + gains[i] = sns_damping * ( xl4[i] - mean ); } /* Smoothing */ - if (smooth) { - gains_smooth[0] = (gains[0] + gains[1] + gains[2]) / 3.0; - gains_smooth[1] = (gains[0] + gains[1] + gains[2] + gains[3]) / 4.0; + if ( smooth ) + { + gains_smooth[0] = ( gains[0] + gains[1] + gains[2] ) / 3.0; + gains_smooth[1] = ( gains[0] + gains[1] + gains[2] + gains[3] ) / 4.0; - for (i = 2; i < 14; i++) { - gains_smooth[i] = (gains[i - 2] + gains[i - 1] + gains[i] + gains[i + 1] + gains[i + 2]) / 5.0; + for ( i = 2; i < 14; i++ ) + { + gains_smooth[i] = ( gains[i - 2] + gains[i - 1] + gains[i] + gains[i + 1] + gains[i + 2] ) / 5.0; } - gains_smooth[M - 2] = (gains[M - 4] + gains[M - 3] + gains[M - 2] + gains[M - 1]) / 4.0; - gains_smooth[M - 1] = (gains[M - 3] + gains[M - 2] + gains[M - 1]) / 3.0; + gains_smooth[M - 2] = ( gains[M - 4] + gains[M - 3] + gains[M - 2] + gains[M - 1] ) / 4.0; + gains_smooth[M - 1] = ( gains[M - 3] + gains[M - 2] + gains[M - 1] ) / 3.0; sum = 0; - for (i = 0; i < M; i++) { + for ( i = 0; i < M; i++ ) + { sum += gains_smooth[i]; } - mean = sum / (LC3_FLOAT)M; + mean = sum / (LC3_FLOAT) M; - for (i = 0; i < M; i++) { - gains[i] = attdec_damping_factor * (gains_smooth[i] - mean); + for ( i = 0; i < M; i++ ) + { + gains[i] = attdec_damping_factor * ( gains_smooth[i] - mean ); } } } diff --git a/lib_lc3plus/sns_interpolate_scf.c b/lib_lc3plus/sns_interpolate_scf.c index 4419397890..4518393003 100644 --- a/lib_lc3plus/sns_interpolate_scf.c +++ b/lib_lc3plus/sns_interpolate_scf.c @@ -1,90 +1,101 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -void processSnsInterpolateScf_fl(LC3_FLOAT* gains, LC3_INT encoder_side, LC3_INT bands_number, LC3_FLOAT* gains_int) +void processSnsInterpolateScf_fl( LC3_FLOAT *gains, LC3_INT encoder_side, LC3_INT bands_number, LC3_FLOAT *gains_int ) { - LC3_INT i = 0, n = 0, d = 0, n4 = 0; - LC3_FLOAT tmp[MAX_BANDS_NUMBER_PLC] = {0}, ratio = 0; + LC3_INT i = 0, n = 0, d = 0, n4 = 0; + LC3_FLOAT tmp[MAX_BANDS_NUMBER_PLC] = { 0 }, ratio = 0; /* Interpolation */ gains_int[0] = gains[0]; gains_int[1] = gains[0]; - for (n = 0; n <= 14; n++) { - gains_int[n * 4 + 2] = gains[n] + (gains[n + 1] - gains[n]) / 8.0; - gains_int[n * 4 + 3] = gains[n] + 3.0 * (gains[n + 1] - gains[n]) / 8.0; - gains_int[n * 4 + 4] = gains[n] + 5.0 * (gains[n + 1] - gains[n]) / 8.0; - gains_int[n * 4 + 5] = gains[n] + 7.0 * (gains[n + 1] - gains[n]) / 8.0; + for ( n = 0; n <= 14; n++ ) + { + gains_int[n * 4 + 2] = gains[n] + ( gains[n + 1] - gains[n] ) / 8.0; + gains_int[n * 4 + 3] = gains[n] + 3.0 * ( gains[n + 1] - gains[n] ) / 8.0; + gains_int[n * 4 + 4] = gains[n] + 5.0 * ( gains[n + 1] - gains[n] ) / 8.0; + gains_int[n * 4 + 5] = gains[n] + 7.0 * ( gains[n + 1] - gains[n] ) / 8.0; } - gains_int[62] = gains[15] + (gains[15] - gains[14]) / 8.0; - gains_int[63] = gains[15] + 3.0 * (gains[15] - gains[14]) / 8.0; + gains_int[62] = gains[15] + ( gains[15] - gains[14] ) / 8.0; + gains_int[63] = gains[15] + 3.0 * ( gains[15] - gains[14] ) / 8.0; /* For 5ms */ - if (bands_number < 64) { + if ( bands_number < 64 ) + { d = 64 - bands_number; - if (d < 32) + if ( d < 32 ) { i = 0; - for (n = 0; n < 2 * d; n = n + 2) { - tmp[i] = (gains_int[n] + gains_int[n + 1]) / (LC3_FLOAT)2.0; + for ( n = 0; n < 2 * d; n = n + 2 ) + { + tmp[i] = ( gains_int[n] + gains_int[n + 1] ) / (LC3_FLOAT) 2.0; i++; } - for (n = 1; n < d; n++) { + for ( n = 1; n < d; n++ ) + { gains_int[n] = gains_int[2 * n]; } - for (n = 2 * d; n < 64; n++) { + for ( n = 2 * d; n < 64; n++ ) + { gains_int[n - d] = gains_int[n]; } - move_float(gains_int, tmp, d); - } else if (ceil(64.0 / (LC3_FLOAT) bands_number) == 4) + move_float( gains_int, tmp, d ); + } + else if ( ceil( 64.0 / (LC3_FLOAT) bands_number ) == 4 ) { - ratio = LC3_FABS((LC3_FLOAT) ((LC3_FLOAT)1.0 - (LC3_FLOAT)32.0 / (LC3_FLOAT) bands_number)); - n4 = LC3_ROUND(ratio * (LC3_FLOAT)bands_number); - - for (i = 0; i < n4; i++) + ratio = LC3_FABS( (LC3_FLOAT) ( (LC3_FLOAT) 1.0 - (LC3_FLOAT) 32.0 / (LC3_FLOAT) bands_number ) ); + n4 = LC3_ROUND( ratio * (LC3_FLOAT) bands_number ); + + for ( i = 0; i < n4; i++ ) { - tmp[i] = (gains_int[4 * i] + gains_int[4 * i + 1] + gains_int[4 * i + 2] + gains_int[4 * i + 3]) / 4.0; + tmp[i] = ( gains_int[4 * i] + gains_int[4 * i + 1] + gains_int[4 * i + 2] + gains_int[4 * i + 3] ) / 4.0; } - - for (i = 0; i < bands_number - n4; i++) + + for ( i = 0; i < bands_number - n4; i++ ) { - tmp[n4 + i] = (gains_int[4 * n4 + 2 * i] + gains_int[4 * n4 + 2 * i + 1]) / 2.0; + tmp[n4 + i] = ( gains_int[4 * n4 + 2 * i] + gains_int[4 * n4 + 2 * i + 1] ) / 2.0; } - - move_float(gains_int, tmp, bands_number); - } else { - assert(0 && "Unsupported number of bands!"); + + move_float( gains_int, tmp, bands_number ); + } + else + { + assert( 0 && "Unsupported number of bands!" ); } } /* Inversion at encoder-side */ - if (encoder_side == 1) { - for (n = 0; n < bands_number; n++) { + if ( encoder_side == 1 ) + { + for ( n = 0; n < bands_number; n++ ) + { gains_int[n] = -gains_int[n]; } } /* Linear domain */ - for (n = 0; n < bands_number; n++) { - gains_int[n] = LC3_POW(2, gains_int[n]); + for ( n = 0; n < bands_number; n++ ) + { + gains_int[n] = LC3_POW( 2, gains_int[n] ); } } diff --git a/lib_lc3plus/sns_quantize_scf.c b/lib_lc3plus/sns_quantize_scf.c index 704127cce7..05bc62f186 100644 --- a/lib_lc3plus/sns_quantize_scf.c +++ b/lib_lc3plus/sns_quantize_scf.c @@ -1,34 +1,35 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -static void pvq_dec(LC3_INT k, LC3_INT m, LC3_INT LS_ind, LC3_INT MPVQ_ind, LC3_INT* pulses); -static LC3_INT find_last_indice_le(LC3_INT compare, const LC3_INT* array, LC3_INT len); -static void idct_II(LC3_FLOAT* in, LC3_FLOAT* out, LC3_INT len); +static void pvq_dec( LC3_INT k, LC3_INT m, LC3_INT LS_ind, LC3_INT MPVQ_ind, LC3_INT *pulses ); +static LC3_INT find_last_indice_le( LC3_INT compare, const LC3_INT *array, LC3_INT len ); +static void idct_II( LC3_FLOAT *in, LC3_FLOAT *out, LC3_INT len ); -void idct_II(LC3_FLOAT* in, LC3_FLOAT* out, LC3_INT len) +void idct_II( LC3_FLOAT *in, LC3_FLOAT *out, LC3_INT len ) { LC3_INT i; LC3_FLOAT norm1, sum; norm1 = 0.353553390593274; /* sqrt(2 / 16) */ - - for (i = 0; i < len; i++) { - sum = mac_loop(in, idct_lookup[i], len); + + for ( i = 0; i < len; i++ ) + { + sum = mac_loop( in, idct_lookup[i], len ); out[i] = norm1 * sum; } } -static LC3_INT pvq_pulse_search(LC3_FLOAT *xabs, LC3_FLOAT *ener, LC3_FLOAT *corr, LC3_INT *y, LC3_INT start, LC3_INT end) +static LC3_INT pvq_pulse_search( LC3_FLOAT *xabs, LC3_FLOAT *ener, LC3_FLOAT *corr, LC3_INT *y, LC3_INT start, LC3_INT end ) { LC3_INT i; LC3_INT nBest; @@ -44,7 +45,7 @@ static LC3_INT pvq_pulse_search(LC3_FLOAT *xabs, LC3_FLOAT *ener, LC3_FLOAT *cor i = start; currCorr = *corr + xabs[i]; - currEn = *ener + (2 * y[i]); + currEn = *ener + ( 2 * y[i] ); corrSq = currCorr * currCorr; @@ -53,14 +54,14 @@ static LC3_INT pvq_pulse_search(LC3_FLOAT *xabs, LC3_FLOAT *ener, LC3_FLOAT *cor nBest = i; /* Iterative max search as recommended in the spec */ - for (; i < end; i++) + for ( ; i < end; i++ ) { currCorr = *corr + xabs[i]; - currEn = *ener + (2 * y[i]); + currEn = *ener + ( 2 * y[i] ); corrSq = currCorr * currCorr; - if ((corrSq * bestEn) > (bestCorrSq * currEn)) + if ( ( corrSq * bestEn ) > ( bestCorrSq * currEn ) ) { bestEn = currEn; bestCorrSq = corrSq; @@ -69,26 +70,26 @@ static LC3_INT pvq_pulse_search(LC3_FLOAT *xabs, LC3_FLOAT *ener, LC3_FLOAT *cor } *corr += xabs[nBest]; - *ener += (2 * y[nBest]); + *ener += ( 2 * y[nBest] ); y[nBest] += 1; /* Add the selected unit pulse */ return nBest; } -static void pvq_enc_vec_normalize(LC3_FLOAT *vec, LC3_INT N) +static void pvq_enc_vec_normalize( LC3_FLOAT *vec, LC3_INT N ) { LC3_FLOAT mag = 0.0, norm_fac; LC3_INT i; - for (i = 0; i < N; i++) + for ( i = 0; i < N; i++ ) { - mag += (vec[i] * vec[i]); + mag += ( vec[i] * vec[i] ); } - norm_fac = 1.0 / LC3_SQRT(mag); + norm_fac = 1.0 / LC3_SQRT( mag ); - for (i = 0; i < N; i++) + for ( i = 0; i < N; i++ ) { vec[i] = vec[i] * norm_fac; } @@ -96,7 +97,7 @@ static void pvq_enc_vec_normalize(LC3_FLOAT *vec, LC3_INT N) return; } -static void pvq_enc_search(LC3_FLOAT* x_in, LC3_INT y[4][M]) +static void pvq_enc_search( LC3_FLOAT *x_in, LC3_INT y[4][M] ) { LC3_INT i, N, K, pulse_total, N_setA; LC3_FLOAT abs_sum, projfac; @@ -113,43 +114,43 @@ static void pvq_enc_search(LC3_FLOAT* x_in, LC3_INT y[4][M]) yy = xy = 0.0f; - for (i = 0; i < N; i++) + for ( i = 0; i < N; i++ ) { - xabs[i] = LC3_FABS(x_in[i]); + xabs[i] = LC3_FABS( x_in[i] ); abs_sum += xabs[i]; } - projfac = (K - 1) / abs_sum; + projfac = ( K - 1 ) / abs_sum; - for (i = 0; i < N; i++) + for ( i = 0; i < N; i++ ) { - y[3][i] = floor(xabs[i] * projfac); + y[3][i] = floor( xabs[i] * projfac ); pulse_total += y[3][i]; - yy += (y[3][i] * y[3][i]); - xy += (xabs[i] * y[3][i]); + yy += ( y[3][i] * y[3][i] ); + xy += ( xabs[i] * y[3][i] ); } /* Step 2: Adding unit pulses up to K = 6 */ - for (; pulse_total < K; pulse_total++) + for ( ; pulse_total < K; pulse_total++ ) { - pvq_pulse_search(xabs, &yy, &xy, y[3], 0, N); + pvq_pulse_search( xabs, &yy, &xy, y[3], 0, N ); } /* Step 3: Adding unit pulses up to K = 8 */ - memcpy(y[2], y[3], sizeof(LC3_INT)*N); + memcpy( y[2], y[3], sizeof( LC3_INT ) * N ); K = 8; - for (; pulse_total < K; pulse_total++) + for ( ; pulse_total < K; pulse_total++ ) { - pvq_pulse_search(xabs, &yy, &xy, y[2], 0, N); + pvq_pulse_search( xabs, &yy, &xy, y[2], 0, N ); } - memcpy(y[1], y[2], sizeof(LC3_INT)*N_setA); + memcpy( y[1], y[2], sizeof( LC3_INT ) * N_setA ); /* Step 4: Remove unit pulses not belonging to set A */ - for (i = N_setA; i < N; i++) + for ( i = N_setA; i < N; i++ ) { y[1][i] = 0; } @@ -159,30 +160,30 @@ static void pvq_enc_search(LC3_FLOAT* x_in, LC3_INT y[4][M]) xy = 0; pulse_total = 0; - for (i = 0; i < N_setA; i++) + for ( i = 0; i < N_setA; i++ ) { - yy += (y[1][i] * y[1][i]); - xy += (xabs[i] * y[1][i]); + yy += ( y[1][i] * y[1][i] ); + xy += ( xabs[i] * y[1][i] ); pulse_total += y[1][i]; } /* Step 6: Add unit pulses until K = 10 over N = 10 */ K = 10; - for (; pulse_total < K; pulse_total++) + for ( ; pulse_total < K; pulse_total++ ) { - pvq_pulse_search(xabs, &yy, &xy, y[1], 0, N_setA); + pvq_pulse_search( xabs, &yy, &xy, y[1], 0, N_setA ); } - memcpy(y[0], y[1], sizeof(LC3_INT)*N); + memcpy( y[0], y[1], sizeof( LC3_INT ) * N ); /* Step 7: Add unit pulses until K = 1 over N = 6 in set B*/ - pvq_pulse_search(xabs, &yy, &xy, y[0], N_setA, N); + pvq_pulse_search( xabs, &yy, &xy, y[0], N_setA, N ); /* Step 8: Add signs to each of the 4 vectors from x */ - for (i = 0; i < N; i++) + for ( i = 0; i < N; i++ ) { - if (x_in[i] < 0) + if ( x_in[i] < 0 ) { y[0][i] = -y[0][i]; y[1][i] = -y[1][i]; @@ -194,24 +195,23 @@ static void pvq_enc_search(LC3_FLOAT* x_in, LC3_INT y[4][M]) return; } -static inline LC3_FLOAT calc_mse(LC3_FLOAT *t2rot, LC3_FLOAT *y, LC3_FLOAT gain, LC3_INT N) +static inline LC3_FLOAT calc_mse( LC3_FLOAT *t2rot, LC3_FLOAT *y, LC3_FLOAT gain, LC3_INT N ) { LC3_FLOAT mse; LC3_INT i; mse = 0.0; - for (i = 0; i < N; i++) + for ( i = 0; i < N; i++ ) { - LC3_FLOAT err = (t2rot[i] - gain * y[i]); - mse += (err * err); + LC3_FLOAT err = ( t2rot[i] - gain * y[i] ); + mse += ( err * err ); } return mse; } -static void sns_quant_adj_gain_shape_search(LC3_FLOAT *t2rot, LC3_INT y[4][M] , - LC3_INT *gain_idx, LC3_INT *shape_idx, LC3_FLOAT *y_norm, LC3_FLOAT *scq_gain) +static void sns_quant_adj_gain_shape_search( LC3_FLOAT *t2rot, LC3_INT y[4][M], LC3_INT *gain_idx, LC3_INT *shape_idx, LC3_FLOAT *y_norm, LC3_FLOAT *scq_gain ) { LC3_INT gidx, sidx; LC3_FLOAT min_mse, mse; @@ -220,8 +220,8 @@ static void sns_quant_adj_gain_shape_search(LC3_FLOAT *t2rot, LC3_INT y[4][M] , LC3_INT i; const LC3_INT gain_levels[4] = { 2, 4, 4, 8 }; - const LC3_FLOAT *sns_vq_gains[4] = { sns_vq_reg_adj_gains_fl , sns_vq_reg_lf_adj_gains_fl , - sns_vq_near_adj_gains_fl , sns_vq_far_adj_gains_fl }; + const LC3_FLOAT *sns_vq_gains[4] = { sns_vq_reg_adj_gains_fl, sns_vq_reg_lf_adj_gains_fl, + sns_vq_near_adj_gains_fl, sns_vq_far_adj_gains_fl }; min_mse = -1.0; N = 16; @@ -229,21 +229,21 @@ static void sns_quant_adj_gain_shape_search(LC3_FLOAT *t2rot, LC3_INT y[4][M] , *gain_idx = *shape_idx = 0; - for (sidx = 0; sidx < 4; sidx++) + for ( sidx = 0; sidx < 4; sidx++ ) { - for (i = 0; i < N; i++) + for ( i = 0; i < N; i++ ) { - yCur[sidx][i] = (LC3_FLOAT)y[sidx][i]; + yCur[sidx][i] = (LC3_FLOAT) y[sidx][i]; } /* Step 9: Normalize the vectors */ - pvq_enc_vec_normalize(yCur[sidx], N); + pvq_enc_vec_normalize( yCur[sidx], N ); - for (gidx = 0; gidx < gain_levels[sidx]; gidx++) + for ( gidx = 0; gidx < gain_levels[sidx]; gidx++ ) { - mse = calc_mse(t2rot, yCur[sidx], sns_vq_gains[sidx][gidx], N); + mse = calc_mse( t2rot, yCur[sidx], sns_vq_gains[sidx][gidx], N ); - if ((mse < min_mse) || (min_mse < 0)) + if ( ( mse < min_mse ) || ( min_mse < 0 ) ) { *gain_idx = gidx; *shape_idx = sidx; @@ -252,7 +252,7 @@ static void sns_quant_adj_gain_shape_search(LC3_FLOAT *t2rot, LC3_INT y[4][M] , } } - for (i = 0; i < N; i++) + for ( i = 0; i < N; i++ ) { y_norm[i] = yCur[*shape_idx][i]; } @@ -262,22 +262,25 @@ static void sns_quant_adj_gain_shape_search(LC3_FLOAT *t2rot, LC3_INT y[4][M] , return; } -static void enc_push_sign(LC3_FLOAT val, LC3_UINT32 *next_sign_ind, LC3_INT *index) +static void enc_push_sign( LC3_FLOAT val, LC3_UINT32 *next_sign_ind, LC3_INT *index ) { - if (((*next_sign_ind & 0x80000000U) == 0) && (val != 0)) { - *index = 2 * (*index) + *next_sign_ind; + if ( ( ( *next_sign_ind & 0x80000000U ) == 0 ) && ( val != 0 ) ) + { + *index = 2 * ( *index ) + *next_sign_ind; } - if (val < 0) { + if ( val < 0 ) + { *next_sign_ind = 1; } - if (val > 0) { + if ( val > 0 ) + { *next_sign_ind = 0; } return; } -static void MPVQ_enum(LC3_INT dim, LC3_INT *sns_vec, LC3_INT *index_val, LC3_INT *lead_sign_ind) +static void MPVQ_enum( LC3_INT dim, LC3_INT *sns_vec, LC3_INT *index_val, LC3_INT *lead_sign_ind ) { LC3_UINT32 next_sign_ind; LC3_INT k_val_acc; @@ -295,20 +298,21 @@ static void MPVQ_enum(LC3_INT dim, LC3_INT *sns_vec, LC3_INT *index_val, LC3_INT index = 0; n = 0; - row_ptr = (LC3_INT const *)&(pvq_enc_A[n]); + row_ptr = (LC3_INT const *) &( pvq_enc_A[n] ); tmp_h_row = row_ptr[0]; - for (pos--; pos >= 0; pos--) + for ( pos--; pos >= 0; pos-- ) { tmp_val = sns_vec[pos]; - enc_push_sign(tmp_val, &next_sign_ind, &index); + enc_push_sign( tmp_val, &next_sign_ind, &index ); index += tmp_h_row; - k_val_acc += abs(tmp_val); - if (pos != 0) { + k_val_acc += abs( tmp_val ); + if ( pos != 0 ) + { n += 1; /* switch row in offset table MPVQ_offsets(n, k) */ } - row_ptr = (LC3_INT const *)&(pvq_enc_A[n]); + row_ptr = (LC3_INT const *) &( pvq_enc_A[n] ); tmp_h_row = row_ptr[k_val_acc]; } @@ -319,7 +323,7 @@ static void MPVQ_enum(LC3_INT dim, LC3_INT *sns_vec, LC3_INT *index_val, LC3_INT return; } -static LC3_INT MSEsearch (LC3_FLOAT *scf, const LC3_FLOAT sns_CB[8][32]) +static LC3_INT MSEsearch( LC3_FLOAT *scf, const LC3_FLOAT sns_CB[8][32] ) { LC3_FLOAT distance, mse; LC3_INT i, n, ind; @@ -327,21 +331,24 @@ static LC3_INT MSEsearch (LC3_FLOAT *scf, const LC3_FLOAT sns_CB[8][32]) ind = 0; distance = (LC3_FLOAT) LC3_CONST_POW_2_100; - for (i = 0; i < 32; i++) { + for ( i = 0; i < 32; i++ ) + { mse = 0; - for (n = 0; n < 8; n++) { - mse += (scf[n] - sns_CB[n][i]) * (scf[n] - sns_CB[n][i]); + for ( n = 0; n < 8; n++ ) + { + mse += ( scf[n] - sns_CB[n][i] ) * ( scf[n] - sns_CB[n][i] ); } - if (mse < distance) { + if ( mse < distance ) + { distance = mse; - ind = i; + ind = i; } } return ind; } -void process_snsQuantizesScf_Enc(LC3_FLOAT* env, LC3_INT* index, LC3_FLOAT* envq, Dct2 dct2structSNS) +void process_snsQuantizesScf_Enc( LC3_FLOAT *env, LC3_INT *index, LC3_FLOAT *envq, Dct2 dct2structSNS ) { LC3_FLOAT stage2_en1_norm_sub[M]; LC3_INT i, j; @@ -354,72 +361,83 @@ void process_snsQuantizesScf_Enc(LC3_FLOAT* env, LC3_INT* index, LC3_FLOAT* envq LC3_INT y[4][M]; /* Stage 1 split VQ */ - index[0] = MSEsearch(&env[0], sns_LFCB); /* ind_LF */ - index[1] = MSEsearch(&env[8], sns_HFCB); /* ind_HF */ + index[0] = MSEsearch( &env[0], sns_LFCB ); /* ind_LF */ + index[1] = MSEsearch( &env[8], sns_HFCB ); /* ind_HF */ j = 8; - for (i = 0; i < 8; i++, j++) { + for ( i = 0; i < 8; i++, j++ ) + { st1_vector[i] = sns_LFCB[i][index[0]]; st1_vector[j] = sns_HFCB[i][index[1]]; } /* STAGE 2 */ - for (i = 0; i < 16; i++) { + for ( i = 0; i < 16; i++ ) + { pvq_target_pre[i] = env[i] - st1_vector[i]; } - dct2_apply(&dct2structSNS, pvq_target_pre, pvq_target); - pvq_enc_search(pvq_target, y); - sns_quant_adj_gain_shape_search(pvq_target, y, &gain, &shape, stage2_en1_norm_pre_sub, &scfq_gain); + dct2_apply( &dct2structSNS, pvq_target_pre, pvq_target ); + pvq_enc_search( pvq_target, y ); + sns_quant_adj_gain_shape_search( pvq_target, y, &gain, &shape, stage2_en1_norm_pre_sub, &scfq_gain ); /* Inverse transform */ - idct_II(stage2_en1_norm_pre_sub, stage2_en1_norm_sub, M); + idct_II( stage2_en1_norm_pre_sub, stage2_en1_norm_sub, M ); index[2] = shape; index[3] = gain; - if (shape < 2) { - MPVQ_enum(10, y[shape], &index[5], &index[4]); + if ( shape < 2 ) + { + MPVQ_enum( 10, y[shape], &index[5], &index[4] ); } - else { - MPVQ_enum(M, y[shape], &index[5], &index[4]); + else + { + MPVQ_enum( M, y[shape], &index[5], &index[4] ); } - if (shape == 0) { + if ( shape == 0 ) + { LC3_INT ls_ind, ind; - MPVQ_enum(6, &y[shape][10], &ind, &ls_ind); + MPVQ_enum( 6, &y[shape][10], &ind, &ls_ind ); index[6] = ind * 2 + ls_ind; } - else if (shape == 2) { + else if ( shape == 2 ) + { index[6] = -1; } - else { + else + { index[6] = -2; } - for (i = 0; i < M; i++) { - envq[i] = st1_vector[i] + (stage2_en1_norm_sub[i] * scfq_gain); + for ( i = 0; i < M; i++ ) + { + envq[i] = st1_vector[i] + ( stage2_en1_norm_sub[i] * scfq_gain ); } } -LC3_INT find_last_indice_le(LC3_INT compare, const LC3_INT* array, LC3_INT len) +LC3_INT find_last_indice_le( LC3_INT compare, const LC3_INT *array, LC3_INT len ) { LC3_INT idx = 0, i = 0; - for (i = 0; i < len; i++) { - if (compare >= array[i]) { + for ( i = 0; i < len; i++ ) + { + if ( compare >= array[i] ) + { idx++; } } - if (idx > 0) { + if ( idx > 0 ) + { idx--; } return idx; } -void pvq_dec(LC3_INT k, LC3_INT m, LC3_INT LS_ind, LC3_INT MPVQ_ind, LC3_INT* pulses) +void pvq_dec( LC3_INT k, LC3_INT m, LC3_INT LS_ind, LC3_INT MPVQ_ind, LC3_INT *pulses ) { LC3_INT leading_sign = 0, idx = 0, k_delta = 0, pos = 0; @@ -427,41 +445,50 @@ void pvq_dec(LC3_INT k, LC3_INT m, LC3_INT LS_ind, LC3_INT MPVQ_ind, LC3_INT* pu /* Decoding loop */ - for (pos = 0; pos < m; pos++) { - if (MPVQ_ind != 0) { + for ( pos = 0; pos < m; pos++ ) + { + if ( MPVQ_ind != 0 ) + { /* Find last indice */ - idx = find_last_indice_le(MPVQ_ind, &pvq_enc_A[m - pos - 1][0], k + 1); + idx = find_last_indice_le( MPVQ_ind, &pvq_enc_A[m - pos - 1][0], k + 1 ); MPVQ_ind = MPVQ_ind - pvq_enc_A[m - pos - 1][idx]; - k_delta = k - idx; - } else { + k_delta = k - idx; + } + else + { pulses[pos] = leading_sign * k; break; } - if (k_delta != 0) { + if ( k_delta != 0 ) + { pulses[pos] = leading_sign * k_delta; - if ((MPVQ_ind % 2) != 0) { + if ( ( MPVQ_ind % 2 ) != 0 ) + { leading_sign = -1; - } else { + } + else + { leading_sign = 1; } - MPVQ_ind = floor(MPVQ_ind / 2); - k = k - k_delta; + MPVQ_ind = floor( MPVQ_ind / 2 ); + k = k - k_delta; } } } -void process_snsQuantizesScf_Dec(LC3_INT* scf_idx, LC3_FLOAT* scf_q) +void process_snsQuantizesScf_Dec( LC3_INT *scf_idx, LC3_FLOAT *scf_q ) { - LC3_INT i = 0, submode = 0; - LC3_INT pulses2[6] = {0}, pulses[M] = {0}; - LC3_FLOAT st2_vector[M] = {0}, st2_vector_idct[M] = {0}, sum = 0; + LC3_INT i = 0, submode = 0; + LC3_INT pulses2[6] = { 0 }, pulses[M] = { 0 }; + LC3_FLOAT st2_vector[M] = { 0 }, st2_vector_idct[M] = { 0 }, sum = 0; /* Decode first stage */ - for (i = 0; i < 8; i++) { - scf_q[i] = sns_LFCB[i][scf_idx[0]]; + for ( i = 0; i < 8; i++ ) + { + scf_q[i] = sns_LFCB[i][scf_idx[0]]; scf_q[i + 8] = sns_HFCB[i][scf_idx[1]]; } @@ -472,46 +499,57 @@ void process_snsQuantizesScf_Dec(LC3_INT* scf_idx, LC3_FLOAT* scf_q) /* Decode pulses */ - if (submode < 2) { - pvq_dec(10, 10, scf_idx[4], scf_idx[5], pulses); - - if (submode == 0) { - pvq_dec(1, 6, (scf_idx[6] % 2), floor(scf_idx[6] / 2), pulses2); + if ( submode < 2 ) + { + pvq_dec( 10, 10, scf_idx[4], scf_idx[5], pulses ); - move_int(&pulses[10], pulses2, 6); + if ( submode == 0 ) + { + pvq_dec( 1, 6, ( scf_idx[6] % 2 ), floor( scf_idx[6] / 2 ), pulses2 ); - } else { + move_int( &pulses[10], pulses2, 6 ); + } + else + { pulses[15] = 0; } - } else if (submode == 2) { - pvq_dec(8, 16, scf_idx[4], scf_idx[5], pulses); - } else { - pvq_dec(6, 16, scf_idx[4], scf_idx[5], pulses); + } + else if ( submode == 2 ) + { + pvq_dec( 8, 16, scf_idx[4], scf_idx[5], pulses ); + } + else + { + pvq_dec( 6, 16, scf_idx[4], scf_idx[5], pulses ); } /* Normalization */ - for (i = 0; i < M; i++) { + for ( i = 0; i < M; i++ ) + { sum += pulses[i] * pulses[i]; } - sum = 1.0 / LC3_SQRT(sum); + sum = 1.0 / LC3_SQRT( sum ); - for (i = 0; i < M; i++) { - st2_vector[i] = pulses[i] * sum; + for ( i = 0; i < M; i++ ) + { + st2_vector[i] = pulses[i] * sum; } /* Inverse transform */ - idct_II(st2_vector, st2_vector_idct, M); + idct_II( st2_vector, st2_vector_idct, M ); /* Gain */ - for (i = 0; i < M; i++) { + for ( i = 0; i < M; i++ ) + { st2_vector_idct[i] = st2_vector_idct[i] * sns_dec_gains[submode][scf_idx[3]]; } /* Add stage 1 and stage 2 */ - for (i = 0; i < M; i++) { + for ( i = 0; i < M; i++ ) + { scf_q[i] = scf_q[i] + st2_vector_idct[i]; } } diff --git a/lib_lc3plus/structs.h b/lib_lc3plus/structs.h index fea377da41..fe00d569bc 100644 --- a/lib_lc3plus/structs.h +++ b/lib_lc3plus/structs.h @@ -1,12 +1,12 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #ifndef STRUCTS_H #define STRUCTS_H @@ -14,164 +14,180 @@ #include "defines.h" #include "fft/iisfft.h" -typedef struct { - LC3_FLOAT r; /* real part */ - LC3_FLOAT i; /* imaginary part */ +typedef struct +{ + LC3_FLOAT r; /* real part */ + LC3_FLOAT i; /* imaginary part */ } Complex; -typedef struct { - LC3_INT length; - void *handle; +typedef struct +{ + LC3_INT length; + void *handle; } Fft; -typedef struct { - LC3_INT length; - Fft fft; +typedef struct +{ + LC3_INT length; + Fft fft; } Dct2; -typedef struct { - LC3_INT length; - Fft fft; +typedef struct +{ + LC3_INT length; + Fft fft; } Dct3; -typedef struct { - LC3_INT length; - Complex *twid1; - Complex *twid2; - Fft fft; +typedef struct +{ + LC3_INT length; + Complex *twid1; + Complex *twid2; + Fft fft; } Dct4; -typedef struct { - LC3_INT length; - LC3_INT leading_zeros; - LC3_INT mem_length; - const LC3_FLOAT *window; - LC3_FLOAT *mem; - Dct4 dct; +typedef struct +{ + LC3_INT length; + LC3_INT leading_zeros; + LC3_INT mem_length; + const LC3_FLOAT *window; + LC3_FLOAT *mem; + Dct4 dct; } Mdct; -typedef struct { - uint32_t ac_low_fl; - uint32_t ac_range_fl; - int BER_detect; - - LC3_INT32 pc_c_bp; - LC3_INT32 pc_c_bp_side; - LC3_INT32 pc_bytes; - LC3_INT32 pc_b_left; - LC3_INT32 pc_b_right; - LC3_INT32 pc_enc; - LC3_INT32 pc_bfi; - LC3_INT32 pc_bbi; - LC3_INT32 pc_be_bp_left; - LC3_INT32 pc_be_bp_right; - LC3_INT32 pc_return; +typedef struct +{ + uint32_t ac_low_fl; + uint32_t ac_range_fl; + int BER_detect; + + LC3_INT32 pc_c_bp; + LC3_INT32 pc_c_bp_side; + LC3_INT32 pc_bytes; + LC3_INT32 pc_b_left; + LC3_INT32 pc_b_right; + LC3_INT32 pc_enc; + LC3_INT32 pc_bfi; + LC3_INT32 pc_bbi; + LC3_INT32 pc_be_bp_left; + LC3_INT32 pc_be_bp_right; + LC3_INT32 pc_return; } Decoder_State_fl; -typedef struct { - LC3_INT bp; - LC3_INT low; - LC3_INT range; - LC3_INT cache; - LC3_INT carry; - LC3_INT carry_count; - uint8_t *ptr; - LC3_INT *bp_side; - LC3_INT *mask_side; +typedef struct +{ + LC3_INT bp; + LC3_INT low; + LC3_INT range; + LC3_INT cache; + LC3_INT carry; + LC3_INT carry_count; + uint8_t *ptr; + LC3_INT *bp_side; + LC3_INT *mask_side; } Encoder_State_fl; -typedef struct { - LC3_INT nbLostCmpt; - LC3_INT prevBfi; - LC3_INT prevprevBfi; +typedef struct +{ + LC3_INT nbLostCmpt; + LC3_INT prevBfi; + LC3_INT prevprevBfi; LC3_FLOAT q_d[MAX_LEN]; LC3_FLOAT q_d_prev[MAX_LEN]; } PlcSetup; -typedef struct { +typedef struct +{ LC3_FLOAT cum_alpha; - LC3_INT seed; + LC3_INT seed; } PlcNsSetup; -typedef struct { +typedef struct +{ LC3_INT32 seed; LC3_INT32 ns_nbLostCmpt_pc; LC3_FLOAT *q_old_res; LC3_FLOAT prev_gg; } pcState; -typedef struct { - LC3_INT len; - LC3_INT sign; - LC3_FLOAT* table; +typedef struct +{ + LC3_INT len; + LC3_INT sign; + LC3_FLOAT *table; } Cfft; -typedef struct T_IIS_FFT { +typedef struct T_IIS_FFT +{ IIS_FFT_DIR sign; - LC3_INT32 len; - LC3_FLOAT* buffer; - LC3_FLOAT* sine_table; - Iisfft iisfft; - Cfft cfft; + LC3_INT32 len; + LC3_FLOAT *buffer; + LC3_FLOAT *sine_table; + Iisfft iisfft; + Cfft cfft; } IIS_FFT; -typedef struct T_IIS_FFT* HANDLE_IIS_FFT; +typedef struct T_IIS_FFT *HANDLE_IIS_FFT; + +typedef struct +{ + Fft PhEcu_Fft; /*no counterpart in BASOP */ + Fft PhEcu_Ifft; /*no counterpart in BASOP */ + + + LC3_FLOAT PhECU_f0hzLtpBin; /* BASOP Word16 PhECU_f0hzLtpBinQ7 */ + LC3_FLOAT PhECU_norm_corr; /* BASOP Word16 norm_corrQ15 */ + + LC3_FLOAT *PhECU_oold_grp_shape; /* BASOP Word16 PhECU_oold_grp_shape_fx[MAX_LGW]; */ + LC3_FLOAT *PhECU_old_grp_shape; /* BASOP Word16 PhECU_old_grp_shape_fx[MAX_LGW] ; */ -typedef struct { - Fft PhEcu_Fft; /*no counterpart in BASOP */ - Fft PhEcu_Ifft; /*no counterpart in BASOP */ + LC3_FLOAT PhECU_L_oold_xfp_w_E; /* BASOP Word32 PhECU_L_oold_xfp_w_E_fx;*/ + LC3_FLOAT PhECU_L_old_xfp_w_E; /* BASOP Word32 PhECU_L_old_xfp_w_E_fx; */ - - LC3_FLOAT PhECU_f0hzLtpBin; /* BASOP Word16 PhECU_f0hzLtpBinQ7 */ - LC3_FLOAT PhECU_norm_corr; /* BASOP Word16 norm_corrQ15 */ + LC3_INT32 PhECU_Lprot; /* BASOP Word16 PhECU_Lprot_fx;*/ - LC3_FLOAT *PhECU_oold_grp_shape; /* BASOP Word16 PhECU_oold_grp_shape_fx[MAX_LGW]; */ - LC3_FLOAT *PhECU_old_grp_shape; /* BASOP Word16 PhECU_old_grp_shape_fx[MAX_LGW] ; */ + LC3_FLOAT *PhECU_xfp; + Complex *PhECU_X_sav_m; + LC3_INT32 *PhECU_plocs; /* BASOP Word16 *PhECU_plocs; */ /* MAX_PLOCS */ + LC3_FLOAT *PhECU_f0est; /*BASOP Word32 *PhECU_f0est;*/ - LC3_FLOAT PhECU_L_oold_xfp_w_E; /* BASOP Word32 PhECU_L_oold_xfp_w_E_fx;*/ - LC3_FLOAT PhECU_L_old_xfp_w_E; /* BASOP Word32 PhECU_L_old_xfp_w_E_fx; */ - - LC3_INT32 PhECU_Lprot ; /* BASOP Word16 PhECU_Lprot_fx;*/ + LC3_FLOAT *PhECU_mag_chg_1st; /* BASOP Word16 PhECU_mag_chg_1st[MAX_LGW];*/ + LC3_FLOAT *PhECU_Xavg; /* BASOP Word16 PhECU_Xavg[MAX_LGW] ; */ - LC3_FLOAT *PhECU_xfp; - Complex *PhECU_X_sav_m; - LC3_INT32 *PhECU_plocs; /* BASOP Word16 *PhECU_plocs; */ /* MAX_PLOCS */ - LC3_FLOAT *PhECU_f0est; /*BASOP Word32 *PhECU_f0est;*/ + LC3_FLOAT PhECU_beta_mute; /* BASOP Word16 PhECU_beta_mute*/ - LC3_FLOAT *PhECU_mag_chg_1st; /* BASOP Word16 PhECU_mag_chg_1st[MAX_LGW];*/ - LC3_FLOAT *PhECU_Xavg; /* BASOP Word16 PhECU_Xavg[MAX_LGW] ; */ + LC3_INT16 PhECU_seed; /* BASOP Word16 PhECU_seed_fx;*/ - LC3_FLOAT PhECU_beta_mute; /* BASOP Word16 PhECU_beta_mute*/ + LC3_INT32 PhECU_LDWIN_OLAP; /* BASOP Word16 PhECU_LDWIN_OLAP; */ + LC3_INT32 PhECU_t_adv; /* BASOP Word16 t_adv; */ - LC3_INT16 PhECU_seed; /* BASOP Word16 PhECU_seed_fx;*/ + LC3_INT32 PhECU_short_flag_prev; + LC3_INT32 PhECU_time_offs; + LC3_INT32 PhECU_num_plocs; + HANDLE_IIS_FFT handle_fft_phaseecu; + HANDLE_IIS_FFT handle_ifft_phaseecu; - LC3_INT32 PhECU_LDWIN_OLAP; /* BASOP Word16 PhECU_LDWIN_OLAP; */ - LC3_INT32 PhECU_t_adv; /* BASOP Word16 t_adv; */ - - LC3_INT32 PhECU_short_flag_prev; - LC3_INT32 PhECU_time_offs; - LC3_INT32 PhECU_num_plocs; - HANDLE_IIS_FFT handle_fft_phaseecu; - HANDLE_IIS_FFT handle_ifft_phaseecu; - } PlcPhEcuSetup; -typedef struct { +typedef struct +{ LC3_INT16 seed; LC3_FLOAT gain_c; - LC3_INT32 lpcorder; - LC3_FLOAT A[M+1]; - LC3_INT32 fract; - LC3_INT32 lagw_bw; + LC3_INT32 lpcorder; + LC3_FLOAT A[M + 1]; + LC3_INT32 fract; + LC3_INT32 lagw_bw; LC3_FLOAT preemphFac; LC3_FLOAT *harmonicBuf; LC3_FLOAT synthHist[M]; } PlcTdcSetup; -typedef struct { +typedef struct +{ LC3_FLOAT *pcmbufHist; - LC3_INT32 max_len_pcm_plc; + LC3_INT32 max_len_pcm_plc; PlcTdcSetup PlcTdcSetup; LC3_FLOAT stabFac; LC3_FLOAT cum_fading_slow; @@ -179,7 +195,7 @@ typedef struct { LC3_FLOAT cum_fflcAtten; LC3_FLOAT scf_q_old[M]; LC3_FLOAT scf_q_old_old[M]; - PlcPhEcuSetup PlcPhEcuSetup; + PlcPhEcuSetup PlcPhEcuSetup; } PlcAdvSetup; diff --git a/lib_lc3plus/tns_coder.c b/lib_lc3plus/tns_coder.c index ff3883d2b5..3c76a50d34 100644 --- a/lib_lc3plus/tns_coder.c +++ b/lib_lc3plus/tns_coder.c @@ -1,37 +1,39 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -static void xcorr(LC3_FLOAT* in, LC3_FLOAT* out, LC3_INT lag, LC3_INT inLen); -static void levdown(LC3_FLOAT* anxt, LC3_FLOAT* out_a, LC3_INT* len); -static void poly2rc(LC3_FLOAT* a, LC3_FLOAT* out, LC3_INT len); -static LC3_INT findRC_idx(const LC3_FLOAT* in1, const LC3_FLOAT* in2, LC3_FLOAT checkValue); +static void xcorr( LC3_FLOAT *in, LC3_FLOAT *out, LC3_INT lag, LC3_INT inLen ); +static void levdown( LC3_FLOAT *anxt, LC3_FLOAT *out_a, LC3_INT *len ); +static void poly2rc( LC3_FLOAT *a, LC3_FLOAT *out, LC3_INT len ); +static LC3_INT findRC_idx( const LC3_FLOAT *in1, const LC3_FLOAT *in2, LC3_FLOAT checkValue ); -void xcorr(LC3_FLOAT* in, LC3_FLOAT* out, LC3_INT lag, LC3_INT inLen) +void xcorr( LC3_FLOAT *in, LC3_FLOAT *out, LC3_INT lag, LC3_INT inLen ) { - LC3_INT i = 0, m = 0; - LC3_FLOAT sum = 0, tmp_buf[MAX_LEN] = {0}; + LC3_INT i = 0, m = 0; + LC3_FLOAT sum = 0, tmp_buf[MAX_LEN] = { 0 }; - for (m = -lag; m <= lag; m++) { + for ( m = -lag; m <= lag; m++ ) + { /* Append zeros and input vector */ - zero_float(tmp_buf, abs(m)); + zero_float( tmp_buf, abs( m ) ); - move_float(&tmp_buf[abs(m)], in, inLen - abs(m)); + move_float( &tmp_buf[abs( m )], in, inLen - abs( m ) ); /* Calculate sum */ sum = 0; - for (i = 0; i < inLen; i++) { + for ( i = 0; i < inLen; i++ ) + { sum += in[i] * tmp_buf[i]; } @@ -39,66 +41,70 @@ void xcorr(LC3_FLOAT* in, LC3_FLOAT* out, LC3_INT lag, LC3_INT inLen) } } -void levinsonDurbin(LC3_FLOAT* r, LC3_FLOAT* out_lev, LC3_FLOAT* rc_unq, LC3_FLOAT* error, LC3_INT len) +void levinsonDurbin( LC3_FLOAT *r, LC3_FLOAT *out_lev, LC3_FLOAT *rc_unq, LC3_FLOAT *error, LC3_INT len ) { - LC3_INT t = 0, i = 0, j = 0; - LC3_FLOAT g = 0, v = 0, sum = 0, buf_tmp[MAX_LEN] = {0}; + LC3_INT t = 0, i = 0, j = 0; + LC3_FLOAT g = 0, v = 0, sum = 0, buf_tmp[MAX_LEN] = { 0 }; - g = r[1] / r[0]; + g = r[1] / r[0]; out_lev[0] = g; - v = (1.0 - g * g) * r[0]; + v = ( 1.0 - g * g ) * r[0]; rc_unq[0] = -g; - for (t = 1; t < len; t++) { - zero_float(buf_tmp, len + 1); + for ( t = 1; t < len; t++ ) + { + zero_float( buf_tmp, len + 1 ); sum = 0; - for (i = 1; i <= t; i++) { + for ( i = 1; i <= t; i++ ) + { sum += out_lev[i - 1] * r[i]; } - g = (r[t + 1] - sum) / v; + g = ( r[t + 1] - sum ) / v; j = 1; - for (i = t - 1; i >= 0; i--) { + for ( i = t - 1; i >= 0; i-- ) + { buf_tmp[j] = out_lev[j - 1] - g * out_lev[i]; j++; } - move_float(&out_lev[1], &buf_tmp[1], len); + move_float( &out_lev[1], &buf_tmp[1], len ); out_lev[0] = g; - v = v * (1 - g * g); + v = v * ( 1 - g * g ); rc_unq[t] = -g; } /* Reorder out_lev */ out_lev[0] = 1; - j = 1; - for (i = len - 1; i >= 0; i--) { + j = 1; + for ( i = len - 1; i >= 0; i-- ) + { buf_tmp[j] = -out_lev[i]; j++; } - move_float(&out_lev[1], &buf_tmp[1], (len - 1)); + move_float( &out_lev[1], &buf_tmp[1], ( len - 1 ) ); out_lev[len] = rc_unq[len - 1]; *error = v; } -void levdown(LC3_FLOAT* anxt, LC3_FLOAT* out_a, LC3_INT* len) +void levdown( LC3_FLOAT *anxt, LC3_FLOAT *out_a, LC3_INT *len ) { - LC3_INT i = 0, j = 0; - LC3_FLOAT tmp_buf[8] = {0}, tmp_buf1[8] = {0}, tmp_buf2[8] = {0}, knxt = 0; + LC3_INT i = 0, j = 0; + LC3_FLOAT tmp_buf[8] = { 0 }, tmp_buf1[8] = { 0 }, tmp_buf2[8] = { 0 }, knxt = 0; /* Initial length = 9 */ /* Drop the leading 1 */ - move_float(&tmp_buf[0], &anxt[1], (*len - 1)); + move_float( &tmp_buf[0], &anxt[1], ( *len - 1 ) ); *len = *len - 1; /* Lenght = 8 */ @@ -107,60 +113,67 @@ void levdown(LC3_FLOAT* anxt, LC3_FLOAT* out_a, LC3_INT* len) *len = *len - 1; /* Lenght = 7 */ - move_float(tmp_buf1, tmp_buf, *len); + move_float( tmp_buf1, tmp_buf, *len ); j = 0; - for (i = *len - 1; i >= 0; i--) { + for ( i = *len - 1; i >= 0; i-- ) + { tmp_buf2[j] = knxt * tmp_buf[i]; j++; } out_a[0] = 1; - for (i = 0; i < *len; i++) { - out_a[i + 1] = (tmp_buf1[i] - tmp_buf2[i]) / (1.0 - (LC3_FABS(knxt)) * (LC3_FABS(knxt))); + for ( i = 0; i < *len; i++ ) + { + out_a[i + 1] = ( tmp_buf1[i] - tmp_buf2[i] ) / ( 1.0 - ( LC3_FABS( knxt ) ) * ( LC3_FABS( knxt ) ) ); } *len = *len + 1; /* Length = 8 */ } -void poly2rc(LC3_FLOAT* a, LC3_FLOAT* out, LC3_INT len) +void poly2rc( LC3_FLOAT *a, LC3_FLOAT *out, LC3_INT len ) { - LC3_INT k = 0, i = 0, len_old = 0; - LC3_FLOAT buf[9] = {0}; + LC3_INT k = 0, i = 0, len_old = 0; + LC3_FLOAT buf[9] = { 0 }; len_old = len; - zero_float(out, len - 1); + zero_float( out, len - 1 ); /* Length = 9 */ /* Normalize */ - for (i = 0; i < len; i++) { + for ( i = 0; i < len; i++ ) + { a[i] = a[i] / a[0]; } out[len - 1] = a[len - 1]; /* Process */ - for (k = len - 2; k >= 0; k--) { - levdown(a, buf, &len); + for ( k = len - 2; k >= 0; k-- ) + { + levdown( a, buf, &len ); out[k] = buf[len - 1]; /* Store last value */ - move_float(a, buf, len); + move_float( a, buf, len ); } /* Shift output array by one to the left to lose leading 1 */ - for (i = 0; i < len_old - 1; i++) { + for ( i = 0; i < len_old - 1; i++ ) + { out[i] = out[i + 1]; } } -LC3_INT findRC_idx(const LC3_FLOAT* in1, const LC3_FLOAT* in2, LC3_FLOAT checkValue) +LC3_INT findRC_idx( const LC3_FLOAT *in1, const LC3_FLOAT *in2, LC3_FLOAT checkValue ) { LC3_INT i = 0, ret = 0; - for (i = 0; i < 17; i++) { - if (checkValue <= in1[i] && checkValue > in2[i]) { + for ( i = 0; i < 17; i++ ) + { + if ( checkValue <= in1[i] && checkValue > in2[i] ) + { ret = i; } } @@ -168,155 +181,180 @@ LC3_INT findRC_idx(const LC3_FLOAT* in1, const LC3_FLOAT* in2, LC3_FLOAT checkVa return ret; } -void processTnsCoder_fl(LC3_FLOAT* x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, LC3_INT fs, LC3_INT N, LC3_INT frame_dms, LC3_INT nBits, - LC3_INT* order_out, LC3_INT* rc_idx, LC3_INT* tns_numfilters, LC3_INT* bits_out - , LC3_INT16 near_nyquist_flag -) +void processTnsCoder_fl( LC3_FLOAT *x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, LC3_INT fs, LC3_INT N, LC3_INT frame_dms, LC3_INT nBits, LC3_INT *order_out, LC3_INT *rc_idx, LC3_INT *tns_numfilters, LC3_INT *bits_out, LC3_INT16 near_nyquist_flag ) { - LC3_INT i = 0, stopfreq[2] = {0}, startfreq[2] = {0}, f = 0, numfilters = 0, maxOrder = 0, bits = 0, sub = 0, - subdiv_startfreq = 0, subdiv_stopfreq = 0, j = 0, rc_idx_tmp[8] = {0}, order_tmp[8] = {0}, tmp = 0, tns = 0; - LC3_FLOAT minPGfac = 0, minPredictionGain = 0, maxPG = 0, xcorr_out[MAX_LEN] = {0}, buf_tmp[MAX_LEN] = {0}, sum = 0, - subdiv_len = 0, nSubdivisions = 0, r[9] = {0}, out_lev[9] = {0}, rc_unq[9] = {0}, error_lev = 0, predGain = 0, - alpha = 0, rc[8] = {0}, st[9] = {0}, s = 0, tmpSave = 0, tmp_fl = 0; - const LC3_INT* order; + LC3_INT i = 0, stopfreq[2] = { 0 }, startfreq[2] = { 0 }, f = 0, numfilters = 0, maxOrder = 0, bits = 0, sub = 0, + subdiv_startfreq = 0, subdiv_stopfreq = 0, j = 0, rc_idx_tmp[8] = { 0 }, order_tmp[8] = { 0 }, tmp = 0, tns = 0; + LC3_FLOAT minPGfac = 0, minPredictionGain = 0, maxPG = 0, xcorr_out[MAX_LEN] = { 0 }, buf_tmp[MAX_LEN] = { 0 }, sum = 0, + subdiv_len = 0, nSubdivisions = 0, r[9] = { 0 }, out_lev[9] = { 0 }, rc_unq[9] = { 0 }, error_lev = 0, predGain = 0, + alpha = 0, rc[8] = { 0 }, st[9] = { 0 }, s = 0, tmpSave = 0, tmp_fl = 0; + const LC3_INT *order; /* Init */ - if (fs >= 32000 && frame_dms >= 50) { + if ( fs >= 32000 && frame_dms >= 50 ) + { numfilters = 2; - } else { + } + else + { numfilters = 1; } - if (N > 40 * ((LC3_FLOAT) (frame_dms) / 10.0)) { - N = 40 * ((LC3_FLOAT) (frame_dms) / 10.0); + if ( N > 40 * ( (LC3_FLOAT) ( frame_dms ) / 10.0 ) ) + { + N = 40 * ( (LC3_FLOAT) ( frame_dms ) / 10.0 ); fs = 40000; } - if (numfilters == 1) { - startfreq[0] = floor(600 * N * 2 / fs) + 1; - stopfreq[0] = N; - } else { - startfreq[0] = floor(600 * N * 2 / fs) + 1; + if ( numfilters == 1 ) + { + startfreq[0] = floor( 600 * N * 2 / fs ) + 1; + stopfreq[0] = N; + } + else + { + startfreq[0] = floor( 600 * N * 2 / fs ) + 1; startfreq[1] = N / 2 + 1; - stopfreq[0] = N / 2; - stopfreq[1] = N; + stopfreq[0] = N / 2; + stopfreq[1] = N; } - - switch (frame_dms) + + switch ( frame_dms ) { case 25: - maxOrder = 4; + maxOrder = 4; nSubdivisions = 2.0; break; case 50: - maxOrder = 4; + maxOrder = 4; nSubdivisions = 2.0; break; case 100: - maxOrder = 8; + maxOrder = 8; nSubdivisions = 3.0; break; } - minPGfac = 0.85; - maxPG = 2; + minPGfac = 0.85; + maxPG = 2; minPredictionGain = 1.5; - if ((frame_dms >= 50 && nBits >= 48 * ((LC3_FLOAT) frame_dms / 10.0)) || frame_dms == 25) { + if ( ( frame_dms >= 50 && nBits >= 48 * ( (LC3_FLOAT) frame_dms / 10.0 ) ) || frame_dms == 25 ) + { maxPG = minPredictionGain; } - if ((frame_dms >= 50 && nBits >= 48 * ((LC3_FLOAT) frame_dms / 10.0)) || frame_dms == 25) { + if ( ( frame_dms >= 50 && nBits >= 48 * ( (LC3_FLOAT) frame_dms / 10.0 ) ) || frame_dms == 25 ) + { order = order1_tns; - } else { + } + else + { order = order2_tns; } - + /* Processing */ - if (bw_cutoff_idx >= 3 && numfilters == 2) { - numfilters = 2; + if ( bw_cutoff_idx >= 3 && numfilters == 2 ) + { + numfilters = 2; startfreq[1] = bw_fcbin / 2 + 1; - stopfreq[0] = bw_fcbin / 2; - stopfreq[1] = bw_fcbin; - } else { - numfilters = 1; + stopfreq[0] = bw_fcbin / 2; + stopfreq[1] = bw_fcbin; + } + else + { + numfilters = 1; stopfreq[0] = bw_fcbin; } bits = 0; - for (f = 0; f < numfilters; f++) { - subdiv_len = ((LC3_FLOAT)stopfreq[f] + 1.0 - (LC3_FLOAT)startfreq[f]) / nSubdivisions; + for ( f = 0; f < numfilters; f++ ) + { + subdiv_len = ( (LC3_FLOAT) stopfreq[f] + 1.0 - (LC3_FLOAT) startfreq[f] ) / nSubdivisions; - zero_float(r, 9); + zero_float( r, 9 ); - for (sub = 1; sub <= nSubdivisions; sub++) { - subdiv_startfreq = floor(subdiv_len * (sub - 1)) + startfreq[f] - 1; - subdiv_stopfreq = floor(subdiv_len * sub) + startfreq[f] - 1; + for ( sub = 1; sub <= nSubdivisions; sub++ ) + { + subdiv_startfreq = floor( subdiv_len * ( sub - 1 ) ) + startfreq[f] - 1; + subdiv_stopfreq = floor( subdiv_len * sub ) + startfreq[f] - 1; sum = 0; - for (i = subdiv_startfreq; i < subdiv_stopfreq; i++) { + for ( i = subdiv_startfreq; i < subdiv_stopfreq; i++ ) + { sum += x[i] * x[i]; } - if (sum < LC3_EPS) + if ( sum < LC3_EPS ) { - zero_float(r, 9); + zero_float( r, 9 ); r[0] = 1; break; } - move_float(buf_tmp, &x[subdiv_startfreq], subdiv_stopfreq - subdiv_startfreq); + move_float( buf_tmp, &x[subdiv_startfreq], subdiv_stopfreq - subdiv_startfreq ); - xcorr(buf_tmp, xcorr_out, maxOrder, subdiv_stopfreq - subdiv_startfreq); + xcorr( buf_tmp, xcorr_out, maxOrder, subdiv_stopfreq - subdiv_startfreq ); j = 0; - for (i = maxOrder; i >= 0; i--) { + for ( i = maxOrder; i >= 0; i-- ) + { r[j] = r[j] + xcorr_out[i] / sum; j++; } } - for (i = 0; i <= maxOrder; i++) { + for ( i = 0; i <= maxOrder; i++ ) + { r[i] = r[i] * lagw_tns[i]; } - levinsonDurbin(r, out_lev, rc_unq, &error_lev, maxOrder); + levinsonDurbin( r, out_lev, rc_unq, &error_lev, maxOrder ); predGain = r[0] / error_lev; - if (predGain > minPredictionGain && near_nyquist_flag == 0) { + if ( predGain > minPredictionGain && near_nyquist_flag == 0 ) + { tns = 1; - } else { + } + else + { tns = 0; } bits++; - if (tns == 1) { + if ( tns == 1 ) + { /* LPC weighting */ - if (predGain < maxPG) { - alpha = (maxPG - predGain) * (minPGfac - 1.0) / (maxPG - minPredictionGain) + 1.0; + if ( predGain < maxPG ) + { + alpha = ( maxPG - predGain ) * ( minPGfac - 1.0 ) / ( maxPG - minPredictionGain ) + 1.0; - for (i = 0; i <= maxOrder; i++) { - out_lev[i] = out_lev[i] * LC3_POW(alpha, i); + for ( i = 0; i <= maxOrder; i++ ) + { + out_lev[i] = out_lev[i] * LC3_POW( alpha, i ); } - poly2rc(out_lev, rc_unq, maxOrder + 1); + poly2rc( out_lev, rc_unq, maxOrder + 1 ); } /* PARCOR Quantization */ - for (i = 0; i < maxOrder; i++) { - rc_idx_tmp[i] = findRC_idx(&quants_thr_tns[1], &quants_thr_tns[0], rc_unq[i]); + for ( i = 0; i < maxOrder; i++ ) + { + rc_idx_tmp[i] = findRC_idx( &quants_thr_tns[1], &quants_thr_tns[0], rc_unq[i] ); } - + /* Filter Order */ j = 0; - for (i = 0; i < maxOrder; i++) { + for ( i = 0; i < maxOrder; i++ ) + { rc[i] = quants_pts_tns[rc_idx_tmp[i]]; - if (rc[i] != 0) { + if ( rc[i] != 0 ) + { order_tmp[j] = i + 1; j++; } @@ -324,7 +362,8 @@ void processTnsCoder_fl(LC3_FLOAT* x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, L order_out[f] = order_tmp[j - 1]; // Disable TNS if order is 0: - if (order_out[f] == 0) { + if ( order_out[f] == 0 ) + { tns = 0; // Jump to else statement @@ -333,42 +372,47 @@ void processTnsCoder_fl(LC3_FLOAT* x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, L tmp = order[order_out[f] - 1]; /* Huffman Coding of PARCOR coefficients */ - for (i = 0; i <= order_out[f] - 1; i++) { + for ( i = 0; i <= order_out[f] - 1; i++ ) + { tmp += huff_bits_tns[i][rc_idx_tmp[i]]; } - bits = bits + ceil((LC3_FLOAT)tmp / 2048.0); + bits = bits + ceil( (LC3_FLOAT) tmp / 2048.0 ); j = 0; - for (i = f * 8; i <= f * 8 + order_out[f] - 1; i++) { + for ( i = f * 8; i <= f * 8 + order_out[f] - 1; i++ ) + { rc_idx[i] = rc_idx_tmp[j]; j++; } } /* Filtering */ - if (tns == 1) { - for (i = startfreq[f]; i <= stopfreq[f]; i++) { - s = x[i - 1]; + if ( tns == 1 ) + { + for ( i = startfreq[f]; i <= stopfreq[f]; i++ ) + { + s = x[i - 1]; tmpSave = s; - for (j = 0; j < order_out[f] - 1; j++) { + for ( j = 0; j < order_out[f] - 1; j++ ) + { tmp_fl = rc[j] * s + st[j]; s += rc[j] * st[j]; - st[j] = tmpSave; + st[j] = tmpSave; tmpSave = tmp_fl; } s += rc[order_out[f] - 1] * st[order_out[f] - 1]; st[order_out[f] - 1] = tmpSave; - x[i - 1] = s; + x[i - 1] = s; } } } tns_disabled: *tns_numfilters = numfilters; - *bits_out = bits; + *bits_out = bits; } diff --git a/lib_lc3plus/tns_decoder.c b/lib_lc3plus/tns_decoder.c index d3aeefc3a3..0df5f33086 100644 --- a/lib_lc3plus/tns_decoder.c +++ b/lib_lc3plus/tns_decoder.c @@ -1,50 +1,58 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #include "options.h" #include "functions.h" -void processTnsDecoder_fl(LC3_FLOAT* x, LC3_INT* rc_idx, LC3_INT* order, LC3_INT numfilters, LC3_INT bw_fcbin, LC3_INT N, LC3_INT fs) +void processTnsDecoder_fl( LC3_FLOAT *x, LC3_INT *rc_idx, LC3_INT *order, LC3_INT numfilters, LC3_INT bw_fcbin, LC3_INT N, LC3_INT fs ) { - LC3_INT startfreq[2] = {0}, stopfreq[2] = {0}, f = 0, i = 0, j = 0, m = 0, l = 0, rc_idx_f[9] = {0}; - LC3_FLOAT rc[9] = {0}, s = 0, st[9] = {0}; + LC3_INT startfreq[2] = { 0 }, stopfreq[2] = { 0 }, f = 0, i = 0, j = 0, m = 0, l = 0, rc_idx_f[9] = { 0 }; + LC3_FLOAT rc[9] = { 0 }, s = 0, st[9] = { 0 }; - if (numfilters == 2) { - startfreq[0] = floor(600 * N * 2 / fs) + 1; - stopfreq[0] = bw_fcbin / 2; + if ( numfilters == 2 ) + { + startfreq[0] = floor( 600 * N * 2 / fs ) + 1; + stopfreq[0] = bw_fcbin / 2; startfreq[1] = bw_fcbin / 2 + 1; - stopfreq[1] = bw_fcbin; - } else { - startfreq[0] = floor(600 * N * 2 / fs) + 1; - stopfreq[0] = bw_fcbin; + stopfreq[1] = bw_fcbin; + } + else + { + startfreq[0] = floor( 600 * N * 2 / fs ) + 1; + stopfreq[0] = bw_fcbin; } - for (f = 0; f < numfilters; f++) { - if (order[f] > 0) { + for ( f = 0; f < numfilters; f++ ) + { + if ( order[f] > 0 ) + { j = 0; - for (i = f * 8; i < f * 8 + 8; i++) { + for ( i = f * 8; i < f * 8 + 8; i++ ) + { rc_idx_f[j] = rc_idx[i]; - rc[j] = quants_pts_tns[rc_idx_f[j]]; + rc[j] = quants_pts_tns[rc_idx_f[j]]; j++; } - for (m = startfreq[f]; m <= stopfreq[f]; m++) { + for ( m = startfreq[f]; m <= stopfreq[f]; m++ ) + { s = x[m - 1] - rc[order[f] - 1] * st[order[f] - 1]; - for (l = order[f] - 2; l >= 0; l--) { - s = s - rc[l] * st[l]; + for ( l = order[f] - 2; l >= 0; l-- ) + { + s = s - rc[l] * st[l]; st[l + 1] = rc[l] * s + st[l]; } - st[0] = s; + st[0] = s; x[m - 1] = s; } } diff --git a/lib_lc3plus/util.h b/lib_lc3plus/util.h index 7ef6dedef7..6a00e69454 100644 --- a/lib_lc3plus/util.h +++ b/lib_lc3plus/util.h @@ -1,12 +1,12 @@ /****************************************************************************** -* ETSI TS 103 634 V1.4.1 * -* Low Complexity Communication Codec Plus (LC3plus) * -* * -* Copyright licence is solely granted through ETSI Intellectual Property * -* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * -* estoppel or otherwise. * -******************************************************************************/ - + * ETSI TS 103 634 V1.4.1 * + * Low Complexity Communication Codec Plus (LC3plus) * + * * + * Copyright licence is solely granted through ETSI Intellectual Property * + * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * + * estoppel or otherwise. * + ******************************************************************************/ + #ifndef UTIL_H #define UTIL_H @@ -16,8 +16,9 @@ #ifdef _MSC_VER /* strcasecmp is not available on visual studio */ -static LC3_INT strcasecmp(const char* a, const char* b) { - return _stricmp(a,b); +static LC3_INT strcasecmp( const char *a, const char *b ) +{ + return _stricmp( a, b ); } #endif @@ -29,186 +30,214 @@ static LC3_INT strcasecmp(const char* a, const char* b) { #endif /* number of elements in array */ -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +#define ARRAY_SIZE( x ) ( sizeof( x ) / sizeof( ( x )[0] ) ) /* min max with no side effects */ -static inline LC3_INT imin(LC3_INT a, LC3_INT b) { return a < b ? a : b; } -static inline LC3_INT imax(LC3_INT a, LC3_INT b) { return a > b ? a : b; } +static inline LC3_INT imin( LC3_INT a, LC3_INT b ) { return a < b ? a : b; } +static inline LC3_INT imax( LC3_INT a, LC3_INT b ) { return a > b ? a : b; } /* restrict x to range [min, max] */ -static inline LC3_INT iclamp(LC3_INT min, LC3_INT x, LC3_INT max) { - return x < min ? min : x > max ? max : x; +static inline LC3_INT iclamp( LC3_INT min, LC3_INT x, LC3_INT max ) +{ + return x < min ? min : x > max ? max + : x; } -static inline double fcmamp(double min, double x, double max) { - return x < min ? min : x > max ? max : x; +static inline double fcmamp( double min, double x, double max ) +{ + return x < min ? min : x > max ? max + : x; } -static inline LC3_FLOAT fclampf(LC3_FLOAT min, LC3_FLOAT x, LC3_FLOAT max) { - return x < min ? min : x > max ? max : x; +static inline LC3_FLOAT fclampf( LC3_FLOAT min, LC3_FLOAT x, LC3_FLOAT max ) +{ + return x < min ? min : x > max ? max + : x; } /* x² */ -static inline LC3_FLOAT sqrf(LC3_FLOAT x) { return x * x; } +static inline LC3_FLOAT sqrf( LC3_FLOAT x ) { return x * x; } /* convenience wrappers around memmove */ -static inline void move_float(LC3_FLOAT *dst, const LC3_FLOAT *src, LC3_INT len) { - memmove(dst, src, len * sizeof(LC3_FLOAT)); +static inline void move_float( LC3_FLOAT *dst, const LC3_FLOAT *src, LC3_INT len ) +{ + memmove( dst, src, len * sizeof( LC3_FLOAT ) ); } -static inline void move_int(LC3_INT *dst, const LC3_INT *src, LC3_INT len) { - memmove(dst, src, len * sizeof(LC3_INT)); +static inline void move_int( LC3_INT *dst, const LC3_INT *src, LC3_INT len ) +{ + memmove( dst, src, len * sizeof( LC3_INT ) ); } /* convenience wrappers around memset */ -static inline void zero_float(LC3_FLOAT *x, LC3_INT len) { - memset(x, 0, len * sizeof(LC3_FLOAT)); +static inline void zero_float( LC3_FLOAT *x, LC3_INT len ) +{ + memset( x, 0, len * sizeof( LC3_FLOAT ) ); } -static inline void zero_int(LC3_INT *x, LC3_INT len) { - memset(x, 0, len * sizeof(LC3_INT)); +static inline void zero_int( LC3_INT *x, LC3_INT len ) +{ + memset( x, 0, len * sizeof( LC3_INT ) ); } /* multiply float vectors element by element, in-place */ -static inline void mult_vec(LC3_FLOAT *a, const LC3_FLOAT *b, - LC3_INT len) { - LC3_INT i = 0; - for (i = 0; i < len; i++) { - a[i] *= b[i]; - } +static inline void mult_vec( LC3_FLOAT *a, const LC3_FLOAT *b, LC3_INT len ) +{ + LC3_INT i = 0; + for ( i = 0; i < len; i++ ) + { + a[i] *= b[i]; + } } /* multiply float vector with constant, in-place */ -static inline void mult_const(LC3_FLOAT *a, LC3_FLOAT b, LC3_INT len) { - LC3_INT i = 0; - for (i = 0; i < len; i++) { - a[i] *= b; - } +static inline void mult_const( LC3_FLOAT *a, LC3_FLOAT b, LC3_INT len ) +{ + LC3_INT i = 0; + for ( i = 0; i < len; i++ ) + { + a[i] *= b; + } } /* sum of vector */ -static inline LC3_FLOAT sum_vec(const LC3_FLOAT *x, LC3_INT len) { - LC3_FLOAT sum = 0; - LC3_INT i = 0; - for (i = 0; i < len; i++) { - sum += x[i]; - } - return sum; +static inline LC3_FLOAT sum_vec( const LC3_FLOAT *x, LC3_INT len ) +{ + LC3_FLOAT sum = 0; + LC3_INT i = 0; + for ( i = 0; i < len; i++ ) + { + sum += x[i]; + } + return sum; } /* complex constructor */ -static inline Complex cmplx(LC3_FLOAT r, LC3_FLOAT i) { return (Complex){r, i}; } +static inline Complex cmplx( LC3_FLOAT r, LC3_FLOAT i ) { return ( Complex ){ r, i }; } /* complex a + b */ -static inline Complex cadd(Complex a, Complex b) { - return cmplx(a.r + b.r, a.i + b.i); +static inline Complex cadd( Complex a, Complex b ) +{ + return cmplx( a.r + b.r, a.i + b.i ); } /* complex a * b */ -static inline Complex cmul(Complex a, Complex b) { - return cmplx(a.r * b.r - a.i * b.i, a.i * b.r + a.r * b.i); +static inline Complex cmul( Complex a, Complex b ) +{ + return cmplx( a.r * b.r - a.i * b.i, a.i * b.r + a.r * b.i ); } /* mac operator */ -static inline LC3_FLOAT mac_loop(const LC3_FLOAT *array1, const LC3_FLOAT *array2, LC3_INT len) +static inline LC3_FLOAT mac_loop( const LC3_FLOAT *array1, const LC3_FLOAT *array2, LC3_INT len ) { LC3_INT i; LC3_FLOAT sum = 0.0; - for (i = 0; i < len; i++) + for ( i = 0; i < len; i++ ) { - sum += (*array1++) * (*array2++); + sum += ( *array1++ ) * ( *array2++ ); } return sum; } /* complex eᶦˣ */ -static inline Complex cexpi(LC3_FLOAT x) { return cmplx(LC3_COS(x), LC3_SIN(x)); } +static inline Complex cexpi( LC3_FLOAT x ) { return cmplx( LC3_COS( x ), LC3_SIN( x ) ); } /* complex -x */ -static inline Complex cneg(Complex x) { return cmplx(-x.r, -x.i); } +static inline Complex cneg( Complex x ) { return cmplx( -x.r, -x.i ); } /* convert string to number. return true on success */ -static inline bool str_to_int(const char *str, LC3_INT *value) { - char *end = NULL; - long v = str ? strtol(str, &end, 0) : 0; - *value = (LC3_INT)v; - return str && *end == 0 && v >= INT_MIN && v <= INT_MAX; +static inline bool str_to_int( const char *str, LC3_INT *value ) +{ + char *end = NULL; + long v = str ? strtol( str, &end, 0 ) : 0; + *value = (LC3_INT) v; + return str && *end == 0 && v >= INT_MIN && v <= INT_MAX; } /* returns true if str ends with str ends with suffix. ignoring case. str may be * NULL */ -static inline bool str_ends_with(const char *str, const char *suffix) { - char *tmp = str ? strrchr(str, suffix[0]) : NULL; - return tmp && !strcasecmp(tmp, suffix); +static inline bool str_ends_with( const char *str, const char *suffix ) +{ + char *tmp = str ? strrchr( str, suffix[0] ) : NULL; + return tmp && !strcasecmp( tmp, suffix ); } /* complex a - b */ -static inline Complex csub(Complex a, Complex b) { - return cmplx(a.r - b.r, a.i - b.i); +static inline Complex csub( Complex a, Complex b ) +{ + return cmplx( a.r - b.r, a.i - b.i ); } -static inline void move_cmplx(Complex *dst, const Complex *src, LC3_INT32 len) { - if (len > 0) { - memmove(dst, src, len * sizeof(Complex)); - assert(src[len - 1].r == dst[len - 1].r && src[len - 1].i == dst[len - 1].i); /*check that Cmplx is stored contiguously*/ - assert(src[0].r == dst[0].r && src[0].i == dst[0].i); /*check that Cmplx is stored contiguously*/ - } +static inline void move_cmplx( Complex *dst, const Complex *src, LC3_INT32 len ) +{ + if ( len > 0 ) + { + memmove( dst, src, len * sizeof( Complex ) ); + assert( src[len - 1].r == dst[len - 1].r && src[len - 1].i == dst[len - 1].i ); /*check that Cmplx is stored contiguously*/ + assert( src[0].r == dst[0].r && src[0].i == dst[0].i ); /*check that Cmplx is stored contiguously*/ + } } -static inline void zero_cmplx(Complex *x, LC3_INT32 len) { - if(len > 0) { - memset(x, 0, len * sizeof(Complex)); - assert(x[0].r == 0 && x[0].i == 0 && x[len-1].r == 0 && x[len-1].i == 0); - } +static inline void zero_cmplx( Complex *x, LC3_INT32 len ) +{ + if ( len > 0 ) + { + memset( x, 0, len * sizeof( Complex ) ); + assert( x[0].r == 0 && x[0].i == 0 && x[len - 1].r == 0 && x[len - 1].i == 0 ); + } } -static inline Complex realtoc(LC3_FLOAT r) { return cmplx(r, 0); } +static inline Complex realtoc( LC3_FLOAT r ) { return cmplx( r, 0 ); } /* set float vector to constant */ -static inline void set_vec(const LC3_FLOAT c, LC3_FLOAT *x, LC3_INT32 len) { +static inline void set_vec( const LC3_FLOAT c, LC3_FLOAT *x, LC3_INT32 len ) +{ LC3_INT32 i = 0; - for (i = 0; i < len; i++) { + for ( i = 0; i < len; i++ ) + { x[i] = c; } } /* set float vector to constant */ -static inline void set_vec_int(const LC3_INT32 c, LC3_INT32 *x, LC3_INT32 len) { +static inline void set_vec_int( const LC3_INT32 c, LC3_INT32 *x, LC3_INT32 len ) +{ LC3_INT32 i = 0; - for (i = 0; i < len; i++) { + for ( i = 0; i < len; i++ ) + { x[i] = c; } } -static inline LC3_INT32 clz_func(LC3_INT32 inp) +static inline LC3_INT32 clz_func( LC3_INT32 inp ) { -#if defined(__clang__) || defined(__GNUC__) - if (inp == 0) +#if defined( __clang__ ) || defined( __GNUC__ ) + if ( inp == 0 ) { return 0; } - return __builtin_clz(inp); + return __builtin_clz( inp ); -#elif defined(_WIN32) || defined(_WIN64) +#elif defined( _WIN32 ) || defined( _WIN64 ) LC3_INT32 leading_zero = 0; - - if (_BitScanReverse(&leading_zero, inp)) + + if ( _BitScanReverse( &leading_zero, inp ) ) { return 31 - leading_zero; } else return 0; - + #else LC3_INT32 i = 0; int64_t x = inp; - - if (inp == 0) + + if ( inp == 0 ) { return 0; } - - inp = (inp < 0) ? ~inp : inp; - while (x < (int64_t)0x80000000L) + inp = ( inp < 0 ) ? ~inp : inp; + + while ( x < (int64_t) 0x80000000L ) { inp <<= 1; i += 1; -- GitLab From e39a74e15fd632dbe3a0eefe7b3aa1d64a06e854 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Fri, 11 Aug 2023 15:28:50 +0200 Subject: [PATCH 03/12] put back the project file lib_lc3plus.vcxproj --- Workspace_msvc/lib_lc3plus.vcxproj | 182 +++++++++++++++++++++++++++++ 1 file changed, 182 insertions(+) create mode 100644 Workspace_msvc/lib_lc3plus.vcxproj diff --git a/Workspace_msvc/lib_lc3plus.vcxproj b/Workspace_msvc/lib_lc3plus.vcxproj new file mode 100644 index 0000000000..241232e140 --- /dev/null +++ b/Workspace_msvc/lib_lc3plus.vcxproj @@ -0,0 +1,182 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {95030B82-70CD-4C6B-84D4-61096035BEA2} + Win32Proj + LC3_FL + 10.0.17763.0 + + + + StaticLibrary + true + v141 + Unicode + + + StaticLibrary + false + v141 + true + Unicode + + + + + + + + + + + + + + + LC3plus + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\Obj\ + + + LC3plus + $(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\Obj\ + + + + + + Level3 + ..\lib_com;%(AdditionalIncludeDirectories) + Disabled + MultiThreadedDebug + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + 4305;4244;4996 + OldStyle + + + Console + true + + + + + Level3 + + + ..\lib_com;%(AdditionalIncludeDirectories) + MaxSpeed + MultiThreaded + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + 4244;4305;4996 + + + Console + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- GitLab From 1cba905e1c7644557db56e2fb41095242b5f5640 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Fri, 11 Aug 2023 15:37:12 +0200 Subject: [PATCH 04/12] change the name of the library output dir to Debug_lib_lc3plus --- Workspace_msvc/lib_lc3plus.vcxproj | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Workspace_msvc/lib_lc3plus.vcxproj b/Workspace_msvc/lib_lc3plus.vcxproj index 241232e140..207b6903c8 100644 --- a/Workspace_msvc/lib_lc3plus.vcxproj +++ b/Workspace_msvc/lib_lc3plus.vcxproj @@ -51,9 +51,9 @@ - LC3plus - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\Obj\ + liblc3plus + .\Debug_$(ProjectName)\ + .\Debug_$(ProjectName)\ LC3plus @@ -71,6 +71,7 @@ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 4305;4244;4996 OldStyle + false Console -- GitLab From 30fb5d57d06141cf98e8d638120a7e3963841deb Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 16 Aug 2023 12:32:20 +0200 Subject: [PATCH 05/12] Revert "clang-format" This reverts commit d1816da1bd4306257071426895ccfc8ce5eb8ce7. --- lib_lc3plus/adjust_global_gain.c | 97 +- lib_lc3plus/al_fec_fl.c | 3364 ++++++--------- lib_lc3plus/apply_global_gain.c | 22 +- lib_lc3plus/ari_codec.c | 1066 +++-- lib_lc3plus/attack_detector.c | 100 +- lib_lc3plus/clib.h | 16 +- lib_lc3plus/constants.c | 3852 +++++++++--------- lib_lc3plus/constants.h | 136 +- lib_lc3plus/cutoff_bandwidth.c | 33 +- lib_lc3plus/dct4.c | 117 +- lib_lc3plus/dec_entropy.c | 253 +- lib_lc3plus/dec_lc3_fl.c | 349 +- lib_lc3plus/defines.h | 301 +- lib_lc3plus/detect_cutoff_warped.c | 72 +- lib_lc3plus/enc_entropy.c | 128 +- lib_lc3plus/enc_lc3_fl.c | 286 +- lib_lc3plus/estimate_global_gain.c | 136 +- lib_lc3plus/functions.h | 409 +- lib_lc3plus/imdct.c | 70 +- lib_lc3plus/lc3.c | 386 +- lib_lc3plus/lc3.h | 183 +- lib_lc3plus/lc3plus_fft.c | 74 +- lib_lc3plus/license.h | 16 +- lib_lc3plus/ltpf_coder.c | 247 +- lib_lc3plus/ltpf_decoder.c | 362 +- lib_lc3plus/mdct.c | 186 +- lib_lc3plus/mdct_shaping.c | 24 +- lib_lc3plus/near_nyquist_detector.c | 28 +- lib_lc3plus/noise_factor.c | 91 +- lib_lc3plus/noise_filling.c | 64 +- lib_lc3plus/olpa.c | 128 +- lib_lc3plus/pc_apply.c | 80 +- lib_lc3plus/pc_classify.c | 163 +- lib_lc3plus/pc_main.c | 41 +- lib_lc3plus/pc_update.c | 44 +- lib_lc3plus/per_band_energy.c | 67 +- lib_lc3plus/plc_classify.c | 160 +- lib_lc3plus/plc_compute_stab_fac.c | 52 +- lib_lc3plus/plc_damping_scrambling.c | 183 +- lib_lc3plus/plc_main.c | 301 +- lib_lc3plus/plc_noise_substitution.c | 23 +- lib_lc3plus/plc_phecu_f0_refine_first.c | 87 +- lib_lc3plus/plc_phecu_fec_hq.c | 161 +- lib_lc3plus/plc_phecu_hq_ecu.c | 189 +- lib_lc3plus/plc_phecu_lf_peak_analysis.c | 130 +- lib_lc3plus/plc_phecu_rec_frame.c | 225 +- lib_lc3plus/plc_phecu_setf0hz.c | 23 +- lib_lc3plus/plc_phecu_spec_ana.c | 737 ++-- lib_lc3plus/plc_phecu_subst_spec.c | 352 +- lib_lc3plus/plc_phecu_tba_per_band_gain.c | 31 +- lib_lc3plus/plc_phecu_tba_spect_Xavg.c | 44 +- lib_lc3plus/plc_phecu_tba_trans_dect_gains.c | 291 +- lib_lc3plus/plc_phecu_trans_burst_ana_sub.c | 51 +- lib_lc3plus/plc_tdc.c | 1087 +++-- lib_lc3plus/plc_tdc_tdac.c | 41 +- lib_lc3plus/plc_update.c | 206 +- lib_lc3plus/quantize_spec.c | 170 +- lib_lc3plus/reorder_bitstream.c | 43 +- lib_lc3plus/resamp12k8.c | 88 +- lib_lc3plus/residual_coding.c | 57 +- lib_lc3plus/residual_decoding.c | 74 +- lib_lc3plus/setup_com_lc3.c | 37 +- lib_lc3plus/setup_dec_lc3.c | 501 ++- lib_lc3plus/setup_dec_lc3.h | 110 +- lib_lc3plus/setup_enc_lc3.c | 543 ++- lib_lc3plus/setup_enc_lc3.h | 38 +- lib_lc3plus/sns_compute_scf.c | 164 +- lib_lc3plus/sns_interpolate_scf.c | 95 +- lib_lc3plus/sns_quantize_scf.c | 322 +- lib_lc3plus/structs.h | 242 +- lib_lc3plus/tns_coder.c | 304 +- lib_lc3plus/tns_decoder.c | 60 +- lib_lc3plus/util.h | 219 +- 73 files changed, 9402 insertions(+), 11030 deletions(-) diff --git a/lib_lc3plus/adjust_global_gain.c b/lib_lc3plus/adjust_global_gain.c index 0566f716c8..e7674dd710 100644 --- a/lib_lc3plus/adjust_global_gain.c +++ b/lib_lc3plus/adjust_global_gain.c @@ -1,103 +1,86 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -void processAdjustGlobalGain_fl( LC3_INT *gg_idx, LC3_INT gg_idx_min, LC3_INT gg_idx_off, LC3_FLOAT *gain, LC3_INT target, LC3_INT nBits, LC3_INT *gainChange, LC3_INT fs_idx, LC3_INT16 hrmode, LC3_INT16 frame_dms ) +void processAdjustGlobalGain_fl(LC3_INT* gg_idx, LC3_INT gg_idx_min, LC3_INT gg_idx_off, LC3_FLOAT* gain, LC3_INT target, LC3_INT nBits, LC3_INT* gainChange, LC3_INT fs_idx + , LC3_INT16 hrmode, LC3_INT16 frame_dms + ) { - LC3_FLOAT delta = 0; - LC3_INT delta2 = 0; - LC3_INT gg_idx_inc; - LC3_INT factor; + LC3_FLOAT delta = 0; + LC3_INT delta2 = 0; + LC3_INT gg_idx_inc; + LC3_INT factor; - if ( frame_dms == 25 ) + if (frame_dms == 25) { - if ( target < 520 ) + if (target < 520) { factor = 3; - } - else - { + } else { factor = 4; } - } - else if ( frame_dms == 50 ) + } else if (frame_dms == 50) { factor = 2; - } - else + } else { factor = 1; } - if ( nBits < gg_p1[fs_idx] ) - { - delta = ( nBits + 48.0 ) / 16.0; - } - else if ( nBits < gg_p2[fs_idx] ) - { - delta = ( nBits + gg_d[fs_idx] ) * gg_c[fs_idx]; - } - else if ( nBits < gg_p3[fs_idx] ) - { + if (nBits < gg_p1[fs_idx]) { + delta = (nBits + 48.0) / 16.0; + } else if (nBits < gg_p2[fs_idx]) { + delta = (nBits + gg_d[fs_idx]) * gg_c[fs_idx]; + } else if (nBits < gg_p3[fs_idx]) { delta = nBits / 48.0; - } - else - { + } else { delta = gg_p3[fs_idx] / 48.0; } - delta = round( delta ); + delta = round(delta); delta2 = delta + 2; *gainChange = 0; - if ( *gg_idx == 255 && nBits > target ) - { + if (*gg_idx == 255 && nBits > target) { *gainChange = 1; } - if ( ( *gg_idx < 255 && nBits > target ) || ( *gg_idx > 0 && nBits < target - delta2 ) ) - { - if ( hrmode ) + if ((*gg_idx < 255 && nBits > target) || (*gg_idx > 0 && nBits < target - delta2)) { + if (hrmode) { - if ( nBits > target ) - { - gg_idx_inc = (int) factor * ( ( ( nBits - target ) / delta ) + 1 ); - gg_idx_inc = MIN( gg_idx_inc, 10 * factor ); - + if (nBits > target) { + gg_idx_inc = (int) factor * (((nBits - target)/ delta) + 1); + gg_idx_inc = MIN(gg_idx_inc, 10 * factor); + *gg_idx += gg_idx_inc; } - *gg_idx = MIN( *gg_idx, 255 ); + *gg_idx = MIN(*gg_idx, 255); } else { - if ( nBits < target - delta2 ) - { + if (nBits < target - delta2) { *gg_idx = *gg_idx - 1; - } - else if ( *gg_idx == 254 || nBits < target + delta ) - { + } else if (*gg_idx == 254 || nBits < target + delta) { *gg_idx = *gg_idx + 1; - } - else - { + } else { *gg_idx = *gg_idx + 2; } } - *gg_idx = MAX( *gg_idx, gg_idx_min - gg_idx_off ); - *gain = LC3_POW( 10, (LC3_FLOAT) ( *gg_idx + gg_idx_off ) / 28 ); + *gg_idx = MAX(*gg_idx, gg_idx_min - gg_idx_off); + *gain = LC3_POW(10, (LC3_FLOAT)(*gg_idx + gg_idx_off) / 28); *gainChange = 1; } } diff --git a/lib_lc3plus/al_fec_fl.c b/lib_lc3plus/al_fec_fl.c index d177a23b02..0cae36dade 100644 --- a/lib_lc3plus/al_fec_fl.c +++ b/lib_lc3plus/al_fec_fl.c @@ -1,12 +1,12 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "stdint.h" @@ -20,31 +20,31 @@ /* channel coder specific constants and macros */ #define RS16_CW_LEN_MAX 15 -#define FEC_N_MODES 4 -#define FEC_N_SYNDROMES_MAX 6 -#define FEC_N_ERR_POS_MAX 3 -#define FEC_N_ELP_COEFF_MAX 4 -#define FEC_N_ERR_SYMB_MAX 3 +#define FEC_N_MODES 4 +#define FEC_N_SYNDROMES_MAX 6 +#define FEC_N_ERR_POS_MAX 3 +#define FEC_N_ELP_COEFF_MAX 4 +#define FEC_N_ERR_SYMB_MAX 3 #define FEC_N_MODE_DETECTION_CW 6 -#define SYNDROME_IDX( mode_index, cw_index ) ( ( (mode_index) *FEC_N_MODE_DETECTION_CW + ( cw_index ) ) * FEC_N_SYNDROMES_MAX ) -#define ELP_IDX( mode_index, cw_index ) ( ( (mode_index) *FEC_N_MODE_DETECTION_CW + ( cw_index ) ) * FEC_N_ELP_COEFF_MAX ) -#define ERR_POS_IDX( mode_index, cw_index ) ( ( (mode_index) *FEC_N_MODE_DETECTION_CW + ( cw_index ) ) * FEC_N_ERR_POS_MAX ) -#define ERR_SYMB_IDX( mode_index, cw_index ) ( ( (mode_index) *FEC_N_MODE_DETECTION_CW + ( cw_index ) ) * FEC_N_ERR_SYMB_MAX ) -#define DEG_ELP_IDX( mode_index, cw_index ) ( (mode_index) *FEC_N_MODE_DETECTION_CW + ( cw_index ) ) - -#define FEC_TOTAL_SYNDROME_SIZE ( FEC_N_SYNDROMES_MAX * FEC_N_MODES * FEC_N_MODE_DETECTION_CW ) -#define FEC_TOTAL_ELP_SIZE ( FEC_N_ELP_COEFF_MAX * FEC_N_MODES * FEC_N_MODE_DETECTION_CW ) -#define FEC_TOTAL_ERR_POS_SIZE ( FEC_N_ERR_POS_MAX * FEC_N_MODES * FEC_N_MODE_DETECTION_CW ) -#define FEC_TOTAL_ERROR_SIZE ( FEC_N_ERR_SYMB_MAX * FEC_N_MODES * FEC_N_MODE_DETECTION_CW ) -#define FEC_TOTAL_DEG_ELP_SIZE ( FEC_N_MODES * FEC_N_MODE_DETECTION_CW ) - -#define ERROR_REPORT_BEC_MASK ( ( 0x0FFF ) >> 1 ) -#define ERROR_REPORT_EP1_OK ( ( 0x1000 ) >> 1 ) -#define ERROR_REPORT_EP2_OK ( ( 0x2000 ) >> 1 ) -#define ERROR_REPORT_EP3_OK ( ( 0x4000 ) >> 1 ) -#define ERROR_REPORT_EP4_OK ( ( 0x8000 ) >> 1 ) -#define ERROR_REPORT_ALL_OK ( ERROR_REPORT_EP1_OK | ERROR_REPORT_EP2_OK | ERROR_REPORT_EP3_OK | ERROR_REPORT_EP4_OK ) +#define SYNDROME_IDX(mode_index, cw_index) (((mode_index)*FEC_N_MODE_DETECTION_CW + (cw_index)) * FEC_N_SYNDROMES_MAX) +#define ELP_IDX(mode_index, cw_index) (((mode_index)*FEC_N_MODE_DETECTION_CW + (cw_index)) * FEC_N_ELP_COEFF_MAX) +#define ERR_POS_IDX(mode_index, cw_index) (((mode_index)*FEC_N_MODE_DETECTION_CW + (cw_index)) * FEC_N_ERR_POS_MAX) +#define ERR_SYMB_IDX(mode_index, cw_index) (((mode_index)*FEC_N_MODE_DETECTION_CW + (cw_index)) * FEC_N_ERR_SYMB_MAX) +#define DEG_ELP_IDX(mode_index, cw_index) ((mode_index)*FEC_N_MODE_DETECTION_CW + (cw_index)) + +#define FEC_TOTAL_SYNDROME_SIZE (FEC_N_SYNDROMES_MAX * FEC_N_MODES * FEC_N_MODE_DETECTION_CW) +#define FEC_TOTAL_ELP_SIZE (FEC_N_ELP_COEFF_MAX * FEC_N_MODES * FEC_N_MODE_DETECTION_CW) +#define FEC_TOTAL_ERR_POS_SIZE (FEC_N_ERR_POS_MAX * FEC_N_MODES * FEC_N_MODE_DETECTION_CW) +#define FEC_TOTAL_ERROR_SIZE (FEC_N_ERR_SYMB_MAX * FEC_N_MODES * FEC_N_MODE_DETECTION_CW) +#define FEC_TOTAL_DEG_ELP_SIZE (FEC_N_MODES * FEC_N_MODE_DETECTION_CW) + +#define ERROR_REPORT_BEC_MASK ((0x0FFF)>>1) +#define ERROR_REPORT_EP1_OK ((0x1000)>>1) +#define ERROR_REPORT_EP2_OK ((0x2000)>>1) +#define ERROR_REPORT_EP3_OK ((0x4000)>>1) +#define ERROR_REPORT_EP4_OK ((0x8000)>>1) +#define ERROR_REPORT_ALL_OK (ERROR_REPORT_EP1_OK | ERROR_REPORT_EP2_OK | ERROR_REPORT_EP3_OK | ERROR_REPORT_EP4_OK) /* debugging switches */ @@ -63,9 +63,9 @@ * Behind this is the assumption that one would store GF16 elements in LC3_INT16 for strict BASOP * implementation. */ -#define GF16_MUL( a, b ) gf16_mult_table[( a ) | ( b << 4 )] -#define GF16_MUL0( a, b ) gf16_mult_table[( a ) | ( b )] -#define GF16_ADD( a, b ) ( ( a ) ^ ( b ) ) +#define GF16_MUL(a, b) gf16_mult_table[(a) | (b << 4)] +#define GF16_MUL0(a, b) gf16_mult_table[(a) | (b)] +#define GF16_ADD(a, b) ((a) ^ (b)) /* tables for finite field arithmetic */ /* tables for arithmetic in GF(16) * @@ -75,849 +75,110 @@ static const LC3_UINT8 gf16_mult_table[256] = { /* gf16_mult_table[a | (b << 4)] contains the product of a and b in GF(16) */ - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 0, - 2, - 4, - 6, - 8, - 10, - 12, - 14, - 3, - 1, - 7, - 5, - 11, - 9, - 15, - 13, - 0, - 3, - 6, - 5, - 12, - 15, - 10, - 9, - 11, - 8, - 13, - 14, - 7, - 4, - 1, - 2, - 0, - 4, - 8, - 12, - 3, - 7, - 11, - 15, - 6, - 2, - 14, - 10, - 5, - 1, - 13, - 9, - 0, - 5, - 10, - 15, - 7, - 2, - 13, - 8, - 14, - 11, - 4, - 1, - 9, - 12, - 3, - 6, - 0, - 6, - 12, - 10, - 11, - 13, - 7, - 1, - 5, - 3, - 9, - 15, - 14, - 8, - 2, - 4, - 0, - 7, - 14, - 9, - 15, - 8, - 1, - 6, - 13, - 10, - 3, - 4, - 2, - 5, - 12, - 11, - 0, - 8, - 3, - 11, - 6, - 14, - 5, - 13, - 12, - 4, - 15, - 7, - 10, - 2, - 9, - 1, - 0, - 9, - 1, - 8, - 2, - 11, - 3, - 10, - 4, - 13, - 5, - 12, - 6, - 15, - 7, - 14, - 0, - 10, - 7, - 13, - 14, - 4, - 9, - 3, - 15, - 5, - 8, - 2, - 1, - 11, - 6, - 12, - 0, - 11, - 5, - 14, - 10, - 1, - 15, - 4, - 7, - 12, - 2, - 9, - 13, - 6, - 8, - 3, - 0, - 12, - 11, - 7, - 5, - 9, - 14, - 2, - 10, - 6, - 1, - 13, - 15, - 3, - 4, - 8, - 0, - 13, - 9, - 4, - 1, - 12, - 8, - 5, - 2, - 15, - 11, - 6, - 3, - 14, - 10, - 7, - 0, - 14, - 15, - 1, - 13, - 3, - 2, - 12, - 9, - 7, - 6, - 8, - 4, - 10, - 11, - 5, - 0, - 15, - 13, - 2, - 9, - 6, - 4, - 11, - 1, - 14, - 12, - 3, - 8, - 7, - 5, - 10, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 0, 2, 4, 6, 8, 10, 12, 14, 3, 1, 7, 5, 11, 9, 15, 13, 0, 3, 6, 5, 12, 15, 10, 9, 11, 8, + 13, 14, 7, 4, 1, 2, 0, 4, 8, 12, 3, 7, 11, 15, 6, 2, 14, 10, 5, 1, 13, 9, 0, 5, 10, 15, 7, 2, 13, + 8, 14, 11, 4, 1, 9, 12, 3, 6, 0, 6, 12, 10, 11, 13, 7, 1, 5, 3, 9, 15, 14, 8, 2, 4, 0, 7, 14, 9, + 15, 8, 1, 6, 13, 10, 3, 4, 2, 5, 12, 11, 0, 8, 3, 11, 6, 14, 5, 13, 12, 4, 15, 7, 10, 2, 9, 1, 0, + 9, 1, 8, 2, 11, 3, 10, 4, 13, 5, 12, 6, 15, 7, 14, 0, 10, 7, 13, 14, 4, 9, 3, 15, 5, 8, 2, 1, 11, + 6, 12, 0, 11, 5, 14, 10, 1, 15, 4, 7, 12, 2, 9, 13, 6, 8, 3, 0, 12, 11, 7, 5, 9, 14, 2, 10, 6, 1, + 13, 15, 3, 4, 8, 0, 13, 9, 4, 1, 12, 8, 5, 2, 15, 11, 6, 3, 14, 10, 7, 0, 14, 15, 1, 13, 3, 2, 12, + 9, 7, 6, 8, 4, 10, 11, 5, 0, 15, 13, 2, 9, 6, 4, 11, 1, 14, 12, 3, 8, 7, 5, 10, }; static const LC3_UINT8 rs16_elp_deg2_table[256] = { /* If the polynomial x^2 + ax + b has distinct non-zero roots z1 and z2 in GF(16), * * then table entry a + 16*b contains log_g(z1) | log_g(z2) << 4, and otherwise it * * contains 0. */ - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 165, - 0, - 0, - 0, - 0, - 105, - 195, - 0, - 210, - 0, - 225, - 0, - 180, - 120, - 0, - 0, - 121, - 0, - 16, - 0, - 211, - 0, - 0, - 181, - 0, - 0, - 106, - 196, - 226, - 0, - 0, - 0, - 214, - 64, - 0, - 199, - 0, - 0, - 0, - 0, - 0, - 49, - 184, - 0, - 154, - 0, - 229, - 0, - 227, - 182, - 0, - 0, - 32, - 0, - 0, - 0, - 197, - 0, - 0, - 122, - 0, - 212, - 152, - 0, - 203, - 0, - 158, - 128, - 0, - 0, - 0, - 98, - 113, - 218, - 0, - 0, - 0, - 53, - 0, - 0, - 65, - 0, - 0, - 185, - 110, - 215, - 80, - 0, - 0, - 200, - 0, - 50, - 0, - 0, - 0, - 0, - 130, - 205, - 115, - 0, - 0, - 160, - 190, - 145, - 0, - 0, - 0, - 0, - 0, - 0, - 100, - 0, - 0, - 168, - 198, - 0, - 183, - 33, - 0, - 0, - 48, - 228, - 213, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 164, - 0, - 179, - 0, - 224, - 104, - 0, - 194, - 149, - 0, - 0, - 209, - 0, - 0, - 0, - 189, - 99, - 84, - 0, - 129, - 0, - 0, - 0, - 144, - 0, - 0, - 234, - 114, - 0, - 0, - 82, - 0, - 0, - 0, - 0, - 217, - 202, - 0, - 112, - 52, - 232, - 0, - 97, - 0, - 0, - 0, - 126, - 0, - 81, - 201, - 0, - 36, - 216, - 186, - 0, - 0, - 0, - 96, - 0, - 0, - 0, - 0, - 0, - 88, - 0, - 0, - 0, - 103, - 0, - 148, - 178, - 0, - 208, - 193, - 0, - 58, - 0, - 0, - 0, - 0, - 0, - 161, - 206, - 0, - 116, - 0, - 101, - 0, - 0, - 56, - 146, - 176, - 0, - 0, - 147, - 162, - 222, - 0, - 132, - 0, - 0, - 0, - 0, - 0, - 177, - 117, - 192, - 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 165, 0, 0, 0, 0, + 105, 195, 0, 210, 0, 225, 0, 180, 120, 0, 0, 121, 0, 16, 0, 211, 0, 0, 181, 0, 0, 106, + 196, 226, 0, 0, 0, 214, 64, 0, 199, 0, 0, 0, 0, 0, 49, 184, 0, 154, 0, 229, 0, 227, + 182, 0, 0, 32, 0, 0, 0, 197, 0, 0, 122, 0, 212, 152, 0, 203, 0, 158, 128, 0, 0, 0, + 98, 113, 218, 0, 0, 0, 53, 0, 0, 65, 0, 0, 185, 110, 215, 80, 0, 0, 200, 0, 50, 0, + 0, 0, 0, 130, 205, 115, 0, 0, 160, 190, 145, 0, 0, 0, 0, 0, 0, 100, 0, 0, 168, 198, + 0, 183, 33, 0, 0, 48, 228, 213, 0, 0, 0, 0, 0, 0, 0, 0, 164, 0, 179, 0, 224, 104, + 0, 194, 149, 0, 0, 209, 0, 0, 0, 189, 99, 84, 0, 129, 0, 0, 0, 144, 0, 0, 234, 114, + 0, 0, 82, 0, 0, 0, 0, 217, 202, 0, 112, 52, 232, 0, 97, 0, 0, 0, 126, 0, 81, 201, + 0, 36, 216, 186, 0, 0, 0, 96, 0, 0, 0, 0, 0, 88, 0, 0, 0, 103, 0, 148, 178, 0, + 208, 193, 0, 58, 0, 0, 0, 0, 0, 161, 206, 0, 116, 0, 101, 0, 0, 56, 146, 176, 0, 0, + 147, 162, 222, 0, 132, 0, 0, 0, 0, 0, 177, 117, 192, 0, }; static const LC3_UINT16 rs16_elp_deg3_table[256] = { /* If the polynomial x^3 + ax + b has distinct roots z1, z2 and z3 in GF(16), * * then table entry a + 16*b contains z1) | z2 << 4 | z3 << 8, and otherwise it * * contains 0. */ - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1889, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 2977, - 0, - 0, - 0, - 0, - 0, - 3990, - 1859, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 3521, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1874, - 0, - 3718, - 0, - 0, - 0, - 0, - 0, - 0, - 2433, - 0, - 0, - 1619, - 0, - 0, - 0, - 0, - 3495, - 0, - 0, - 0, - 0, - 0, - 0, - 4065, - 0, - 0, - 0, - 0, - 0, - 0, - 3255, - 0, - 0, - 0, - 1602, - 0, - 3735, - 0, - 0, - 0, - 0, - 3238, - 801, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 3510, - 0, - 0, - 0, - 0, - 1345, - 3975, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 3778, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 2947, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 3476, - 0, - 4005, - 0, - 3461, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 3748, - 0, - 0, - 2962, - 0, - 0, - 0, - 0, - 4035, - 0, - 0, - 4020, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 3221, - 0, - 0, - 0, - 0, - 0, - 0, - 2690, - 0, - 0, - 0, - 3795, - 0, - 0, - 0, - 4050, - 0, - 0, - 0, - 0, - 0, - 3204, - 3765, - 0, - 0, - 0, - 0, - 0, - 2707, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1889, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2977, 0, 0, 0, 0, 0, 3990, 1859, 0, + 0, 0, 0, 0, 0, 0, 3521, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1874, 0, 3718, 0, 0, 0, + 0, 0, 0, 2433, 0, 0, 1619, 0, 0, 0, 0, 3495, 0, 0, 0, 0, 0, 0, 4065, 0, 0, 0, + 0, 0, 0, 3255, 0, 0, 0, 1602, 0, 3735, 0, 0, 0, 0, 3238, 801, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 3510, 0, 0, 0, 0, 1345, 3975, 0, 0, 0, 0, 0, 0, 0, 0, 3778, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2947, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 3476, 0, 4005, 0, 3461, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 3748, 0, 0, 2962, 0, 0, 0, 0, 4035, 0, 0, 4020, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3221, 0, 0, 0, 0, 0, 0, 2690, + 0, 0, 0, 3795, 0, 0, 0, 4050, 0, 0, 0, 0, 0, 3204, 3765, 0, 0, 0, 0, 0, 2707, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -static const LC3_UINT8 gf16_g_pow[16] = { 1, 2, 4, 8, 3, 6, 12, 11, 5, 10, 7, 14, 15, 13, 9, 1 }; +static const LC3_UINT8 gf16_g_pow[16] = {1, 2, 4, 8, 3, 6, 12, 11, 5, 10, 7, 14, 15, 13, 9, 1}; /* g_pow[i] contains g^i*/ -static const LC3_UINT8 gf16_log_g[16] = { 255, 0, 1, 4, 2, 8, 5, 10, 3, 14, 9, 7, 6, 13, 11, 12 }; +static const LC3_UINT8 gf16_log_g[16] = {255, 0, 1, 4, 2, 8, 5, 10, 3, 14, 9, 7, 6, 13, 11, 12}; /* log_g[n] contains contains the value i such that g^i = n for n=1, 2, ..., 15, log_g[0] is set to 255 */ -static const LC3_UINT8 gf16_inv_table[16] = { 255, 1, 9, 14, 13, 11, 7, 6, 15, 2, 12, 5, 10, 4, 3, 8 }; +static const LC3_UINT8 gf16_inv_table[16] = {255, 1, 9, 14, 13, 11, 7, 6, 15, 2, 12, 5, 10, 4, 3, 8}; /* gf16_inv_table[n] contains the multiplicative inverse of n in GF(16) (1/0 is set to 255)*/ /* RS16 generating polynomials (from lowest to highest coefficient without leading 1)*/ -static const LC3_UINT8 rs16_gp_d3[] = { 8, 6 }; -static const LC3_UINT8 rs16_gp_d5[] = { 7, 8, 12, 13 }; -static const LC3_UINT8 rs16_gp_d7[] = { 12, 10, 12, 3, 9, 7 }; +static const LC3_UINT8 rs16_gp_d3[] = {8, 6}; +static const LC3_UINT8 rs16_gp_d5[] = {7, 8, 12, 13}; +static const LC3_UINT8 rs16_gp_d7[] = {12, 10, 12, 3, 9, 7}; /* FEC mode signaling polynomials */ #define EP_SIG_POLY_DEG 12 -static const LC3_UINT8 sig_polys[4][15] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 7, 15, 5, 6, 14, 9, 1, 3, 12, 10, 13, 3, 2, 0, 0 }, - { 7, 11, 14, 1, 2, 3, 12, 11, 6, 15, 7, 6, 12, 0, 0 }, - { 6, 15, 12, 2, 9, 15, 2, 8, 12, 3, 10, 5, 4, 0, 0 } }; +static const LC3_UINT8 sig_polys[4][15] = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {7, 15, 5, 6, 14, 9, 1, 3, 12, 10, 13, 3, 2, 0, 0}, + {7, 11, 14, 1, 2, 3, 12, 11, 6, 15, 7, 6, 12, 0, 0}, + {6, 15, 12, 2, 9, 15, 2, 8, 12, 3, 10, 5, 4, 0, 0}}; static const LC3_UINT8 sig_poly_syndr[4][6] = { - { 0, 0, 0, 0, 0, 0 }, - { 0, 4, 5, 11, 5, 8 }, - { 0, 5, 9, 0, 1, 7 }, - { 0, 12, 5, 12, 9, 8 } -}; + {0, 0, 0, 0, 0, 0}, {0, 4, 5, 11, 5, 8}, {0, 5, 9, 0, 1, 7}, {0, 12, 5, 12, 9, 8}}; /* bit count table for error report (0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111) */ -static const LC3_UINT8 rs16_bit_count_table[] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 }; +static const LC3_UINT8 rs16_bit_count_table[] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4}; /* List of RS16 generators by Hamming distance */ -static const LC3_UINT8 *const rs16_gp_by_hd[8] = { NULL, NULL, NULL, rs16_gp_d3, NULL, rs16_gp_d5, NULL, rs16_gp_d7 }; +static const LC3_UINT8 *const rs16_gp_by_hd[8] = {NULL, NULL, NULL, rs16_gp_d3, NULL, rs16_gp_d5, NULL, rs16_gp_d7}; /* fec config data */ -static const LC3_UINT8 hamming_distance_by_mode0[] = { 1, 3, 3, 5, 7 }; -static const LC3_UINT8 hamming_distance_by_mode1[] = { 1, 1, 3, 5, 7 }; +static const LC3_UINT8 hamming_distance_by_mode0[] = {1, 3, 3, 5, 7}; +static const LC3_UINT8 hamming_distance_by_mode1[] = {1, 1, 3, 5, 7}; -static const LC3_UINT8 crc1_bytes_by_mode0[] = { 0, 3, 2, 2, 2 }; -static const LC3_UINT8 crc1_bytes_by_mode1[] = { 0, 3, 3, 3, 3 }; -static const LC3_UINT8 crc2_bytes_by_mode[] = { 0, 0, 2, 2, 2 }; +static const LC3_UINT8 crc1_bytes_by_mode0[] = {0, 3, 2, 2, 2}; +static const LC3_UINT8 crc1_bytes_by_mode1[] = {0, 3, 3, 3, 3}; +static const LC3_UINT8 crc2_bytes_by_mode[] = {0, 0, 2, 2, 2}; /* fec mode risk table */ typedef struct { LC3_UINT32 mantissa; - LC3_INT16 exponent; + LC3_INT16 exponent; } simple_float; -static const simple_float risk_table_f[4][4] = { { { 16384, 0 }, { 16384, 0 }, { 16384, 0 }, { 16384, 0 } }, - { { 16384, -8 }, { 26880, -1 }, { 16384, 0 }, { 16384, 0 } }, - { { 16384, -16 }, { 26880, -9 }, { 20475, -2 }, { 16384, 0 } }, - { { 16384, -24 }, { 26880, -17 }, { 20475, -10 }, { 19195, -4 } } }; +static const simple_float risk_table_f[4][4] = {{{16384, 0}, {16384, 0}, {16384, 0}, {16384, 0}}, + {{16384, -8}, {26880, -1}, {16384, 0}, {16384, 0}}, + {{16384, -16}, {26880, -9}, {20475, -2}, {16384, 0}}, + {{16384, -24}, {26880, -17}, {20475, -10}, {19195, -4}}}; /* bit error limits for slot size 40 */ -static LC3_INT16 const low_br_max_bit_errors_by_mode[] = { 0, 0, 3, 9, 18 }; +static LC3_INT16 const low_br_max_bit_errors_by_mode[] = {0, 0, 3, 9, 18}; /* corresponding float values: @@ -929,75 +190,81 @@ corresponding float values: /* internal encoder routines */ -FEC_STATIC void fec_interleave_pack( LC3_UINT8 *out, LC3_UINT8 *in, LC3_INT16 n_nibbles, LC3_INT16 n_codewords ); +FEC_STATIC void fec_interleave_pack(LC3_UINT8 *out, LC3_UINT8 *in, LC3_INT16 n_nibbles, LC3_INT16 n_codewords); -FEC_STATIC void rs16_enc( LC3_UINT8 *iobuf, LC3_INT16 codeword_length, LC3_INT16 hamming_distance, LC3_INT16 fec_mode, LC3_INT16 signal_mode ); +FEC_STATIC void rs16_enc(LC3_UINT8 *iobuf, LC3_INT16 codeword_length, LC3_INT16 hamming_distance, LC3_INT16 fec_mode, + LC3_INT16 signal_mode); /* internal decoder routines */ -FEC_STATIC void fec_deinterleave_unpack( LC3_UINT8 *out, LC3_UINT8 *in, LC3_INT16 n_nibbles, LC3_INT16 n_codewords ); +FEC_STATIC void fec_deinterleave_unpack(LC3_UINT8 *out, LC3_UINT8 *in, LC3_INT16 n_nibbles, LC3_INT16 n_codewords); -FEC_STATIC LC3_INT16 fec_data_preproc( LC3_INT16 mode, LC3_INT16 epmr, LC3_UINT8 *iobuf, LC3_UINT8 *cw_buf, LC3_INT16 data_bytes, LC3_INT16 slot_bytes, LC3_INT16 pc_split ); +FEC_STATIC LC3_INT16 fec_data_preproc(LC3_INT16 mode, LC3_INT16 epmr, LC3_UINT8 *iobuf, LC3_UINT8 *cw_buf, LC3_INT16 data_bytes, + LC3_INT16 slot_bytes, LC3_INT16 pc_split); -FEC_STATIC void fec_data_postproc( LC3_INT16 mode, LC3PLUS_EpModeRequest *epmr, LC3_UINT8 *iobuf, LC3_INT16 data_bytes, LC3_UINT8 *cw_buf, LC3_INT16 slot_bytes, LC3_INT16 pc_split, LC3_INT32 *bfi ); +FEC_STATIC void fec_data_postproc(LC3_INT16 mode, LC3PLUS_EpModeRequest *epmr, LC3_UINT8 *iobuf, LC3_INT16 data_bytes, LC3_UINT8 *cw_buf, + LC3_INT16 slot_bytes, LC3_INT16 pc_split, LC3_INT32 *bfi); -FEC_STATIC LC3_INT32 rs16_detect_and_correct( LC3_UINT8 *iobuf, LC3_INT32 n_symb, LC3_INT32 n_codewords, LC3PLUS_EpModeRequest *epmr, LC3_INT16 *error_report, LC3_INT32 *bfi, LC3_UINT8 *array_of_trust, LC3_INT32 ccc_flag_flag, LC3_INT16 *n_pccw ); +FEC_STATIC LC3_INT32 rs16_detect_and_correct(LC3_UINT8 *iobuf, LC3_INT32 n_symb, LC3_INT32 n_codewords, LC3PLUS_EpModeRequest *epmr, LC3_INT16 *error_report, + LC3_INT32 *bfi, LC3_UINT8 *array_of_trust, LC3_INT32 ccc_flag_flag, LC3_INT16 *n_pccw); -FEC_STATIC void rs16_calculate_six_syndromes( LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg ); +FEC_STATIC void rs16_calculate_six_syndromes(LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg); -FEC_STATIC void rs16_calculate_four_syndromes( LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg ); +FEC_STATIC void rs16_calculate_four_syndromes(LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg); -FEC_STATIC void rs16_calculate_two_syndromes( LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg ); +FEC_STATIC void rs16_calculate_two_syndromes(LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg); -FEC_STATIC LC3_INT8 rs16_calculate_elp( LC3_UINT8 *elp, LC3_UINT8 *syndromes, LC3_INT16 hamming_distance ); +FEC_STATIC LC3_INT8 rs16_calculate_elp(LC3_UINT8 *elp, LC3_UINT8 *syndromes, LC3_INT16 hamming_distance); -FEC_STATIC LC3_INT16 rs16_factorize_elp( LC3_UINT8 *error_locations, LC3_UINT8 *elp, LC3_INT16 deg_elp, LC3_INT16 max_pos ); +FEC_STATIC LC3_INT16 rs16_factorize_elp(LC3_UINT8 *error_locations, LC3_UINT8 *elp, LC3_INT16 deg_elp, LC3_INT16 max_pos); -FEC_STATIC void rs16_calculate_errors( LC3_UINT8 *errors, LC3_UINT8 *err_pos, LC3_UINT8 *syndromes, LC3_INT8 deg_elp, LC3_INT8 t ); +FEC_STATIC void rs16_calculate_errors(LC3_UINT8 *errors, LC3_UINT8 *err_pos, LC3_UINT8 *syndromes, LC3_INT8 deg_elp, LC3_INT8 t); /* auxiliary routines */ -FEC_STATIC LC3_INT16 crc1( LC3_UINT8 *data, LC3_INT16 data_size, LC3_INT16 epmr, LC3_UINT8 *hash_val, LC3_INT16 hash_size, LC3_INT16 check ); +FEC_STATIC LC3_INT16 crc1(LC3_UINT8 *data, LC3_INT16 data_size, LC3_INT16 epmr, LC3_UINT8 *hash_val, LC3_INT16 hash_size, LC3_INT16 check); -FEC_STATIC LC3PLUS_EpModeRequest fec_estimate_epmr_from_cw0( LC3_UINT8 *cw0, LC3_INT8 *t, LC3_UINT8 *syndromes, LC3_UINT8 *elp, LC3_INT8 *deg_elp, LC3_UINT8 *err_pos, LC3_UINT8 *err_symb, LC3_INT16 n_codewords, LC3_INT16 n_symb ); +FEC_STATIC LC3PLUS_EpModeRequest fec_estimate_epmr_from_cw0(LC3_UINT8 *cw0, LC3_INT8 *t, LC3_UINT8 *syndromes, LC3_UINT8 *elp, LC3_INT8 *deg_elp, + LC3_UINT8 *err_pos, LC3_UINT8 *err_symb, LC3_INT16 n_codewords, LC3_INT16 n_symb); -FEC_STATIC void dw0_bitswap( LC3_UINT8 *dw0, LC3_INT16 mode, LC3_INT16 slot_bytes ); +FEC_STATIC void dw0_bitswap(LC3_UINT8 *dw0, LC3_INT16 mode, LC3_INT16 slot_bytes); -FEC_STATIC LC3PLUS_EpModeRequest cw0_get_epmr( LC3_UINT8 *cw0, LC3_INT16 epmr_position ); +FEC_STATIC LC3PLUS_EpModeRequest cw0_get_epmr(LC3_UINT8 *cw0, LC3_INT16 epmr_position); -FEC_STATIC LC3PLUS_EpModeRequest dw0_get_epmr( LC3_UINT8 *dw0, LC3_INT16 mode, LC3_INT16 slot_size ); +FEC_STATIC LC3PLUS_EpModeRequest dw0_get_epmr(LC3_UINT8 *dw0, LC3_INT16 mode, LC3_INT16 slot_size); -FEC_STATIC LC3_INT16 crc2( LC3_UINT8 *data, LC3_INT16 data_size, LC3_UINT8 *hash_val, LC3_INT16 hash_size, LC3_INT16 check ); +FEC_STATIC LC3_INT16 crc2(LC3_UINT8 *data, LC3_INT16 data_size, LC3_UINT8 *hash_val, LC3_INT16 hash_size, LC3_INT16 check); -FEC_STATIC simple_float simple_float_mul( simple_float op1, simple_float op2 ); +FEC_STATIC simple_float simple_float_mul(simple_float op1, simple_float op2); -FEC_STATIC LC3_INT16 simple_float_cmp( simple_float op1, simple_float op2 ); +FEC_STATIC LC3_INT16 simple_float_cmp(simple_float op1, simple_float op2); -FEC_STATIC LC3_INT16 get_total_crc_size( LC3_INT16 slot_bytes, LC3_INT16 fec_mode, LC3_INT16 pc_split ); +FEC_STATIC LC3_INT16 get_total_crc_size(LC3_INT16 slot_bytes, LC3_INT16 fec_mode, LC3_INT16 pc_split); -FEC_STATIC LC3_INT16 get_n_codewords( LC3_INT16 slot_bytes ); +FEC_STATIC LC3_INT16 get_n_codewords(LC3_INT16 slot_bytes); -FEC_STATIC LC3_INT16 get_codeword_length( LC3_INT16 n_codewords, LC3_INT16 slot_nibbles, LC3_INT16 codeword_index ); +FEC_STATIC LC3_INT16 get_codeword_length(LC3_INT16 n_codewords, LC3_INT16 slot_nibbles, LC3_INT16 codeword_index); -LC3_INT16 fec_get_n_pccw( LC3_INT16 slot_bytes, LC3_INT16 fec_mode, LC3_INT16 ccc_flag ) + +LC3_INT16 fec_get_n_pccw(LC3_INT16 slot_bytes, LC3_INT16 fec_mode, LC3_INT16 ccc_flag) { LC3_INT16 n_pccw; - if ( fec_mode == 3 ) + if (fec_mode == 3) { - n_pccw = (LC3_INT16) ( 0.080447761194030 * slot_bytes - 1.791044776119394 + 0.5 ); + n_pccw = (LC3_INT16) (0.080447761194030 * slot_bytes - 1.791044776119394 + 0.5); } - else if ( fec_mode == 4 ) + else if (fec_mode == 4) { - n_pccw = (LC3_INT16) ( 0.066492537313433 * slot_bytes - 1.970149253731338 + 0.5 ); + n_pccw = (LC3_INT16) (0.066492537313433 * slot_bytes - 1.970149253731338 + 0.5); } else { n_pccw = 0; } - if ( ccc_flag == 1 || slot_bytes < 80 ) + if (ccc_flag == 1 || slot_bytes < 80) { n_pccw = 0; } @@ -1005,58 +272,59 @@ LC3_INT16 fec_get_n_pccw( LC3_INT16 slot_bytes, LC3_INT16 fec_mode, LC3_INT16 cc return n_pccw; } -FEC_STATIC LC3_INT16 get_total_crc_size( LC3_INT16 slot_bytes, LC3_INT16 fec_mode, LC3_INT16 pc_split ) +FEC_STATIC LC3_INT16 get_total_crc_size(LC3_INT16 slot_bytes, LC3_INT16 fec_mode, LC3_INT16 pc_split) { - LC3_INT16 n_crc; + LC3_INT16 n_crc; n_crc = crc1_bytes_by_mode1[fec_mode]; - if ( slot_bytes == 40 ) + if (slot_bytes == 40) { n_crc = crc1_bytes_by_mode0[fec_mode]; } - if ( pc_split > 0 ) + if (pc_split > 0) { n_crc = n_crc + crc2_bytes_by_mode[fec_mode]; } - + + return n_crc; } -FEC_STATIC LC3_INT16 get_n_codewords( LC3_INT16 slot_bytes ) +FEC_STATIC LC3_INT16 get_n_codewords(LC3_INT16 slot_bytes) { - return ( 2 * slot_bytes + 14 ) / 15; + return (2*slot_bytes + 14)/15; } -FEC_STATIC LC3_INT16 get_codeword_length( LC3_INT16 n_codewords, LC3_INT16 slot_nibbles, LC3_INT16 codeword_index ) +FEC_STATIC LC3_INT16 get_codeword_length(LC3_INT16 n_codewords, LC3_INT16 slot_nibbles, LC3_INT16 codeword_index) { - return ( slot_nibbles - codeword_index - 1 ) / n_codewords + 1; + return (slot_nibbles - codeword_index - 1) / n_codewords + 1; } /* Encoder */ -LC3_INT16 fec_get_data_size( LC3_INT16 fec_mode, LC3_INT16 ccc_flag, LC3_INT16 slot_bytes ) +LC3_INT16 fec_get_data_size(LC3_INT16 fec_mode, LC3_INT16 ccc_flag, LC3_INT16 slot_bytes) /* not time critical */ { - LC3_INT16 n_codewords, payload_size; + LC3_INT16 n_codewords, payload_size; - n_codewords = get_n_codewords( slot_bytes ); + n_codewords = get_n_codewords(slot_bytes); - assert( n_codewords == ( 2 * slot_bytes + RS16_CW_LEN_MAX - 1 ) / RS16_CW_LEN_MAX ); + assert(n_codewords == (2 * slot_bytes + RS16_CW_LEN_MAX - 1) / RS16_CW_LEN_MAX); payload_size = slot_bytes; - if ( fec_mode > 0 ) + if (fec_mode > 0) { - if ( fec_mode == 1 ) + if (fec_mode == 1) { - payload_size--; + payload_size --; } else { - payload_size -= ( fec_mode - 1 ) * n_codewords; + payload_size -= (fec_mode - 1) * n_codewords; } - if ( slot_bytes == 40 ) + if (slot_bytes == 40) { payload_size -= crc1_bytes_by_mode0[fec_mode]; } @@ -1065,113 +333,119 @@ LC3_INT16 fec_get_data_size( LC3_INT16 fec_mode, LC3_INT16 ccc_flag, LC3_INT16 s payload_size -= crc1_bytes_by_mode1[fec_mode]; } - if ( ccc_flag == 0 && fec_mode > 2 && slot_bytes >= 80 ) + if (ccc_flag == 0 && fec_mode > 2 && slot_bytes >= 80) { payload_size -= crc2_bytes_by_mode[fec_mode]; } } - + + return payload_size; } -LC3_INT16 fec_get_n_pc( LC3_INT16 fec_mode, LC3_INT16 n_pccw, LC3_INT16 slot_bytes ) +LC3_INT16 fec_get_n_pc(LC3_INT16 fec_mode, LC3_INT16 n_pccw, LC3_INT16 slot_bytes) /* not time critical */ { - LC3_INT16 n_codewords, pc_split; - LC3_INT32 i; + LC3_INT16 n_codewords, pc_split; + LC3_INT32 i; - n_codewords = get_n_codewords( slot_bytes ); + n_codewords = get_n_codewords(slot_bytes); - assert( n_codewords == ( 2 * slot_bytes + RS16_CW_LEN_MAX - 1 ) / RS16_CW_LEN_MAX ); + assert(n_codewords == (2 * slot_bytes + RS16_CW_LEN_MAX - 1) / RS16_CW_LEN_MAX); - pc_split = -2 * n_pccw * ( fec_mode - 1 ); + pc_split = - 2*n_pccw*(fec_mode - 1); - if ( fec_mode == 1 || slot_bytes < 80 ) + if (fec_mode == 1 || slot_bytes < 80) { pc_split = 0; } else { - for ( i = 0; i < n_pccw; i++ ) + for (i = 0; i < n_pccw; i++) { - pc_split += ( 2 * slot_bytes + i ) / n_codewords; + pc_split += (2 * slot_bytes + i) / n_codewords; } } - + + return pc_split; } /* functions for EPMR handling */ -FEC_STATIC void dw0_bitswap( LC3_UINT8 *dw0, LC3_INT16 mode, LC3_INT16 slot_bytes ) +FEC_STATIC void dw0_bitswap(LC3_UINT8 *dw0, LC3_INT16 mode, LC3_INT16 slot_bytes) /* swap epmr bits with bits that will be positioned at 30 and 32 in code word 0 */ { - LC3_UINT8 tmp; - LC3_INT32 ind0, ind1, position; + LC3_UINT8 tmp; + LC3_INT32 ind0, ind1, position; - position = get_codeword_length( get_n_codewords( slot_bytes ), 2 * slot_bytes, 0 ) - 1; + position = get_codeword_length(get_n_codewords(slot_bytes), 2*slot_bytes, 0) - 1; - if ( slot_bytes == 40 ) + if (slot_bytes == 40) { - ind0 = 2 * crc1_bytes_by_mode0[mode] - 1; + ind0 = 2*crc1_bytes_by_mode0[mode] - 1; } else { - ind0 = 2 * crc1_bytes_by_mode1[mode] - 1; + ind0 = 2*crc1_bytes_by_mode1[mode] - 1; } ind1 = position - hamming_distance_by_mode0[mode] + 1; /* swap bits 2 and 3 of dw0[ind0] with bits 0 and 1 of dw0[ind1] */ - tmp = ( dw0[ind0] >> 2 ) & 3; + tmp = (dw0[ind0] >> 2) & 3; dw0[ind0] = dw0[ind0] & 3; - dw0[ind0] = dw0[ind0] | ( ( dw0[ind1] & 3 ) << 2 ); + dw0[ind0] = dw0[ind0] | ((dw0[ind1] & 3) << 2); dw0[ind1] = dw0[ind1] & 12; dw0[ind1] = dw0[ind1] | tmp; + + } -FEC_STATIC LC3PLUS_EpModeRequest cw0_get_epmr( LC3_UINT8 *cw0, LC3_INT16 position ) +FEC_STATIC LC3PLUS_EpModeRequest cw0_get_epmr(LC3_UINT8 *cw0, LC3_INT16 position) { - return (LC3PLUS_EpModeRequest) ( cw0[position] & 3 ); + return (LC3PLUS_EpModeRequest)(cw0[position] & 3); } -FEC_STATIC LC3PLUS_EpModeRequest dw0_get_epmr( LC3_UINT8 *dw0, LC3_INT16 mode, LC3_INT16 slot_size ) +FEC_STATIC LC3PLUS_EpModeRequest dw0_get_epmr(LC3_UINT8 *dw0, LC3_INT16 mode, LC3_INT16 slot_size) { - LC3_INT32 ncrc1; - LC3PLUS_EpModeRequest epmr; + LC3_INT32 ncrc1; + LC3PLUS_EpModeRequest epmr; ncrc1 = crc1_bytes_by_mode1[mode]; - if ( slot_size == 40 ) + if (slot_size == 40) { ncrc1 = crc1_bytes_by_mode0[mode]; } - epmr = (LC3PLUS_EpModeRequest) ( dw0[2 * ncrc1 - 1] >> 2 ); - + epmr = (LC3PLUS_EpModeRequest)(dw0[2 * ncrc1 - 1] >> 2); + + return epmr; } -FEC_STATIC LC3_INT16 fec_data_preproc( LC3_INT16 mode, LC3_INT16 epmr, LC3_UINT8 *iobuf, LC3_UINT8 *cw_buf, LC3_INT16 data_bytes, LC3_INT16 slot_bytes, LC3_INT16 pc_split ) +FEC_STATIC LC3_INT16 fec_data_preproc(LC3_INT16 mode, LC3_INT16 epmr, LC3_UINT8 *iobuf, LC3_UINT8 *cw_buf, LC3_INT16 data_bytes, + LC3_INT16 slot_bytes, LC3_INT16 pc_split) { - LC3_INT16 data_offset, n_crc1, n_crc2; - LC3_INT32 i, j; + LC3_INT16 data_offset, n_crc1, n_crc2; + LC3_INT32 i, j; - data_offset = 2 * ( slot_bytes - data_bytes ); + data_offset = 2*(slot_bytes - data_bytes); /* extract and reverse data*/ - j = 2 * slot_bytes - 1; - for ( i = 0; i < data_bytes; i++ ) + j = 2*slot_bytes - 1; + for (i = 0; i < data_bytes; i++) { cw_buf[j--] = iobuf[i] & 15; cw_buf[j--] = iobuf[i] >> 4; } /* add crc hashes */ - if ( slot_bytes == 40 ) + if (slot_bytes == 40) { n_crc1 = crc1_bytes_by_mode0[mode]; } @@ -1180,7 +454,7 @@ FEC_STATIC LC3_INT16 fec_data_preproc( LC3_INT16 mode, LC3_INT16 epmr, LC3_UINT8 n_crc1 = crc1_bytes_by_mode1[mode]; } - if ( pc_split > 0 && mode > 1 ) + if (pc_split > 0 && mode > 1) { n_crc2 = crc2_bytes_by_mode[mode]; } @@ -1189,207 +463,214 @@ FEC_STATIC LC3_INT16 fec_data_preproc( LC3_INT16 mode, LC3_INT16 epmr, LC3_UINT8 n_crc2 = 0; } - if ( n_crc2 ) + if (n_crc2) { - crc2( cw_buf + data_offset + 2 * data_bytes - pc_split, pc_split, cw_buf + data_offset - 2 * n_crc2, n_crc2, 0 ); + crc2(cw_buf + data_offset + 2 * data_bytes - pc_split, pc_split, cw_buf + data_offset - 2 * n_crc2, n_crc2, 0); } - if ( n_crc1 ) + if (n_crc1) { - crc1( cw_buf + data_offset, 2 * data_bytes - pc_split, epmr, cw_buf + data_offset - 2 * ( n_crc1 + n_crc2 ), n_crc1, - 0 ); + crc1(cw_buf + data_offset, 2 * data_bytes - pc_split, epmr, cw_buf + data_offset - 2 * (n_crc1 + n_crc2), n_crc1, + 0); } - data_offset -= 2 * ( n_crc1 + n_crc2 ); - - dw0_bitswap( cw_buf + data_offset, mode, slot_bytes ); + data_offset -= 2* (n_crc1 + n_crc2); + dw0_bitswap(cw_buf + data_offset, mode, slot_bytes); + + return data_offset; } -void fec_encoder( LC3_INT16 mode, LC3_INT16 epmr, LC3_UINT8 *iobuf, LC3_INT16 data_bytes, LC3_INT16 slot_bytes, LC3_INT16 n_pccw ) +void fec_encoder(LC3_INT16 mode, LC3_INT16 epmr, LC3_UINT8 *iobuf, LC3_INT16 data_bytes, LC3_INT16 slot_bytes, LC3_INT16 n_pccw) { - LC3_INT16 n_codewords, codeword_length, hd, redundancy_nibbles, cw_offset, dw_offset, pc_split; - LC3_INT32 i, j; + LC3_INT16 n_codewords, codeword_length, hd, redundancy_nibbles, cw_offset, dw_offset, pc_split; + LC3_INT32 i, j; LC3_UINT8 cw_buf[2 * FEC_SLOT_BYTES_MAX]; cw_offset = 0; dw_offset = 0; - pc_split = 0; + pc_split = 0; - n_codewords = get_n_codewords( slot_bytes ); + n_codewords = get_n_codewords(slot_bytes); /* some sanity checks */ { LC3_INT32 tmp = slot_bytes; - - assert( ( slot_bytes >= FEC_SLOT_BYTES_MIN && slot_bytes <= FEC_SLOT_BYTES_MAX ) && - "fec_encoder: slot_bytes out of range" ); - tmp -= mode == 1 ? 1 : n_codewords * ( mode - 1 ); // reed solomon redundancy + + assert((slot_bytes >= FEC_SLOT_BYTES_MIN && slot_bytes <= FEC_SLOT_BYTES_MAX) && + "fec_encoder: slot_bytes out of range"); + tmp -= mode == 1 ? 1 : n_codewords * (mode - 1); // reed solomon redundancy tmp -= slot_bytes == 40 ? crc1_bytes_by_mode0[mode] : crc1_bytes_by_mode1[mode]; // crc1 - tmp -= ( n_pccw > 0 ) && ( mode > 1 ) ? crc2_bytes_by_mode[mode] : 0; // crc2 - assert( data_bytes == tmp && "fec_encoder: inconsistent payload size" ); - assert( n_codewords - n_pccw >= 6 ); + tmp -= (n_pccw > 0) && (mode > 1) ? crc2_bytes_by_mode[mode] : 0; // crc2 + assert(data_bytes == tmp && "fec_encoder: inconsistent payload size"); + assert(n_codewords - n_pccw >= 6); } /* data preproc: re-ordering and hash extension */ - pc_split = fec_get_n_pc( mode, n_pccw, slot_bytes ); + pc_split = fec_get_n_pc(mode, n_pccw, slot_bytes); - dw_offset = fec_data_preproc( mode, epmr, iobuf, cw_buf, data_bytes, slot_bytes, pc_split ); + dw_offset = fec_data_preproc(mode, epmr, iobuf, cw_buf, data_bytes, slot_bytes, pc_split); /* encoding of first data word*/ - hd = hamming_distance_by_mode0[mode]; + hd = hamming_distance_by_mode0[mode]; redundancy_nibbles = hd - 1; - codeword_length = get_codeword_length( n_codewords, 2 * slot_bytes, 0 ); + codeword_length = get_codeword_length(n_codewords, 2 * slot_bytes, 0); - assert( codeword_length == ( 2 * slot_bytes - 1 ) / n_codewords + 1 ); + assert(codeword_length == (2 * slot_bytes - 1) / n_codewords + 1); - for ( j = redundancy_nibbles; j < codeword_length; ( j++, dw_offset++ ) ) + for (j = redundancy_nibbles; j < codeword_length; (j++, dw_offset++)) { cw_buf[j] = cw_buf[dw_offset]; } - rs16_enc( cw_buf, codeword_length, hd, mode, 1 ); + rs16_enc(cw_buf, codeword_length, hd, mode, 1); cw_offset += codeword_length; /* encoding of remaining data words */ - hd = hamming_distance_by_mode1[mode]; + hd = hamming_distance_by_mode1[mode]; redundancy_nibbles = hd - 1; - for ( i = 1; i < n_codewords; i++ ) + for (i = 1; i < n_codewords; i++) { - codeword_length = get_codeword_length( n_codewords, 2 * slot_bytes, i ); + codeword_length = get_codeword_length(n_codewords, 2*slot_bytes, i); - for ( j = redundancy_nibbles; j < codeword_length; ( j++, dw_offset++ ) ) + for (j = redundancy_nibbles; j < codeword_length; (j++, dw_offset++)) { cw_buf[cw_offset + j] = cw_buf[dw_offset]; } - rs16_enc( cw_buf + cw_offset, codeword_length, hd, mode, i < 6 ); + rs16_enc(cw_buf + cw_offset, codeword_length, hd, mode, i < 6); cw_offset += codeword_length; } - assert( cw_offset == 2 * slot_bytes && dw_offset == 2 * slot_bytes ); + assert(cw_offset == 2 * slot_bytes && dw_offset == 2 * slot_bytes); - fec_interleave_pack( iobuf, cw_buf, 2 * slot_bytes, n_codewords ); + fec_interleave_pack(iobuf, cw_buf, 2 * slot_bytes, n_codewords); + + } -FEC_STATIC void rs16_enc( LC3_UINT8 *iobuf, LC3_INT16 codeword_length, LC3_INT16 hamming_distance, LC3_INT16 fec_mode, LC3_INT16 signal_mode ) +FEC_STATIC void rs16_enc(LC3_UINT8 *iobuf, LC3_INT16 codeword_length, LC3_INT16 hamming_distance, LC3_INT16 fec_mode, + LC3_INT16 signal_mode) /* expects (data polynomial) * x^(hamming_distance - 1) in iobuf */ { - LC3_UINT8 const *gp; - LC3_UINT8 shift_buffer[RS16_CW_LEN_MAX + 1], lc; - LC3_INT32 i, j, deg_gp; + LC3_UINT8 const *gp; + LC3_UINT8 shift_buffer[RS16_CW_LEN_MAX + 1], lc; + LC3_INT32 i, j, deg_gp; - memset( shift_buffer, 0, sizeof( shift_buffer ) ); - gp = rs16_gp_by_hd[hamming_distance]; + memset(shift_buffer, 0, sizeof(shift_buffer)); + gp = rs16_gp_by_hd[hamming_distance]; deg_gp = hamming_distance - 1; - if ( hamming_distance > 1 ) + if (hamming_distance > 1) { - assert( codeword_length > deg_gp ); + assert(codeword_length > deg_gp); /* initialize redundancy part to zero */ - memset( iobuf, 0, deg_gp ); + memset(iobuf, 0, deg_gp); /* initialize shift_buffer */ - memmove( shift_buffer + 1, iobuf + codeword_length - deg_gp, deg_gp ); + memmove(shift_buffer + 1, iobuf + codeword_length - deg_gp, deg_gp); /* calculate remainder */ - for ( i = codeword_length - deg_gp - 1; i >= 0; i-- ) + for (i = codeword_length - deg_gp - 1; i >= 0; i--) { shift_buffer[0] = iobuf[i]; - lc = shift_buffer[deg_gp] << 4; + lc = shift_buffer[deg_gp] << 4; - for ( j = deg_gp - 1; j >= 0; j-- ) + for (j = deg_gp - 1; j >= 0; j--) { - shift_buffer[j + 1] = GF16_ADD( shift_buffer[j], GF16_MUL0( gp[j], lc ) ); + shift_buffer[j + 1] = GF16_ADD(shift_buffer[j], GF16_MUL0(gp[j], lc)); } } /* add remainder to shifted data polynomial */ - for ( i = 0; i < deg_gp; i++ ) + for (i = 0; i < deg_gp; i++) { iobuf[i] = shift_buffer[i + 1]; } /* add signaling polynomial */ - if ( signal_mode ) + if (signal_mode) { - assert( codeword_length > EP_SIG_POLY_DEG ); - for ( i = 0; i <= EP_SIG_POLY_DEG; i++ ) + assert(codeword_length > EP_SIG_POLY_DEG); + for (i = 0; i <= EP_SIG_POLY_DEG; i++) { - iobuf[i] = GF16_ADD( iobuf[i], sig_polys[fec_mode - 1][i] ); + iobuf[i] = GF16_ADD(iobuf[i], sig_polys[fec_mode - 1][i]); } } } + + } -FEC_STATIC void fec_interleave_pack( LC3_UINT8 *out, LC3_UINT8 *in, LC3_INT16 n_nibbles, LC3_INT16 n_codewords ) +FEC_STATIC void fec_interleave_pack(LC3_UINT8 *out, LC3_UINT8 *in, LC3_INT16 n_nibbles, LC3_INT16 n_codewords) { - LC3_INT16 out_offset, cw_offset, codeword_length; - LC3_INT32 i, j; + LC3_INT16 out_offset, cw_offset, codeword_length; + LC3_INT32 i, j; out_offset = 0; - cw_offset = 0; + cw_offset = 0; /* initialize output buffer to zero */ - memset( out, 0, n_nibbles >> 1 ); + memset(out, 0, n_nibbles >> 1); /* interleave and pack codewords */ - for ( i = 0; i < n_codewords; i++ ) + for (i = 0; i < n_codewords; i++) { - codeword_length = get_codeword_length( n_codewords, n_nibbles, i ); + codeword_length = get_codeword_length(n_codewords, n_nibbles, i); - for ( j = 0; j < codeword_length; j++ ) + for (j = 0; j < codeword_length; j++) { - out_offset = n_nibbles - 1 - j * n_codewords - i; - out[out_offset >> 1] |= in[cw_offset] << ( ( out_offset & 1 ) << 2 ); + out_offset = n_nibbles - 1 - j*n_codewords - i; + out[out_offset >> 1] |= in[cw_offset] << ((out_offset & 1) << 2); cw_offset = cw_offset + 1; } } - - assert( cw_offset == n_nibbles ); + + assert(cw_offset == n_nibbles); } /* Decoder */ -FEC_STATIC void fec_data_postproc( LC3_INT16 mode, LC3PLUS_EpModeRequest *epmr, LC3_UINT8 *obuf, LC3_INT16 data_bytes, LC3_UINT8 *cw_buf, LC3_INT16 slot_bytes, LC3_INT16 pc_split, LC3_INT32 *bfi ) +FEC_STATIC void fec_data_postproc(LC3_INT16 mode, LC3PLUS_EpModeRequest *epmr, LC3_UINT8 *obuf, LC3_INT16 data_bytes, LC3_UINT8 *cw_buf, + LC3_INT16 slot_bytes, LC3_INT16 pc_split, LC3_INT32 *bfi) { - LC3_INT16 i; - LC3_INT16 n_crc1, n_crc2; - LC3_INT16 cw_buf_len; - LC3PLUS_EpModeRequest tmp_epmr; + LC3_INT16 i; + LC3_INT16 n_crc1, n_crc2; + LC3_INT16 cw_buf_len; + LC3PLUS_EpModeRequest tmp_epmr; n_crc1 = crc1_bytes_by_mode1[mode]; - if ( slot_bytes == 40 ) + if (slot_bytes == 40) { n_crc1 = crc1_bytes_by_mode0[mode]; } n_crc2 = 0; - if ( pc_split > 0 ) + if (pc_split > 0) { n_crc2 = crc2_bytes_by_mode[mode]; } - assert( n_crc1 == ( slot_bytes == 40 ? crc1_bytes_by_mode0[mode] : crc1_bytes_by_mode1[mode] ) ); - assert( n_crc2 == ( ( pc_split > 0 ) && ( mode > 1 ) ? crc2_bytes_by_mode[mode] : 0 ) ); + assert(n_crc1 == (slot_bytes == 40 ? crc1_bytes_by_mode0[mode] : crc1_bytes_by_mode1[mode])); + assert(n_crc2 == ((pc_split > 0) && (mode > 1) ? crc2_bytes_by_mode[mode] : 0)); - cw_buf_len = 2 * ( data_bytes + n_crc1 + n_crc2 ); + cw_buf_len = 2 * (data_bytes + n_crc1 + n_crc2); - if ( ( mode - 1 ) ) + if ((mode - 1)) { /* reverse bit-swap */ - dw0_bitswap( cw_buf, mode, slot_bytes ); - tmp_epmr = dw0_get_epmr( cw_buf, mode, slot_bytes ); + dw0_bitswap(cw_buf, mode, slot_bytes); + tmp_epmr = dw0_get_epmr(cw_buf, mode, slot_bytes); - if ( crc1( cw_buf + ( ( n_crc1 + n_crc2 ) << 1 ), ( ( data_bytes << 1 ) - pc_split ), tmp_epmr, cw_buf, n_crc1, 1 ) ) + if (crc1(cw_buf + ((n_crc1 + n_crc2) << 1), ((data_bytes << 1) - pc_split), tmp_epmr, cw_buf, n_crc1, 1)) { *bfi = 1; - + return; } else @@ -1398,109 +679,112 @@ FEC_STATIC void fec_data_postproc( LC3_INT16 mode, LC3PLUS_EpModeRequest *epmr, } } - if ( pc_split > 0 && *bfi != 2 ) + if (pc_split > 0 && *bfi != 2) { - if ( crc2( cw_buf + ( ( ( data_bytes + ( n_crc1 + n_crc2 ) ) << 1 ) - pc_split ), pc_split, - cw_buf + ( n_crc1 << 1 ), n_crc2, 1 ) ) + if (crc2(cw_buf + (((data_bytes + (n_crc1 + n_crc2)) << 1) - pc_split), pc_split, + cw_buf + (n_crc1 << 1), n_crc2, 1)) { *bfi = 2; } } - for ( i = 0; i < data_bytes; i++ ) + for (i = 0; i < data_bytes; i++) { - obuf[i] = (LC3_UINT8) ( cw_buf[cw_buf_len - 2 * i - 1] | ( cw_buf[cw_buf_len - 2 * i - 2] << 4 ) ); + obuf[i] = (LC3_UINT8)(cw_buf[cw_buf_len - 2 * i - 1] | (cw_buf[cw_buf_len - 2 * i - 2] << 4)); } + + } -LC3_INT32 fec_decoder( LC3_UINT8 *iobuf, LC3_INT16 slot_bytes, LC3_INT32 *data_bytes, LC3PLUS_EpModeRequest *epmr, LC3_INT16 ccc_flag, LC3_INT16 *n_pccw, LC3_INT32 *bfi, LC3_INT16 *be_bp_left, LC3_INT16 *be_bp_right, LC3_INT16 *n_pc, LC3_INT16 *m_fec ) +LC3_INT32 fec_decoder(LC3_UINT8 *iobuf, LC3_INT16 slot_bytes, LC3_INT32 *data_bytes, LC3PLUS_EpModeRequest *epmr, LC3_INT16 ccc_flag, LC3_INT16 *n_pccw, + LC3_INT32 *bfi, LC3_INT16 *be_bp_left, LC3_INT16 *be_bp_right, LC3_INT16 *n_pc, LC3_INT16 *m_fec) { - LC3_UINT8 cw_buf[2 * FEC_SLOT_BYTES_MAX]; - LC3_UINT8 array_of_trust[MAX_LEN]; - LC3_INT16 i, j; - LC3_INT16 cw_offset, dw_offset; - LC3_INT16 n_codewords, redundancy_nibbles, codeword_length; - LC3_INT16 mode, error_report; - LC3_INT16 n_crc; - LC3_INT16 first_bad_cw; - LC3_INT16 pc_split; - - UNUSED( n_crc ); - - - if ( *bfi == 1 ) - { - + LC3_UINT8 cw_buf[2 * FEC_SLOT_BYTES_MAX]; + LC3_UINT8 array_of_trust[MAX_LEN]; + LC3_INT16 i, j; + LC3_INT16 cw_offset, dw_offset; + LC3_INT16 n_codewords, redundancy_nibbles, codeword_length; + LC3_INT16 mode, error_report; + LC3_INT16 n_crc; + LC3_INT16 first_bad_cw; + LC3_INT16 pc_split; + + UNUSED(n_crc); + + + if (*bfi == 1) + { + return ERROR_REPORT_BEC_MASK; } - if ( slot_bytes < FEC_SLOT_BYTES_MIN || slot_bytes > FEC_SLOT_BYTES_MAX ) + if (slot_bytes < FEC_SLOT_BYTES_MIN || slot_bytes > FEC_SLOT_BYTES_MAX) { *bfi = 1; - + return ERROR_REPORT_BEC_MASK; } - if ( ccc_flag == 0 ) + if (ccc_flag == 0) { *be_bp_left = -1; *be_bp_right = -1; } - n_codewords = get_n_codewords( slot_bytes ); + n_codewords = get_n_codewords(slot_bytes); /* extract and de-interleave nibbles */ - fec_deinterleave_unpack( cw_buf, iobuf, 2 * slot_bytes, n_codewords ); + fec_deinterleave_unpack(cw_buf, iobuf, 2 * slot_bytes, n_codewords); /* mode detection and error correction */ - mode = rs16_detect_and_correct( cw_buf, 2 * slot_bytes, n_codewords, epmr, &error_report, bfi, array_of_trust, - ccc_flag, n_pccw ); + mode = rs16_detect_and_correct(cw_buf, 2 * slot_bytes, n_codewords, epmr, &error_report, bfi, array_of_trust, + ccc_flag, n_pccw); /* for normal slots the maximal number of bit errors is limited */ #ifndef APPLY_MAX_ERRORS - if ( slot_bytes == 40 && mode > 0 ) + if (slot_bytes == 40 && mode > 0) { - if ( ( error_report & ERROR_REPORT_BEC_MASK ) > low_br_max_bit_errors_by_mode[mode] ) - { - error_report &= ERROR_REPORT_BEC_MASK; + if ((error_report & ERROR_REPORT_BEC_MASK) > low_br_max_bit_errors_by_mode[mode]) + { + error_report &= ERROR_REPORT_BEC_MASK; mode = -1; *bfi = 1; } else { - if ( ( error_report & ERROR_REPORT_BEC_MASK ) > low_br_max_bit_errors_by_mode[2] ) + if ((error_report & ERROR_REPORT_BEC_MASK) > low_br_max_bit_errors_by_mode[2]) { error_report &= ~ERROR_REPORT_EP2_OK; } - if ( ( error_report & ERROR_REPORT_BEC_MASK ) > low_br_max_bit_errors_by_mode[3] ) + if ((error_report & ERROR_REPORT_BEC_MASK) > low_br_max_bit_errors_by_mode[3]) { error_report &= ~ERROR_REPORT_EP3_OK; } } } #endif - - if ( *bfi == 1 ) + + if (*bfi == 1) { *data_bytes = 0; - + return error_report; } /* initialization for decoding */ - *data_bytes = fec_get_data_size( mode, ccc_flag, slot_bytes ); - pc_split = fec_get_n_pc( mode, *n_pccw, slot_bytes ); - n_crc = get_total_crc_size( slot_bytes, mode, pc_split ); + *data_bytes = fec_get_data_size(mode, ccc_flag, slot_bytes); + pc_split = fec_get_n_pc(mode, *n_pccw, slot_bytes); + n_crc = get_total_crc_size(slot_bytes, mode, pc_split); /* decoding of first code word */ redundancy_nibbles = hamming_distance_by_mode0[mode] - 1; - codeword_length = get_codeword_length( n_codewords, slot_bytes + slot_bytes, 0 ); + codeword_length = get_codeword_length(n_codewords, slot_bytes + slot_bytes, 0); dw_offset = 0; cw_offset = 0; - for ( j = redundancy_nibbles; j < codeword_length; j++ ) + for (j = redundancy_nibbles; j < codeword_length; j++) { cw_buf[dw_offset++] = cw_buf[j]; } @@ -1509,11 +793,11 @@ LC3_INT32 fec_decoder( LC3_UINT8 *iobuf, LC3_INT16 slot_bytes, LC3_INT32 *data_b /* decoding of remaining code words */ redundancy_nibbles = hamming_distance_by_mode1[mode] - 1; - for ( i = 1; i < n_codewords; i++ ) + for (i = 1; i < n_codewords; i++) { - codeword_length = get_codeword_length( n_codewords, slot_bytes + slot_bytes, i ); + codeword_length = get_codeword_length(n_codewords, slot_bytes + slot_bytes, i); - for ( j = redundancy_nibbles; j < codeword_length; j++ ) + for (j = redundancy_nibbles; j < codeword_length; j++) { cw_buf[dw_offset++] = cw_buf[j + cw_offset]; } @@ -1523,635 +807,638 @@ LC3_INT32 fec_decoder( LC3_UINT8 *iobuf, LC3_INT16 slot_bytes, LC3_INT32 *data_b /* data postproc: hash validation and re-ordering */ - fec_data_postproc( mode, epmr, iobuf, *data_bytes, cw_buf, slot_bytes, pc_split, bfi ); + fec_data_postproc(mode, epmr, iobuf, *data_bytes, cw_buf, slot_bytes, pc_split, bfi); - if ( *bfi == 1 ) + if (*bfi == 1) { *data_bytes = 0; error_report &= ERROR_REPORT_BEC_MASK; - + return error_report; } - if ( *bfi == 2 ) + if (*bfi == 2) { - first_bad_cw = 0; + first_bad_cw = 0; array_of_trust[*n_pccw] = 0; - while ( array_of_trust[first_bad_cw] != 0 ) + while (array_of_trust[first_bad_cw] != 0) { first_bad_cw = first_bad_cw + 1; } - if ( first_bad_cw == *n_pccw ) + if (first_bad_cw == *n_pccw) { /* this is the case when CRC failed */ *be_bp_left = 0; } else { - *be_bp_left = 4 * fec_get_n_pc( mode, first_bad_cw, slot_bytes ); + *be_bp_left = 4*fec_get_n_pc(mode, first_bad_cw, slot_bytes); } - for ( i = *n_pccw - 1; i >= 0; i-- ) + for (i = *n_pccw - 1; i >= 0; i--) { - if ( !array_of_trust[i] ) + if (!array_of_trust[i]) { break; } } - if ( i < 0 ) + if (i < 0) { i = *n_pccw - 1; } - *be_bp_right = 4 * fec_get_n_pc( mode, i + 1, slot_bytes ) - 1; + *be_bp_right = 4*fec_get_n_pc(mode, i + 1, slot_bytes) - 1; } - if ( ccc_flag == 0 ) + if (ccc_flag == 0) { - *n_pc = pc_split; + *n_pc = pc_split; *m_fec = mode; } - + return error_report; } -FEC_STATIC void fec_deinterleave_unpack( LC3_UINT8 *out, LC3_UINT8 *in, LC3_INT16 n_nibbles, LC3_INT16 n_codewords ) +FEC_STATIC void fec_deinterleave_unpack(LC3_UINT8 *out, LC3_UINT8 *in, LC3_INT16 n_nibbles, LC3_INT16 n_codewords) { - LC3_INT16 in_offset, out_offset, codeword_length; - LC3_INT32 i, j; + LC3_INT16 in_offset, out_offset, codeword_length; + LC3_INT32 i, j; - in_offset = 0; + in_offset = 0; out_offset = 0; /* unpack nibbles in input buffer and deinterleave codewords */ - for ( i = 0; i < n_codewords; i++ ) + for (i = 0; i < n_codewords; i++) { - codeword_length = get_codeword_length( n_codewords, n_nibbles, i ); - for ( j = 0; j < codeword_length; ( j++, out_offset++ ) ) + codeword_length = get_codeword_length(n_codewords, n_nibbles, i); + for (j = 0; j < codeword_length; (j++, out_offset++)) { - in_offset = n_nibbles - 1 - j * n_codewords - i; - out[out_offset] = ( in[in_offset >> 1] >> ( ( in_offset & 1 ) << 2 ) ) & 15; + in_offset = n_nibbles - 1 - j*n_codewords - i; + out[out_offset] = (in[in_offset >> 1] >> ((in_offset & 1) << 2)) & 15; } } + + assert(out_offset == n_nibbles); - assert( out_offset == n_nibbles ); } -FEC_STATIC LC3PLUS_EpModeRequest fec_estimate_epmr_from_cw0( LC3_UINT8 *cw0, LC3_INT8 *t, LC3_UINT8 *syndromes, LC3_UINT8 *elp, LC3_INT8 *deg_elp, LC3_UINT8 *err_pos, LC3_UINT8 *err_symb, LC3_INT16 n_codewords, LC3_INT16 n_symb ) +FEC_STATIC LC3PLUS_EpModeRequest fec_estimate_epmr_from_cw0(LC3_UINT8 *cw0, LC3_INT8 *t, LC3_UINT8 *syndromes, LC3_UINT8 *elp, LC3_INT8 *deg_elp, + LC3_UINT8 *err_pos, LC3_UINT8 *err_symb, LC3_INT16 n_codewords, LC3_INT16 n_symb) { - LC3_INT32 epmr_lowest_risk_exp; - LC3_INT32 start, inc, i, n_candidates; - LC3_INT32 first_codeword_length; - LC3_INT32 mode_counter; - LC3PLUS_EpModeRequest epmr; - - epmr_lowest_risk_exp = 0; - first_codeword_length = get_codeword_length( n_codewords, n_symb, 0 ); - start = 2; - inc = 1; - n_candidates = 0; + LC3_INT32 epmr_lowest_risk_exp; + LC3_INT32 start, inc, i, n_candidates; + LC3_INT32 first_codeword_length; + LC3_INT32 mode_counter; + LC3PLUS_EpModeRequest epmr; + + epmr_lowest_risk_exp = 0; + first_codeword_length = get_codeword_length(n_codewords, n_symb, 0); + start = 2; + inc = 1; + n_candidates = 0; /* test if first code word decodes in mode 0 or 1 without error correction */ - if ( ( syndromes[SYNDROME_IDX( 0, 0 )] | syndromes[SYNDROME_IDX( 0, 0 ) + 1] ) == 0 || - ( syndromes[SYNDROME_IDX( 1, 0 )] | syndromes[SYNDROME_IDX( 1, 0 ) + 1] ) == 0 ) + if ((syndromes[SYNDROME_IDX(0, 0)] | syndromes[SYNDROME_IDX(0, 0) + 1]) == 0 || + (syndromes[SYNDROME_IDX(1, 0)] | syndromes[SYNDROME_IDX(1, 0) + 1]) == 0) { epmr_lowest_risk_exp = risk_table_f[1][0].exponent; } /* test if first code word decodes in mode 2 or 3 with lower risk */ - if ( deg_elp[DEG_ELP_IDX( 2, 0 )] <= t[2] ) + if (deg_elp[DEG_ELP_IDX(2, 0)] <= t[2]) { - if ( risk_table_f[2][deg_elp[DEG_ELP_IDX( 2, 0 )]].exponent <= -8 ) + if (risk_table_f[2][deg_elp[DEG_ELP_IDX(2, 0)]].exponent <= -8) { n_candidates++; start = 2; } } - if ( deg_elp[DEG_ELP_IDX( 3, 0 )] <= t[3] ) + if (deg_elp[DEG_ELP_IDX(3, 0)] <= t[3]) { - if ( risk_table_f[3][deg_elp[DEG_ELP_IDX( 3, 0 )]].exponent <= -8 ) + if (risk_table_f[3][deg_elp[DEG_ELP_IDX(3, 0)]].exponent <= -8) { n_candidates++; start = 3; } } - if ( n_candidates > 1 ) + if (n_candidates > 1) { /* decide on order if mode 2 and 3 are considered */ - if ( simple_float_cmp( risk_table_f[2][deg_elp[DEG_ELP_IDX( 2, 0 )]], risk_table_f[3][deg_elp[DEG_ELP_IDX( 3, 0 )]] ) < - 0 ) + if (simple_float_cmp(risk_table_f[2][deg_elp[DEG_ELP_IDX(2, 0)]], risk_table_f[3][deg_elp[DEG_ELP_IDX(3, 0)]]) < + 0) { start = 2; - inc = 1; + inc = 1; } else { start = 3; - inc = -1; + inc = -1; } } - for ( mode_counter = start, i = 0; i < n_candidates; mode_counter += inc, i++ ) + for (mode_counter = start, i = 0; i < n_candidates; mode_counter += inc, i++) { - if ( risk_table_f[mode_counter][deg_elp[DEG_ELP_IDX( mode_counter, 0 )]].exponent < epmr_lowest_risk_exp ) + if (risk_table_f[mode_counter][deg_elp[DEG_ELP_IDX(mode_counter, 0)]].exponent < epmr_lowest_risk_exp) { - if ( !rs16_factorize_elp( err_pos + ERR_POS_IDX( mode_counter, 0 ), elp + ELP_IDX( mode_counter, 0 ), - deg_elp[DEG_ELP_IDX( mode_counter, 0 )], first_codeword_length - 1 ) ) + if (!rs16_factorize_elp(err_pos + ERR_POS_IDX(mode_counter, 0), elp + ELP_IDX(mode_counter, 0), + deg_elp[DEG_ELP_IDX(mode_counter, 0)], first_codeword_length - 1)) { /* code word is decodable with error correction */ - epmr_lowest_risk_exp = risk_table_f[mode_counter][deg_elp[DEG_ELP_IDX( mode_counter, 0 )]].exponent; + epmr_lowest_risk_exp = risk_table_f[mode_counter][deg_elp[DEG_ELP_IDX(mode_counter, 0)]].exponent; - rs16_calculate_errors( err_symb + ERR_SYMB_IDX( mode_counter, 0 ), err_pos + ERR_POS_IDX( mode_counter, 0 ), - syndromes + SYNDROME_IDX( mode_counter, 0 ), deg_elp[DEG_ELP_IDX( mode_counter, 0 )], - t[mode_counter] ); + rs16_calculate_errors(err_symb + ERR_SYMB_IDX(mode_counter, 0), err_pos + ERR_POS_IDX(mode_counter, 0), + syndromes + SYNDROME_IDX(mode_counter, 0), deg_elp[DEG_ELP_IDX(mode_counter, 0)], + t[mode_counter]); - for ( i = 0; i < deg_elp[DEG_ELP_IDX( mode_counter, 0 )]; i++ ) + for (i = 0; i < deg_elp[DEG_ELP_IDX(mode_counter, 0)]; i++) { - cw0[err_pos[ERR_POS_IDX( mode_counter, 0 ) + i]] = GF16_ADD( - cw0[err_pos[ERR_POS_IDX( mode_counter, 0 ) + i]], err_symb[ERR_SYMB_IDX( mode_counter, 0 ) + i] ); + cw0[err_pos[ERR_POS_IDX(mode_counter, 0) + i]] = GF16_ADD( + cw0[err_pos[ERR_POS_IDX(mode_counter, 0) + i]], err_symb[ERR_SYMB_IDX(mode_counter, 0) + i]); } break; } } } - epmr = cw0_get_epmr( cw0, first_codeword_length - 1 ); + epmr = cw0_get_epmr(cw0, first_codeword_length - 1); - if ( epmr_lowest_risk_exp > -16 ) + if (epmr_lowest_risk_exp > -16) { epmr += 4; } - if ( epmr_lowest_risk_exp > -8 ) + if (epmr_lowest_risk_exp > -8) { epmr += 4; } - + return epmr; } -FEC_STATIC LC3_INT32 rs16_detect_and_correct( LC3_UINT8 *iobuf, LC3_INT32 n_symb, LC3_INT32 n_codewords, LC3PLUS_EpModeRequest *epmr, LC3_INT16 *error_report, LC3_INT32 *bfi, LC3_UINT8 *array_of_trust, LC3_INT32 ccc_flag, LC3_INT16 *n_pccw ) +FEC_STATIC LC3_INT32 rs16_detect_and_correct(LC3_UINT8 *iobuf, LC3_INT32 n_symb, LC3_INT32 n_codewords, LC3PLUS_EpModeRequest *epmr, LC3_INT16 *error_report, + LC3_INT32 *bfi, LC3_UINT8 *array_of_trust, LC3_INT32 ccc_flag, LC3_INT16 *n_pccw) { - LC3_INT16 mode_broken[4]; - LC3_INT16 error_report_ep_ok[4]; - LC3_INT16 i, cw_counter, mode_counter, cw_offset; - LC3_INT16 codeword_length; - LC3_INT16 mode; - LC3_INT16 mode_candidates[4]; - LC3_INT16 n_mode_candidates; - LC3_INT16 broken_cw, n_broken_cw; - LC3_INT16 j, idx_min; - LC3_INT16 n_pccw0; - simple_float val_min_f; - LC3_INT16 tmp; - LC3_INT16 epmr_position; - simple_float dec_risk_f[FEC_N_MODES]; - simple_float risk_min_f; - simple_float ep_risk_thresh; - LC3_INT32 epmr_dec_fail_increment; - LC3_UINT8 const *hamming_distance; - LC3_UINT8 syndromes[FEC_TOTAL_SYNDROME_SIZE]; - LC3_UINT8 elp[FEC_TOTAL_ELP_SIZE]; - LC3_UINT8 err_pos[FEC_TOTAL_ERR_POS_SIZE]; - LC3_UINT8 err_symb[FEC_TOTAL_ERROR_SIZE]; - LC3_INT8 t[FEC_N_MODES]; - LC3_INT8 deg_elp[FEC_TOTAL_DEG_ELP_SIZE]; - LC3_UINT8 blacklist[FEC_N_MODES]; - LC3_INT32 rop; - - void ( *syndr_calc[3] )( LC3_UINT8 *, LC3_UINT8 *, LC3_INT32 ); + LC3_INT16 mode_broken[4]; + LC3_INT16 error_report_ep_ok[4]; + LC3_INT16 i, cw_counter, mode_counter, cw_offset; + LC3_INT16 codeword_length; + LC3_INT16 mode; + LC3_INT16 mode_candidates[4]; + LC3_INT16 n_mode_candidates; + LC3_INT16 broken_cw, n_broken_cw; + LC3_INT16 j, idx_min; + LC3_INT16 n_pccw0; + simple_float val_min_f; + LC3_INT16 tmp; + LC3_INT16 epmr_position; + simple_float dec_risk_f[FEC_N_MODES]; + simple_float risk_min_f; + simple_float ep_risk_thresh; + LC3_INT32 epmr_dec_fail_increment; + LC3_UINT8 const *hamming_distance; + LC3_UINT8 syndromes[FEC_TOTAL_SYNDROME_SIZE]; + LC3_UINT8 elp[FEC_TOTAL_ELP_SIZE]; + LC3_UINT8 err_pos[FEC_TOTAL_ERR_POS_SIZE]; + LC3_UINT8 err_symb[FEC_TOTAL_ERROR_SIZE]; + LC3_INT8 t[FEC_N_MODES]; + LC3_INT8 deg_elp[FEC_TOTAL_DEG_ELP_SIZE]; + LC3_UINT8 blacklist[FEC_N_MODES]; + LC3_INT32 rop; + + void (*syndr_calc[3])(LC3_UINT8 *, LC3_UINT8 *, LC3_INT32); rop = 0; /* initialization */ - blacklist[0] = 0; - blacklist[1] = 0; - blacklist[2] = 0; - blacklist[3] = 0; - mode_broken[0] = 0; - mode_broken[1] = 0; - mode_broken[2] = 0; - mode_broken[3] = 0; + blacklist[0] = 0; + blacklist[1] = 0; + blacklist[2] = 0; + blacklist[3] = 0; + mode_broken[0] = 0; + mode_broken[1] = 0; + mode_broken[2] = 0; + mode_broken[3] = 0; error_report_ep_ok[0] = ERROR_REPORT_EP1_OK; error_report_ep_ok[1] = ERROR_REPORT_EP2_OK; error_report_ep_ok[2] = ERROR_REPORT_EP3_OK; error_report_ep_ok[3] = ERROR_REPORT_EP4_OK; - hamming_distance = &hamming_distance_by_mode0[1]; - mode = -1; - n_mode_candidates = 0; + hamming_distance = &hamming_distance_by_mode0[1]; + mode = -1; + n_mode_candidates = 0; risk_min_f.mantissa = SIMPLE_FLOAT_1_MANTISSA; risk_min_f.exponent = 0; - - if ( n_symb <= 80 ) + + if (n_symb <= 80) { - ep_risk_thresh.mantissa = EP_RISK_THRESH_NS_M; - ep_risk_thresh.exponent = EP_RISK_THRESH_NS_E; + ep_risk_thresh.mantissa = EP_RISK_THRESH_NS_M; + ep_risk_thresh.exponent = EP_RISK_THRESH_NS_E; } else { - ep_risk_thresh.mantissa = EP_RISK_THRESH_OS_M; - ep_risk_thresh.exponent = EP_RISK_THRESH_OS_E; + ep_risk_thresh.mantissa = EP_RISK_THRESH_OS_M; + ep_risk_thresh.exponent = EP_RISK_THRESH_OS_E; } - + syndr_calc[0] = &rs16_calculate_two_syndromes; syndr_calc[1] = &rs16_calculate_four_syndromes; syndr_calc[2] = &rs16_calculate_six_syndromes; - - for ( i = 0; i < FEC_N_MODES; i++ ) + + for (i = 0; i < FEC_N_MODES; i++) { - t[i] = ( hamming_distance[i] - 1 ) / 2; + t[i] = (hamming_distance[i] -1)/2; } - + *error_report = 0; - *bfi = 0; - + *bfi = 0; + /* mode detection (stage 1) */ - codeword_length = get_codeword_length( n_codewords, n_symb, 0 ); - + codeword_length = get_codeword_length(n_codewords, n_symb, 0); + epmr_position = codeword_length - 1; - - rs16_calculate_two_syndromes( syndromes + SYNDROME_IDX( 0, 0 ), iobuf, codeword_length - 1 ); - - if ( ( syndromes[0 + SYNDROME_IDX( 0, 0 )] | syndromes[1 + SYNDROME_IDX( 0, 0 )] ) == 0 ) + + rs16_calculate_two_syndromes(syndromes + SYNDROME_IDX(0, 0), iobuf, codeword_length - 1); + + if ((syndromes[0 + SYNDROME_IDX(0, 0)] | syndromes[1 + SYNDROME_IDX(0, 0)]) == 0) + { + + /* data validation for fec mode 1 */ + *epmr = cw0_get_epmr(iobuf, epmr_position); + + dw0_bitswap(iobuf + 2, 1, n_symb / 2); + + if (!crc1(iobuf + 8, n_symb - 8, *epmr, iobuf + 2, 3, 1)) { - - /* data validation for fec mode 1 */ - *epmr = cw0_get_epmr( iobuf, epmr_position ); - - dw0_bitswap( iobuf + 2, 1, n_symb / 2 ); - - if ( !crc1( iobuf + 8, n_symb - 8, *epmr, iobuf + 2, 3, 1 ) ) - { *error_report |= ERROR_REPORT_ALL_OK; - mode = 0; - - - rop = mode + 1; - goto CLEANUP; - } - else - { - /* reverse bit swap */ - dw0_bitswap( iobuf + 2, 1, n_symb / 2 ); - - *epmr += 4; - } + mode = 0; + + + rop = mode + 1; + goto CLEANUP; } - + else + { + /* reverse bit swap */ + dw0_bitswap(iobuf + 2, 1, n_symb / 2); + + *epmr += 4; + } + } + blacklist[0] = 1; - + /* mode detection (stage 2) */ - + /* calculate syndromes of code words 0 to 5 and modes 1 to 3 */ cw_offset = 0; - - for ( cw_counter = 0; cw_counter < 6; cw_counter++ ) + + for (cw_counter = 0; cw_counter < 6; cw_counter++) + { + codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); + + rs16_calculate_six_syndromes(syndromes + SYNDROME_IDX(1, cw_counter), iobuf + cw_offset, + codeword_length - 1); + + cw_offset += codeword_length; + + for (mode_counter = FEC_N_MODES - 1; mode_counter >= 1; mode_counter--) { - codeword_length = get_codeword_length( n_codewords, n_symb, cw_counter ); - - rs16_calculate_six_syndromes( syndromes + SYNDROME_IDX( 1, cw_counter ), iobuf + cw_offset, - codeword_length - 1 ); - - cw_offset += codeword_length; - - for ( mode_counter = FEC_N_MODES - 1; mode_counter >= 1; mode_counter-- ) + for (i = 0; i < hamming_distance[mode_counter] - 1; i++) { - for ( i = 0; i < hamming_distance[mode_counter] - 1; i++ ) - { - syndromes[SYNDROME_IDX( mode_counter, cw_counter ) + i] = GF16_ADD( - syndromes[SYNDROME_IDX( 1, cw_counter ) + i], sig_poly_syndr[mode_counter][i] ); - } + syndromes[SYNDROME_IDX(mode_counter, cw_counter) + i] = GF16_ADD( + syndromes[SYNDROME_IDX(1, cw_counter) + i], sig_poly_syndr[mode_counter][i]); } } + } /* check for valid code words */ - for ( mode_counter = 1; mode_counter < FEC_N_MODES; mode_counter++ ) + for (mode_counter = 1; mode_counter < FEC_N_MODES; mode_counter++) { - n_broken_cw = 0; - for ( cw_counter = 0; cw_counter < 6; cw_counter++ ) + n_broken_cw = 0; + for (cw_counter = 0; cw_counter < 6; cw_counter++) + { + broken_cw = 0; + for (i = 0; i < hamming_distance[mode_counter] - 1; i++) { - broken_cw = 0; - for ( i = 0; i < hamming_distance[mode_counter] - 1; i++ ) - { - broken_cw |= syndromes[SYNDROME_IDX( mode_counter, cw_counter ) + i]; - } - if ( broken_cw != 0 ) - { - n_broken_cw++; - } + broken_cw |= syndromes[SYNDROME_IDX(mode_counter, cw_counter) + i]; } - - if ( n_broken_cw == 0 ) + if (broken_cw != 0) { - mode = mode_counter; - cw_offset = 0; - - *epmr = cw0_get_epmr( iobuf, epmr_position ); - - for ( cw_counter = 0; cw_counter < 6; cw_counter++ ) - { - codeword_length = get_codeword_length( n_codewords, n_symb, cw_counter ); - for ( i = 0; i <= EP_SIG_POLY_DEG; i++ ) - { - iobuf[cw_offset + i] = GF16_ADD( iobuf[cw_offset + i], sig_polys[mode][i] ); - } - cw_offset += codeword_length; - } + n_broken_cw ++; } } - - if ( mode < 0 ) /* mode hasn't been detected so far -> errors occurred in transmission */ + + if (n_broken_cw == 0) { - /* calculate error locator polynomials for code words 0 to 5 */ - for ( mode_counter = 1; mode_counter < FEC_N_MODES; mode_counter++ ) + mode = mode_counter; + cw_offset = 0; + + *epmr = cw0_get_epmr(iobuf, epmr_position); + + for (cw_counter = 0; cw_counter < 6; cw_counter++) { - for ( cw_counter = 0; cw_counter < 6; cw_counter++ ) - { - deg_elp[DEG_ELP_IDX( mode_counter, cw_counter )] = rs16_calculate_elp( - elp + ELP_IDX( mode_counter, cw_counter ), syndromes + SYNDROME_IDX( mode_counter, cw_counter ), - t[mode_counter] ); - if ( deg_elp[DEG_ELP_IDX( mode_counter, cw_counter )] > t[mode_counter] ) - { - blacklist[mode_counter] = 1; - break; - } - } + codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); + for (i = 0; i <= EP_SIG_POLY_DEG; i++) + { + iobuf[cw_offset + i] = GF16_ADD(iobuf[cw_offset + i], sig_polys[mode][i]); } - - /* risk analysis for mode candidate selection */ - for ( mode_counter = 1; mode_counter < FEC_N_MODES; mode_counter++ ) + cw_offset += codeword_length; + } + } + } + + if (mode < 0) /* mode hasn't been detected so far -> errors occurred in transmission */ + { + /* calculate error locator polynomials for code words 0 to 5 */ + for (mode_counter = 1; mode_counter < FEC_N_MODES; mode_counter++) + { + for (cw_counter = 0; cw_counter < 6; cw_counter++) { - dec_risk_f[mode_counter].mantissa = SIMPLE_FLOAT_1_MANTISSA; - dec_risk_f[mode_counter].exponent = 0; - - if ( blacklist[mode_counter] == 0 ) - { - for ( cw_counter = 0; cw_counter < 6; cw_counter++ ) - { - dec_risk_f[mode_counter] = simple_float_mul( - dec_risk_f[mode_counter], - risk_table_f[mode_counter][deg_elp[DEG_ELP_IDX( mode_counter, cw_counter )]] ); - } - - if ( simple_float_cmp( dec_risk_f[mode_counter], ep_risk_thresh ) <= 0 ) - { - mode_candidates[n_mode_candidates++] = mode_counter; - } - - if ( simple_float_cmp( dec_risk_f[mode_counter], risk_min_f ) < 0 ) - { - risk_min_f = dec_risk_f[mode_counter]; - } - } + deg_elp[DEG_ELP_IDX(mode_counter, cw_counter)] = rs16_calculate_elp( + elp + ELP_IDX(mode_counter, cw_counter), syndromes + SYNDROME_IDX(mode_counter, cw_counter), + t[mode_counter]); + if (deg_elp[DEG_ELP_IDX(mode_counter, cw_counter)] > t[mode_counter]) + { + blacklist[mode_counter] = 1; + break; } - assert( n_mode_candidates <= 4 ); // suppress false gcc warning when OPTIM=3 - - /* sort mode candidates by risk */ - for ( i = 0; i < n_mode_candidates; i++ ) + } + } + + /* risk analysis for mode candidate selection */ + for (mode_counter = 1; mode_counter < FEC_N_MODES; mode_counter++) + { + dec_risk_f[mode_counter].mantissa = SIMPLE_FLOAT_1_MANTISSA; + dec_risk_f[mode_counter].exponent = 0; + + if (blacklist[mode_counter] == 0) { - idx_min = i; - val_min_f = dec_risk_f[mode_candidates[i]]; - - for ( j = i + 1; j < n_mode_candidates; j++ ) - { - if ( simple_float_cmp( dec_risk_f[mode_candidates[j]], val_min_f ) < 0 ) - { - val_min_f = dec_risk_f[mode_candidates[j]]; - idx_min = j; - } - } - - if ( idx_min > i ) - { - tmp = mode_candidates[i]; - mode_candidates[i] = mode_candidates[idx_min]; - mode_candidates[idx_min] = tmp; - } + for (cw_counter = 0; cw_counter < 6; cw_counter++) + { + dec_risk_f[mode_counter] = simple_float_mul( + dec_risk_f[mode_counter], + risk_table_f[mode_counter][deg_elp[DEG_ELP_IDX(mode_counter, cw_counter)]]); } - - /* try out candidate modes */ - for ( i = 0; i < n_mode_candidates; i++ ) + + if (simple_float_cmp(dec_risk_f[mode_counter], ep_risk_thresh) <= 0) { - mode = mode_candidates[i]; - - for ( cw_counter = 0; cw_counter < 6; cw_counter++ ) - { - codeword_length = get_codeword_length( n_codewords, n_symb, cw_counter ); - - if ( deg_elp[DEG_ELP_IDX( mode, cw_counter )] ) - { - if ( rs16_factorize_elp( err_pos + ERR_POS_IDX( mode, cw_counter ), elp + ELP_IDX( mode, cw_counter ), - deg_elp[DEG_ELP_IDX( mode, cw_counter )], codeword_length - 1 ) ) - { - /* elp did not split into distinct linear factors or error position was out of range */ - mode = -1; - break; - } - } - } - if ( mode > 0 ) + mode_candidates[n_mode_candidates++] = mode_counter; + } + + if (simple_float_cmp(dec_risk_f[mode_counter], risk_min_f) < 0) + { + risk_min_f = dec_risk_f[mode_counter]; + } + } + } + assert(n_mode_candidates <= 4); // suppress false gcc warning when OPTIM=3 + + /* sort mode candidates by risk */ + for (i = 0; i < n_mode_candidates; i++) + { + idx_min = i; + val_min_f = dec_risk_f[mode_candidates[i]]; + + for (j = i + 1; j < n_mode_candidates; j++) + { + if (simple_float_cmp(dec_risk_f[mode_candidates[j]], val_min_f) < 0) + { + val_min_f = dec_risk_f[mode_candidates[j]]; + idx_min = j; + } + } + + if (idx_min > i) + { + tmp = mode_candidates[i]; + mode_candidates[i] = mode_candidates[idx_min]; + mode_candidates[idx_min] = tmp; + } + } + + /* try out candidate modes */ + for (i = 0; i < n_mode_candidates; i++) + { + mode = mode_candidates[i]; + + for (cw_counter = 0; cw_counter < 6; cw_counter++) + { + codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); + + if (deg_elp[DEG_ELP_IDX(mode, cw_counter)]) + { + if (rs16_factorize_elp(err_pos + ERR_POS_IDX(mode, cw_counter), elp + ELP_IDX(mode, cw_counter), + deg_elp[DEG_ELP_IDX(mode, cw_counter)], codeword_length - 1)) { - /* decodable mode with lowest risk has been found */ - break; + /* elp did not split into distinct linear factors or error position was out of range */ + mode = -1; + break; } } - - if ( mode < 0 ) + } + if (mode > 0) { - /* no decodable mode has been found */ - *error_report = ERROR_REPORT_BEC_MASK; - *bfi = 1; - mode = -1; - - *epmr = fec_estimate_epmr_from_cw0( iobuf, t, syndromes, elp, deg_elp, err_pos, err_symb, n_codewords, - n_symb ); - - - rop = mode; - goto CLEANUP; + /* decodable mode with lowest risk has been found */ + break; } - - /* perform error correction */ - cw_offset = 0; - *error_report = 0; - for ( cw_counter = 0; cw_counter < 6; cw_counter++ ) + } + + if (mode < 0) + { + /* no decodable mode has been found */ + *error_report = ERROR_REPORT_BEC_MASK; + *bfi = 1; + mode = -1; + + *epmr = fec_estimate_epmr_from_cw0(iobuf, t, syndromes, elp, deg_elp, err_pos, err_symb, n_codewords, + n_symb); + + + rop = mode; + goto CLEANUP; + } + + /* perform error correction */ + cw_offset = 0; + *error_report = 0; + for (cw_counter = 0; cw_counter < 6; cw_counter++) + { + codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); + + if (deg_elp[DEG_ELP_IDX(mode, cw_counter)]) { - codeword_length = get_codeword_length( n_codewords, n_symb, cw_counter ); - - if ( deg_elp[DEG_ELP_IDX( mode, cw_counter )] ) - { - rs16_calculate_errors( - err_symb + ERR_SYMB_IDX( mode, cw_counter ), err_pos + ERR_POS_IDX( mode, cw_counter ), - syndromes + SYNDROME_IDX( mode, cw_counter ), deg_elp[DEG_ELP_IDX( mode, cw_counter )], t[mode] ); - - /* correct errors and sum up number of corrected bits */ - for ( i = 0; i < deg_elp[DEG_ELP_IDX( mode, cw_counter )]; i++ ) - { - iobuf[err_pos[ERR_POS_IDX( mode, cw_counter ) + i] + cw_offset] = - GF16_ADD( iobuf[err_pos[ERR_POS_IDX( mode, cw_counter ) + i] + cw_offset], - err_symb[ERR_SYMB_IDX( mode, cw_counter ) + i] ); - *error_report += rs16_bit_count_table[err_symb[ERR_SYMB_IDX( mode, cw_counter ) + i]]; - } + rs16_calculate_errors( + err_symb + ERR_SYMB_IDX(mode, cw_counter), err_pos + ERR_POS_IDX(mode, cw_counter), + syndromes + SYNDROME_IDX(mode, cw_counter), deg_elp[DEG_ELP_IDX(mode, cw_counter)], t[mode]); + + /* correct errors and sum up number of corrected bits */ + for (i = 0; i < deg_elp[DEG_ELP_IDX(mode, cw_counter)]; i++) + { + iobuf[err_pos[ERR_POS_IDX(mode, cw_counter) + i] + cw_offset] = + GF16_ADD(iobuf[err_pos[ERR_POS_IDX(mode, cw_counter) + i] + cw_offset], + err_symb[ERR_SYMB_IDX(mode, cw_counter) + i]); + *error_report += rs16_bit_count_table[err_symb[ERR_SYMB_IDX(mode, cw_counter) + i]]; + } - for ( i = 0; i < mode; i++ ) + for (i = 0; i < mode; i ++) { - if ( deg_elp[DEG_ELP_IDX( mode, cw_counter )] > i ) + if(deg_elp[DEG_ELP_IDX(mode, cw_counter)] > i) { mode_broken[i] = 1; } } - } - - for ( i = 0; i <= EP_SIG_POLY_DEG; i++ ) - { - iobuf[cw_offset + i] = GF16_ADD( iobuf[cw_offset + i], sig_polys[mode][i] ); - } - cw_offset += codeword_length; - } - - /* set epmr according to risk value of cw0 */ - epmr_dec_fail_increment = 8; - if ( risk_table_f[mode][deg_elp[DEG_ELP_IDX( mode, 0 )]].exponent <= -8 ) - { - epmr_dec_fail_increment -= 4; } - if ( risk_table_f[mode][deg_elp[DEG_ELP_IDX( mode, 0 )]].exponent <= -16 ) + + for (i = 0; i <= EP_SIG_POLY_DEG; i++) { - epmr_dec_fail_increment -= 4; + iobuf[cw_offset + i] = GF16_ADD(iobuf[cw_offset + i], sig_polys[mode][i]); } - - *epmr = (LC3PLUS_EpModeRequest) ( cw0_get_epmr( iobuf, epmr_position ) + epmr_dec_fail_increment ); + cw_offset += codeword_length; } - + + /* set epmr according to risk value of cw0 */ + epmr_dec_fail_increment = 8; + + if (risk_table_f[mode][deg_elp[DEG_ELP_IDX(mode, 0)]].exponent <= -8) + { + epmr_dec_fail_increment -= 4; + } + if (risk_table_f[mode][deg_elp[DEG_ELP_IDX(mode, 0)]].exponent <= -16) + { + epmr_dec_fail_increment -= 4; + } + + *epmr = (LC3PLUS_EpModeRequest)(cw0_get_epmr(iobuf, epmr_position) + epmr_dec_fail_increment); + } + /* mode has been successfully detected -> now check and try to correct remaining code words*/ - *n_pccw = fec_get_n_pccw( n_symb / 2, mode + 1, ccc_flag ); - if ( ccc_flag == 0 ) + *n_pccw = fec_get_n_pccw(n_symb / 2, mode + 1, ccc_flag); + if (ccc_flag == 0) { - n_pccw0 = fec_get_n_pccw( n_symb / 2, mode + 1, ccc_flag ); - *n_pccw = n_pccw0; + n_pccw0 = fec_get_n_pccw(n_symb / 2, mode + 1, ccc_flag); + *n_pccw = n_pccw0; } else { - n_pccw0 = 0; + n_pccw0 = 0; } - - for ( cw_counter = 6; cw_counter < n_codewords; cw_counter++ ) + + for (cw_counter = 6; cw_counter < n_codewords; cw_counter++) { - /* usual error correction scheme: syndromes -> elp's, errors, etc. */ - codeword_length = get_codeword_length( n_codewords, n_symb, cw_counter ); - array_of_trust[n_codewords - 1 - cw_counter] = 1; - - syndr_calc[t[mode] - 1]( syndromes, iobuf + cw_offset, codeword_length - 1 ); - - deg_elp[0] = rs16_calculate_elp( elp, syndromes, t[mode] ); - - for ( i = 0; i < mode; i++ ) + /* usual error correction scheme: syndromes -> elp's, errors, etc. */ + codeword_length = get_codeword_length(n_codewords, n_symb, cw_counter); + array_of_trust[n_codewords - 1 - cw_counter] = 1; + + syndr_calc[t[mode] - 1](syndromes, iobuf + cw_offset, codeword_length -1); + + deg_elp[0] = rs16_calculate_elp(elp, syndromes, t[mode]); + + for (i = 0; i < mode; i ++) { - if ( deg_elp[0] > i ) + if (deg_elp[0] > i) { mode_broken[i] = 1; } } - if ( deg_elp[0] > t[mode] ) - { - for ( i = 0; i < 4; i++ ) + if (deg_elp[0] > t[mode]) + { + for (i = 0; i < 4; i ++) { mode_broken[i] = 1; } + cw_offset += codeword_length; + if (cw_counter < n_codewords - n_pccw0) + { + *error_report = ERROR_REPORT_BEC_MASK; + mode = -1; + *bfi = 1; + break; + } + else + { + *bfi = 2; + array_of_trust[n_codewords - 1 - cw_counter] = 0; + continue; + } + } + + if (deg_elp[0]) + { + if (rs16_factorize_elp(err_pos, elp, deg_elp[0], codeword_length - 1)) + { cw_offset += codeword_length; - if ( cw_counter < n_codewords - n_pccw0 ) + for (i = 0; i < 4; i ++) + { + mode_broken[i] = 1; + } + if (cw_counter < n_codewords - n_pccw0) { *error_report = ERROR_REPORT_BEC_MASK; mode = -1; *bfi = 1; + break; } else { - *bfi = 2; + *bfi = 2; array_of_trust[n_codewords - 1 - cw_counter] = 0; continue; } } - - if ( deg_elp[0] ) + + rs16_calculate_errors(err_symb, err_pos, syndromes, deg_elp[0], t[mode]); + + /* correct errors and sum up number of corrected bits */ + for (i = 0; i < deg_elp[0]; i++) { - if ( rs16_factorize_elp( err_pos, elp, deg_elp[0], codeword_length - 1 ) ) - { - cw_offset += codeword_length; - for ( i = 0; i < 4; i++ ) - { - mode_broken[i] = 1; - } - if ( cw_counter < n_codewords - n_pccw0 ) - { - *error_report = ERROR_REPORT_BEC_MASK; - mode = -1; - *bfi = 1; - - break; - } - else - { - *bfi = 2; - array_of_trust[n_codewords - 1 - cw_counter] = 0; - continue; - } - } - - rs16_calculate_errors( err_symb, err_pos, syndromes, deg_elp[0], t[mode] ); - - /* correct errors and sum up number of corrected bits */ - for ( i = 0; i < deg_elp[0]; i++ ) - { - iobuf[err_pos[i] + cw_offset] = GF16_ADD( iobuf[err_pos[i] + cw_offset], err_symb[i] ); - *error_report += rs16_bit_count_table[err_symb[i]]; - } - } - cw_offset += codeword_length; - if ( risk_table_f[mode][deg_elp[0]].exponent > -16 ) - { - array_of_trust[n_codewords - 1 - cw_counter] = 0; + iobuf[err_pos[i] + cw_offset] = GF16_ADD(iobuf[err_pos[i] + cw_offset], err_symb[i]); + *error_report += rs16_bit_count_table[err_symb[i]]; } } - + cw_offset += codeword_length; + if (risk_table_f[mode][deg_elp[0]].exponent > -16) + { + array_of_trust[n_codewords - 1 - cw_counter] = 0; + } + } + *error_report &= ERROR_REPORT_BEC_MASK; - for ( i = 0; i < 4; i++ ) + for (i = 0; i < 4; i ++) { - if ( !mode_broken[i] ) + if (!mode_broken[i]) { *error_report |= error_report_ep_ok[i]; } } - if ( mode >= 0 ) + if (mode >= 0) { rop = mode + 1; - } - else - { + } else { rop = -1; } - + + CLEANUP: return rop; } -FEC_STATIC void rs16_calculate_six_syndromes( LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg ) +FEC_STATIC void rs16_calculate_six_syndromes(LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg) { - LC3_INT32 i; - LC3_UINT8 buffer[15]; + LC3_INT32 i; + LC3_UINT8 buffer[15]; - assert( cw_poly_deg >= 12 ); + assert(cw_poly_deg >= 12); - for ( i = 0; i <= cw_poly_deg; i++ ) + for (i = 0; i <= cw_poly_deg; i++) { buffer[i] = cw[i]; } @@ -2163,119 +1450,121 @@ FEC_STATIC void rs16_calculate_six_syndromes( LC3_UINT8 *syndromes, LC3_UINT8 *c syndromes[4] = buffer[0]; syndromes[5] = buffer[0]; - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[1], 32 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[1], 64 ) ); - syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[1], 128 ) ); - syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[1], 48 ) ); - syndromes[4] = GF16_ADD( syndromes[4], GF16_MUL0( buffer[1], 96 ) ); - syndromes[5] = GF16_ADD( syndromes[5], GF16_MUL0( buffer[1], 192 ) ); - - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[2], 64 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[2], 48 ) ); - syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[2], 192 ) ); - syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[2], 80 ) ); - syndromes[4] = GF16_ADD( syndromes[4], GF16_MUL0( buffer[2], 112 ) ); - syndromes[5] = GF16_ADD( syndromes[5], GF16_MUL0( buffer[2], 240 ) ); - - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[3], 128 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[3], 192 ) ); - syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[3], 160 ) ); - syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[3], 240 ) ); - syndromes[4] = GF16_ADD( syndromes[4], GF16_MUL0( buffer[3], 16 ) ); - syndromes[5] = GF16_ADD( syndromes[5], GF16_MUL0( buffer[3], 128 ) ); - - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[4], 48 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[4], 80 ) ); - syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[4], 240 ) ); - syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[4], 32 ) ); - syndromes[4] = GF16_ADD( syndromes[4], GF16_MUL0( buffer[4], 96 ) ); - syndromes[5] = GF16_ADD( syndromes[5], GF16_MUL0( buffer[4], 160 ) ); - - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[5], 96 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[5], 112 ) ); - syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[5], 16 ) ); - syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[5], 96 ) ); - syndromes[4] = GF16_ADD( syndromes[4], GF16_MUL0( buffer[5], 112 ) ); - syndromes[5] = GF16_ADD( syndromes[5], GF16_MUL0( buffer[5], 16 ) ); - - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[6], 192 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[6], 240 ) ); - syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[6], 128 ) ); - syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[6], 160 ) ); - syndromes[4] = GF16_ADD( syndromes[4], GF16_MUL0( buffer[6], 16 ) ); - syndromes[5] = GF16_ADD( syndromes[5], GF16_MUL0( buffer[6], 192 ) ); - - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[7], 176 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[7], 144 ) ); - syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[7], 192 ) ); - syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[7], 208 ) ); - syndromes[4] = GF16_ADD( syndromes[4], GF16_MUL0( buffer[7], 96 ) ); - syndromes[5] = GF16_ADD( syndromes[5], GF16_MUL0( buffer[7], 240 ) ); - - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[8], 80 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[8], 32 ) ); - syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[8], 160 ) ); - syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[8], 64 ) ); - syndromes[4] = GF16_ADD( syndromes[4], GF16_MUL0( buffer[8], 112 ) ); - syndromes[5] = GF16_ADD( syndromes[5], GF16_MUL0( buffer[8], 128 ) ); - - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[9], 160 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[9], 128 ) ); - syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[9], 240 ) ); - syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[9], 192 ) ); - syndromes[4] = GF16_ADD( syndromes[4], GF16_MUL0( buffer[9], 16 ) ); - syndromes[5] = GF16_ADD( syndromes[5], GF16_MUL0( buffer[9], 160 ) ); - - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[10], 112 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[10], 96 ) ); - syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[10], 16 ) ); - syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[10], 112 ) ); - syndromes[4] = GF16_ADD( syndromes[4], GF16_MUL0( buffer[10], 96 ) ); - syndromes[5] = GF16_ADD( syndromes[5], GF16_MUL0( buffer[10], 16 ) ); - - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[11], 224 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[11], 176 ) ); - syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[11], 128 ) ); - syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[11], 144 ) ); - syndromes[4] = GF16_ADD( syndromes[4], GF16_MUL0( buffer[11], 112 ) ); - syndromes[5] = GF16_ADD( syndromes[5], GF16_MUL0( buffer[11], 192 ) ); - - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[12], 240 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[12], 160 ) ); - syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[12], 192 ) ); - syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[12], 128 ) ); - syndromes[4] = GF16_ADD( syndromes[4], GF16_MUL0( buffer[12], 16 ) ); - syndromes[5] = GF16_ADD( syndromes[5], GF16_MUL0( buffer[12], 240 ) ); - - if ( cw_poly_deg >= 13 ) - { - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[13], 208 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[13], 224 ) ); - syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[13], 160 ) ); - syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[13], 176 ) ); - syndromes[4] = GF16_ADD( syndromes[4], GF16_MUL0( buffer[13], 96 ) ); - syndromes[5] = GF16_ADD( syndromes[5], GF16_MUL0( buffer[13], 128 ) ); - } - - if ( cw_poly_deg >= 14 ) - { - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[14], 144 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[14], 208 ) ); - syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[14], 240 ) ); - syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[14], 224 ) ); - syndromes[4] = GF16_ADD( syndromes[4], GF16_MUL0( buffer[14], 112 ) ); - syndromes[5] = GF16_ADD( syndromes[5], GF16_MUL0( buffer[14], 160 ) ); - } + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[1], 32)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[1], 64)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[1], 128)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[1], 48)); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[1], 96)); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[1], 192)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[2], 64)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[2], 48)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[2], 192)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[2], 80)); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[2], 112)); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[2], 240)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[3], 128)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[3], 192)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[3], 160)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[3], 240)); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[3], 16)); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[3], 128)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[4], 48)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[4], 80)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[4], 240)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[4], 32)); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[4], 96)); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[4], 160)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[5], 96)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[5], 112)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[5], 16)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[5], 96)); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[5], 112)); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[5], 16)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[6], 192)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[6], 240)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[6], 128)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[6], 160)); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[6], 16)); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[6], 192)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[7], 176)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[7], 144)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[7], 192)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[7], 208)); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[7], 96)); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[7], 240)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[8], 80)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[8], 32)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[8], 160)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[8], 64)); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[8], 112)); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[8], 128)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[9], 160)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[9], 128)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[9], 240)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[9], 192)); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[9], 16)); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[9], 160)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[10], 112)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[10], 96)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[10], 16)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[10], 112)); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[10], 96)); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[10], 16)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[11], 224)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[11], 176)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[11], 128)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[11], 144)); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[11], 112)); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[11], 192)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[12], 240)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[12], 160)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[12], 192)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[12], 128)); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[12], 16)); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[12], 240)); + + if (cw_poly_deg >= 13) + { + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[13], 208)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[13], 224)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[13], 160)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[13], 176)); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[13], 96)); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[13], 128)); + } + + if (cw_poly_deg >= 14) + { + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[14], 144)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[14], 208)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[14], 240)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[14], 224)); + syndromes[4] = GF16_ADD(syndromes[4], GF16_MUL0(buffer[14], 112)); + syndromes[5] = GF16_ADD(syndromes[5], GF16_MUL0(buffer[14], 160)); + } + + } -FEC_STATIC void rs16_calculate_four_syndromes( LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg ) +FEC_STATIC void rs16_calculate_four_syndromes(LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg) { - LC3_INT32 i; - LC3_UINT8 buffer[15]; + LC3_INT32 i; + LC3_UINT8 buffer[15]; - assert( cw_poly_deg >= 12 ); + assert(cw_poly_deg >= 12); - for ( i = 0; i <= cw_poly_deg; i++ ) + for (i = 0; i <= cw_poly_deg; i++) { buffer[i] = cw[i]; } @@ -2285,91 +1574,93 @@ FEC_STATIC void rs16_calculate_four_syndromes( LC3_UINT8 *syndromes, LC3_UINT8 * syndromes[2] = buffer[0]; syndromes[3] = buffer[0]; - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[1], 32 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[1], 64 ) ); - syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[1], 128 ) ); - syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[1], 48 ) ); - - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[2], 64 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[2], 48 ) ); - syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[2], 192 ) ); - syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[2], 80 ) ); - - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[3], 128 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[3], 192 ) ); - syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[3], 160 ) ); - syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[3], 240 ) ); - - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[4], 48 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[4], 80 ) ); - syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[4], 240 ) ); - syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[4], 32 ) ); - - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[5], 96 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[5], 112 ) ); - syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[5], 16 ) ); - syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[5], 96 ) ); - - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[6], 192 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[6], 240 ) ); - syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[6], 128 ) ); - syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[6], 160 ) ); - - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[7], 176 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[7], 144 ) ); - syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[7], 192 ) ); - syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[7], 208 ) ); - - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[8], 80 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[8], 32 ) ); - syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[8], 160 ) ); - syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[8], 64 ) ); - - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[9], 160 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[9], 128 ) ); - syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[9], 240 ) ); - syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[9], 192 ) ); - - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[10], 112 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[10], 96 ) ); - syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[10], 16 ) ); - syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[10], 112 ) ); - - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[11], 224 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[11], 176 ) ); - syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[11], 128 ) ); - syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[11], 144 ) ); - - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[12], 240 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[12], 160 ) ); - syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[12], 192 ) ); - syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[12], 128 ) ); - - if ( cw_poly_deg >= 13 ) - { - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[13], 208 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[13], 224 ) ); - syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[13], 160 ) ); - syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[13], 176 ) ); - } - - if ( cw_poly_deg >= 14 ) - { - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[14], 144 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[14], 208 ) ); - syndromes[2] = GF16_ADD( syndromes[2], GF16_MUL0( buffer[14], 240 ) ); - syndromes[3] = GF16_ADD( syndromes[3], GF16_MUL0( buffer[14], 224 ) ); + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[1], 32)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[1], 64)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[1], 128)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[1], 48)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[2], 64)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[2], 48)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[2], 192)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[2], 80)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[3], 128)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[3], 192)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[3], 160)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[3], 240)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[4], 48)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[4], 80)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[4], 240)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[4], 32)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[5], 96)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[5], 112)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[5], 16)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[5], 96)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[6], 192)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[6], 240)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[6], 128)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[6], 160)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[7], 176)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[7], 144)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[7], 192)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[7], 208)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[8], 80)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[8], 32)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[8], 160)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[8], 64)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[9], 160)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[9], 128)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[9], 240)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[9], 192)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[10], 112)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[10], 96)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[10], 16)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[10], 112)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[11], 224)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[11], 176)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[11], 128)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[11], 144)); + + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[12], 240)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[12], 160)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[12], 192)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[12], 128)); + + if (cw_poly_deg >= 13) + { + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[13], 208)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[13], 224)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[13], 160)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[13], 176)); + } + + if (cw_poly_deg >= 14) + { + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[14], 144)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[14], 208)); + syndromes[2] = GF16_ADD(syndromes[2], GF16_MUL0(buffer[14], 240)); + syndromes[3] = GF16_ADD(syndromes[3], GF16_MUL0(buffer[14], 224)); } + + } -FEC_STATIC void rs16_calculate_two_syndromes( LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg ) +FEC_STATIC void rs16_calculate_two_syndromes(LC3_UINT8 *syndromes, LC3_UINT8 *cw, LC3_INT32 cw_poly_deg) { - LC3_INT32 i; - LC3_UINT8 buffer[15]; + LC3_INT32 i; + LC3_UINT8 buffer[15]; - assert( cw_poly_deg >= 12 ); + assert(cw_poly_deg >= 12); - for ( i = 0; i <= cw_poly_deg; i++ ) + for (i = 0; i <= cw_poly_deg; i++) { buffer[i] = cw[i]; } @@ -2377,659 +1668,662 @@ FEC_STATIC void rs16_calculate_two_syndromes( LC3_UINT8 *syndromes, LC3_UINT8 *c syndromes[0] = buffer[0]; syndromes[1] = buffer[0]; - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[1], 32 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[1], 64 ) ); + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[1], 32)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[1], 64)); - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[2], 64 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[2], 48 ) ); + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[2], 64)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[2], 48)); - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[3], 128 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[3], 192 ) ); + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[3], 128)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[3], 192)); - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[4], 48 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[4], 80 ) ); + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[4], 48)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[4], 80)); - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[5], 96 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[5], 112 ) ); + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[5], 96)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[5], 112)); - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[6], 192 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[6], 240 ) ); + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[6], 192)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[6], 240)); - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[7], 176 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[7], 144 ) ); + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[7], 176)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[7], 144)); - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[8], 80 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[8], 32 ) ); + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[8], 80)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[8], 32)); - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[9], 160 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[9], 128 ) ); + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[9], 160)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[9], 128)); - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[10], 112 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[10], 96 ) ); + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[10], 112)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[10], 96)); - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[11], 224 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[11], 176 ) ); + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[11], 224)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[11], 176)); - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[12], 240 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[12], 160 ) ); + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[12], 240)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[12], 160)); - if ( cw_poly_deg >= 13 ) + if (cw_poly_deg >= 13) { - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[13], 208 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[13], 224 ) ); + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[13], 208)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[13], 224)); } - if ( cw_poly_deg >= 14 ) + if (cw_poly_deg >= 14) { - syndromes[0] = GF16_ADD( syndromes[0], GF16_MUL0( buffer[14], 144 ) ); - syndromes[1] = GF16_ADD( syndromes[1], GF16_MUL0( buffer[14], 208 ) ); + syndromes[0] = GF16_ADD(syndromes[0], GF16_MUL0(buffer[14], 144)); + syndromes[1] = GF16_ADD(syndromes[1], GF16_MUL0(buffer[14], 208)); } + + } -FEC_STATIC LC3_INT8 rs16_calculate_elp( LC3_UINT8 *elp, LC3_UINT8 *syndromes, LC3_INT16 t ) +FEC_STATIC LC3_INT8 rs16_calculate_elp(LC3_UINT8 *elp, LC3_UINT8 *syndromes, LC3_INT16 t) /* calculates error locator polynomial vie Petterson's algorithm */ { - LC3_INT8 ret; - LC3_UINT8 det, det_inv, aux, all_s, *s; - LC3_UINT8 s22, s33, s44, s13, s14, s15; - LC3_UINT8 s23, s24, s25, s34, s35; - LC3_UINT8 a, b, c, d, e, f; - - ret = 0; - all_s = 0; - s = syndromes; + LC3_INT8 ret; + LC3_UINT8 det, det_inv, aux, all_s, *s; + LC3_UINT8 s22, s33, s44, s13, s14, s15; + LC3_UINT8 s23, s24, s25, s34, s35; + LC3_UINT8 a, b, c, d, e, f; + + ret = 0; + all_s = 0; + s = syndromes; elp[0] = 1; - memset( elp + 1, 0, 3 ); + memset(elp + 1, 0, 3); - switch ( t ) + switch (t) { - case 3: - { - /* check for errors */ - all_s = s[0] | s[1] | s[2] | s[3] | s[4] | s[5]; + case 3: + { + /* check for errors */ + all_s = s[0] | s[1] | s[2] | s[3] | s[4] | s[5]; - if ( all_s == 0 ) - { - break; - } + if (all_s == 0) + { + break; + } - /* assume 3 errors */ - s22 = GF16_MUL( s[1], s[1] ); - s33 = GF16_MUL( s[2], s[2] ); - s44 = GF16_MUL( s[3], s[3] ); - s13 = GF16_MUL( s[0], s[2] ); + /* assume 3 errors */ + s22 = GF16_MUL(s[1], s[1]); + s33 = GF16_MUL(s[2], s[2]); + s44 = GF16_MUL(s[3], s[3]); + s13 = GF16_MUL(s[0], s[2]); - det = GF16_ADD( GF16_ADD( GF16_MUL( s13, s[4] ), GF16_MUL( s44, s[0] ) ), - GF16_ADD( GF16_MUL( s22, s[4] ), GF16_MUL( s33, s[2] ) ) ); + det = GF16_ADD(GF16_ADD(GF16_MUL(s13, s[4]), GF16_MUL(s44, s[0])), + GF16_ADD(GF16_MUL(s22, s[4]), GF16_MUL(s33, s[2]))); - if ( det ) - { - det_inv = gf16_inv_table[det] << 4; + if (det) + { + det_inv = gf16_inv_table[det] << 4; - s14 = GF16_MUL( s[0], s[3] ); - s15 = GF16_MUL( s[0], s[4] ); + s14 = GF16_MUL(s[0], s[3]); + s15 = GF16_MUL(s[0], s[4]); - s23 = GF16_MUL( s[1], s[2] ); - s24 = GF16_MUL( s[1], s[3] ); - s25 = GF16_MUL( s[1], s[4] ); + s23 = GF16_MUL(s[1], s[2]); + s24 = GF16_MUL(s[1], s[3]); + s25 = GF16_MUL(s[1], s[4]); - s34 = GF16_MUL( s[2], s[3] ); - s35 = GF16_MUL( s[2], s[4] ); + s34 = GF16_MUL(s[2], s[3]); + s35 = GF16_MUL(s[2], s[4]); - a = GF16_ADD( s35, s44 ) << 4; - b = GF16_ADD( s15, s33 ) << 4; - c = GF16_ADD( s13, s22 ) << 4; - d = GF16_ADD( s34, s25 ) << 4; - e = GF16_ADD( s23, s14 ) << 4; - f = GF16_ADD( s24, s33 ) << 4; + a = GF16_ADD(s35, s44) << 4; + b = GF16_ADD(s15, s33) << 4; + c = GF16_ADD(s13, s22) << 4; + d = GF16_ADD(s34, s25) << 4; + e = GF16_ADD(s23, s14) << 4; + f = GF16_ADD(s24, s33) << 4; - aux = GF16_ADD( GF16_ADD( GF16_MUL0( a, s[3] ), GF16_MUL0( d, s[4] ) ), GF16_MUL0( f, s[5] ) ); - elp[3] = GF16_MUL0( aux, det_inv ); + aux = GF16_ADD(GF16_ADD(GF16_MUL0(a, s[3]), GF16_MUL0(d, s[4])), GF16_MUL0(f, s[5])); + elp[3] = GF16_MUL0(aux, det_inv); - aux = GF16_ADD( GF16_ADD( GF16_MUL0( d, s[3] ), GF16_MUL0( b, s[4] ) ), GF16_MUL0( e, s[5] ) ); - elp[2] = GF16_MUL0( aux, det_inv ); + aux = GF16_ADD(GF16_ADD(GF16_MUL0(d, s[3]), GF16_MUL0(b, s[4])), GF16_MUL0(e, s[5])); + elp[2] = GF16_MUL0(aux, det_inv); - aux = GF16_ADD( GF16_ADD( GF16_MUL0( f, s[3] ), GF16_MUL0( e, s[4] ) ), GF16_MUL0( c, s[5] ) ); - elp[1] = GF16_MUL0( aux, det_inv ); + aux = GF16_ADD(GF16_ADD(GF16_MUL0(f, s[3]), GF16_MUL0(e, s[4])), GF16_MUL0(c, s[5])); + elp[1] = GF16_MUL0(aux, det_inv); - if ( elp[3] == 0 ) - { - ret = t + 1; - } - else - { - ret = 3; - } - break; + if (elp[3] == 0) + { + ret = t+1; } + else + { + ret = 3; + } + break; + } - /* assume two errors */ - det = GF16_ADD( GF16_MUL( syndromes[0], syndromes[2] ), GF16_MUL( syndromes[1], syndromes[1] ) ); + /* assume two errors */ + det = GF16_ADD(GF16_MUL(syndromes[0], syndromes[2]), GF16_MUL(syndromes[1], syndromes[1])); - if ( det ) - { - det_inv = gf16_inv_table[det] << 4; + if (det) + { + det_inv = gf16_inv_table[det] << 4; - aux = GF16_ADD( GF16_MUL( syndromes[1], syndromes[2] ), GF16_MUL( syndromes[0], syndromes[3] ) ); - elp[1] = GF16_MUL0( aux, det_inv ); + aux = GF16_ADD(GF16_MUL(syndromes[1], syndromes[2]), GF16_MUL(syndromes[0], syndromes[3])); + elp[1] = GF16_MUL0(aux, det_inv); - aux = GF16_ADD( GF16_MUL( syndromes[2], syndromes[2] ), GF16_MUL( syndromes[1], syndromes[3] ) ); - elp[2] = GF16_MUL0( aux, det_inv ); + aux = GF16_ADD(GF16_MUL(syndromes[2], syndromes[2]), GF16_MUL(syndromes[1], syndromes[3])); + elp[2] = GF16_MUL0(aux, det_inv); - /* check remaining LSF relations */ - aux = GF16_ADD( GF16_ADD( GF16_MUL( elp[2], s[2] ), GF16_MUL( elp[1], s[3] ) ), s[4] ) | GF16_ADD( GF16_ADD( GF16_MUL( elp[2], s[3] ), GF16_MUL( elp[1], s[4] ) ), s[5] ); + /* check remaining LSF relations */ + aux = GF16_ADD(GF16_ADD(GF16_MUL(elp[2], s[2]), GF16_MUL(elp[1], s[3])), s[4]) + | GF16_ADD(GF16_ADD(GF16_MUL(elp[2], s[3]), GF16_MUL(elp[1], s[4])), s[5]); - aux |= elp[2] == 0; + aux |= elp[2] == 0; - if ( aux != 0 ) - { - ret = t + 1; - } - else - { - ret = 2; - } - break; + if (aux != 0) + { + ret = t + 1; } - - /* assume one error */ - if ( syndromes[0] != 0 ) + else { - elp[1] = GF16_MUL( syndromes[1], gf16_inv_table[syndromes[0]] ); + ret = 2; + } + break; + } - /* check remaining LSF relations */ - aux = GF16_ADD( GF16_MUL( elp[1], s[1] ), s[2] ) | GF16_ADD( GF16_MUL( elp[1], s[2] ), s[3] ) | GF16_ADD( GF16_MUL( elp[1], s[3] ), s[4] ) | GF16_ADD( GF16_MUL( elp[1], s[4] ), s[5] ); + /* assume one error */ + if (syndromes[0] != 0) + { + elp[1] = GF16_MUL(syndromes[1], gf16_inv_table[syndromes[0]]); - aux |= elp[1] == 0; + /* check remaining LSF relations */ + aux = GF16_ADD(GF16_MUL(elp[1], s[1]), s[2]) + | GF16_ADD(GF16_MUL(elp[1], s[2]), s[3]) + | GF16_ADD(GF16_MUL(elp[1], s[3]), s[4]) + | GF16_ADD(GF16_MUL(elp[1], s[4]), s[5]); - if ( aux != 0 ) - { - ret = t + 1; - } - else - { - ret = 1; - } - break; + aux |= elp[1] == 0; + + if (aux != 0) + { + ret = t + 1; } + else + { + ret = 1; + } + break; + } + + ret = t + 1; + break; + } + case 2: + { + all_s = s[0] | s[1] | s[2] | s[3]; - ret = t + 1; + if (all_s == 0) + { break; } - case 2: + + /* assume two errors */ + det = GF16_ADD(GF16_MUL(syndromes[0], syndromes[2]), GF16_MUL(syndromes[1], syndromes[1])); + + if (det) { - all_s = s[0] | s[1] | s[2] | s[3]; + det_inv = gf16_inv_table[det] << 4; - if ( all_s == 0 ) - { - break; - } + aux = GF16_ADD(GF16_MUL(syndromes[1], syndromes[2]), GF16_MUL(syndromes[0], syndromes[3])); + elp[1] = GF16_MUL0(aux, det_inv); - /* assume two errors */ - det = GF16_ADD( GF16_MUL( syndromes[0], syndromes[2] ), GF16_MUL( syndromes[1], syndromes[1] ) ); + aux = GF16_ADD(GF16_MUL(syndromes[2], syndromes[2]), GF16_MUL(syndromes[1], syndromes[3])); + elp[2] = GF16_MUL0(aux, det_inv); - if ( det ) + if (elp[2] == 0) { - det_inv = gf16_inv_table[det] << 4; + ret = t + 1; + } + else + { + ret = 2; + } + break; + } - aux = GF16_ADD( GF16_MUL( syndromes[1], syndromes[2] ), GF16_MUL( syndromes[0], syndromes[3] ) ); - elp[1] = GF16_MUL0( aux, det_inv ); + /* assume one error */ + if (syndromes[0] != 0) + { + elp[1] = GF16_MUL(syndromes[1], gf16_inv_table[syndromes[0]]); - aux = GF16_ADD( GF16_MUL( syndromes[2], syndromes[2] ), GF16_MUL( syndromes[1], syndromes[3] ) ); - elp[2] = GF16_MUL0( aux, det_inv ); + /* check remaining LSF relation */ + aux = GF16_ADD(GF16_MUL(elp[1], s[1]), s[2]) | GF16_ADD(GF16_MUL(elp[1], s[2]), s[3]); + aux |= elp[1] == 0; - if ( elp[2] == 0 ) - { - ret = t + 1; - } - else - { - ret = 2; - } - break; + if (aux != 0) + { + ret = t + 1; } - - /* assume one error */ - if ( syndromes[0] != 0 ) + else { - elp[1] = GF16_MUL( syndromes[1], gf16_inv_table[syndromes[0]] ); - - /* check remaining LSF relation */ - aux = GF16_ADD( GF16_MUL( elp[1], s[1] ), s[2] ) | GF16_ADD( GF16_MUL( elp[1], s[2] ), s[3] ); - aux |= elp[1] == 0; - - if ( aux != 0 ) - { - ret = t + 1; - } - else - { - ret = 1; - } - break; + ret = 1; } - - ret = t + 1; break; } - case 1: + + ret = t + 1; + break; + } + case 1: + { + all_s = s[0] | s[1]; + + if (all_s == 0) { - all_s = s[0] | s[1]; + break; + } - if ( all_s == 0 ) + if (syndromes[0] != 0) + { + elp[1] = GF16_MUL(syndromes[1], gf16_inv_table[syndromes[0]]); + if (elp[1] == 0) { - break; + ret = t + 1; } - - if ( syndromes[0] != 0 ) + else { - elp[1] = GF16_MUL( syndromes[1], gf16_inv_table[syndromes[0]] ); - if ( elp[1] == 0 ) - { - ret = t + 1; - } - else - { - ret = 1; - } - break; + ret = 1; } - - ret = t + 1; break; } - default: - assert( 0 && "calculating elp of this degree not implemented" ); - } + ret = t + 1; + break; + } + default: assert(0 && "calculating elp of this degree not implemented"); + } + return ret; } -FEC_STATIC LC3_INT16 rs16_factorize_elp( LC3_UINT8 *err_pos, LC3_UINT8 *elp, LC3_INT16 deg_elp, LC3_INT16 max_pos ) +FEC_STATIC LC3_INT16 rs16_factorize_elp(LC3_UINT8 *err_pos, LC3_UINT8 *elp, LC3_INT16 deg_elp, LC3_INT16 max_pos) { - LC3_UINT8 beta, gamma; - LC3_INT16 zeros, err_pos0, err_pos1, err_pos2, ret; + LC3_UINT8 beta, gamma; + LC3_INT16 zeros, err_pos0, err_pos1, err_pos2, ret; - beta = 0; + beta = 0; gamma = 0; zeros = 0; - ret = 0; + ret = 0; - switch ( deg_elp ) + switch (deg_elp) { - case 0: - break; - - case 1: - err_pos0 = gf16_log_g[elp[1]]; - if ( err_pos0 > max_pos ) - { - ret = 1; - break; - } + case 0: break; - err_pos[0] = (LC3_UINT8) err_pos0; + case 1: + err_pos0 = gf16_log_g[elp[1]]; + if (err_pos0 > max_pos) + { + ret = 1; break; + } - case 2: - zeros = rs16_elp_deg2_table[elp[1] | ( elp[2] << 4 )]; - if ( zeros == 0 ) - { - - return 1; - } + err_pos[0] = (LC3_UINT8)err_pos0; + break; - err_pos0 = zeros & 15; - err_pos1 = ( zeros >> 4 ) & 15; + case 2: + zeros = rs16_elp_deg2_table[elp[1] | (elp[2] << 4)]; + if (zeros == 0) + { + + return 1; + } - if ( err_pos0 > max_pos || err_pos1 > max_pos ) - { - ret = 1; - break; - } + err_pos0 = zeros & 15; + err_pos1 = (zeros >> 4) & 15; - err_pos[0] = (LC3_UINT8) err_pos0; - err_pos[1] = (LC3_UINT8) err_pos1; + if (err_pos0 > max_pos || err_pos1 > max_pos) + { + ret = 1; break; + } - case 3: - /* beta = a*a + b, gamma = a*b + c */ - beta = GF16_ADD( GF16_MUL( elp[1], elp[1] ), elp[2] ); - gamma = GF16_ADD( GF16_MUL( elp[1], elp[2] ), elp[3] ); - zeros = rs16_elp_deg3_table[beta | gamma << 4]; + err_pos[0] = (LC3_UINT8)err_pos0; + err_pos[1] = (LC3_UINT8)err_pos1; + break; - if ( zeros == 0 ) - /* elp does not split over GF(16) or has multiple zeros */ - { - ret = 1; - break; - } + case 3: + /* beta = a*a + b, gamma = a*b + c */ + beta = GF16_ADD(GF16_MUL(elp[1], elp[1]), elp[2]); + gamma = GF16_ADD(GF16_MUL(elp[1], elp[2]), elp[3]); + zeros = rs16_elp_deg3_table[beta | gamma << 4]; - /* remove shift from zeros */ - err_pos0 = GF16_ADD( zeros & 15, elp[1] ); - err_pos1 = GF16_ADD( ( zeros >> 4 ) & 15, elp[1] ); - err_pos2 = GF16_ADD( ( zeros >> 8 ) & 15, elp[1] ); + if (zeros == 0) + /* elp does not split over GF(16) or has multiple zeros */ + { + ret = 1; + break; + } - if ( err_pos0 == 0 || err_pos1 == 0 || err_pos2 == 0 ) - { + /* remove shift from zeros */ + err_pos0 = GF16_ADD(zeros & 15, elp[1]); + err_pos1 = GF16_ADD((zeros >> 4) & 15, elp[1]); + err_pos2 = GF16_ADD((zeros >> 8) & 15, elp[1]); - return 1; - } + if (err_pos0 == 0 || err_pos1 == 0 || err_pos2 == 0) + { + + return 1; + } - err_pos0 = gf16_log_g[err_pos0]; - err_pos1 = gf16_log_g[err_pos1]; - err_pos2 = gf16_log_g[err_pos2]; + err_pos0 = gf16_log_g[err_pos0]; + err_pos1 = gf16_log_g[err_pos1]; + err_pos2 = gf16_log_g[err_pos2]; - if ( err_pos0 > max_pos || err_pos1 > max_pos || err_pos2 > max_pos ) - { - ret = 1; - break; - } + if (err_pos0 > max_pos || err_pos1 > max_pos || err_pos2 > max_pos) + { + ret = 1; + break; + } - err_pos[0] = (LC3_UINT8) err_pos0; - err_pos[1] = (LC3_UINT8) err_pos1; - err_pos[2] = (LC3_UINT8) err_pos2; + err_pos[0] = (LC3_UINT8)err_pos0; + err_pos[1] = (LC3_UINT8)err_pos1; + err_pos[2] = (LC3_UINT8)err_pos2; - break; + break; - default: - assert( 0 && "invalid degree in rs16_error_locator" ); + default: assert(0 && "invalid degree in rs16_error_locator"); } - + return ret; } -FEC_STATIC void rs16_calculate_errors( LC3_UINT8 *err_symb, LC3_UINT8 *err_pos, LC3_UINT8 *syndromes, LC3_INT8 deg_elp, LC3_INT8 t ) +FEC_STATIC void rs16_calculate_errors(LC3_UINT8 *err_symb, LC3_UINT8 *err_pos, LC3_UINT8 *syndromes, LC3_INT8 deg_elp, LC3_INT8 t) { - LC3_UINT8 det_inv; - LC3_UINT8 x0, x1, x2; - LC3_UINT8 x0sq, x1sq, x2sq; - LC3_UINT8 c0, c1, c2; - LC3_UINT8 s0, s1, s2; - LC3_UINT8 tmp; - - UNUSED( t ); + LC3_UINT8 det_inv; + LC3_UINT8 x0, x1, x2; + LC3_UINT8 x0sq, x1sq, x2sq; + LC3_UINT8 c0, c1, c2; + LC3_UINT8 s0, s1, s2; + LC3_UINT8 tmp; + + UNUSED(t); - assert( deg_elp <= t ); + assert(deg_elp <= t); - switch ( deg_elp ) + switch (deg_elp) { - case 0: - break; + case 0: break; - case 1: - err_symb[0] = GF16_MUL( gf16_g_pow[15 - err_pos[0]], syndromes[0] ); + case 1: + err_symb[0] = GF16_MUL(gf16_g_pow[15 - err_pos[0]], syndromes[0]); - break; + break; - case 2: - s0 = (LC3_UINT8) ( syndromes[0] << 4 ); - s1 = (LC3_UINT8) ( syndromes[1] << 4 ); + case 2: + s0 = (LC3_UINT8) (syndromes[0] << 4); + s1 = (LC3_UINT8) (syndromes[1] << 4); - x0 = gf16_g_pow[err_pos[0]]; - x1 = gf16_g_pow[err_pos[1]]; + x0 = gf16_g_pow[err_pos[0]]; + x1 = gf16_g_pow[err_pos[1]]; - x0sq = GF16_MUL( x0, x0 ); - x1sq = GF16_MUL( x1, x1 ); + x0sq = GF16_MUL(x0, x0); + x1sq = GF16_MUL(x1, x1); - tmp = GF16_ADD( GF16_MUL( x0sq, x1 ), GF16_MUL( x1sq, x0 ) ); - det_inv = gf16_inv_table[tmp] << 4; + tmp = GF16_ADD(GF16_MUL(x0sq, x1), GF16_MUL(x1sq, x0)); + det_inv = gf16_inv_table[tmp] << 4; - tmp = GF16_ADD( GF16_MUL0( x1sq, s0 ), GF16_MUL0( x1, s1 ) ); - err_symb[0] = GF16_MUL0( tmp, det_inv ); + tmp = GF16_ADD(GF16_MUL0(x1sq, s0), GF16_MUL0(x1, s1)); + err_symb[0] = GF16_MUL0(tmp, det_inv); - tmp = GF16_ADD( GF16_MUL0( x0sq, s0 ), GF16_MUL0( x0, s1 ) ); - err_symb[1] = GF16_MUL0( tmp, det_inv ); + tmp = GF16_ADD(GF16_MUL0(x0sq, s0), GF16_MUL0(x0, s1)); + err_symb[1] = GF16_MUL0(tmp, det_inv); - break; + break; - case 3: - s0 = syndromes[0] << 4; - s1 = syndromes[1] << 4; - s2 = syndromes[2] << 4; + case 3: + s0 = syndromes[0] << 4; + s1 = syndromes[1] << 4; + s2 = syndromes[2] << 4; - x0 = gf16_g_pow[err_pos[0]]; - x1 = gf16_g_pow[err_pos[1]]; - x2 = gf16_g_pow[err_pos[2]]; + x0 = gf16_g_pow[err_pos[0]]; + x1 = gf16_g_pow[err_pos[1]]; + x2 = gf16_g_pow[err_pos[2]]; - x0sq = GF16_MUL( x0, x0 ); - x1sq = GF16_MUL( x1, x1 ); - x2sq = GF16_MUL( x2, x2 ); + x0sq = GF16_MUL(x0, x0); + x1sq = GF16_MUL(x1, x1); + x2sq = GF16_MUL(x2, x2); - tmp = GF16_MUL( GF16_ADD( x1, x0 ), GF16_ADD( x2, x0 ) ); - tmp = GF16_MUL( GF16_ADD( x2, x1 ), tmp ); - det_inv = gf16_inv_table[tmp] << 4; + tmp = GF16_MUL(GF16_ADD(x1, x0), GF16_ADD(x2, x0)); + tmp = GF16_MUL(GF16_ADD(x2, x1), tmp); + det_inv = gf16_inv_table[tmp] << 4; - c0 = GF16_ADD( GF16_MUL( x1, x2sq ), GF16_MUL( x2, x1sq ) ); - c1 = GF16_ADD( x2sq, x1sq ); - c2 = GF16_ADD( x2, x1 ); + c0 = GF16_ADD(GF16_MUL(x1, x2sq), GF16_MUL(x2, x1sq)); + c1 = GF16_ADD(x2sq, x1sq); + c2 = GF16_ADD(x2, x1); - err_symb[0] = GF16_ADD( GF16_ADD( GF16_MUL0( c0, s0 ), GF16_MUL0( c1, s1 ) ), GF16_MUL0( c2, s2 ) ); + err_symb[0] = GF16_ADD(GF16_ADD(GF16_MUL0(c0, s0), GF16_MUL0(c1, s1)), GF16_MUL0(c2, s2)); - c0 = GF16_ADD( GF16_MUL( x0, x2sq ), GF16_MUL( x2, x0sq ) ); - c1 = GF16_ADD( x2sq, x0sq ); - c2 = GF16_ADD( x2, x0 ); + c0 = GF16_ADD(GF16_MUL(x0, x2sq), GF16_MUL(x2, x0sq)); + c1 = GF16_ADD(x2sq, x0sq); + c2 = GF16_ADD(x2, x0); - err_symb[1] = GF16_ADD( GF16_ADD( GF16_MUL0( c0, s0 ), GF16_MUL0( c1, s1 ) ), GF16_MUL0( c2, s2 ) ); + err_symb[1] = GF16_ADD(GF16_ADD(GF16_MUL0(c0, s0), GF16_MUL0(c1, s1)), GF16_MUL0(c2, s2)); - c0 = GF16_ADD( GF16_MUL( x0, x1sq ), GF16_MUL( x1, x0sq ) ); - c1 = GF16_ADD( x1sq, x0sq ); - c2 = GF16_ADD( x1, x0 ); + c0 = GF16_ADD(GF16_MUL(x0, x1sq), GF16_MUL(x1, x0sq)); + c1 = GF16_ADD(x1sq, x0sq); + c2 = GF16_ADD(x1, x0); - err_symb[2] = GF16_ADD( GF16_ADD( GF16_MUL0( c0, s0 ), GF16_MUL0( c1, s1 ) ), GF16_MUL0( c2, s2 ) ); + err_symb[2] = GF16_ADD(GF16_ADD(GF16_MUL0(c0, s0), GF16_MUL0(c1, s1)), GF16_MUL0(c2, s2)); - tmp = GF16_MUL0( err_symb[0], det_inv ); - err_symb[0] = GF16_MUL( tmp, gf16_inv_table[x0] ); + tmp = GF16_MUL0(err_symb[0], det_inv); + err_symb[0] = GF16_MUL(tmp, gf16_inv_table[x0]); - tmp = GF16_MUL0( err_symb[1], det_inv ); - err_symb[1] = GF16_MUL( tmp, gf16_inv_table[x1] ); + tmp = GF16_MUL0(err_symb[1], det_inv); + err_symb[1] = GF16_MUL(tmp, gf16_inv_table[x1]); - tmp = GF16_MUL0( err_symb[2], det_inv ); - err_symb[2] = GF16_MUL( tmp, gf16_inv_table[x2] ); + tmp = GF16_MUL0(err_symb[2], det_inv); + err_symb[2] = GF16_MUL(tmp, gf16_inv_table[x2]); - break; + break; - default: - assert( 0 && "method not implemented\n" ); - break; + default: assert(0 && "method not implemented\n"); break; } + + } /* hash functions for data validation */ /* hamming distance 4 */ -static const LC3_UINT32 crc14_mask[16] = { 0, 17989, 35978, 51919, 71956, 89937, 103838, 119771, - 143912, 160877, 179874, 194791, 207676, 224633, 239542, 254451 }; +static const LC3_UINT32 crc14_mask[16] = {0, 17989, 35978, 51919, 71956, 89937, 103838, 119771, + 143912, 160877, 179874, 194791, 207676, 224633, 239542, 254451}; /* hamming distance 4 */ -static const LC3_UINT32 crc22_mask[16] = { 0, 4788009, 9576018, 14356859, 19152036, 23933837, 28713718, 33500639, - 33650273, 38304072, 43214899, 47867674, 52775621, 57427436, 62346391, 67001278 }; +static const LC3_UINT32 crc22_mask[16] = {0, 4788009, 9576018, 14356859, 19152036, 23933837, 28713718, 33500639, + 33650273, 38304072, 43214899, 47867674, 52775621, 57427436, 62346391, 67001278}; -FEC_STATIC LC3_INT16 crc1( LC3_UINT8 *data, LC3_INT16 data_size, LC3_INT16 epmr, LC3_UINT8 *hash_val, LC3_INT16 hash_size, LC3_INT16 check ) +FEC_STATIC LC3_INT16 crc1(LC3_UINT8 *data, LC3_INT16 data_size, LC3_INT16 epmr, LC3_UINT8 *hash_val, LC3_INT16 hash_size, LC3_INT16 check) { - LC3_UINT32 const *mask; - LC3_INT32 shift, i, fail; - LC3_UINT32 rem; + LC3_UINT32 const *mask; + LC3_INT32 shift, i, fail; + LC3_UINT32 rem; fail = 0; - rem = 0; + rem = 0; - assert( hash_size > 0 ); + assert(hash_size > 0); - switch ( hash_size ) + switch (hash_size) { - case 2: - shift = 14; - mask = crc14_mask; - break; - case 3: - shift = 22; - mask = crc22_mask; - break; - default: - shift = 0; - mask = 0; - assert( 0 && "crc hash size not implemented" ); + case 2: + shift = 14; + mask = crc14_mask; + break; + case 3: + shift = 22; + mask = crc22_mask; + break; + default: + shift = 0; + mask = 0; + assert(0 && "crc hash size not implemented"); } /* data array contains 4-bit words */ - for ( i = data_size - 1; i >= 0; i-- ) + for (i = data_size - 1; i >= 0; i--) { - rem = ( rem << 4 ) ^ data[i]; - rem ^= mask[( rem >> shift ) & 15]; + rem = (rem << 4) ^ data[i]; + rem ^= mask[(rem >> shift) & 15]; } - rem = ( rem << 4 ) ^ ( epmr << 2 ); - rem ^= mask[( rem >> shift ) & 15]; + rem = (rem << 4) ^ (epmr << 2); + rem ^= mask[(rem >> shift) & 15]; - for ( i = 0; i < 2 * hash_size - 1; i++ ) + for (i = 0; i < 2 * hash_size - 1; i++) { rem <<= 4; - rem ^= mask[( rem >> shift ) & 15]; + rem ^= mask[(rem >> shift) & 15]; } - rem ^= ( (LC3_UINT32) epmr ) << shift; + rem ^= ((LC3_UINT32) epmr) << shift; - if ( check ) + if (check) { /* test hash value */ - for ( i = 0; i < 2 * hash_size; i++ ) + for (i = 0; i < 2 * hash_size; i++) { - fail |= hash_val[i] ^ ( ( rem >> ( 4 * i ) ) & 15 ); + fail |= hash_val[i] ^ ((rem >> (4*i)) & 15); } } else { /* write hash value */ - for ( i = 0; i < 2 * hash_size; i++ ) + for (i = 0; i < 2 * hash_size; i++) { - hash_val[i] = (LC3_UINT8) ( ( rem >> ( 4 * i ) ) & 15 ); + hash_val[i] = (LC3_UINT8) ((rem >> (4*i)) & 15); } } - + return fail; } /* hamming distance = 4 */ -static const LC3_UINT32 crc16_mask[16] = { 0, 107243, 190269, 214486, 289937, 380538, 428972, 469319, - 579874, 621513, 671263, 761076, 832947, 857944, 938638, 1044581 }; +static const LC3_UINT32 crc16_mask[16] = {0, 107243, 190269, 214486, 289937, 380538, 428972, 469319, + 579874, 621513, 671263, 761076, 832947, 857944, 938638, 1044581}; -FEC_STATIC LC3_INT16 crc2( LC3_UINT8 *data, LC3_INT16 data_size, LC3_UINT8 *hash_val, LC3_INT16 hash_size, LC3_INT16 check ) +FEC_STATIC LC3_INT16 crc2(LC3_UINT8 *data, LC3_INT16 data_size, LC3_UINT8 *hash_val, LC3_INT16 hash_size, LC3_INT16 check) { - LC3_UINT32 const *mask; - LC3_INT32 shift, i, fail; - LC3_UINT32 rem; + LC3_UINT32 const *mask; + LC3_INT32 shift, i, fail; + LC3_UINT32 rem; fail = 0; - rem = 0; + rem = 0; - assert( hash_size > 0 ); + assert(hash_size > 0); - switch ( hash_size ) + switch (hash_size) { - case 2: - shift = 16; - mask = crc16_mask; - break; - default: - shift = 0; - mask = 0; - assert( 0 && "crc hash size not implemented" ); + case 2: + shift = 16; + mask = crc16_mask; + break; + default: + shift = 0; + mask = 0; + assert(0 && "crc hash size not implemented"); } /* data array contains 4-bit words */ - for ( i = data_size - 1; i >= 0; i-- ) + for (i = data_size - 1; i >= 0; i--) { - rem = ( rem << 4 ) ^ data[i]; - rem ^= mask[( rem >> shift ) & 15]; + rem = (rem << 4) ^ data[i]; + rem ^= mask[(rem >> shift) & 15]; } - for ( i = 0; i < 2 * hash_size; i++ ) + for (i = 0; i < 2 * hash_size; i++) { rem <<= 4; - rem ^= mask[( rem >> shift ) & 15]; + rem ^= mask[(rem >> shift) & 15]; } - if ( check ) + if (check) { /* test hash value */ - for ( i = 0; i < 2 * hash_size; i++ ) + for (i = 0; i < 2 * hash_size; i++) { - fail |= hash_val[i] ^ ( ( rem >> ( 4 * i ) ) & 15 ); + fail |= hash_val[i] ^ ((rem >> (4*i)) & 15); } } else { /* write hash value */ - for ( i = 0; i < 2 * hash_size; i++ ) + for (i = 0; i < 2 * hash_size; i++) { - hash_val[i] = (LC3_UINT8) ( ( rem >> ( 4 * i ) ) & 15 ); + hash_val[i] = (LC3_UINT8) ((rem >> (4*i)) & 15); } } - + return fail; } /* simple float implementation */ -FEC_STATIC simple_float simple_float_mul( simple_float op1, simple_float op2 ) +FEC_STATIC simple_float simple_float_mul(simple_float op1, simple_float op2) { - simple_float rop; - LC3_INT32 aux; - - aux = ( op1.mantissa * op2.mantissa ) >> 14; + simple_float rop; + LC3_INT32 aux; + + aux = (op1.mantissa * op2.mantissa) >> 14; rop.exponent = op1.exponent + op2.exponent; - if ( aux & 32768L ) + if (aux & 32768L) { - aux >>= 1; - rop.exponent++; + aux >>= 1; + rop.exponent ++; } rop.mantissa = (LC3_INT16) aux; - + return rop; } /* Auxiliary */ -FEC_STATIC LC3_INT16 simple_float_cmp( simple_float op1, simple_float op2 ) +FEC_STATIC LC3_INT16 simple_float_cmp(simple_float op1, simple_float op2) /* returns 1 if op1 > op2, 0 if op1 = op2, and -1 if op1 < op2 */ { - LC3_INT16 rval; - LC3_INT16 mdiff; - LC3_INT16 ediff; + LC3_INT16 rval; + LC3_INT16 mdiff; + LC3_INT16 ediff; rval = 0; ediff = op1.exponent - op2.exponent; mdiff = (LC3_INT16) op1.mantissa - (LC3_INT16) op2.mantissa; - if ( ediff == 0 ) + if (ediff == 0) { - if ( mdiff > 0 ) + if (mdiff > 0) { rval = 1; } - if ( mdiff < 0 ) + if (mdiff < 0) { rval = -1; } } else { - if ( ediff > 0 ) + if (ediff > 0) { rval = 1; } - if ( ediff < 0 ) + if (ediff < 0) { rval = -1; } } - + return rval; } + diff --git a/lib_lc3plus/apply_global_gain.c b/lib_lc3plus/apply_global_gain.c index 2f7a3d880b..c67432e2c3 100644 --- a/lib_lc3plus/apply_global_gain.c +++ b/lib_lc3plus/apply_global_gain.c @@ -1,21 +1,21 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -void processApplyGlobalGain_fl( LC3_FLOAT x[], LC3_INT xLen, LC3_INT global_gain_idx, LC3_INT global_gain_off ) +void processApplyGlobalGain_fl(LC3_FLOAT x[], LC3_INT xLen, LC3_INT global_gain_idx, LC3_INT global_gain_off) { LC3_FLOAT gg = 0; - gg = LC3_POW( 10, (LC3_FLOAT) ( global_gain_idx + global_gain_off ) / 28 ); + gg = LC3_POW(10, (LC3_FLOAT)(global_gain_idx + global_gain_off) / 28); - mult_const( x, gg, xLen ); + mult_const(x, gg, xLen); } diff --git a/lib_lc3plus/ari_codec.c b/lib_lc3plus/ari_codec.c index 818c62021b..80c75fcf0c 100644 --- a/lib_lc3plus/ari_codec.c +++ b/lib_lc3plus/ari_codec.c @@ -1,310 +1,284 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -static void ac_shift_fl( Encoder_State_fl *st ); -static void ac_encode_fl( Encoder_State_fl *st, LC3_INT sym_freq, LC3_INT cum_freq ); -static void tns_order_freq_enc( LC3_INT enable_lpc_weighting, LC3_INT order, LC3_INT *symfreq, LC3_INT *cumfreq ); -static void tns_coef_freq_enc( LC3_INT k, LC3_INT idx, LC3_INT *symfreq, LC3_INT *cumfreq ); -static void ac_freq_fl( LC3_INT pki, LC3_INT s, LC3_INT *symfreq, LC3_INT *cumfreq ); -static void ac_finalize_fl( Encoder_State_fl *st ); -static void write_uint_forward_fl( Encoder_State_fl *st, LC3_INT val, LC3_INT numbits ); -static void ari_enc_init( Encoder_State_fl *st, LC3_UINT8 *bytes, LC3_INT *bp_side, LC3_INT *mask_side ); -static LC3_INT sign( LC3_INT x ); -static void read_bit_fl( LC3_UINT8 *ptr, LC3_INT *mask_side, LC3_INT *bp_side, LC3_INT *bit, LC3_INT *bp, Decoder_State_fl *st_fl, LC3_INT from_left ); -static void ac_dec_init_fl( LC3_UINT8 *ptr, LC3_INT *bp, Decoder_State_fl *st_fl, LC3_INT from_left, LC3_INT mask_side, LC3_INT *bp_side ); -static void tns_order_freq( LC3_INT enable_lpc_weighting, LC3_INT *symfreq, LC3_INT *cumfreq, LC3_INT *numsym ); -static void tns_coef_freq( LC3_INT k, LC3_INT *symfreq, LC3_INT *cumfreq, LC3_INT *numsym ); -static LC3_INT ac_decode_fl( Decoder_State_fl *st, LC3_INT *sym_freq, LC3_INT *cum_freq, LC3_INT num_sym, LC3_UINT8 *ptr, LC3_INT *bp, LC3_INT from_left, LC3_INT mask_side, LC3_INT *bp_side ); -static void ac_freq( LC3_INT pki, LC3_INT *symfreq, LC3_INT *cumfreq, LC3_INT *numsym ); -static void findNonZero( LC3_INT *in, LC3_INT *out, LC3_INT len, LC3_INT *outLen ); -static void pc_check_bytes( LC3_INT32 *bp, Decoder_State_fl *st_fl, LC3_INT32 from_left, LC3_INT32 mask_side, LC3_INT32 *bp_side ); -static void calculate_nfseed( LC3_INT *x, LC3_INT L_spec, LC3_INT *nf_seed ); - -void calculate_nfseed( LC3_INT *x, LC3_INT L_spec, LC3_INT *nf_seed ) +static void ac_shift_fl(Encoder_State_fl* st); +static void ac_encode_fl(Encoder_State_fl* st, LC3_INT sym_freq, LC3_INT cum_freq); +static void tns_order_freq_enc(LC3_INT enable_lpc_weighting, LC3_INT order, LC3_INT* symfreq, LC3_INT* cumfreq); +static void tns_coef_freq_enc(LC3_INT k, LC3_INT idx, LC3_INT* symfreq, LC3_INT* cumfreq); +static void ac_freq_fl(LC3_INT pki, LC3_INT s, LC3_INT* symfreq, LC3_INT* cumfreq); +static void ac_finalize_fl(Encoder_State_fl* st); +static void write_uint_forward_fl(Encoder_State_fl* st, LC3_INT val, LC3_INT numbits); +static void ari_enc_init(Encoder_State_fl* st, LC3_UINT8* bytes, LC3_INT* bp_side, LC3_INT* mask_side); +static LC3_INT sign(LC3_INT x); +static void read_bit_fl(LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* bit, LC3_INT *bp, Decoder_State_fl* st_fl, LC3_INT from_left); +static void ac_dec_init_fl(LC3_UINT8* ptr, LC3_INT* bp, Decoder_State_fl* st_fl, LC3_INT from_left, LC3_INT mask_side, LC3_INT *bp_side); +static void tns_order_freq(LC3_INT enable_lpc_weighting, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym); +static void tns_coef_freq(LC3_INT k, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym); +static LC3_INT ac_decode_fl(Decoder_State_fl* st, LC3_INT* sym_freq, LC3_INT* cum_freq, LC3_INT num_sym, LC3_UINT8* ptr, LC3_INT* bp, LC3_INT from_left, LC3_INT mask_side, LC3_INT *bp_side); +static void ac_freq(LC3_INT pki, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym); +static void findNonZero(LC3_INT* in, LC3_INT* out, LC3_INT len, LC3_INT* outLen); +static void pc_check_bytes(LC3_INT32* bp, Decoder_State_fl* st_fl, LC3_INT32 from_left, LC3_INT32 mask_side, LC3_INT32 *bp_side); +static void calculate_nfseed(LC3_INT *x, LC3_INT L_spec, LC3_INT *nf_seed); + +void calculate_nfseed(LC3_INT *x, LC3_INT L_spec, LC3_INT *nf_seed) { LC3_INT k = 0; - + *nf_seed = 0; - - for ( k = 0; k < L_spec; k++ ) - { - *nf_seed = *nf_seed + ( abs( x[k] ) & 32767 ) * k; + + for (k = 0; k < L_spec; k++) { + *nf_seed = *nf_seed + (abs(x[k]) & 32767) * k; } *nf_seed = *nf_seed & 65535; - if ( *nf_seed >= 32768 ) - { + if (*nf_seed >= 32768) { *nf_seed = *nf_seed - 65536; } } -static void pc_check_bytes( LC3_INT32 *bp, Decoder_State_fl *st_fl, LC3_INT32 from_left, LC3_INT32 mask_side, LC3_INT32 *bp_side ) +static void pc_check_bytes(LC3_INT32* bp, Decoder_State_fl* st_fl, LC3_INT32 from_left, LC3_INT32 mask_side, LC3_INT32 *bp_side) { LC3_INT32 bp_local, bp_side_local, offset; - - if ( st_fl->pc_bytes > 0 ) + + if (st_fl->pc_bytes > 0) { - if ( !from_left && mask_side != 1 ) + if (!from_left && mask_side != 1) { return; } - if ( st_fl->pc_c_bp_side > 0 && *bp_side < 0 ) + if (st_fl->pc_c_bp_side > 0 && *bp_side < 0) { - assert( mask_side == 1 ); - assert( st_fl->pc_b_right != -1 ); + assert(mask_side == 1); + assert(st_fl->pc_b_right != -1); *bp_side = st_fl->pc_b_right; return; } bp_local = *bp; bp_side_local = *bp_side; - - if ( from_left ) + + if (from_left) { - if ( mask_side == 1 ) + if (mask_side == 1) { bp_side_local = bp_side_local + 1; } - } - else - { + } else { bp_local = bp_local - 1; } - - if ( st_fl->pc_b_right == -1 ) + + if (st_fl->pc_b_right == -1) { offset = -1; - if ( !st_fl->pc_enc ) + if (!st_fl->pc_enc) { offset = offset + st_fl->pc_bytes; } - - if ( ( bp_side_local + offset - bp_local ) == st_fl->pc_bytes ) + + if ((bp_side_local + offset - bp_local) == st_fl->pc_bytes) { st_fl->pc_b_left = bp_local + 1; st_fl->pc_b_right = bp_side_local - 1; - - if ( st_fl->pc_enc ) + + if (st_fl->pc_enc) { st_fl->pc_return = 1; return; } } } - - if ( !st_fl->pc_enc && st_fl->pc_b_right > -1 ) + + if (!st_fl->pc_enc && st_fl->pc_b_right > -1) { - if ( from_left && *bp == st_fl->pc_b_left ) + if (from_left && *bp == st_fl->pc_b_left) { *bp = 0; st_fl->pc_c_bp = 1; } - - if ( !from_left && bp_side_local == st_fl->pc_b_right ) + + if (!from_left && bp_side_local == st_fl->pc_b_right) { *bp_side = st_fl->pc_bytes - 1; st_fl->pc_c_bp_side = 1; } - - if ( st_fl->pc_bfi == 2 ) + + if (st_fl->pc_bfi == 2) { - - if ( ( st_fl->pc_c_bp && ( *bp + 1 ) >= st_fl->pc_be_bp_left ) || ( st_fl->pc_c_bp_side && ( *bp_side + 1 ) <= st_fl->pc_be_bp_right ) ) + + if ((st_fl->pc_c_bp && (*bp + 1) >= st_fl->pc_be_bp_left) || (st_fl->pc_c_bp_side && (*bp_side + 1) <= st_fl->pc_be_bp_right)) { st_fl->pc_bbi = 2; - } - else if ( ( st_fl->pc_c_bp && *bp >= 0 ) || ( st_fl->pc_c_bp_side && *bp_side <= ( st_fl->pc_bytes - 1 ) ) ) + } else if ((st_fl->pc_c_bp && *bp >= 0) || (st_fl->pc_c_bp_side && *bp_side <= (st_fl->pc_bytes - 1))) { st_fl->pc_bbi = 1; } } - } + } } - + return; } -void ac_dec_init_fl( LC3_UINT8 *ptr, LC3_INT *bp, Decoder_State_fl *st_fl, LC3_INT from_left, LC3_INT mask_side, LC3_INT *bp_side ) +void ac_dec_init_fl(LC3_UINT8* ptr, LC3_INT* bp, Decoder_State_fl* st_fl, LC3_INT from_left, LC3_INT mask_side, LC3_INT *bp_side) { LC3_INT i = 0; - if ( !st_fl->pc_enc ) + if (!st_fl->pc_enc) { *bp = *bp + st_fl->pc_bytes; } st_fl->ac_low_fl = 0; - st_fl->ac_range_fl = (LC3_UINT32) pow( 2, 24 ) - (LC3_UINT32) 1; - for ( i = 0; i < 3; i++ ) - { - pc_check_bytes( bp, st_fl, from_left, mask_side, bp_side ); - - st_fl->ac_low_fl = ( st_fl->ac_low_fl << 8 ) + (LC3_UINT32) ptr[*bp]; - *bp = *bp + 1; + st_fl->ac_range_fl = (LC3_UINT32)pow(2, 24) - (LC3_UINT32)1; + for (i = 0; i < 3; i++) { + pc_check_bytes(bp, st_fl, from_left, mask_side, bp_side); + + st_fl->ac_low_fl = (st_fl->ac_low_fl << 8) + (LC3_UINT32)ptr[*bp]; + *bp = *bp + 1; } st_fl->BER_detect = 0; } -void tns_order_freq( LC3_INT enable_lpc_weighting, LC3_INT *symfreq, LC3_INT *cumfreq, LC3_INT *numsym ) +void tns_order_freq(LC3_INT enable_lpc_weighting, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym) { LC3_INT i = 0, j = 0; *numsym = 8; j = 0; - for ( i = 1; i < 9; i++ ) - { + for (i = 1; i < 9; i++) { symfreq[j] = ari_tns_order_cf[enable_lpc_weighting][i]; j++; } - for ( i = 0; i < *numsym; i++ ) - { + for (i = 0; i < *numsym; i++) { symfreq[i] -= ari_tns_order_cf[enable_lpc_weighting][i]; } - for ( i = 0; i < *numsym; i++ ) - { + for (i = 0; i < *numsym; i++) { cumfreq[i] = ari_tns_order_cf[enable_lpc_weighting][i]; } } /* Returns val */ -LC3_INT ac_decode_fl( Decoder_State_fl *st, LC3_INT *sym_freq, LC3_INT *cum_freq, LC3_INT num_sym, LC3_UINT8 *ptr, LC3_INT *bp, LC3_INT from_left, LC3_INT mask_side, LC3_INT *bp_side ) +LC3_INT ac_decode_fl(Decoder_State_fl* st, LC3_INT* sym_freq, LC3_INT* cum_freq, LC3_INT num_sym, LC3_UINT8* ptr, LC3_INT* bp, LC3_INT from_left, LC3_INT mask_side, LC3_INT *bp_side) { LC3_INT val = 0, tmp = 0; - + tmp = st->ac_range_fl >> 10; - if ( st->ac_low_fl >= (LC3_UINT32) ( tmp << 10 ) ) - { + if (st->ac_low_fl >= (LC3_UINT32)(tmp << 10)) { st->BER_detect = 1; } val = num_sym - 1; - while ( st->ac_low_fl < (LC3_UINT32) ( tmp * cum_freq[val] ) ) - { + while (st->ac_low_fl < (LC3_UINT32)(tmp * cum_freq[val])) { val--; } - st->ac_low_fl = st->ac_low_fl - tmp * cum_freq[val]; + st->ac_low_fl = st->ac_low_fl - tmp * cum_freq[val]; st->ac_range_fl = tmp * sym_freq[val]; - while ( st->ac_range_fl < pow( 2, 16 ) ) - { - st->ac_low_fl = st->ac_low_fl << 8; - st->ac_low_fl = ( (LC3_INT) st->ac_low_fl ) & ( (LC3_INT) ( pow( 2, 24 ) - 1 ) ); - - pc_check_bytes( bp, st, from_left, mask_side, bp_side ); - - st->ac_low_fl = st->ac_low_fl + ptr[*bp]; - *bp = *bp + 1; + while (st->ac_range_fl < pow(2, 16)) { + st->ac_low_fl = st->ac_low_fl << 8; + st->ac_low_fl = ((LC3_INT)st->ac_low_fl) & ((LC3_INT)(pow(2, 24) - 1)); + + pc_check_bytes(bp, st, from_left, mask_side, bp_side); + + st->ac_low_fl = st->ac_low_fl + ptr[*bp]; + *bp = *bp + 1; st->ac_range_fl = st->ac_range_fl << 8; } return val; } -void tns_coef_freq( LC3_INT k, LC3_INT *symfreq, LC3_INT *cumfreq, LC3_INT *numsym ) +void tns_coef_freq(LC3_INT k, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym) { LC3_INT i = 0, j = 0; *numsym = 18 - 1; j = 0; - for ( i = 1; i <= *numsym; i++ ) - { + for (i = 1; i <= *numsym; i++) { symfreq[j] = ari_tns_freq_cf[k][i]; j++; } - for ( i = 0; i < *numsym; i++ ) - { + for (i = 0; i < *numsym; i++) { symfreq[i] -= ari_tns_freq_cf[k][i]; } - for ( i = 0; i < *numsym; i++ ) - { + for (i = 0; i < *numsym; i++) { cumfreq[i] = ari_tns_freq_cf[k][i]; } } -void ac_freq( LC3_INT pki, LC3_INT *symfreq, LC3_INT *cumfreq, LC3_INT *numsym ) +void ac_freq(LC3_INT pki, LC3_INT* symfreq, LC3_INT* cumfreq, LC3_INT* numsym) { LC3_INT i = 0, j = 0; *numsym = 18 - 1; j = 0; - for ( i = 1; i <= *numsym; i++ ) - { + for (i = 1; i <= *numsym; i++) { symfreq[j] = ari_spec_cumfreq_fl[pki][i]; j++; } - for ( i = 0; i < *numsym; i++ ) - { + for (i = 0; i < *numsym; i++) { symfreq[i] -= ari_spec_cumfreq_fl[pki][i]; } - for ( i = 0; i < *numsym; i++ ) - { + for (i = 0; i < *numsym; i++) { cumfreq[i] = ari_spec_cumfreq_fl[pki][i]; } } -void read_bit_fl( LC3_UINT8 *ptr, LC3_INT *mask_side, LC3_INT *bp_side, LC3_INT *bit, LC3_INT *bp, Decoder_State_fl *st_fl, LC3_INT from_left ) +void read_bit_fl(LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* bit, LC3_INT *bp, Decoder_State_fl* st_fl, LC3_INT from_left) { *bit = 0; + + UNUSED(bp); + UNUSED(st_fl); + UNUSED(from_left); - UNUSED( bp ); - UNUSED( st_fl ); - UNUSED( from_left ); - - if ( ptr[*bp_side] & *mask_side ) - { + if (ptr[*bp_side] & *mask_side) { *bit = 1; - } - else - { + } else { *bit = 0; } - if ( *mask_side == 128 ) - { + if (*mask_side == 128) { *mask_side = 1; - *bp_side = *bp_side - 1; - } - else - { + *bp_side = *bp_side - 1; + } else { *mask_side = *mask_side * 2; } } -void findNonZero( LC3_INT *in, LC3_INT *out, LC3_INT len, LC3_INT *outLen ) +void findNonZero(LC3_INT* in, LC3_INT* out, LC3_INT len, LC3_INT* outLen) { LC3_INT i = 0, j = 0; - for ( i = 0; i < len; i++ ) - { - if ( in[i] != 0 ) - { + for (i = 0; i < len; i++) { + if (in[i] != 0) { out[j] = i; j++; } @@ -313,119 +287,119 @@ void findNonZero( LC3_INT *in, LC3_INT *out, LC3_INT len, LC3_INT *outLen ) *outLen = j; } -void processAriDecoder_fl( LC3_UINT8 *bytes, LC3_INT bp_side, LC3_INT mask_side, LC3_INT L_spec, LC3_INT fs_idx, LC3_INT enable_lpc_weighting, LC3_INT tns_numfilters, LC3_INT lsbMode, LC3_INT lastnz, LC3_INT *bfi, LC3_INT *tns_order, LC3_INT fac_ns_idx, LC3_INT gg_idx, uint8_t *resBits, LC3_INT *x, LC3_INT *nf_seed, LC3_INT *tns_idx, LC3_INT *zero_frame, LC3_INT numbytes, LC3_INT *nbits_residual, LC3_INT *residualPresent, LC3_INT frame_dms, LC3_INT32 n_pc, LC3_INT32 be_bp_left, LC3_INT32 be_bp_right, LC3_INT32 enc, LC3_INT32 *b_left, LC3_INT32 *spec_inv_idx, LC3_INT hrmode ) +void processAriDecoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side, LC3_INT L_spec, LC3_INT fs_idx, LC3_INT enable_lpc_weighting, + LC3_INT tns_numfilters, LC3_INT lsbMode, LC3_INT lastnz, LC3_INT* bfi, LC3_INT* tns_order, LC3_INT fac_ns_idx, + LC3_INT gg_idx, uint8_t * resBits, LC3_INT* x, LC3_INT* nf_seed, LC3_INT* tns_idx, LC3_INT* zero_frame, LC3_INT numbytes, + LC3_INT* nbits_residual, LC3_INT* residualPresent, LC3_INT frame_dms, + LC3_INT32 n_pc, LC3_INT32 be_bp_left, LC3_INT32 be_bp_right, LC3_INT32 enc, LC3_INT32 *b_left, LC3_INT32 *spec_inv_idx, + LC3_INT hrmode +) { Decoder_State_fl st; - LC3_INT a = 0, b = 0, t = 0, bp = 0; - LC3_INT c = 0; - LC3_INT nbits_side = 0, extra_bits = 0; - LC3_UINT8 *ptr = NULL; - LC3_INT n = 0, k = 0, lev = 0; - LC3_INT max_lev = 0, tmp = 0; - LC3_INT sym_freq[MAX_LEN] = { 0 }, cum_freq[MAX_LEN] = { 0 }, numsym = 0, bit = 0, lev1 = 0, pki = 0, sym = 0, - save_lev[MAX_LEN] = { 0 }, idx_len = 0, total_bits = 0, nbits_ari = 0, idx[MAX_LEN] = { 0 }, rateFlag = 0; + LC3_INT a = 0, b = 0, t = 0, bp = 0; + LC3_INT c = 0; + LC3_INT nbits_side = 0, extra_bits = 0; + LC3_UINT8* ptr = NULL; + LC3_INT n = 0, k = 0, lev = 0; + LC3_INT max_lev = 0, tmp = 0; + LC3_INT sym_freq[MAX_LEN] = {0}, cum_freq[MAX_LEN] = {0}, numsym = 0, bit = 0, lev1 = 0, pki = 0, sym = 0, + save_lev[MAX_LEN] = {0}, idx_len = 0, total_bits = 0, nbits_ari = 0, idx[MAX_LEN] = {0}, rateFlag = 0; total_bits = 8 * numbytes; - - memset( &st, 0, sizeof( st ) ); - - - st.pc_bytes = ( n_pc + 1 ) >> 1; + + memset(&st, 0, sizeof(st)); + + + st.pc_bytes = (n_pc + 1) >> 1; st.pc_b_left = numbytes + 1; st.pc_b_right = -1; st.pc_enc = enc; st.pc_bfi = *bfi; - st.pc_be_bp_left = floor( be_bp_left / 8 ); - st.pc_be_bp_right = floor( be_bp_right / 8 ) - 1; + st.pc_be_bp_left = floor(be_bp_left / 8); + st.pc_be_bp_right = floor(be_bp_right / 8) - 1; *spec_inv_idx = L_spec + 1; - assert( st.pc_be_bp_right < st.pc_bytes || st.pc_bytes == 0 ); + assert(st.pc_be_bp_right < st.pc_bytes || st.pc_bytes == 0); /* Rate flag */ - if ( fs_idx != 5 ) + if (fs_idx != 5) { - if ( total_bits > ( 160 + fs_idx * 160 ) ) - { + if (total_bits > (160 + fs_idx * 160)) { rateFlag = 512; } } /* Init */ - c = 0; - t = 0; + c = 0; + t = 0; bp = 0; - + *b_left = -1; ptr = bytes; /* Start Decoding */ - ac_dec_init_fl( ptr, &bp, &st, 1, mask_side, &bp_side ); - + ac_dec_init_fl(ptr, &bp, &st, 1, mask_side, &bp_side); + /* Decode TNS data */ tmp = MAXLAG; - if ( frame_dms == 25 ) + if (frame_dms == 25) { tmp /= 2; } - if ( frame_dms == 50 ) + if (frame_dms == 50) { tmp /= 2; } /* Decode TNS data */ - for ( n = 0; n < tns_numfilters; n++ ) - { - - if ( tns_order[n] > 0 ) - { - tns_order_freq( enable_lpc_weighting, sym_freq, cum_freq, &numsym ); - - tns_order[n] = ac_decode_fl( &st, sym_freq, cum_freq, numsym, ptr, &bp, 1, mask_side, &bp_side ); - - if ( st.pc_return ) + for (n = 0; n < tns_numfilters; n++) { + + if (tns_order[n] > 0) { + tns_order_freq(enable_lpc_weighting, sym_freq, cum_freq, &numsym); + + tns_order[n] = ac_decode_fl(&st, sym_freq, cum_freq, numsym, ptr, &bp, 1, mask_side, &bp_side); + + if (st.pc_return) { *b_left = st.pc_b_left; return; } - + tns_order[n] = tns_order[n] + 1; - - if ( tns_order[n] > tmp ) + + if (tns_order[n] > tmp) { st.BER_detect = 1; } - - if ( st.pc_bbi == 1 ) + + if (st.pc_bbi == 1) { spec_inv_idx = 0; - } - else if ( st.pc_bbi == 2 ) + } else if (st.pc_bbi == 2) { st.BER_detect = 1; } - for ( k = 0; k < tns_order[n]; k++ ) - { - if ( bp_side < bp ) + for (k = 0; k < tns_order[n]; k++) { + if (bp_side < bp) { *bfi = 1; return; } - - tns_coef_freq( k, sym_freq, cum_freq, &numsym ); - tns_idx[n * 8 + k] = ac_decode_fl( &st, sym_freq, cum_freq, numsym, ptr, &bp, 1, mask_side, &bp_side ); - - if ( st.pc_return ) + + tns_coef_freq(k, sym_freq, cum_freq, &numsym); + tns_idx[n * 8 + k] = ac_decode_fl(&st, sym_freq, cum_freq, numsym, ptr, &bp, 1, mask_side, &bp_side); + + if (st.pc_return) { *b_left = st.pc_b_left; return; } - - if ( st.pc_bbi == 1 ) + + if (st.pc_bbi == 1) { spec_inv_idx = 0; - } - else if ( st.pc_bbi == 2 ) + } else if (st.pc_bbi == 2) { st.BER_detect = 1; } @@ -433,216 +407,196 @@ void processAriDecoder_fl( LC3_UINT8 *bytes, LC3_INT bp_side, LC3_INT mask_side, } } - if ( st.BER_detect > 0 ) - { + if (st.BER_detect > 0) { *bfi = 1; return; } /* Spectral data */ - for ( k = 0; k < lastnz; k = k + 2 ) - { + for (k = 0; k < lastnz; k = k + 2) { /* Context */ t = c + rateFlag; - if ( k > L_spec / 2 ) - { + if (k > L_spec / 2) { t = t + 256; } /* Decode amplitude */ - x[k] = 0; + x[k] = 0; x[k + 1] = 0; - if ( hrmode == 1 ) - { + if (hrmode == 1) { max_lev = 13 + 8; - } - else - { + } else { max_lev = 13; } - for ( lev = 0; lev <= max_lev; lev++ ) - { - lev1 = MIN( lev, 3 ); - pki = ari_spec_lookup_fl[t + lev1 * 1024]; - ac_freq( pki, sym_freq, cum_freq, &numsym ); - sym = ac_decode_fl( &st, sym_freq, cum_freq, numsym, ptr, &bp, 1, mask_side, &bp_side ); + for (lev = 0; lev <= max_lev; lev++) { + lev1 = MIN(lev, 3); + pki = ari_spec_lookup_fl[t + lev1 * 1024]; + ac_freq(pki, sym_freq, cum_freq, &numsym); + sym = ac_decode_fl(&st, sym_freq, cum_freq, numsym, ptr, &bp, 1, mask_side, &bp_side); - if ( st.pc_return ) - { - *b_left = st.pc_b_left; - return; - } - - if ( st.pc_bbi == 1 ) - { - *spec_inv_idx = MIN( *spec_inv_idx, k ); - } - else if ( st.pc_bbi == 2 ) - { - *spec_inv_idx = k; - x[k] = 0; - x[k + 1] = 0; - calculate_nfseed( x, k, nf_seed ); - return; - } + if (st.pc_return) + { + *b_left = st.pc_b_left; + return; + } + + if (st.pc_bbi == 1) + { + *spec_inv_idx = MIN(*spec_inv_idx, k); + } else if (st.pc_bbi == 2) + { + *spec_inv_idx = k; + x[k] = 0; + x[k + 1] = 0; + calculate_nfseed(x, k, nf_seed); + return; + } - if ( sym < 16 ) - { + if (sym < 16) { break; } - if ( lsbMode == 0 || lev > 0 ) - { - pc_check_bytes( &bp, &st, 0, mask_side, &bp_side ); - read_bit_fl( ptr, &mask_side, &bp_side, &bit, &bp, &st, 0 ); + if (lsbMode == 0 || lev > 0) { + pc_check_bytes(&bp, &st, 0, mask_side, &bp_side); + read_bit_fl(ptr, &mask_side, &bp_side, &bit, &bp, &st, 0); - if ( st.pc_return ) + if (st.pc_return) { *b_left = st.pc_b_left; return; } - - if ( st.pc_bbi == 2 ) + + if (st.pc_bbi == 2) { *spec_inv_idx = k; x[k] = 0; x[k + 1] = 0; - calculate_nfseed( x, k, nf_seed ); + calculate_nfseed(x, k, nf_seed); return; } + + x[k] = x[k] + (bit << lev); + pc_check_bytes(&bp, &st, 0, mask_side, &bp_side); + read_bit_fl(ptr, &mask_side, &bp_side, &bit, &bp, &st, 0); - x[k] = x[k] + ( bit << lev ); - pc_check_bytes( &bp, &st, 0, mask_side, &bp_side ); - read_bit_fl( ptr, &mask_side, &bp_side, &bit, &bp, &st, 0 ); - - if ( st.pc_return ) + if (st.pc_return) { *b_left = st.pc_b_left; return; } - - if ( st.pc_bbi == 2 ) + + if (st.pc_bbi == 2) { *spec_inv_idx = k; x[k] = 0; x[k + 1] = 0; - calculate_nfseed( x, k, nf_seed ); + calculate_nfseed(x, k, nf_seed); return; } - x[k + 1] = x[k + 1] + ( bit << lev ); + x[k + 1] = x[k + 1] + (bit << lev); } } - - if ( ( lev - 1 ) == 13 && sym == 16 ) + + if ((lev - 1) == 13 && sym == 16) { st.BER_detect = 1; } - - if ( hrmode == 0 ) - { - lev = MIN( lev, 13 ); + + if (hrmode == 0) { + lev = MIN(lev, 13); } - if ( lsbMode == 1 ) - { + if (lsbMode == 1) { save_lev[k] = lev; } a = sym & 3; b = sym >> 2; - x[k] = x[k] + ( a << lev ); - x[k + 1] = x[k + 1] + ( b << lev ); + x[k] = x[k] + (a << lev); + x[k + 1] = x[k + 1] + (b << lev); /* Decode signs */ - if ( x[k] > 0 ) - { - pc_check_bytes( &bp, &st, 0, mask_side, &bp_side ); - read_bit_fl( ptr, &mask_side, &bp_side, &bit, &bp, &st, 0 ); - - if ( st.pc_return ) + if (x[k] > 0) { + pc_check_bytes(&bp, &st, 0, mask_side, &bp_side); + read_bit_fl(ptr, &mask_side, &bp_side, &bit, &bp, &st, 0); + + if (st.pc_return) { *b_left = st.pc_b_left; return; } - - if ( st.pc_bbi == 2 ) + + if (st.pc_bbi == 2) { *spec_inv_idx = k; x[k] = 0; x[k + 1] = 0; - calculate_nfseed( x, k, nf_seed ); + calculate_nfseed(x, k, nf_seed); return; } - if ( bit == 1 ) - { + if (bit == 1) { x[k] = -x[k]; } } - if ( x[k + 1] > 0 ) - { - pc_check_bytes( &bp, &st, 0, mask_side, &bp_side ); - read_bit_fl( ptr, &mask_side, &bp_side, &bit, &bp, &st, 0 ); - - if ( st.pc_return ) + if (x[k + 1] > 0) { + pc_check_bytes(&bp, &st, 0, mask_side, &bp_side); + read_bit_fl(ptr, &mask_side, &bp_side, &bit, &bp, &st, 0); + + if (st.pc_return) { *b_left = st.pc_b_left; return; } - - if ( st.pc_bbi == 2 ) + + if (st.pc_bbi == 2) { *spec_inv_idx = k + 1; x[k + 1] = 0; - calculate_nfseed( x, k, nf_seed ); + calculate_nfseed(x, k, nf_seed); return; } - - if ( bit == 1 ) - { + + if (bit == 1) { x[k + 1] = -x[k + 1]; } } /* Context */ - lev1 = MIN( lev, 3 ); - if ( lev1 <= 1 ) - { - t = 1 + ( a + b ) * ( lev1 + 1 ); - } - else - { + lev1 = MIN(lev, 3); + if (lev1 <= 1) { + t = 1 + (a + b) * (lev1 + 1); + } else { t = 12 + lev1; } - c = ( c & 15 ) * 16 + t; + c = (c & 15) * 16 + t; - if ( ( ( bp - bp_side ) > 3 && ( st.pc_c_bp == st.pc_c_bp_side ) ) ) - { + if (((bp - bp_side) > 3 && (st.pc_c_bp == st.pc_c_bp_side))) { - if ( ( 0 < *spec_inv_idx ) && ( *spec_inv_idx < ( L_spec + 1 ) ) ) + if ((0 < *spec_inv_idx) && (*spec_inv_idx < (L_spec + 1))) { *bfi = 2; - calculate_nfseed( x, k, nf_seed ); - return; + calculate_nfseed(x, k, nf_seed); + return; } *bfi = 1; return; } - - if ( st.BER_detect > 0 ) + + if (st.BER_detect > 0) { - if ( ( 0 < *spec_inv_idx ) && ( *spec_inv_idx < ( L_spec + 1 ) ) ) + if ((0 < *spec_inv_idx) && (*spec_inv_idx < (L_spec + 1))) { *bfi = 2; - calculate_nfseed( x, k, nf_seed ); + calculate_nfseed(x, k, nf_seed); return; } @@ -652,220 +606,189 @@ void processAriDecoder_fl( LC3_UINT8 *bytes, LC3_INT bp_side, LC3_INT mask_side, } /* Residual bits */ - nbits_side = total_bits - ( 8 * bp_side + 8 - ( 31 - clz_func( mask_side ) ) ); - nbits_ari = ( bp - 3 ) * 8; - extra_bits = 25 - ( 31 - clz_func( st.ac_range_fl ) ); + nbits_side = total_bits - (8 * bp_side + 8 - (31 - clz_func(mask_side))); + nbits_ari = (bp - 3) * 8; + extra_bits = 25 - (31 - clz_func(st.ac_range_fl)); - if ( enc == 0 ) + if (enc == 0) { - if ( st.pc_c_bp == 0 ) + if (st.pc_c_bp == 0) { - nbits_ari = ( bp - st.pc_bytes - 3 ) * 8; + nbits_ari = (bp - st.pc_bytes - 3) * 8; + } else { + nbits_ari = (bp + st.pc_b_left - st.pc_bytes - 3) * 8; } - else + + if (st.pc_c_bp_side != 0) { - nbits_ari = ( bp + st.pc_b_left - st.pc_bytes - 3 ) * 8; - } - - if ( st.pc_c_bp_side != 0 ) - { - nbits_side = total_bits - 8 * ( st.pc_b_left ) + 8 * ( st.pc_bytes - bp_side ) - ( 8 - LC3_LOGTWO( mask_side ) ); + nbits_side = total_bits - 8 * (st.pc_b_left) + 8 * (st.pc_bytes - bp_side) - (8 - LC3_LOGTWO(mask_side)); } } + + *nbits_residual = total_bits - (nbits_side + nbits_ari + extra_bits); - *nbits_residual = total_bits - ( nbits_side + nbits_ari + extra_bits ); - - if ( *nbits_residual < 0 ) - { - if ( ( 0 < *spec_inv_idx ) && ( *spec_inv_idx < ( L_spec + 1 ) ) ) + if (*nbits_residual < 0) { + if ((0 < *spec_inv_idx) && (*spec_inv_idx < (L_spec + 1))) { *bfi = 2; - calculate_nfseed( x, k, nf_seed ); + calculate_nfseed(x, k, nf_seed); return; } - + *bfi = 1; return; } - if ( lsbMode == 0 ) - { - findNonZero( x, idx, L_spec, &idx_len ); - if ( hrmode ) + if (lsbMode == 0) { + findNonZero(x, idx, L_spec, &idx_len); + if (hrmode) { idx_len *= EXT_RES_ITER_MAX; } - *nbits_residual = MIN( *nbits_residual, idx_len ); + *nbits_residual = MIN(*nbits_residual, idx_len); *residualPresent = 1; - memset( resBits, 0, MAX_RESBITS_LEN ); + memset(resBits, 0, MAX_RESBITS_LEN); - for ( k = 0; k < *nbits_residual; k++ ) - { - pc_check_bytes( &bp, &st, 0, mask_side, &bp_side ); - read_bit_fl( ptr, &mask_side, &bp_side, &tmp, &bp, &st, 0 ); - - if ( st.pc_return ) + for (k = 0; k < *nbits_residual; k++) { + pc_check_bytes(&bp, &st, 0, mask_side, &bp_side); + read_bit_fl(ptr, &mask_side, &bp_side, &tmp, &bp, &st, 0); + + if (st.pc_return) { - *b_left = st.pc_b_left; + *b_left = st.pc_b_left; return; } - - if ( st.pc_bbi == 2 ) + + if (st.pc_bbi == 2) { *bfi = 0; - memset( resBits, 0, sizeof( uint8_t ) * ( *nbits_residual ) ); - calculate_nfseed( x, k, nf_seed ); + memset(resBits, 0, sizeof(uint8_t) * (*nbits_residual)); + calculate_nfseed(x, k, nf_seed); return; } - - resBits[k >> 3] |= tmp << ( k & 7 ); + + resBits[k >> 3] |= tmp << (k & 7); } - } - else - { - for ( k = 0; k < lastnz; k = k + 2 ) - { - if ( save_lev[k] > 0 ) - { - if ( *nbits_residual == 0 ) - { + } else { + for (k = 0; k < lastnz; k = k + 2) { + if (save_lev[k] > 0) { + if (*nbits_residual == 0) { break; } - pc_check_bytes( &bp, &st, 0, mask_side, &bp_side ); - read_bit_fl( ptr, &mask_side, &bp_side, &bit, &bp, &st, 0 ); - - if ( st.pc_return ) + pc_check_bytes(&bp, &st, 0, mask_side, &bp_side); + read_bit_fl(ptr, &mask_side, &bp_side, &bit, &bp, &st, 0); + + if (st.pc_return) { *b_left = st.pc_b_left; return; } - if ( st.pc_bbi == 2 ) + if (st.pc_bbi == 2) { *bfi = 0; - memset( resBits, 0, sizeof( LC3_INT32 ) * ( *nbits_residual ) ); - calculate_nfseed( x, k, nf_seed ); + memset(resBits, 0, sizeof(LC3_INT32) * (*nbits_residual)); + calculate_nfseed(x, k, nf_seed); return; } - + *nbits_residual = *nbits_residual - 1; - if ( bit == 1 ) - { - if ( x[k] > 0 ) - { + if (bit == 1) { + if (x[k] > 0) { x[k] = x[k] + 1; - } - else if ( x[k] < 0 ) - { + } else if (x[k] < 0) { x[k] = x[k] - 1; - } - else - { - if ( *nbits_residual == 0 ) - { + } else { + if (*nbits_residual == 0) { break; } - pc_check_bytes( &bp, &st, 0, mask_side, &bp_side ); - read_bit_fl( ptr, &mask_side, &bp_side, &bit, &bp, &st, 0 ); - - if ( st.pc_return ) + pc_check_bytes(&bp, &st, 0, mask_side, &bp_side); + read_bit_fl(ptr, &mask_side, &bp_side, &bit, &bp, &st, 0); + + if (st.pc_return) { *b_left = st.pc_b_left; return; } - if ( st.pc_bbi == 2 ) + if (st.pc_bbi == 2) { *bfi = 0; - memset( resBits, 0, sizeof( LC3_INT32 ) * ( *nbits_residual ) ); - calculate_nfseed( x, k, nf_seed ); + memset(resBits, 0, sizeof(LC3_INT32) * (*nbits_residual)); + calculate_nfseed(x, k, nf_seed); return; } - + *nbits_residual = *nbits_residual - 1; - if ( bit == 0 ) - { + if (bit == 0) { x[k] = 1; - } - else - { + } else { x[k] = -1; } } } - if ( *nbits_residual == 0 ) - { + if (*nbits_residual == 0) { break; } - pc_check_bytes( &bp, &st, 0, mask_side, &bp_side ); - read_bit_fl( ptr, &mask_side, &bp_side, &bit, &bp, &st, 0 ); - - if ( st.pc_return ) + pc_check_bytes(&bp, &st, 0, mask_side, &bp_side); + read_bit_fl(ptr, &mask_side, &bp_side, &bit, &bp, &st, 0); + + if (st.pc_return) { *b_left = st.pc_b_left; return; } - if ( st.pc_bbi == 2 ) + if (st.pc_bbi == 2) { *bfi = 0; - memset( resBits, 0, sizeof( LC3_INT32 ) * ( *nbits_residual ) ); - calculate_nfseed( x, k, nf_seed ); + memset(resBits, 0, sizeof(LC3_INT32) * (*nbits_residual)); + calculate_nfseed(x, k, nf_seed); return; } - + *nbits_residual = *nbits_residual - 1; - if ( bit == 1 ) - { - if ( x[k + 1] > 0 ) - { + if (bit == 1) { + if (x[k + 1] > 0) { x[k + 1] = x[k + 1] + 1; - } - else if ( x[k + 1] < 0 ) - { + } else if (x[k + 1] < 0) { x[k + 1] = x[k + 1] - 1; - } - else - { - if ( *nbits_residual == 0 ) - { + } else { + if (*nbits_residual == 0) { break; } - pc_check_bytes( &bp, &st, 0, mask_side, &bp_side ); - read_bit_fl( ptr, &mask_side, &bp_side, &bit, &bp, &st, 0 ); - - if ( st.pc_return ) + pc_check_bytes(&bp, &st, 0, mask_side, &bp_side); + read_bit_fl(ptr, &mask_side, &bp_side, &bit, &bp, &st, 0); + + if (st.pc_return) { *b_left = st.pc_b_left; return; } - if ( st.pc_bbi == 2 ) + if (st.pc_bbi == 2) { *bfi = 0; - memset( resBits, 0, sizeof( LC3_INT32 ) * ( *nbits_residual ) ); - calculate_nfseed( x, k, nf_seed ); + memset(resBits, 0, sizeof(LC3_INT32) * (*nbits_residual)); + calculate_nfseed(x, k, nf_seed); return; } - + *nbits_residual = *nbits_residual - 1; - if ( bit == 0 ) - { + if (bit == 0) { x[k + 1] = 1; - } - else - { + } else { x[k + 1] = -1; } } @@ -875,132 +798,119 @@ void processAriDecoder_fl( LC3_UINT8 *bytes, LC3_INT bp_side, LC3_INT mask_side, } /* Noise-filling seed */ - calculate_nfseed( x, L_spec, nf_seed ); + calculate_nfseed(x, L_spec, nf_seed); /* Zero frame flag */ - if ( lastnz == 2 && x[0] == 0 && x[1] == 0 && gg_idx == 0 && fac_ns_idx == 7 ) - { + if (lastnz == 2 && x[0] == 0 && x[1] == 0 && gg_idx == 0 && fac_ns_idx == 7) { *zero_frame = 1; - } - else - { + } else { *zero_frame = 0; } - - if ( enc ) + + if (enc) { - if ( st.pc_bytes > 0 ) + if (st.pc_bytes > 0) { - if ( st.pc_b_left > numbytes ) + if (st.pc_b_left > numbytes) { *b_left = bp_side - st.pc_bytes; } } } - - if ( ( *bfi == 2 ) && ( *spec_inv_idx == ( L_spec + 1 ) ) ) + + if ((*bfi == 2) && (*spec_inv_idx == (L_spec + 1))) { *bfi = 0; } - + *spec_inv_idx = *spec_inv_idx - 1; } -void ac_encode_fl( Encoder_State_fl *st, LC3_INT sym_freq, LC3_INT cum_freq ) +void ac_encode_fl(Encoder_State_fl* st, LC3_INT sym_freq, LC3_INT cum_freq) { LC3_INT r = 0; - r = st->range >> 10; + r = st->range >> 10; st->low = st->low + r * cum_freq; - if ( ( st->low >> 24 ) == 1 ) - { + if ((st->low >> 24) == 1) { st->carry = 1; } - st->low = ( st->low ) & ( (LC3_INT) pow( 2, 24 ) - 1 ); + st->low = (st->low) & ((LC3_INT)pow(2, 24) - 1); st->range = r * sym_freq; - while ( st->range < (LC3_INT) pow( 2, 16 ) ) - { + while (st->range < (LC3_INT)pow(2, 16)) { st->range = st->range << 8; - ac_shift_fl( st ); + ac_shift_fl(st); } } -void ac_shift_fl( Encoder_State_fl *st ) +void ac_shift_fl(Encoder_State_fl* st) { - if ( st->low < 16711680 || st->carry == 1 ) - { - if ( st->cache >= 0 ) - { + if (st->low < 16711680 || st->carry == 1) { + if (st->cache >= 0) { st->ptr[st->bp] = st->cache + st->carry; - st->bp = st->bp + 1; + st->bp = st->bp + 1; } - while ( st->carry_count > 0 ) - { - st->ptr[st->bp] = ( st->carry + 255 ) & 255; - st->bp = st->bp + 1; + while (st->carry_count > 0) { + st->ptr[st->bp] = (st->carry + 255) & 255; + st->bp = st->bp + 1; st->carry_count = st->carry_count - 1; } st->cache = st->low >> 16; st->carry = 0; - } - else - { + } else { st->carry_count = st->carry_count + 1; } st->low = st->low << 8; - st->low = ( st->low ) & ( (LC3_INT) pow( 2, 24 ) - 1 ); + st->low = (st->low) & ((LC3_INT)pow(2, 24) - 1); } -void tns_order_freq_enc( LC3_INT enable_lpc_weighting, LC3_INT order, LC3_INT *symfreq, LC3_INT *cumfreq ) +void tns_order_freq_enc(LC3_INT enable_lpc_weighting, LC3_INT order, LC3_INT* symfreq, LC3_INT* cumfreq) { *symfreq = tns_freq_cf[enable_lpc_weighting][order] - tns_freq_cf[enable_lpc_weighting][order - 1]; *cumfreq = tns_freq_cf[enable_lpc_weighting][order - 1]; } -void tns_coef_freq_enc( LC3_INT k, LC3_INT idx, LC3_INT *symfreq, LC3_INT *cumfreq ) +void tns_coef_freq_enc(LC3_INT k, LC3_INT idx, LC3_INT* symfreq, LC3_INT* cumfreq) { *symfreq = tns_cf[k][idx + 1] - tns_cf[k][idx]; *cumfreq = tns_cf[k][idx]; } -void ac_freq_fl( LC3_INT pki, LC3_INT s, LC3_INT *symfreq, LC3_INT *cumfreq ) +void ac_freq_fl(LC3_INT pki, LC3_INT s, LC3_INT* symfreq, LC3_INT* cumfreq) { *symfreq = ari_spec_cumfreq_fl[pki][s + 1] - ari_spec_cumfreq_fl[pki][s]; *cumfreq = ari_spec_cumfreq_fl[pki][s]; } -void ac_finalize_fl( Encoder_State_fl *st ) +void ac_finalize_fl(Encoder_State_fl* st) { LC3_INT bits = 0, mask = 0, val = 0, over1 = 0, high = 0, over2 = 0, c = 0, b = 0; - bits = 24 - floor( LC3_LOGTWO( st->range ) ); - mask = ( (LC3_INT) pow( 2, 24 ) - 1 ) >> bits; - val = st->low + mask; + bits = 24 - floor(LC3_LOGTWO(st->range)); + mask = ((LC3_INT)pow(2, 24) - 1) >> bits; + val = st->low + mask; over1 = val >> 24; - val = ( val ) & ( (LC3_INT) pow( 2, 24 ) - 1 ); - high = st->low + st->range; + val = (val) & ((LC3_INT)pow(2, 24) - 1); + high = st->low + st->range; over2 = high >> 24; - high = high & ( (LC3_INT) pow( 2, 24 ) - 1 ); - val = val & ( ( (LC3_INT) pow( 2, 24 ) - 1 ) - mask ); + high = high & ((LC3_INT)pow(2, 24) - 1); + val = val & (((LC3_INT)pow(2, 24) - 1) - mask); - if ( over1 == over2 ) - { - if ( val + mask >= high ) - { + if (over1 == over2) { + if (val + mask >= high) { bits = bits + 1; mask = mask >> 1; - val = ( ( st->low + mask ) & ( (LC3_INT) pow( 2, 24 ) - 1 ) ) & ( ( (LC3_INT) pow( 2, 24 ) - 1 ) - mask ); + val = ((st->low + mask) & ((LC3_INT)pow(2, 24) - 1)) & (((LC3_INT)pow(2, 24) - 1) - mask); } - if ( val < st->low ) - { + if (val < st->low) { st->carry = 1; } } @@ -1009,57 +919,44 @@ void ac_finalize_fl( Encoder_State_fl *st ) b = bits; - if ( bits > 8 ) - { - for ( ; b >= 1; b = b - 8 ) - { - ac_shift_fl( st ); + if (bits > 8) { + for (; b >= 1; b = b - 8) { + ac_shift_fl(st); } - } - else - { - ac_shift_fl( st ); + } else { + ac_shift_fl(st); } bits = b; - if ( bits < 0 ) - { + if (bits < 0) { bits += 8; } - if ( st->carry_count > 0 ) - { + if (st->carry_count > 0) { st->ptr[st->bp] = st->cache; - st->bp = st->bp + 1; + st->bp = st->bp + 1; - for ( c = st->carry_count; c >= 2; c-- ) - { + for (c = st->carry_count; c >= 2; c--) { st->ptr[st->bp] = 255; - st->bp = st->bp + 1; + st->bp = st->bp + 1; } - write_uint_forward_fl( st, 255 << ( bits - 8 ), bits ); - } - else - { - write_uint_forward_fl( st, st->cache, bits ); + write_uint_forward_fl(st, 255 << (bits - 8), bits); + } else { + write_uint_forward_fl(st, st->cache, bits); } } -void write_uint_forward_fl( Encoder_State_fl *st, LC3_INT val, LC3_INT numbits ) +void write_uint_forward_fl(Encoder_State_fl* st, LC3_INT val, LC3_INT numbits) { LC3_INT k = 0, bit = 0, mask = 128; - for ( k = 0; k < numbits; k++ ) - { + for (k = 0; k < numbits; k++) { bit = val & mask; - if ( bit == 0 ) - { - st->ptr[st->bp] = st->ptr[st->bp] & ( 255 - mask ); - } - else - { + if (bit == 0) { + st->ptr[st->bp] = st->ptr[st->bp] & (255 - mask); + } else { st->ptr[st->bp] = st->ptr[st->bp] | mask; } @@ -1067,176 +964,159 @@ void write_uint_forward_fl( Encoder_State_fl *st, LC3_INT val, LC3_INT numbits ) } } -void ari_enc_init( Encoder_State_fl *st, LC3_UINT8 *bytes, LC3_INT *bp_side, LC3_INT *mask_side ) +void ari_enc_init(Encoder_State_fl* st, LC3_UINT8* bytes, LC3_INT* bp_side, LC3_INT* mask_side) { - st->ptr = bytes; - st->bp_side = bp_side; - st->mask_side = mask_side; - st->bp = 0; - st->low = 0; - st->range = (LC3_INT) pow( 2, 24 ) - 1; - st->cache = -1; - st->carry = 0; + st->ptr = bytes; + st->bp_side = bp_side; + st->mask_side = mask_side; + st->bp = 0; + st->low = 0; + st->range = (LC3_INT)pow(2, 24) - 1; + st->cache = -1; + st->carry = 0; st->carry_count = 0; } -LC3_INT sign( LC3_INT x ) +LC3_INT sign(LC3_INT x) { - if ( x > 0 ) + if (x > 0) return 1; - if ( x < 0 ) + if (x < 0) return -1; return 0; } -void processAriEncoder_fl( LC3_UINT8 *bytes, LC3_INT bp_side, LC3_INT mask_side, LC3_INT *x, LC3_INT *tns_order, LC3_INT tns_numfilters, LC3_INT *tns_idx, LC3_INT lastnz, LC3_INT *codingdata, uint8_t *res_bits, LC3_INT resBitsLen, LC3_INT lsbMode, LC3_INT nbbits, LC3_INT enable_lpc_weighting ) +void processAriEncoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side, LC3_INT* x, LC3_INT* tns_order, LC3_INT tns_numfilters, + LC3_INT* tns_idx, LC3_INT lastnz, LC3_INT* codingdata, uint8_t* res_bits, LC3_INT resBitsLen, LC3_INT lsbMode, + LC3_INT nbbits, LC3_INT enable_lpc_weighting) { - LC3_INT total_bits = 0, cumfreq = 0, symfreq = 0, k = 0, i = 0, j = 0, lev = 0, lev1 = 0; - LC3_INT bit1 = 0, bit2 = 0, lsb1 = 0, lsb2 = 0, a = 0, b = 0, bit = 0, pki = 0, nbits_side = 0; - LC3_INT nbits_residual_enc = 0, nbits_ari = 0, lsbs[MAX_LEN] = { 0 }, lsbsLen = 0; + LC3_INT total_bits = 0, cumfreq = 0, symfreq = 0, k = 0, i = 0, j = 0, lev = 0, lev1 = 0; + LC3_INT bit1 = 0, bit2 = 0, lsb1 = 0, lsb2 = 0, a = 0, b = 0, bit = 0, pki = 0, nbits_side = 0; + LC3_INT nbits_residual_enc = 0, nbits_ari = 0, lsbs[MAX_LEN] = {0}, lsbsLen = 0; Encoder_State_fl st; - ari_enc_init( &st, bytes, &bp_side, &mask_side ); + ari_enc_init(&st, bytes, &bp_side, &mask_side); total_bits = nbbits; /* TNS data */ - for ( i = 0; i < tns_numfilters; i++ ) - { - if ( tns_order[i] > 0 ) - { - tns_order_freq_enc( enable_lpc_weighting, tns_order[i], &symfreq, &cumfreq ); - ac_encode_fl( &st, symfreq, cumfreq ); - - for ( j = 0; j < tns_order[i]; j++ ) - { - tns_coef_freq_enc( j, tns_idx[i * 8 + j], &symfreq, &cumfreq ); - ac_encode_fl( &st, symfreq, cumfreq ); + for (i = 0; i < tns_numfilters; i++) { + if (tns_order[i] > 0) { + tns_order_freq_enc(enable_lpc_weighting, tns_order[i], &symfreq, &cumfreq); + ac_encode_fl(&st, symfreq, cumfreq); + + for (j = 0; j < tns_order[i]; j++) { + tns_coef_freq_enc(j, tns_idx[i * 8 + j], &symfreq, &cumfreq); + ac_encode_fl(&st, symfreq, cumfreq); } } } /* Spectral data */ - for ( k = 0; k < lastnz; k = k + 2 ) - { - for ( lev = 0; lev < codingdata[1]; lev++ ) - { - lev1 = MIN( lev, 3 ); - pki = ari_spec_lookup_fl[codingdata[0] + lev1 * 1024]; - ac_freq_fl( pki, 16, &symfreq, &cumfreq ); + for (k = 0; k < lastnz; k = k + 2) { + for (lev = 0; lev < codingdata[1]; lev++) { + lev1 = MIN(lev, 3); + pki = ari_spec_lookup_fl[codingdata[0] + lev1 * 1024]; + ac_freq_fl(pki, 16, &symfreq, &cumfreq); - ac_encode_fl( &st, symfreq, cumfreq ); - bit1 = ( abs( x[k] ) >> lev ) & 1; - bit2 = ( abs( x[k + 1] ) >> lev ) & 1; + ac_encode_fl(&st, symfreq, cumfreq); + bit1 = (abs(x[k]) >> lev) & 1; + bit2 = (abs(x[k + 1]) >> lev) & 1; - if ( lsbMode == 1 && lev == 0 ) - { + if (lsbMode == 1 && lev == 0) { lsb1 = bit1; lsb2 = bit2; - } - else - { - write_bit_backward_fl( st.ptr, st.bp_side, st.mask_side, bit1 ); - write_bit_backward_fl( st.ptr, st.bp_side, st.mask_side, bit2 ); + } else { + write_bit_backward_fl(st.ptr, st.bp_side, st.mask_side, bit1); + write_bit_backward_fl(st.ptr, st.bp_side, st.mask_side, bit2); } } - lev1 = MIN( MAX( codingdata[1], 0 ), 3 ); - pki = ari_spec_lookup_fl[codingdata[0] + lev1 * 1024]; + lev1 = MIN(MAX(codingdata[1], 0), 3); + pki = ari_spec_lookup_fl[codingdata[0] + lev1 * 1024]; - ac_freq_fl( pki, codingdata[2], &symfreq, &cumfreq ); - ac_encode_fl( &st, symfreq, cumfreq ); + ac_freq_fl(pki, codingdata[2], &symfreq, &cumfreq); + ac_encode_fl(&st, symfreq, cumfreq); - a = abs( x[k] ); - b = abs( x[k + 1] ); + a = abs(x[k]); + b = abs(x[k + 1]); - if ( lsbMode == 1 && codingdata[1] > 0 ) - { - a = a >> 1; + if (lsbMode == 1 && codingdata[1] > 0) { + a = a >> 1; lsbs[lsbsLen] = lsb1; lsbsLen++; - if ( a == 0 && x[k] != 0 ) - { - bit = MAX( 0, -sign( x[k] ) ); + if (a == 0 && x[k] != 0) { + bit = MAX(0, -sign(x[k])); lsbs[lsbsLen] = bit; lsbsLen++; } - b = b >> 1; + b = b >> 1; lsbs[lsbsLen] = lsb2; lsbsLen++; - if ( b == 0 && x[k + 1] != 0 ) - { - bit = MAX( 0, -sign( x[k + 1] ) ); + if (b == 0 && x[k + 1] != 0) { + bit = MAX(0, -sign(x[k + 1])); lsbs[lsbsLen] = bit; lsbsLen++; } } - if ( a != 0 ) - { - bit = MAX( 0, -sign( x[k] ) ); - write_bit_backward_fl( st.ptr, st.bp_side, st.mask_side, bit ); + if (a != 0) { + bit = MAX(0, -sign(x[k])); + write_bit_backward_fl(st.ptr, st.bp_side, st.mask_side, bit); } - if ( b != 0 ) - { - bit = MAX( 0, -sign( x[k + 1] ) ); - write_bit_backward_fl( st.ptr, st.bp_side, st.mask_side, bit ); + if (b != 0) { + bit = MAX(0, -sign(x[k + 1])); + write_bit_backward_fl(st.ptr, st.bp_side, st.mask_side, bit); } codingdata += 3; } /* Residual bits */ - nbits_side = total_bits - ( 8 * ( *( st.bp_side ) + 1 ) + 8 - LC3_LOGTWO( *( st.mask_side ) ) ); - nbits_ari = ( st.bp + 1 ) * 8 + 25 - floor( LC3_LOGTWO( st.range ) ); + nbits_side = total_bits - (8 * (*(st.bp_side) + 1) + 8 - LC3_LOGTWO(*(st.mask_side))); + nbits_ari = (st.bp + 1) * 8 + 25 - floor(LC3_LOGTWO(st.range)); - if ( st.cache >= 0 ) - { + if (st.cache >= 0) { nbits_ari = nbits_ari + 8; } - if ( st.carry_count > 0 ) - { + if (st.carry_count > 0) { nbits_ari = nbits_ari + st.carry_count * 8; } - nbits_residual_enc = MAX( total_bits - ( nbits_side + nbits_ari ), 0 ); + nbits_residual_enc = MAX(total_bits - (nbits_side + nbits_ari), 0); /* the max operation avoids in very rare cases, that - * nbits_residual_enc becomes negative; having overwritten - * the last bit(s) of the side information is in this case - * assumed to be not critical, since no spectral data bits - * were written */ - - if ( lsbMode == 0 ) - { - nbits_residual_enc = MIN( nbits_residual_enc, resBitsLen ); - for ( k = 0; k < nbits_residual_enc; k++ ) - { - if ( res_bits[k >> 3] & ( 1 << ( k & 7 ) ) ) + * nbits_residual_enc becomes negative; having overwritten + * the last bit(s) of the side information is in this case + * assumed to be not critical, since no spectral data bits + * were written */ + + if (lsbMode == 0) { + nbits_residual_enc = MIN(nbits_residual_enc, resBitsLen); + for (k = 0; k < nbits_residual_enc; k++) { + if (res_bits[k >> 3] & (1 << (k & 7))) { - write_bit_backward_fl( st.ptr, st.bp_side, st.mask_side, 1 ); + write_bit_backward_fl(st.ptr, st.bp_side, st.mask_side, 1); } else { - write_bit_backward_fl( st.ptr, st.bp_side, st.mask_side, 0 ); + write_bit_backward_fl(st.ptr, st.bp_side, st.mask_side, 0); } } - } - else - { - nbits_residual_enc = MIN( nbits_residual_enc, lsbsLen ); + } else { + nbits_residual_enc = MIN(nbits_residual_enc, lsbsLen); - for ( k = 0; k < nbits_residual_enc; k++ ) - { - write_bit_backward_fl( st.ptr, st.bp_side, st.mask_side, lsbs[k] ); + for (k = 0; k < nbits_residual_enc; k++) { + write_bit_backward_fl(st.ptr, st.bp_side, st.mask_side, lsbs[k]); } } - ac_finalize_fl( &st ); + ac_finalize_fl(&st); } + diff --git a/lib_lc3plus/attack_detector.c b/lib_lc3plus/attack_detector.c index 56dd248519..c9f7c0a94c 100644 --- a/lib_lc3plus/attack_detector.c +++ b/lib_lc3plus/attack_detector.c @@ -1,20 +1,21 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -void attack_detector_fl( LC3_FLOAT *in, LC3_INT frame_size, LC3_INT fs, LC3_INT *lastAttackPosition, LC3_FLOAT *accNrg, LC3_INT *attackFlag, LC3_FLOAT *attdec_filter_mem, LC3_INT attackHandlingOn, LC3_INT attdec_nblocks, LC3_INT attdec_hangover_threshold ) +void attack_detector_fl(LC3_FLOAT* in, LC3_INT frame_size, LC3_INT fs, LC3_INT* lastAttackPosition, LC3_FLOAT* accNrg, LC3_INT* attackFlag, + LC3_FLOAT* attdec_filter_mem, LC3_INT attackHandlingOn, LC3_INT attdec_nblocks, LC3_INT attdec_hangover_threshold) { - LC3_FLOAT f_sig[160] = { 0 }, block_nrg[4] = { 0 }, sum = 0, tmpEne = 0, *ptr = NULL, tmp[162] = { 0 }; - LC3_INT i = 0, j = 0, attackPosition = 0; + LC3_FLOAT f_sig[160] = {0}, block_nrg[4] = {0}, sum = 0, tmpEne = 0, *ptr = NULL, tmp[162] = {0}; + LC3_INT i = 0, j = 0, attackPosition = 0; LC3_FLOAT mval = 0; LC3_INT frame_size_16k = attdec_nblocks * 40; @@ -22,97 +23,80 @@ void attack_detector_fl( LC3_FLOAT *in, LC3_INT frame_size, LC3_INT fs, LC3_INT ptr = &tmp[2]; - if ( attackHandlingOn ) - { + + if (attackHandlingOn) { /* Decimate 96, 48 and 32 kHz signals to 16 kHz */ - if ( fs == 96000 ) - { - for ( i = 0; i < frame_size; ) - { + if (fs == 96000) { + for (i = 0; i < frame_size;) { ptr[j] = in[i] + in[i + 1] + in[i + 2] + in[i + 3] + in[i + 4] + in[i + 5]; - i = i + 6; + i = i + 6; j++; } mval = 1e-5; - } - else if ( fs == 48000 ) - { + } else if (fs == 48000) { j = 0; - for ( i = 0; i < frame_size; ) - { - ptr[j] = ( in[i] + in[i + 1] + in[i + 2] ); - i = i + 3; + for (i = 0; i < frame_size;) { + ptr[j] = (in[i] + in[i + 1] + in[i + 2]); + i = i + 3; j++; } - } - else if ( fs == 32000 ) - { + } else if (fs == 32000) { j = 0; - for ( i = 0; i < frame_size; ) - { - ptr[j] = ( in[i] + in[i + 1] ); - i = i + 2; + for (i = 0; i < frame_size;) { + ptr[j] = (in[i] + in[i + 1]); + i = i + 2; j++; } - } - else if ( fs == 24000 ) - { + } else if (fs == 24000) { j = 0; - for ( i = 0; i < frame_size; ) - { - ptr[j] = ( in[i] + ( in[i + 1] + in[i + 2] ) / 2.0 ); - i = i + 3; + for (i = 0; i < frame_size;) { + ptr[j] = (in[i] + (in[i + 1] + in[i + 2]) / 2.0); + i = i + 3; j++; } } /* Filter */ - ptr[-2] = (LC3_FLOAT) attdec_filter_mem[0]; - ptr[-1] = (LC3_FLOAT) attdec_filter_mem[1]; + ptr[-2] = (LC3_FLOAT)attdec_filter_mem[0]; + ptr[-1] = (LC3_FLOAT)attdec_filter_mem[1]; attdec_filter_mem[0] = ptr[frame_size_16k - 2]; attdec_filter_mem[1] = ptr[frame_size_16k - 1]; - for ( i = 159; i >= 0; i-- ) - { + for (i = 159; i >= 0; i--) { tmpEne = 0; tmpEne += ptr[i] * 0.375; - tmpEne += ptr[i - 1] * ( -0.5 ); - tmpEne += ptr[i - 2] * ( 0.125 ); + tmpEne += ptr[i - 1] * (-0.5); + tmpEne += ptr[i - 2] * (0.125); f_sig[i] = tmpEne; } - for ( i = 0; i < attdec_nblocks; i++ ) - { + for (i = 0; i < attdec_nblocks; i++) { sum = 0; - for ( j = 0; j < 40; j++ ) - { + for (j = 0; j < 40; j++) { sum += f_sig[j + i * 40] * f_sig[j + i * 40]; } block_nrg[i] = sum; } - *attackFlag = 0; + *attackFlag = 0; attackPosition = -1; - for ( i = 0; i < attdec_nblocks; i++ ) - { + for (i = 0; i < attdec_nblocks; i++) { tmpEne = block_nrg[i] / 8.5; - if ( tmpEne > MAX( *accNrg, mval ) ) - { - *attackFlag = 1; + if (tmpEne > MAX(*accNrg, mval)) { + *attackFlag = 1; attackPosition = i + 1; } - *accNrg = MAX( block_nrg[i], 0.25 * ( *accNrg ) ); + *accNrg = MAX(block_nrg[i], 0.25 * (*accNrg)); } - if ( *lastAttackPosition > attdec_hangover_threshold ) - { + if (*lastAttackPosition > attdec_hangover_threshold) { *attackFlag = 1; } diff --git a/lib_lc3plus/clib.h b/lib_lc3plus/clib.h index 163da2baae..bd70927808 100644 --- a/lib_lc3plus/clib.h +++ b/lib_lc3plus/clib.h @@ -1,12 +1,12 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #ifndef CLIB_H #define CLIB_H diff --git a/lib_lc3plus/constants.c b/lib_lc3plus/constants.c index d2dc0bb822..8189761a04 100644 --- a/lib_lc3plus/constants.c +++ b/lib_lc3plus/constants.c @@ -1,114 +1,65 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" /* DCT */ -#define ENTRY_DCT2_1 \ - { \ - 0.353553, 0.000000 \ - } -#define ENTRY_DCT2_2 \ - { \ - 0.351851, -0.034654 \ - } -#define ENTRY_DCT2_3 \ - { \ - 0.346760, -0.068975 \ - } -#define ENTRY_DCT2_4 \ - { \ - 0.338329, -0.102631 \ - } -#define ENTRY_DCT2_5 \ - { \ - 0.326641, -0.135299 \ - } -#define ENTRY_DCT2_6 \ - { \ - 0.311806, -0.166664 \ - } -#define ENTRY_DCT2_7 \ - { \ - 0.293969, -0.196424 \ - } -#define ENTRY_DCT2_8 \ - { \ - 0.273300, -0.224292 \ - } -#define ENTRY_DCT2_9 \ - { \ - 0.250000, -0.250000 \ - } -#define ENTRY_DCT2_10 \ - { \ - 0.224292, -0.273300 \ - } -#define ENTRY_DCT2_11 \ - { \ - 0.196424, -0.293969 \ - } -#define ENTRY_DCT2_12 \ - { \ - 0.166664, -0.311806 \ - } -#define ENTRY_DCT2_13 \ - { \ - 0.135299, -0.326641 \ - } -#define ENTRY_DCT2_14 \ - { \ - 0.102631, -0.338329 \ - } -#define ENTRY_DCT2_15 \ - { \ - 0.068975, -0.346760 \ - } -#define ENTRY_DCT2_16 \ - { \ - 0.034654, -0.351851 \ - } +#define ENTRY_DCT2_1 {0.353553, 0.000000} +#define ENTRY_DCT2_2 {0.351851, -0.034654} +#define ENTRY_DCT2_3 {0.346760, -0.068975} +#define ENTRY_DCT2_4 {0.338329, -0.102631} +#define ENTRY_DCT2_5 {0.326641, -0.135299} +#define ENTRY_DCT2_6 {0.311806, -0.166664} +#define ENTRY_DCT2_7 {0.293969, -0.196424} +#define ENTRY_DCT2_8 {0.273300, -0.224292} +#define ENTRY_DCT2_9 {0.250000, -0.250000} +#define ENTRY_DCT2_10 {0.224292, -0.273300} +#define ENTRY_DCT2_11 {0.196424, -0.293969} +#define ENTRY_DCT2_12 {0.166664, -0.311806} +#define ENTRY_DCT2_13 {0.135299, -0.326641} +#define ENTRY_DCT2_14 {0.102631, -0.338329} +#define ENTRY_DCT2_15 {0.068975, -0.346760} +#define ENTRY_DCT2_16 {0.034654, -0.351851} const Complex dct2_16[16] = { - ENTRY_DCT2_1, - ENTRY_DCT2_2, - ENTRY_DCT2_3, - ENTRY_DCT2_4, - ENTRY_DCT2_5, - ENTRY_DCT2_6, - ENTRY_DCT2_7, - ENTRY_DCT2_8, - ENTRY_DCT2_9, - ENTRY_DCT2_10, - ENTRY_DCT2_11, - ENTRY_DCT2_12, - ENTRY_DCT2_13, - ENTRY_DCT2_14, - ENTRY_DCT2_15, - ENTRY_DCT2_16 -}; - -const LC3_INT ari_tns_order_cf[2][9] = { { 0, 3, 12, 35, 89, 200, 390, 658, 1024 }, - { 0, 14, 56, 156, 313, 494, 672, 839, 1024 } }; +ENTRY_DCT2_1, +ENTRY_DCT2_2, +ENTRY_DCT2_3, +ENTRY_DCT2_4, +ENTRY_DCT2_5, +ENTRY_DCT2_6, +ENTRY_DCT2_7, +ENTRY_DCT2_8, +ENTRY_DCT2_9, +ENTRY_DCT2_10, +ENTRY_DCT2_11, +ENTRY_DCT2_12, +ENTRY_DCT2_13, +ENTRY_DCT2_14, +ENTRY_DCT2_15, +ENTRY_DCT2_16 +}; + +const LC3_INT ari_tns_order_cf[2][9] = {{0, 3, 12, 35, 89, 200, 390, 658, 1024}, + {0, 14, 56, 156, 313, 494, 672, 839, 1024}}; const LC3_INT ari_tns_freq_cf[8][18] = { - { 0, 1, 6, 21, 52, 106, 192, 289, 409, 568, 720, 831, 935, 994, 1016, 1022, 1023, 1024 }, - { 0, 1, 2, 3, 4, 17, 60, 154, 293, 466, 626, 780, 911, 989, 1016, 1022, 1023, 1024 }, - { 0, 1, 2, 3, 4, 13, 56, 162, 361, 578, 788, 929, 1003, 1020, 1021, 1022, 1023, 1024 }, - { 0, 1, 2, 3, 4, 6, 17, 66, 270, 555, 852, 972, 1011, 1020, 1021, 1022, 1023, 1024 }, - { 0, 1, 2, 3, 4, 5, 12, 54, 295, 636, 950, 1008, 1017, 1020, 1021, 1022, 1023, 1024 }, - { 0, 1, 2, 3, 4, 5, 6, 19, 224, 590, 967, 1014, 1019, 1020, 1021, 1022, 1023, 1024 }, - { 0, 1, 2, 3, 4, 5, 6, 19, 300, 630, 1001, 1018, 1019, 1020, 1021, 1022, 1023, 1024 }, - { 0, 1, 2, 3, 4, 5, 6, 11, 308, 309, 991, 1017, 1019, 1020, 1021, 1022, 1023, 1024 } -}; + {0, 1, 6, 21, 52, 106, 192, 289, 409, 568, 720, 831, 935, 994, 1016, 1022, 1023, 1024}, + {0, 1, 2, 3, 4, 17, 60, 154, 293, 466, 626, 780, 911, 989, 1016, 1022, 1023, 1024}, + {0, 1, 2, 3, 4, 13, 56, 162, 361, 578, 788, 929, 1003, 1020, 1021, 1022, 1023, 1024}, + {0, 1, 2, 3, 4, 6, 17, 66, 270, 555, 852, 972, 1011, 1020, 1021, 1022, 1023, 1024}, + {0, 1, 2, 3, 4, 5, 12, 54, 295, 636, 950, 1008, 1017, 1020, 1021, 1022, 1023, 1024}, + {0, 1, 2, 3, 4, 5, 6, 19, 224, 590, 967, 1014, 1019, 1020, 1021, 1022, 1023, 1024}, + {0, 1, 2, 3, 4, 5, 6, 19, 300, 630, 1001, 1018, 1019, 1020, 1021, 1022, 1023, 1024}, + {0, 1, 2, 3, 4, 5, 6, 11, 308, 309, 991, 1017, 1019, 1020, 1021, 1022, 1023, 1024}}; const LC3_INT ari_spec_lookup_fl[4096] = { 0x01, 0x27, 0x07, 0x19, 0x16, 0x16, 0x1C, 0x16, 0x16, 0x16, 0x16, 0x1C, 0x1C, 0x1C, 0x22, 0x1F, 0x1F, 0x28, 0x2B, @@ -326,736 +277,723 @@ const LC3_INT ari_spec_lookup_fl[4096] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; const LC3_INT ari_spec_cumfreq_fl[64][18] = { - { 0, 1, 2, 177, 225, 226, 227, 336, 372, 543, 652, 699, 719, 768, 804, 824, 834, 1024 }, - { 0, 18, 44, 61, 71, 98, 135, 159, 175, 197, 229, 251, 265, 282, 308, 328, 341, 1024 }, - { 0, 71, 163, 212, 237, 318, 420, 481, 514, 556, 613, 652, 675, 697, 727, 749, 764, 1024 }, - { 0, 160, 290, 336, 354, 475, 598, 653, 677, 722, 777, 808, 823, 842, 866, 881, 890, 1024 }, - { 0, 71, 144, 177, 195, 266, 342, 385, 411, 445, 489, 519, 539, 559, 586, 607, 622, 1024 }, - { 0, 48, 108, 140, 159, 217, 285, 327, 354, 385, 427, 457, 478, 497, 524, 545, 561, 1024 }, - { 0, 138, 247, 290, 308, 419, 531, 584, 609, 655, 710, 742, 759, 780, 807, 825, 836, 1024 }, - { 0, 16, 40, 62, 79, 103, 139, 170, 195, 215, 245, 270, 290, 305, 327, 346, 362, 1024 }, - { 0, 579, 729, 741, 743, 897, 970, 980, 982, 996, 1007, 1010, 1011, 1014, 1017, 1018, 1019, 1024 }, - { 0, 398, 582, 607, 612, 788, 902, 925, 931, 956, 979, 987, 990, 996, 1002, 1005, 1007, 1024 }, - { 0, 13, 34, 52, 63, 83, 112, 134, 149, 163, 183, 199, 211, 221, 235, 247, 257, 1024 }, - { 0, 281, 464, 501, 510, 681, 820, 857, 867, 902, 938, 953, 959, 968, 978, 984, 987, 1024 }, - { 0, 198, 362, 408, 421, 575, 722, 773, 789, 832, 881, 905, 915, 928, 944, 954, 959, 1024 }, - { 0, 1, 2, 95, 139, 140, 141, 213, 251, 337, 407, 450, 475, 515, 551, 576, 592, 1024 }, - { 0, 133, 274, 338, 366, 483, 605, 664, 691, 730, 778, 807, 822, 837, 857, 870, 878, 1024 }, - { 0, 128, 253, 302, 320, 443, 577, 636, 659, 708, 767, 799, 814, 833, 857, 872, 881, 1024 }, - { 0, 1, 2, 25, 42, 43, 44, 67, 85, 105, 126, 144, 159, 174, 191, 205, 217, 1024 }, - { 0, 70, 166, 229, 267, 356, 468, 533, 569, 606, 653, 685, 705, 722, 745, 762, 774, 1024 }, - { 0, 55, 130, 175, 200, 268, 358, 416, 449, 488, 542, 581, 606, 628, 659, 683, 699, 1024 }, - { 0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 1024 }, - { 0, 34, 85, 123, 147, 196, 265, 317, 352, 386, 433, 470, 497, 518, 549, 574, 593, 1024 }, - { 0, 30, 73, 105, 127, 170, 229, 274, 305, 335, 377, 411, 436, 455, 483, 506, 524, 1024 }, - { 0, 9, 24, 38, 51, 65, 87, 108, 126, 139, 159, 177, 193, 204, 221, 236, 250, 1024 }, - { 0, 30, 74, 105, 125, 166, 224, 266, 294, 322, 361, 391, 413, 431, 457, 478, 494, 1024 }, - { 0, 15, 38, 58, 73, 95, 128, 156, 178, 196, 222, 245, 263, 276, 296, 314, 329, 1024 }, - { 0, 11, 28, 44, 57, 74, 100, 123, 142, 157, 179, 199, 216, 228, 246, 262, 276, 1024 }, - { 0, 448, 619, 639, 643, 821, 926, 944, 948, 971, 991, 998, 1000, 1005, 1010, 1012, 1013, 1024 }, - { 0, 332, 520, 549, 555, 741, 874, 903, 910, 940, 970, 981, 985, 991, 998, 1002, 1004, 1024 }, - { 0, 8, 21, 34, 45, 58, 78, 96, 112, 124, 141, 157, 170, 180, 194, 207, 219, 1024 }, - { 0, 239, 415, 457, 468, 631, 776, 820, 833, 872, 914, 933, 940, 951, 964, 971, 975, 1024 }, - { 0, 165, 310, 359, 375, 513, 652, 707, 727, 774, 828, 856, 868, 884, 904, 916, 923, 1024 }, - { 0, 3, 8, 13, 18, 23, 30, 37, 44, 48, 55, 62, 68, 72, 78, 84, 90, 1024 }, - { 0, 115, 237, 289, 311, 422, 547, 608, 635, 680, 737, 771, 788, 807, 832, 849, 859, 1024 }, - { 0, 107, 221, 272, 293, 399, 521, 582, 610, 656, 714, 749, 767, 787, 813, 831, 842, 1024 }, - { 0, 6, 16, 26, 35, 45, 60, 75, 89, 98, 112, 125, 137, 145, 157, 168, 178, 1024 }, - { 0, 72, 160, 210, 236, 320, 422, 482, 514, 555, 608, 644, 665, 685, 712, 732, 745, 1024 }, - { 0, 45, 108, 153, 183, 244, 327, 385, 421, 455, 502, 536, 559, 578, 605, 626, 641, 1024 }, - { 0, 1, 2, 9, 16, 17, 18, 26, 34, 40, 48, 55, 62, 68, 75, 82, 88, 1024 }, - { 0, 29, 73, 108, 132, 174, 236, 284, 318, 348, 391, 426, 452, 471, 500, 524, 543, 1024 }, - { 0, 20, 51, 76, 93, 123, 166, 200, 225, 247, 279, 305, 326, 342, 365, 385, 401, 1024 }, - { 0, 742, 845, 850, 851, 959, 997, 1001, 1002, 1009, 1014, 1016, 1017, 1019, 1020, 1021, 1022, 1024 }, - { 0, 42, 94, 121, 137, 186, 244, 280, 303, 330, 366, 392, 410, 427, 451, 470, 484, 1024 }, - { 0, 13, 33, 51, 66, 85, 114, 140, 161, 178, 203, 225, 243, 256, 275, 292, 307, 1024 }, - { 0, 501, 670, 689, 693, 848, 936, 952, 956, 975, 991, 997, 999, 1004, 1008, 1010, 1011, 1024 }, - { 0, 445, 581, 603, 609, 767, 865, 888, 895, 926, 954, 964, 968, 977, 986, 991, 993, 1024 }, - { 0, 285, 442, 479, 489, 650, 779, 818, 830, 870, 912, 930, 937, 949, 963, 971, 975, 1024 }, - { 0, 349, 528, 561, 569, 731, 852, 883, 892, 923, 953, 965, 970, 978, 987, 992, 994, 1024 }, - { 0, 199, 355, 402, 417, 563, 700, 750, 767, 811, 860, 884, 894, 909, 926, 936, 942, 1024 }, - { 0, 141, 275, 325, 343, 471, 606, 664, 686, 734, 791, 822, 836, 854, 877, 891, 899, 1024 }, - { 0, 243, 437, 493, 510, 649, 775, 820, 836, 869, 905, 923, 931, 941, 953, 960, 964, 1024 }, - { 0, 91, 197, 248, 271, 370, 487, 550, 580, 625, 684, 721, 741, 761, 788, 807, 819, 1024 }, - { 0, 107, 201, 242, 262, 354, 451, 503, 531, 573, 626, 660, 680, 701, 730, 751, 765, 1024 }, - { 0, 168, 339, 407, 432, 553, 676, 731, 755, 789, 830, 854, 866, 879, 895, 906, 912, 1024 }, - { 0, 67, 147, 191, 214, 290, 384, 441, 472, 513, 567, 604, 627, 648, 678, 700, 715, 1024 }, - { 0, 46, 109, 148, 171, 229, 307, 359, 391, 427, 476, 513, 537, 558, 588, 612, 629, 1024 }, - { 0, 848, 918, 920, 921, 996, 1012, 1013, 1014, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024 }, - { 0, 36, 88, 123, 145, 193, 260, 308, 340, 372, 417, 452, 476, 496, 525, 548, 565, 1024 }, - { 0, 24, 61, 90, 110, 145, 196, 237, 266, 292, 330, 361, 385, 403, 430, 453, 471, 1024 }, - { 0, 85, 182, 230, 253, 344, 454, 515, 545, 590, 648, 685, 706, 727, 756, 776, 789, 1024 }, - { 0, 22, 55, 82, 102, 135, 183, 222, 252, 278, 315, 345, 368, 385, 410, 431, 448, 1024 }, - { 0, 1, 2, 56, 89, 90, 91, 140, 172, 221, 268, 303, 328, 358, 388, 412, 430, 1024 }, - { 0, 45, 109, 152, 177, 239, 320, 376, 411, 448, 499, 537, 563, 585, 616, 640, 658, 1024 }, - { 0, 247, 395, 433, 445, 599, 729, 771, 785, 829, 875, 896, 905, 920, 937, 946, 951, 1024 }, - { 0, 231, 367, 408, 423, 557, 676, 723, 742, 786, 835, 860, 872, 889, 909, 921, 928, 1024 } -}; + {0, 1, 2, 177, 225, 226, 227, 336, 372, 543, 652, 699, 719, 768, 804, 824, 834, 1024}, + {0, 18, 44, 61, 71, 98, 135, 159, 175, 197, 229, 251, 265, 282, 308, 328, 341, 1024}, + {0, 71, 163, 212, 237, 318, 420, 481, 514, 556, 613, 652, 675, 697, 727, 749, 764, 1024}, + {0, 160, 290, 336, 354, 475, 598, 653, 677, 722, 777, 808, 823, 842, 866, 881, 890, 1024}, + {0, 71, 144, 177, 195, 266, 342, 385, 411, 445, 489, 519, 539, 559, 586, 607, 622, 1024}, + {0, 48, 108, 140, 159, 217, 285, 327, 354, 385, 427, 457, 478, 497, 524, 545, 561, 1024}, + {0, 138, 247, 290, 308, 419, 531, 584, 609, 655, 710, 742, 759, 780, 807, 825, 836, 1024}, + {0, 16, 40, 62, 79, 103, 139, 170, 195, 215, 245, 270, 290, 305, 327, 346, 362, 1024}, + {0, 579, 729, 741, 743, 897, 970, 980, 982, 996, 1007, 1010, 1011, 1014, 1017, 1018, 1019, 1024}, + {0, 398, 582, 607, 612, 788, 902, 925, 931, 956, 979, 987, 990, 996, 1002, 1005, 1007, 1024}, + {0, 13, 34, 52, 63, 83, 112, 134, 149, 163, 183, 199, 211, 221, 235, 247, 257, 1024}, + {0, 281, 464, 501, 510, 681, 820, 857, 867, 902, 938, 953, 959, 968, 978, 984, 987, 1024}, + {0, 198, 362, 408, 421, 575, 722, 773, 789, 832, 881, 905, 915, 928, 944, 954, 959, 1024}, + {0, 1, 2, 95, 139, 140, 141, 213, 251, 337, 407, 450, 475, 515, 551, 576, 592, 1024}, + {0, 133, 274, 338, 366, 483, 605, 664, 691, 730, 778, 807, 822, 837, 857, 870, 878, 1024}, + {0, 128, 253, 302, 320, 443, 577, 636, 659, 708, 767, 799, 814, 833, 857, 872, 881, 1024}, + {0, 1, 2, 25, 42, 43, 44, 67, 85, 105, 126, 144, 159, 174, 191, 205, 217, 1024}, + {0, 70, 166, 229, 267, 356, 468, 533, 569, 606, 653, 685, 705, 722, 745, 762, 774, 1024}, + {0, 55, 130, 175, 200, 268, 358, 416, 449, 488, 542, 581, 606, 628, 659, 683, 699, 1024}, + {0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 1024}, + {0, 34, 85, 123, 147, 196, 265, 317, 352, 386, 433, 470, 497, 518, 549, 574, 593, 1024}, + {0, 30, 73, 105, 127, 170, 229, 274, 305, 335, 377, 411, 436, 455, 483, 506, 524, 1024}, + {0, 9, 24, 38, 51, 65, 87, 108, 126, 139, 159, 177, 193, 204, 221, 236, 250, 1024}, + {0, 30, 74, 105, 125, 166, 224, 266, 294, 322, 361, 391, 413, 431, 457, 478, 494, 1024}, + {0, 15, 38, 58, 73, 95, 128, 156, 178, 196, 222, 245, 263, 276, 296, 314, 329, 1024}, + {0, 11, 28, 44, 57, 74, 100, 123, 142, 157, 179, 199, 216, 228, 246, 262, 276, 1024}, + {0, 448, 619, 639, 643, 821, 926, 944, 948, 971, 991, 998, 1000, 1005, 1010, 1012, 1013, 1024}, + {0, 332, 520, 549, 555, 741, 874, 903, 910, 940, 970, 981, 985, 991, 998, 1002, 1004, 1024}, + {0, 8, 21, 34, 45, 58, 78, 96, 112, 124, 141, 157, 170, 180, 194, 207, 219, 1024}, + {0, 239, 415, 457, 468, 631, 776, 820, 833, 872, 914, 933, 940, 951, 964, 971, 975, 1024}, + {0, 165, 310, 359, 375, 513, 652, 707, 727, 774, 828, 856, 868, 884, 904, 916, 923, 1024}, + {0, 3, 8, 13, 18, 23, 30, 37, 44, 48, 55, 62, 68, 72, 78, 84, 90, 1024}, + {0, 115, 237, 289, 311, 422, 547, 608, 635, 680, 737, 771, 788, 807, 832, 849, 859, 1024}, + {0, 107, 221, 272, 293, 399, 521, 582, 610, 656, 714, 749, 767, 787, 813, 831, 842, 1024}, + {0, 6, 16, 26, 35, 45, 60, 75, 89, 98, 112, 125, 137, 145, 157, 168, 178, 1024}, + {0, 72, 160, 210, 236, 320, 422, 482, 514, 555, 608, 644, 665, 685, 712, 732, 745, 1024}, + {0, 45, 108, 153, 183, 244, 327, 385, 421, 455, 502, 536, 559, 578, 605, 626, 641, 1024}, + {0, 1, 2, 9, 16, 17, 18, 26, 34, 40, 48, 55, 62, 68, 75, 82, 88, 1024}, + {0, 29, 73, 108, 132, 174, 236, 284, 318, 348, 391, 426, 452, 471, 500, 524, 543, 1024}, + {0, 20, 51, 76, 93, 123, 166, 200, 225, 247, 279, 305, 326, 342, 365, 385, 401, 1024}, + {0, 742, 845, 850, 851, 959, 997, 1001, 1002, 1009, 1014, 1016, 1017, 1019, 1020, 1021, 1022, 1024}, + {0, 42, 94, 121, 137, 186, 244, 280, 303, 330, 366, 392, 410, 427, 451, 470, 484, 1024}, + {0, 13, 33, 51, 66, 85, 114, 140, 161, 178, 203, 225, 243, 256, 275, 292, 307, 1024}, + {0, 501, 670, 689, 693, 848, 936, 952, 956, 975, 991, 997, 999, 1004, 1008, 1010, 1011, 1024}, + {0, 445, 581, 603, 609, 767, 865, 888, 895, 926, 954, 964, 968, 977, 986, 991, 993, 1024}, + {0, 285, 442, 479, 489, 650, 779, 818, 830, 870, 912, 930, 937, 949, 963, 971, 975, 1024}, + {0, 349, 528, 561, 569, 731, 852, 883, 892, 923, 953, 965, 970, 978, 987, 992, 994, 1024}, + {0, 199, 355, 402, 417, 563, 700, 750, 767, 811, 860, 884, 894, 909, 926, 936, 942, 1024}, + {0, 141, 275, 325, 343, 471, 606, 664, 686, 734, 791, 822, 836, 854, 877, 891, 899, 1024}, + {0, 243, 437, 493, 510, 649, 775, 820, 836, 869, 905, 923, 931, 941, 953, 960, 964, 1024}, + {0, 91, 197, 248, 271, 370, 487, 550, 580, 625, 684, 721, 741, 761, 788, 807, 819, 1024}, + {0, 107, 201, 242, 262, 354, 451, 503, 531, 573, 626, 660, 680, 701, 730, 751, 765, 1024}, + {0, 168, 339, 407, 432, 553, 676, 731, 755, 789, 830, 854, 866, 879, 895, 906, 912, 1024}, + {0, 67, 147, 191, 214, 290, 384, 441, 472, 513, 567, 604, 627, 648, 678, 700, 715, 1024}, + {0, 46, 109, 148, 171, 229, 307, 359, 391, 427, 476, 513, 537, 558, 588, 612, 629, 1024}, + {0, 848, 918, 920, 921, 996, 1012, 1013, 1014, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024}, + {0, 36, 88, 123, 145, 193, 260, 308, 340, 372, 417, 452, 476, 496, 525, 548, 565, 1024}, + {0, 24, 61, 90, 110, 145, 196, 237, 266, 292, 330, 361, 385, 403, 430, 453, 471, 1024}, + {0, 85, 182, 230, 253, 344, 454, 515, 545, 590, 648, 685, 706, 727, 756, 776, 789, 1024}, + {0, 22, 55, 82, 102, 135, 183, 222, 252, 278, 315, 345, 368, 385, 410, 431, 448, 1024}, + {0, 1, 2, 56, 89, 90, 91, 140, 172, 221, 268, 303, 328, 358, 388, 412, 430, 1024}, + {0, 45, 109, 152, 177, 239, 320, 376, 411, 448, 499, 537, 563, 585, 616, 640, 658, 1024}, + {0, 247, 395, 433, 445, 599, 729, 771, 785, 829, 875, 896, 905, 920, 937, 946, 951, 1024}, + {0, 231, 367, 408, 423, 557, 676, 723, 742, 786, 835, 860, 872, 889, 909, 921, 928, 1024}}; const LC3_INT ari_spec_bits_fl[64][17] = { - { 20480, 20480, 5220, 9042, 20480, 20480, 6619, 9892, 5289, 6619, 9105, 11629, 8982, 9892, 11629, 13677, 4977 }, - { 11940, 10854, 12109, 13677, 10742, 9812, 11090, 12288, 11348, 10240, 11348, 12683, 12109, 10854, 11629, 12902, - 1197 }, - { 7886, 7120, 8982, 10970, 7496, 6815, 8334, 10150, 9437, 8535, 9656, 11216, 11348, 10431, 11348, 12479, 4051 }, - { 5485, 6099, 9168, 11940, 6311, 6262, 8640, 11090, 9233, 8640, 10334, 12479, 11781, 11090, 12479, 13988, 6009 }, - { 7886, 7804, 10150, 11940, 7886, 7685, 9368, 10854, 10061, 9300, 10431, 11629, 11629, 10742, 11485, 12479, 2763 }, - { 9042, 8383, 10240, 11781, 8483, 8013, 9437, 10742, 10334, 9437, 10431, 11485, 11781, 10742, 11485, 12288, 2346 }, - { 5922, 6619, 9368, 11940, 6566, 6539, 8750, 10970, 9168, 8640, 10240, 12109, 11485, 10742, 11940, 13396, 5009 }, - { 12288, 11090, 11348, 12109, 11090, 9892, 10334, 10970, 11629, 10431, 10970, 11629, 12479, 11348, 11781, 12288, - 1289 }, - { 1685, 5676, 13138, 18432, 5598, 7804, 13677, 18432, 12683, 13396, 17234, 20480, 17234, 17234, 20480, 20480, 15725 }, - { 2793, 5072, 10970, 15725, 5204, 6487, 11216, 15186, 10970, 11216, 14336, 17234, 15186, 15186, 17234, 18432, 12109 }, - { 12902, 11485, 11940, 13396, 11629, 10531, 11348, 12479, 12683, 11629, 12288, 13138, 13677, 12683, 13138, 13677, - 854 }, - { 3821, 5088, 9812, 13988, 5289, 5901, 9812, 13677, 9976, 9892, 12479, 15186, 13988, 13677, 15186, 17234, 9812 }, - { 4856, 5412, 9168, 12902, 5598, 5736, 8863, 12288, 9368, 8982, 11090, 13677, 12902, 12288, 13677, 15725, 8147 }, - { 20480, 20480, 7088, 9300, 20480, 20480, 7844, 9733, 7320, 7928, 9368, 10970, 9581, 9892, 10970, 12288, 2550 }, - { 6031, 5859, 8192, 10635, 6410, 6286, 8433, 10742, 9656, 9042, 10531, 12479, 12479, 11629, 12902, 14336, 5756 }, - { 6144, 6215, 8982, 11940, 6262, 6009, 8433, 11216, 8982, 8433, 10240, 12479, 11781, 11090, 12479, 13988, 5817 }, - { 20480, 20480, 11216, 12109, 20480, 20480, 11216, 11940, 11629, 11485, 11940, 12479, 12479, 12109, 12683, 13138, - 704 }, - { 7928, 6994, 8239, 9733, 7218, 6539, 8147, 9892, 9812, 9105, 10240, 11629, 12109, 11216, 12109, 13138, 4167 }, - { 8640, 7724, 9233, 10970, 8013, 7185, 8483, 10150, 9656, 8694, 9656, 10970, 11348, 10334, 11090, 12288, 3391 }, - { 20480, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, - 91 }, - { 10061, 8863, 9733, 11090, 8982, 7970, 8806, 9976, 10061, 9105, 9812, 10742, 11485, 10334, 10970, 11781, 2557 }, - { 10431, 9368, 10240, 11348, 9368, 8433, 9233, 10334, 10431, 9437, 10061, 10970, 11781, 10635, 11216, 11940, 2119 }, - { 13988, 12479, 12683, 12902, 12683, 11348, 11485, 11940, 12902, 11629, 11940, 12288, 13396, 12109, 12479, 12683, - 828 }, - { 10431, 9300, 10334, 11629, 9508, 8483, 9437, 10635, 10635, 9656, 10431, 11348, 11940, 10854, 11485, 12288, 1946 }, - { 12479, 11216, 11629, 12479, 11348, 10150, 10635, 11348, 11940, 10854, 11216, 11940, 12902, 11629, 11940, 12479, - 1146 }, - { 13396, 12109, 12288, 12902, 12109, 10854, 11216, 11781, 12479, 11348, 11629, 12109, 13138, 11940, 12288, 12683, - 928 }, - { 2443, 5289, 11629, 16384, 5170, 6730, 11940, 16384, 11216, 11629, 14731, 18432, 15725, 15725, 18432, 20480, 13396 }, - { 3328, 5009, 10531, 15186, 5040, 6031, 10531, 14731, 10431, 10431, 13396, 16384, 15186, 14731, 16384, 18432, 11629 }, - { 14336, 12902, 12902, 13396, 12902, 11629, 11940, 12288, 13138, 12109, 12288, 12902, 13677, 12683, 12902, 13138, - 711 }, - { 4300, 5204, 9437, 13396, 5430, 5776, 9300, 12902, 9656, 9437, 11781, 14731, 13396, 12902, 14731, 16384, 8982 }, - { 5394, 5776, 8982, 12288, 5922, 5901, 8640, 11629, 9105, 8694, 10635, 13138, 12288, 11629, 13138, 14731, 6844 }, - { 17234, 15725, 15725, 15725, 15725, 14731, 14731, 14731, 16384, 14731, 14731, 15186, 16384, 15186, 15186, 15186, - 272 }, - { 6461, 6286, 8806, 11348, 6566, 6215, 8334, 10742, 9233, 8535, 10061, 12109, 11781, 10970, 12109, 13677, 5394 }, - { 6674, 6487, 8863, 11485, 6702, 6286, 8334, 10635, 9168, 8483, 9976, 11940, 11629, 10854, 11940, 13396, 5105 }, - { 15186, 13677, 13677, 13988, 13677, 12479, 12479, 12683, 13988, 12683, 12902, 13138, 14336, 13138, 13396, 13677, - 565 }, - { 7844, 7252, 8922, 10854, 7389, 6815, 8383, 10240, 9508, 8750, 9892, 11485, 11629, 10742, 11629, 12902, 3842 }, - { 9233, 8239, 9233, 10431, 8334, 7424, 8483, 9892, 10061, 9105, 10061, 11216, 11781, 10742, 11485, 12479, 2906 }, - { 20480, 20480, 14731, 14731, 20480, 20480, 14336, 14336, 15186, 14336, 14731, 14731, 15186, 14731, 14731, 15186, - 266 }, - { 10531, 9300, 9976, 11090, 9437, 8286, 9042, 10061, 10431, 9368, 9976, 10854, 11781, 10531, 11090, 11781, 2233 }, - { 11629, 10334, 10970, 12109, 10431, 9368, 10061, 10970, 11348, 10240, 10854, 11485, 12288, 11216, 11629, 12288, - 1469 }, - { 952, 6787, 15725, 20480, 6646, 9733, 16384, 20480, 14731, 15725, 18432, 20480, 18432, 20480, 20480, 20480, 18432 }, - { 9437, 8806, 10742, 12288, 8982, 8483, 9892, 11216, 10742, 9892, 10854, 11940, 12109, 11090, 11781, 12683, 1891 }, - { 12902, 11629, 11940, 12479, 11781, 10531, 10854, 11485, 12109, 10970, 11348, 11940, 12902, 11781, 12109, 12479, - 1054 }, - { 2113, 5323, 11781, 16384, 5579, 7252, 12288, 16384, 11781, 12288, 15186, 18432, 15725, 16384, 18432, 20480, 12902 }, - { 2463, 5965, 11348, 15186, 5522, 6934, 11216, 14731, 10334, 10635, 13677, 16384, 13988, 13988, 15725, 18432, 10334 }, - { 3779, 5541, 9812, 13677, 5467, 6122, 9656, 13138, 9581, 9437, 11940, 14731, 13138, 12683, 14336, 16384, 8982 }, - { 3181, 5154, 10150, 14336, 5448, 6311, 10334, 13988, 10334, 10431, 13138, 15725, 14336, 13988, 15725, 18432, 10431 }, - { 4841, 5560, 9105, 12479, 5756, 5944, 8922, 12109, 9300, 8982, 11090, 13677, 12479, 12109, 13677, 15186, 7460 }, - { 5859, 6009, 8922, 11940, 6144, 5987, 8483, 11348, 9042, 8535, 10334, 12683, 11940, 11216, 12683, 14336, 6215 }, - { 4250, 4916, 8587, 12109, 5901, 6191, 9233, 12288, 10150, 9892, 11940, 14336, 13677, 13138, 14731, 16384, 8383 }, - { 7153, 6702, 8863, 11216, 6904, 6410, 8239, 10431, 9233, 8433, 9812, 11629, 11629, 10742, 11781, 13138, 4753 }, - { 6674, 7057, 9508, 11629, 7120, 6964, 8806, 10635, 9437, 8750, 10061, 11629, 11485, 10531, 11485, 12683, 4062 }, - { 5341, 5289, 8013, 10970, 6311, 6262, 8640, 11090, 10061, 9508, 11090, 13138, 12902, 12288, 13396, 15186, 6539 }, - { 8057, 7533, 9300, 11216, 7685, 7057, 8535, 10334, 9508, 8694, 9812, 11216, 11485, 10431, 11348, 12479, 3541 }, - { 9168, 8239, 9656, 11216, 8483, 7608, 8806, 10240, 9892, 8982, 9812, 11090, 11485, 10431, 11090, 12109, 2815 }, - { 558, 7928, 18432, 20480, 7724, 12288, 20480, 20480, 18432, 20480, 20480, 20480, 20480, 20480, 20480, 20480, 20480 }, - { 9892, 8806, 9976, 11348, 9042, 8057, 9042, 10240, 10240, 9233, 9976, 11090, 11629, 10531, 11216, 12109, 2371 }, - { 11090, 9812, 10531, 11629, 9976, 8863, 9508, 10531, 10854, 9733, 10334, 11090, 11940, 10742, 11216, 11940, 1821 }, - { 7354, 6964, 9042, 11216, 7153, 6592, 8334, 10431, 9233, 8483, 9812, 11485, 11485, 10531, 11629, 12902, 4349 }, - { 11348, 10150, 10742, 11629, 10150, 9042, 9656, 10431, 10854, 9812, 10431, 11216, 12109, 10970, 11485, 12109, 1700 }, - { 20480, 20480, 8694, 10150, 20480, 20480, 8982, 10240, 8982, 9105, 9976, 10970, 10431, 10431, 11090, 11940, 1610 }, - { 9233, 8192, 9368, 10970, 8286, 7496, 8587, 9976, 9812, 8863, 9733, 10854, 11348, 10334, 11090, 11940, 3040 }, - { 4202, 5716, 9733, 13138, 5598, 6099, 9437, 12683, 9300, 9168, 11485, 13988, 12479, 12109, 13988, 15725, 7804 }, - { 4400, 5965, 9508, 12479, 6009, 6360, 9105, 11781, 9300, 8982, 10970, 13138, 12109, 11629, 13138, 14731, 6994 } -}; + {20480, 20480, 5220, 9042, 20480, 20480, 6619, 9892, 5289, 6619, 9105, 11629, 8982, 9892, 11629, 13677, 4977}, + {11940, 10854, 12109, 13677, 10742, 9812, 11090, 12288, 11348, 10240, 11348, 12683, 12109, 10854, 11629, 12902, + 1197}, + {7886, 7120, 8982, 10970, 7496, 6815, 8334, 10150, 9437, 8535, 9656, 11216, 11348, 10431, 11348, 12479, 4051}, + {5485, 6099, 9168, 11940, 6311, 6262, 8640, 11090, 9233, 8640, 10334, 12479, 11781, 11090, 12479, 13988, 6009}, + {7886, 7804, 10150, 11940, 7886, 7685, 9368, 10854, 10061, 9300, 10431, 11629, 11629, 10742, 11485, 12479, 2763}, + {9042, 8383, 10240, 11781, 8483, 8013, 9437, 10742, 10334, 9437, 10431, 11485, 11781, 10742, 11485, 12288, 2346}, + {5922, 6619, 9368, 11940, 6566, 6539, 8750, 10970, 9168, 8640, 10240, 12109, 11485, 10742, 11940, 13396, 5009}, + {12288, 11090, 11348, 12109, 11090, 9892, 10334, 10970, 11629, 10431, 10970, 11629, 12479, 11348, 11781, 12288, + 1289}, + {1685, 5676, 13138, 18432, 5598, 7804, 13677, 18432, 12683, 13396, 17234, 20480, 17234, 17234, 20480, 20480, 15725}, + {2793, 5072, 10970, 15725, 5204, 6487, 11216, 15186, 10970, 11216, 14336, 17234, 15186, 15186, 17234, 18432, 12109}, + {12902, 11485, 11940, 13396, 11629, 10531, 11348, 12479, 12683, 11629, 12288, 13138, 13677, 12683, 13138, 13677, + 854}, + {3821, 5088, 9812, 13988, 5289, 5901, 9812, 13677, 9976, 9892, 12479, 15186, 13988, 13677, 15186, 17234, 9812}, + {4856, 5412, 9168, 12902, 5598, 5736, 8863, 12288, 9368, 8982, 11090, 13677, 12902, 12288, 13677, 15725, 8147}, + {20480, 20480, 7088, 9300, 20480, 20480, 7844, 9733, 7320, 7928, 9368, 10970, 9581, 9892, 10970, 12288, 2550}, + {6031, 5859, 8192, 10635, 6410, 6286, 8433, 10742, 9656, 9042, 10531, 12479, 12479, 11629, 12902, 14336, 5756}, + {6144, 6215, 8982, 11940, 6262, 6009, 8433, 11216, 8982, 8433, 10240, 12479, 11781, 11090, 12479, 13988, 5817}, + {20480, 20480, 11216, 12109, 20480, 20480, 11216, 11940, 11629, 11485, 11940, 12479, 12479, 12109, 12683, 13138, + 704}, + {7928, 6994, 8239, 9733, 7218, 6539, 8147, 9892, 9812, 9105, 10240, 11629, 12109, 11216, 12109, 13138, 4167}, + {8640, 7724, 9233, 10970, 8013, 7185, 8483, 10150, 9656, 8694, 9656, 10970, 11348, 10334, 11090, 12288, 3391}, + {20480, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, 18432, + 91}, + {10061, 8863, 9733, 11090, 8982, 7970, 8806, 9976, 10061, 9105, 9812, 10742, 11485, 10334, 10970, 11781, 2557}, + {10431, 9368, 10240, 11348, 9368, 8433, 9233, 10334, 10431, 9437, 10061, 10970, 11781, 10635, 11216, 11940, 2119}, + {13988, 12479, 12683, 12902, 12683, 11348, 11485, 11940, 12902, 11629, 11940, 12288, 13396, 12109, 12479, 12683, + 828}, + {10431, 9300, 10334, 11629, 9508, 8483, 9437, 10635, 10635, 9656, 10431, 11348, 11940, 10854, 11485, 12288, 1946}, + {12479, 11216, 11629, 12479, 11348, 10150, 10635, 11348, 11940, 10854, 11216, 11940, 12902, 11629, 11940, 12479, + 1146}, + {13396, 12109, 12288, 12902, 12109, 10854, 11216, 11781, 12479, 11348, 11629, 12109, 13138, 11940, 12288, 12683, + 928}, + {2443, 5289, 11629, 16384, 5170, 6730, 11940, 16384, 11216, 11629, 14731, 18432, 15725, 15725, 18432, 20480, 13396}, + {3328, 5009, 10531, 15186, 5040, 6031, 10531, 14731, 10431, 10431, 13396, 16384, 15186, 14731, 16384, 18432, 11629}, + {14336, 12902, 12902, 13396, 12902, 11629, 11940, 12288, 13138, 12109, 12288, 12902, 13677, 12683, 12902, 13138, + 711}, + {4300, 5204, 9437, 13396, 5430, 5776, 9300, 12902, 9656, 9437, 11781, 14731, 13396, 12902, 14731, 16384, 8982}, + {5394, 5776, 8982, 12288, 5922, 5901, 8640, 11629, 9105, 8694, 10635, 13138, 12288, 11629, 13138, 14731, 6844}, + {17234, 15725, 15725, 15725, 15725, 14731, 14731, 14731, 16384, 14731, 14731, 15186, 16384, 15186, 15186, 15186, + 272}, + {6461, 6286, 8806, 11348, 6566, 6215, 8334, 10742, 9233, 8535, 10061, 12109, 11781, 10970, 12109, 13677, 5394}, + {6674, 6487, 8863, 11485, 6702, 6286, 8334, 10635, 9168, 8483, 9976, 11940, 11629, 10854, 11940, 13396, 5105}, + {15186, 13677, 13677, 13988, 13677, 12479, 12479, 12683, 13988, 12683, 12902, 13138, 14336, 13138, 13396, 13677, + 565}, + {7844, 7252, 8922, 10854, 7389, 6815, 8383, 10240, 9508, 8750, 9892, 11485, 11629, 10742, 11629, 12902, 3842}, + {9233, 8239, 9233, 10431, 8334, 7424, 8483, 9892, 10061, 9105, 10061, 11216, 11781, 10742, 11485, 12479, 2906}, + {20480, 20480, 14731, 14731, 20480, 20480, 14336, 14336, 15186, 14336, 14731, 14731, 15186, 14731, 14731, 15186, + 266}, + {10531, 9300, 9976, 11090, 9437, 8286, 9042, 10061, 10431, 9368, 9976, 10854, 11781, 10531, 11090, 11781, 2233}, + {11629, 10334, 10970, 12109, 10431, 9368, 10061, 10970, 11348, 10240, 10854, 11485, 12288, 11216, 11629, 12288, + 1469}, + {952, 6787, 15725, 20480, 6646, 9733, 16384, 20480, 14731, 15725, 18432, 20480, 18432, 20480, 20480, 20480, 18432}, + {9437, 8806, 10742, 12288, 8982, 8483, 9892, 11216, 10742, 9892, 10854, 11940, 12109, 11090, 11781, 12683, 1891}, + {12902, 11629, 11940, 12479, 11781, 10531, 10854, 11485, 12109, 10970, 11348, 11940, 12902, 11781, 12109, 12479, + 1054}, + {2113, 5323, 11781, 16384, 5579, 7252, 12288, 16384, 11781, 12288, 15186, 18432, 15725, 16384, 18432, 20480, 12902}, + {2463, 5965, 11348, 15186, 5522, 6934, 11216, 14731, 10334, 10635, 13677, 16384, 13988, 13988, 15725, 18432, 10334}, + {3779, 5541, 9812, 13677, 5467, 6122, 9656, 13138, 9581, 9437, 11940, 14731, 13138, 12683, 14336, 16384, 8982}, + {3181, 5154, 10150, 14336, 5448, 6311, 10334, 13988, 10334, 10431, 13138, 15725, 14336, 13988, 15725, 18432, 10431}, + {4841, 5560, 9105, 12479, 5756, 5944, 8922, 12109, 9300, 8982, 11090, 13677, 12479, 12109, 13677, 15186, 7460}, + {5859, 6009, 8922, 11940, 6144, 5987, 8483, 11348, 9042, 8535, 10334, 12683, 11940, 11216, 12683, 14336, 6215}, + {4250, 4916, 8587, 12109, 5901, 6191, 9233, 12288, 10150, 9892, 11940, 14336, 13677, 13138, 14731, 16384, 8383}, + {7153, 6702, 8863, 11216, 6904, 6410, 8239, 10431, 9233, 8433, 9812, 11629, 11629, 10742, 11781, 13138, 4753}, + {6674, 7057, 9508, 11629, 7120, 6964, 8806, 10635, 9437, 8750, 10061, 11629, 11485, 10531, 11485, 12683, 4062}, + {5341, 5289, 8013, 10970, 6311, 6262, 8640, 11090, 10061, 9508, 11090, 13138, 12902, 12288, 13396, 15186, 6539}, + {8057, 7533, 9300, 11216, 7685, 7057, 8535, 10334, 9508, 8694, 9812, 11216, 11485, 10431, 11348, 12479, 3541}, + {9168, 8239, 9656, 11216, 8483, 7608, 8806, 10240, 9892, 8982, 9812, 11090, 11485, 10431, 11090, 12109, 2815}, + {558, 7928, 18432, 20480, 7724, 12288, 20480, 20480, 18432, 20480, 20480, 20480, 20480, 20480, 20480, 20480, 20480}, + {9892, 8806, 9976, 11348, 9042, 8057, 9042, 10240, 10240, 9233, 9976, 11090, 11629, 10531, 11216, 12109, 2371}, + {11090, 9812, 10531, 11629, 9976, 8863, 9508, 10531, 10854, 9733, 10334, 11090, 11940, 10742, 11216, 11940, 1821}, + {7354, 6964, 9042, 11216, 7153, 6592, 8334, 10431, 9233, 8483, 9812, 11485, 11485, 10531, 11629, 12902, 4349}, + {11348, 10150, 10742, 11629, 10150, 9042, 9656, 10431, 10854, 9812, 10431, 11216, 12109, 10970, 11485, 12109, 1700}, + {20480, 20480, 8694, 10150, 20480, 20480, 8982, 10240, 8982, 9105, 9976, 10970, 10431, 10431, 11090, 11940, 1610}, + {9233, 8192, 9368, 10970, 8286, 7496, 8587, 9976, 9812, 8863, 9733, 10854, 11348, 10334, 11090, 11940, 3040}, + {4202, 5716, 9733, 13138, 5598, 6099, 9437, 12683, 9300, 9168, 11485, 13988, 12479, 12109, 13988, 15725, 7804}, + {4400, 5965, 9508, 12479, 6009, 6360, 9105, 11781, 9300, 8982, 10970, 13138, 12109, 11629, 13138, 14731, 6994}}; const LC3_FLOAT sns_LFCB[8][32] = { - { 2.26283365592678, 2.94516479191376, -2.18610707009979, 0.693688236528920, -1.29752132315296, 0.914652037830672, - -2.51428812578962, -0.922188404812385, 0.790322288369266, 1.44775580178724, 0.793354526417474, 2.72425347385034, - -0.530830198375400, 1.68728410845006, -2.95183272801858, 0.101878342785628, 2.68254575498426, 4.82697923680403, - 0.0878419936470335, 1.39102308204326, 0.384585893889182, 1.93227399441719, 0.175080462899884, -1.18817020250556, - 2.53322203327061, 3.99889837485606, 0.507902593186381, 3.16856825107569, 1.89414766731764, 0.948880604517188, - -1.88026757045628, 0.246375746277129 }, - { 0.813311269061339, 2.41143317956679, -1.97152135675228, 0.955609857158220, -0.740369057177853, - 1.74293043435257, -2.89175271384373, 0.632495141440552, 0.628401261876199, 2.72399951674952, - 0.0143931185523454, 2.95947572404824, -0.212690682812164, 2.43614509237656, -1.59393496773345, - 0.589857324228917, 1.32738010899420, 3.11947804492488, -0.569586840238501, 1.98146479199466, - -0.160588785536510, 3.01030180412057, -0.750522832248985, 0.366792873662636, 2.11274642695908, - 4.07901751451956, 1.58838449789527, 3.25853458159407, 1.25108694609232, 2.13239439249982, - -1.26431072758705, 0.955621773393099 }, - { -0.530193494871436, 0.960455106400727, -1.78718619681006, 0.575230787038733, -0.345372483642106, - 1.90906626859986, -2.00450666759434, 1.08736431254641, 0.393117923540450, 2.31083268737528, - -0.567834844729679, 1.84953559268461, 0.00576613628377097, 2.33019429078225, -0.109918772878022, - 0.619047646793466, 0.130185273804048, 1.39513671385178, -1.14506015668811, 1.11265796388770, - -0.539366809557710, 3.06543893826204, -1.03943893342231, 1.30957830409096, 1.26288411502064, - 2.82285661102496, 1.72899023869209, 2.42230591328599, 0.590451210720628, 2.72345350344278, - 0.311424976968699, 1.52046776741766 }, - { -1.35664835903442, -0.443226488076917, -1.91865895685577, -0.114603419462889, -0.313285696247940, - 1.54408483842665, -0.750912273903127, 0.608628624535820, 0.480007710866901, 0.935051269566529, - -0.654760467916745, 0.563284922322364, 0.424871484383745, 1.77983777835091, 0.388609072919257, - 1.26731313851796, -0.338533088511347, 0.250295315918722, -1.66968488172598, -0.220107509420743, - -0.529309078789857, 2.50110160870008, -1.13577508937648, 1.68330687280491, 0.761513512430427, - 1.72607212849580, 1.00692230241726, 1.79446077643261, 0.608358583293714, 2.76986076866588, - 1.83670210306430, 1.97647400419457 }, - { -1.59952176563196, -1.22913612425590, -1.79399121836596, -0.646050637436029, -0.402977242824477, - 1.09344960761455, 0.441202104904691, 0.131174567547348, 0.447815138050143, -0.274743911383688, - -0.479458998475743, 0.139917088125072, 0.473128952158668, 1.44411295390082, 0.512932649517584, - 2.41961047769804, -0.368219235899667, -0.393613839379793, -1.84534417603682, -0.774965611552366, - 0.190433547437932, 1.93089592978934, -1.04197903837494, 1.25100924225127, 0.522117937976170, - 0.647144377348619, 0.377121231816382, 1.52177910653089, 0.878171010011082, 2.54286973254946, - 2.25634191839874, 1.94043867177462 }, - { -1.44098768430095, -1.55590039118170, -1.35738404257288, -0.952351370449625, -0.372020853465227, - 0.647479549518278, 1.20190987601009, -0.296149157743752, 0.209734214552234, -0.902077696828602, - -0.173894661902889, 0.359641093366222, 0.858894199321281, 1.51995177009730, 0.628112597063497, - 2.25174252572187, -0.191689946715961, -0.643458173054701, -1.56468027328802, -0.594063874149117, - 2.56062918106522, 0.572153810961837, -0.0152060098993382, 0.942375751628615, 0.118680069757121, - -0.331148521217238, 0.476370766899498, 1.17196706537602, 1.11912510950950, 2.02046263825019, - 2.04818998463474, 2.23375847282686 }, - { -1.14381648305821, -1.49688655952376, -0.705444279353869, -1.07405247226150, -0.0783414177323738, - 0.0361790752449642, 1.32742857257290, -0.207013516525629, 0.00656691996428021, -0.940681511945404, - 0.0680162705515438, 0.689461354774589, 1.19111160854435, 1.47199393750425, 0.822621796430634, - 0.526537030991201, -0.154782377153908, -0.642570736856943, -1.11746759076420, 0.136937680628923, - 2.81896398245248, -0.811741794081091, 2.07048391716707, 0.826250483374133, -0.452346827507370, - -0.884042570848749, 1.08754740372170, 0.489394596980695, 1.01857661550342, 0.830045859400910, - 2.19526837458568, 1.98835977758407 }, - { -0.755203767909064, -1.11689986501469, -0.0478172944777711, -0.758087707094905, 0.0970441303992295, - -0.297092807178889, 1.22049081140984, 0.134924916642080, -0.0861242342061857, -0.633697038974310, - 0.295125948369794, 0.639790176833105, 0.996189669638358, 0.977682473891761, 0.875891424655081, - -0.396591513227999, -0.234207177774392, -0.723193223444072, -0.533981663366786, 0.818242891264338, - 0.656670875696161, -1.17641810861903, 3.42948918081689, 0.439952741120956, -0.700352426161103, - -1.12697340645478, 1.08756266099221, -0.0622795715718769, 0.620453891011724, -0.0275569173888263, - 2.02659613836619, 1.27232672554701 } -}; + {2.26283365592678, 2.94516479191376, -2.18610707009979, 0.693688236528920, -1.29752132315296, 0.914652037830672, + -2.51428812578962, -0.922188404812385, 0.790322288369266, 1.44775580178724, 0.793354526417474, 2.72425347385034, + -0.530830198375400, 1.68728410845006, -2.95183272801858, 0.101878342785628, 2.68254575498426, 4.82697923680403, + 0.0878419936470335, 1.39102308204326, 0.384585893889182, 1.93227399441719, 0.175080462899884, -1.18817020250556, + 2.53322203327061, 3.99889837485606, 0.507902593186381, 3.16856825107569, 1.89414766731764, 0.948880604517188, + -1.88026757045628, 0.246375746277129}, + {0.813311269061339, 2.41143317956679, -1.97152135675228, 0.955609857158220, -0.740369057177853, + 1.74293043435257, -2.89175271384373, 0.632495141440552, 0.628401261876199, 2.72399951674952, + 0.0143931185523454, 2.95947572404824, -0.212690682812164, 2.43614509237656, -1.59393496773345, + 0.589857324228917, 1.32738010899420, 3.11947804492488, -0.569586840238501, 1.98146479199466, + -0.160588785536510, 3.01030180412057, -0.750522832248985, 0.366792873662636, 2.11274642695908, + 4.07901751451956, 1.58838449789527, 3.25853458159407, 1.25108694609232, 2.13239439249982, + -1.26431072758705, 0.955621773393099}, + {-0.530193494871436, 0.960455106400727, -1.78718619681006, 0.575230787038733, -0.345372483642106, + 1.90906626859986, -2.00450666759434, 1.08736431254641, 0.393117923540450, 2.31083268737528, + -0.567834844729679, 1.84953559268461, 0.00576613628377097, 2.33019429078225, -0.109918772878022, + 0.619047646793466, 0.130185273804048, 1.39513671385178, -1.14506015668811, 1.11265796388770, + -0.539366809557710, 3.06543893826204, -1.03943893342231, 1.30957830409096, 1.26288411502064, + 2.82285661102496, 1.72899023869209, 2.42230591328599, 0.590451210720628, 2.72345350344278, + 0.311424976968699, 1.52046776741766}, + {-1.35664835903442, -0.443226488076917, -1.91865895685577, -0.114603419462889, -0.313285696247940, + 1.54408483842665, -0.750912273903127, 0.608628624535820, 0.480007710866901, 0.935051269566529, + -0.654760467916745, 0.563284922322364, 0.424871484383745, 1.77983777835091, 0.388609072919257, + 1.26731313851796, -0.338533088511347, 0.250295315918722, -1.66968488172598, -0.220107509420743, + -0.529309078789857, 2.50110160870008, -1.13577508937648, 1.68330687280491, 0.761513512430427, + 1.72607212849580, 1.00692230241726, 1.79446077643261, 0.608358583293714, 2.76986076866588, + 1.83670210306430, 1.97647400419457}, + {-1.59952176563196, -1.22913612425590, -1.79399121836596, -0.646050637436029, -0.402977242824477, + 1.09344960761455, 0.441202104904691, 0.131174567547348, 0.447815138050143, -0.274743911383688, + -0.479458998475743, 0.139917088125072, 0.473128952158668, 1.44411295390082, 0.512932649517584, + 2.41961047769804, -0.368219235899667, -0.393613839379793, -1.84534417603682, -0.774965611552366, + 0.190433547437932, 1.93089592978934, -1.04197903837494, 1.25100924225127, 0.522117937976170, + 0.647144377348619, 0.377121231816382, 1.52177910653089, 0.878171010011082, 2.54286973254946, + 2.25634191839874, 1.94043867177462}, + {-1.44098768430095, -1.55590039118170, -1.35738404257288, -0.952351370449625, -0.372020853465227, + 0.647479549518278, 1.20190987601009, -0.296149157743752, 0.209734214552234, -0.902077696828602, + -0.173894661902889, 0.359641093366222, 0.858894199321281, 1.51995177009730, 0.628112597063497, + 2.25174252572187, -0.191689946715961, -0.643458173054701, -1.56468027328802, -0.594063874149117, + 2.56062918106522, 0.572153810961837, -0.0152060098993382, 0.942375751628615, 0.118680069757121, + -0.331148521217238, 0.476370766899498, 1.17196706537602, 1.11912510950950, 2.02046263825019, + 2.04818998463474, 2.23375847282686}, + {-1.14381648305821, -1.49688655952376, -0.705444279353869, -1.07405247226150, -0.0783414177323738, + 0.0361790752449642, 1.32742857257290, -0.207013516525629, 0.00656691996428021, -0.940681511945404, + 0.0680162705515438, 0.689461354774589, 1.19111160854435, 1.47199393750425, 0.822621796430634, + 0.526537030991201, -0.154782377153908, -0.642570736856943, -1.11746759076420, 0.136937680628923, + 2.81896398245248, -0.811741794081091, 2.07048391716707, 0.826250483374133, -0.452346827507370, + -0.884042570848749, 1.08754740372170, 0.489394596980695, 1.01857661550342, 0.830045859400910, + 2.19526837458568, 1.98835977758407}, + {-0.755203767909064, -1.11689986501469, -0.0478172944777711, -0.758087707094905, 0.0970441303992295, + -0.297092807178889, 1.22049081140984, 0.134924916642080, -0.0861242342061857, -0.633697038974310, + 0.295125948369794, 0.639790176833105, 0.996189669638358, 0.977682473891761, 0.875891424655081, + -0.396591513227999, -0.234207177774392, -0.723193223444072, -0.533981663366786, 0.818242891264338, + 0.656670875696161, -1.17641810861903, 3.42948918081689, 0.439952741120956, -0.700352426161103, + -1.12697340645478, 1.08756266099221, -0.0622795715718769, 0.620453891011724, -0.0275569173888263, + 2.02659613836619, 1.27232672554701}}; const LC3_FLOAT sns_HFCB[8][32] = { - { 0.232028419124465, -1.29503936673618, 0.139285716045803, -0.316513102185725, 0.879518405226496, - -0.296701922455375, 0.340981100469697, -1.41229759077597, -0.228839511827379, -1.07148628544449, - -0.590988511188051, -0.848434098836164, 1.14069145562382, -0.376283237967464, 0.665004120598402, - -0.826265953982679, 1.41008326832173, 0.361386817574348, 0.437469239330329, 0.648100318996503, - 1.11919833091304, 0.141847497087176, 0.504046955390252, -0.501076050479357, 3.74970982709642, - -1.15258990980549, 1.02827246422140, 0.128831971707817, 1.34033030334757, 2.13843105419313, - 0.564830487355396, -0.422460547586087 }, - { -1.00890270604455, -1.79929965384339, -0.258185126171752, -0.477747657209805, 0.298340096007189, - -0.975004919174553, 0.268899788946055, -1.48522119349852, -0.333719069784662, -1.41767015456261, - -0.0711737758537628, -0.583226810708889, 0.964016892398293, 0.0425675462096105, 1.09790764690795, - -0.671181232766603, 0.754441907835468, -0.0219991705427826, 0.305440419605961, 0.682299133640680, - 1.23465532536005, -0.110660070633151, 0.826982162959097, -0.325678006081417, 1.52342611847045, - -1.10800885906241, 1.09770519389828, 0.689439395264878, 1.38996825067789, 4.24711267303104, - 1.59184977958743, 0.326149625049801 }, - { -2.14223502789471, -1.88703147531519, -0.650804572670110, -0.551162075879755, -0.915386396405710, - -1.35857500246993, 0.0563335684828033, -1.18603579834700, -0.809321359324656, -1.54891762265441, - 0.345719522947313, 0.0900423688142873, 0.381461205984798, 0.516547696592306, 1.38342667112079, - -0.228495592779472, -1.30550584958631, -0.579368833633824, -0.00738786566478374, 0.253247464332976, - 0.589170238085318, -0.282824592543629, 1.11981236291828, 0.0280798194947077, -0.457715661897855, - -0.562615116512472, 0.768645545764776, 1.12346905009575, 1.04467921708883, 2.89734109830439, - 2.39771699015146, 1.39171313342261 }, - { -2.37533813570664, -1.80991659687332, -1.06815731781969, -0.484788283381197, -2.20645974739762, - -0.983721105837444, 0.0499114046826685, -0.625001634441352, -1.63587876923797, -1.45296062475530, - 0.300549460996251, 0.845025007556886, -0.482849340608998, 0.251716881864630, 1.34327358628285, - 0.518980852551937, -1.87133711350971, -0.879427960941070, -0.495649854710252, 0.0735842143788469, - -1.37192459653166, -0.00659813474614194, 1.17914044332734, 0.262054554763133, -0.798711008243192, - -0.220562123765675, 0.206081977740766, 1.30934523106594, 0.635822746244367, 0.932730658026815, - 3.03697343600704, 2.23146614636474 }, - { -2.23041933049655, -1.76340038479206, -1.61928741524302, -0.238388394455814, -2.74142180959951, - -0.652956939100809, -0.0954130727414369, 0.153902497468304, -1.88486397330982, -1.03182970062270, - -1.11865218295857, 1.06572384501716, -1.81632721260589, -0.216179967524303, 0.822978836855922, - 1.36721896340278, -1.24008685156305, -0.850685023408119, -0.806651271118393, 0.314216709389010, - -2.37095707241577, 0.285929279627216, 1.07987429197260, 0.360590806085767, -0.386819329309100, - -0.349842880336644, -0.342805735091998, 1.35511964713935, -0.274733755518482, -0.292822249729810, - 2.66424350337151, 2.61179442169688 }, - { -2.17595881223696, -1.83418428467950, -2.18762566441756, -0.143024507285504, -2.86139074276891, - -0.989986992921811, -0.760166146083885, 0.576386497810755, -1.64496691316356, -0.690642640272584, - -2.44089151148049, 0.737582999377756, -2.80279512728555, -0.534074091124504, 0.215876798515679, - 2.18023038253092, -1.26712924866274, -0.779397050155816, -1.22431891984401, 0.234729880923679, - -2.00779782682360, 0.0460445529952971, 0.697536239067500, 0.635623722053700, -0.375901062231203, - -0.753432770250495, -0.754939404625340, 1.42311381470799, -1.54923372430695, -0.810404296853182, - 1.39304485032606, 2.66540340196570 }, - { -2.29065913541000, -1.80480980687405, -2.63757586939054, 0.0683186673649074, -2.88841597105271, - -1.61467224598900, -2.32758120177007, 0.795092603798871, -1.40515778046612, -0.428843804532171, - -2.22854732450735, 0.256590452459912, -3.23385724833864, -0.640786096262196, -0.404925753080293, - 2.53596092750107, -2.03670813003907, -0.732182927291826, -1.70157770043181, 0.144600134479837, - -1.66688540224395, -0.602596415577886, -0.912548817371081, 0.959012467178154, -0.657836899930538, - -0.988596593396384, -1.04196177632000, 1.15706449190905, -2.44239710278007, -0.788868098756483, - 0.403834023595745, 2.40103554105707 }, - { -2.53286397979846, -1.73679545317401, -2.97897749575096, 0.0883061717288066, -2.95182608262521, - -2.40712302385116, -3.77155485385656, 0.596564632144913, -1.46666471326146, -0.494960215408874, - -1.89509228210853, -0.491963359762378, -3.45908714491473, -0.869745032374135, -1.07025605870523, - 2.20121098860036, -2.89685162242381, -0.888348514821255, -2.24491913755611, -0.0682120178880174, - -1.92631846258406, -2.26568728632575, -3.57684747062773, 1.30745156688653, -1.28163964243603, - -1.28790471791471, -1.50335652955529, 0.406319437516838, -3.02457606944550, -0.935353148761338, - -0.656270971328114, 1.75920379670881 } -}; - -const LC3_INT pvq_enc_A[16][11] = { { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, - { 0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19 }, - { 0, 1, 5, 13, 25, 41, 61, 85, 113, 145, 181 }, - { 0, 1, 7, 25, 63, 129, 231, 377, 575, 833, 1159 }, - { 0, 1, 9, 41, 129, 321, 681, 1289, 2241, 3649, 5641 }, - { 0, 1, 11, 61, 231, 681, 1683, 3653, 7183, 13073, 22363 }, - { 0, 1, 13, 85, 377, 1289, 3653, 8989, 19825, 40081, 75517 }, - { 0, 1, 15, 113, 575, 2241, 7183, 19825, 48639, 108545, 224143 }, - { 0, 1, 17, 145, 833, 3649, 13073, 40081, 108545, 265729, 598417 }, - { 0, 1, 19, 181, 1159, 5641, 22363, 75517, 224143, 598417, 1462563 }, - { 0, 1, 21, 221, 1561, 8361, 36365, 134245, 433905, 1256465, 3317445 }, - { 0, 1, 23, 265, 2047, 11969, 56695, 227305, 795455, 2485825, 7059735 }, - { 0, 1, 25, 313, 2625, 16641, 85305, 369305, 1392065, 4673345, 14218905 }, - { 0, 1, 27, 365, 3303, 22569, 124515, 579125, 2340495, 8405905, 27298155 }, - { 0, 1, 29, 421, 4089, 29961, 177045, 880685, 3800305, 14546705, 50250765 }, - { 0, 1, 31, 481, 4991, 39041, 246047, 1303777, 5984767, 24331777, 89129247 } }; - -const LC3_FLOAT lp_scale_factors[6] = { 1, 1, 0.6666666666666666, .5, 0.3333333333333333, 0.16666666666666666 }; + {0.232028419124465, -1.29503936673618, 0.139285716045803, -0.316513102185725, 0.879518405226496, + -0.296701922455375, 0.340981100469697, -1.41229759077597, -0.228839511827379, -1.07148628544449, + -0.590988511188051, -0.848434098836164, 1.14069145562382, -0.376283237967464, 0.665004120598402, + -0.826265953982679, 1.41008326832173, 0.361386817574348, 0.437469239330329, 0.648100318996503, + 1.11919833091304, 0.141847497087176, 0.504046955390252, -0.501076050479357, 3.74970982709642, + -1.15258990980549, 1.02827246422140, 0.128831971707817, 1.34033030334757, 2.13843105419313, + 0.564830487355396, -0.422460547586087}, + {-1.00890270604455, -1.79929965384339, -0.258185126171752, -0.477747657209805, 0.298340096007189, + -0.975004919174553, 0.268899788946055, -1.48522119349852, -0.333719069784662, -1.41767015456261, + -0.0711737758537628, -0.583226810708889, 0.964016892398293, 0.0425675462096105, 1.09790764690795, + -0.671181232766603, 0.754441907835468, -0.0219991705427826, 0.305440419605961, 0.682299133640680, + 1.23465532536005, -0.110660070633151, 0.826982162959097, -0.325678006081417, 1.52342611847045, + -1.10800885906241, 1.09770519389828, 0.689439395264878, 1.38996825067789, 4.24711267303104, + 1.59184977958743, 0.326149625049801}, + {-2.14223502789471, -1.88703147531519, -0.650804572670110, -0.551162075879755, -0.915386396405710, + -1.35857500246993, 0.0563335684828033, -1.18603579834700, -0.809321359324656, -1.54891762265441, + 0.345719522947313, 0.0900423688142873, 0.381461205984798, 0.516547696592306, 1.38342667112079, + -0.228495592779472, -1.30550584958631, -0.579368833633824, -0.00738786566478374, 0.253247464332976, + 0.589170238085318, -0.282824592543629, 1.11981236291828, 0.0280798194947077, -0.457715661897855, + -0.562615116512472, 0.768645545764776, 1.12346905009575, 1.04467921708883, 2.89734109830439, + 2.39771699015146, 1.39171313342261}, + {-2.37533813570664, -1.80991659687332, -1.06815731781969, -0.484788283381197, -2.20645974739762, + -0.983721105837444, 0.0499114046826685, -0.625001634441352, -1.63587876923797, -1.45296062475530, + 0.300549460996251, 0.845025007556886, -0.482849340608998, 0.251716881864630, 1.34327358628285, + 0.518980852551937, -1.87133711350971, -0.879427960941070, -0.495649854710252, 0.0735842143788469, + -1.37192459653166, -0.00659813474614194, 1.17914044332734, 0.262054554763133, -0.798711008243192, + -0.220562123765675, 0.206081977740766, 1.30934523106594, 0.635822746244367, 0.932730658026815, + 3.03697343600704, 2.23146614636474}, + {-2.23041933049655, -1.76340038479206, -1.61928741524302, -0.238388394455814, -2.74142180959951, + -0.652956939100809, -0.0954130727414369, 0.153902497468304, -1.88486397330982, -1.03182970062270, + -1.11865218295857, 1.06572384501716, -1.81632721260589, -0.216179967524303, 0.822978836855922, + 1.36721896340278, -1.24008685156305, -0.850685023408119, -0.806651271118393, 0.314216709389010, + -2.37095707241577, 0.285929279627216, 1.07987429197260, 0.360590806085767, -0.386819329309100, + -0.349842880336644, -0.342805735091998, 1.35511964713935, -0.274733755518482, -0.292822249729810, + 2.66424350337151, 2.61179442169688}, + {-2.17595881223696, -1.83418428467950, -2.18762566441756, -0.143024507285504, -2.86139074276891, + -0.989986992921811, -0.760166146083885, 0.576386497810755, -1.64496691316356, -0.690642640272584, + -2.44089151148049, 0.737582999377756, -2.80279512728555, -0.534074091124504, 0.215876798515679, + 2.18023038253092, -1.26712924866274, -0.779397050155816, -1.22431891984401, 0.234729880923679, + -2.00779782682360, 0.0460445529952971, 0.697536239067500, 0.635623722053700, -0.375901062231203, + -0.753432770250495, -0.754939404625340, 1.42311381470799, -1.54923372430695, -0.810404296853182, + 1.39304485032606, 2.66540340196570}, + {-2.29065913541000, -1.80480980687405, -2.63757586939054, 0.0683186673649074, -2.88841597105271, + -1.61467224598900, -2.32758120177007, 0.795092603798871, -1.40515778046612, -0.428843804532171, + -2.22854732450735, 0.256590452459912, -3.23385724833864, -0.640786096262196, -0.404925753080293, + 2.53596092750107, -2.03670813003907, -0.732182927291826, -1.70157770043181, 0.144600134479837, + -1.66688540224395, -0.602596415577886, -0.912548817371081, 0.959012467178154, -0.657836899930538, + -0.988596593396384, -1.04196177632000, 1.15706449190905, -2.44239710278007, -0.788868098756483, + 0.403834023595745, 2.40103554105707}, + {-2.53286397979846, -1.73679545317401, -2.97897749575096, 0.0883061717288066, -2.95182608262521, + -2.40712302385116, -3.77155485385656, 0.596564632144913, -1.46666471326146, -0.494960215408874, + -1.89509228210853, -0.491963359762378, -3.45908714491473, -0.869745032374135, -1.07025605870523, + 2.20121098860036, -2.89685162242381, -0.888348514821255, -2.24491913755611, -0.0682120178880174, + -1.92631846258406, -2.26568728632575, -3.57684747062773, 1.30745156688653, -1.28163964243603, + -1.28790471791471, -1.50335652955529, 0.406319437516838, -3.02457606944550, -0.935353148761338, + -0.656270971328114, 1.75920379670881}}; + +const LC3_INT pvq_enc_A[16][11] = {{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, + {0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19}, + {0, 1, 5, 13, 25, 41, 61, 85, 113, 145, 181}, + {0, 1, 7, 25, 63, 129, 231, 377, 575, 833, 1159}, + {0, 1, 9, 41, 129, 321, 681, 1289, 2241, 3649, 5641}, + {0, 1, 11, 61, 231, 681, 1683, 3653, 7183, 13073, 22363}, + {0, 1, 13, 85, 377, 1289, 3653, 8989, 19825, 40081, 75517}, + {0, 1, 15, 113, 575, 2241, 7183, 19825, 48639, 108545, 224143}, + {0, 1, 17, 145, 833, 3649, 13073, 40081, 108545, 265729, 598417}, + {0, 1, 19, 181, 1159, 5641, 22363, 75517, 224143, 598417, 1462563}, + {0, 1, 21, 221, 1561, 8361, 36365, 134245, 433905, 1256465, 3317445}, + {0, 1, 23, 265, 2047, 11969, 56695, 227305, 795455, 2485825, 7059735}, + {0, 1, 25, 313, 2625, 16641, 85305, 369305, 1392065, 4673345, 14218905}, + {0, 1, 27, 365, 3303, 22569, 124515, 579125, 2340495, 8405905, 27298155}, + {0, 1, 29, 421, 4089, 29961, 177045, 880685, 3800305, 14546705, 50250765}, + {0, 1, 31, 481, 4991, 39041, 246047, 1303777, 5984767, 24331777, 89129247}}; + +const LC3_FLOAT lp_scale_factors[6] = {1, 1, 0.6666666666666666, .5, 0.3333333333333333, 0.16666666666666666}; /* 12.8 kHz resampler */ -const LC3_FLOAT highpass50_filt_b[3] = { 0.9827947082978771, -1.965589416595754, 0.9827947082978771 }; -const LC3_FLOAT highpass50_filt_a[3] = { 1, -1.9652933726226904, 0.9658854605688177 }; +const LC3_FLOAT highpass50_filt_b[3] = {0.9827947082978771, -1.965589416595754, 0.9827947082978771}; +const LC3_FLOAT highpass50_filt_a[3] = {1, -1.9652933726226904, 0.9658854605688177}; const LC3_INT32 resamp_params[][4] = { - { 24, 5, 0, 15 }, - { 12, 10, 1, 3 }, - { 8, 15, 1, 7 }, - { 6, 20, 2, 3 }, - { 4, 30, 3, 3 }, - { 2, 60, 7, 1 } + {24, 5, 0, 15}, + {12, 10, 1, 3}, + {8, 15, 1, 7}, + {6, 20, 2, 3}, + {4, 30, 3, 3}, + {2, 60, 7, 1} }; -const LC3_FLOAT lp_filter_8[240] = { 0.0065408750, 0.0127360141, -0.0320970677, -0.1382038444, 0.8005587459, -0.1382038444, -0.0320970677, 0.0127360141, 0.0065408750, 0.0000000000, 0.0064595463, 0.0084537705, -0.0391003005, -0.1198658869, 0.7945935130, -0.1519452035, -0.0230523963, 0.0167804975, 0.0063002659, -0.0002451667, 0.0060938913, 0.0041435249, -0.0439039879, -0.0980933905, 0.7768620253, -0.1600013375, -0.0122310519, 0.0203715712, 0.0057131811, -0.0005356151, 0.0054914863, 0.0000000000, -0.0464562289, -0.0740769655, 0.7478516698, -0.1614013463, 0.0000000000, 0.0232978407, 0.0047708568, -0.0008596397, 0.0047065411, -0.0038048958, -0.0468063876, -0.0489920303, 0.7083564401, -0.1553338468, 0.0131809860, 0.0253629088, 0.0034824028, -0.0012012133, 0.0037965439, -0.0071282135, -0.0450960808, -0.0239577144, 0.6594504118, -0.1411849856, 0.0267735831, 0.0263961889, 0.0018761361, -0.0015404741, 0.0028190494, -0.0098603060, -0.0415467210, -0.0000000000, 0.6024519205, -0.1185704023, 0.0401797108, 0.0262632743, -0.0000000000, -0.0018545259, 0.0018287648, -0.0119272992, -0.0364444591, 0.0219798349, 0.5388799906, -0.0873604342, 0.0527642742, 0.0248753466, -0.0020790326, -0.0021185349, 0.0008750616, -0.0132916924, -0.0301232301, 0.0412303619, 0.4704038501, -0.0476967618, 0.0638811216, 0.0221970305, -0.0042766319, -0.0023070835, 0.0000000000, -0.0139512215, -0.0229468606, 0.0571681485, 0.3987891078, 0.0000000000, 0.0729012638, 0.0182522610, -0.0064938627, -0.0023957258, -0.0007630716, -0.0139361415, -0.0152910165, 0.0693885013, 0.3258404732, 0.0550325289, 0.0792422444, 0.0131276902, -0.0086209681, -0.0023626641, -0.0013903243, -0.0133052040, -0.0075258445, 0.0776687115, 0.2533447146, 0.1164389849, 0.0823974460, 0.0069732964, -0.0105420630, -0.0021904600, -0.0018676731, -0.0121405739, -0.0000000000, 0.0819641128, 0.1830149740, 0.1830149740, 0.0819641128, -0.0000000000, -0.0121405739, -0.0018676731, -0.0021904600, -0.0105420630, 0.0069732964, 0.0823974460, 0.1164389849, 0.2533447146, 0.0776687115, -0.0075258445, -0.0133052040, -0.0013903243, -0.0023626641, -0.0086209681, 0.0131276902, 0.0792422444, 0.0550325289, 0.3258404732, 0.0693885013, -0.0152910165, -0.0139361415, -0.0007630716, -0.0023957258, -0.0064938627, 0.0182522610, 0.0729012638, 0.0000000000, 0.3987891078, 0.0571681485, -0.0229468606, -0.0139512215, 0.0000000000, -0.0023070835, -0.0042766319, 0.0221970305, 0.0638811216, -0.0476967618, 0.4704038501, 0.0412303619, -0.0301232301, -0.0132916924, 0.0008750616, -0.0021185349, -0.0020790326, 0.0248753466, 0.0527642742, -0.0873604342, 0.5388799906, 0.0219798349, -0.0364444591, -0.0119272992, 0.0018287648, -0.0018545259, -0.0000000000, 0.0262632743, 0.0401797108, -0.1185704023, 0.6024519205, -0.0000000000, -0.0415467210, -0.0098603060, 0.0028190494, -0.0015404741, 0.0018761361, 0.0263961889, 0.0267735831, -0.1411849856, 0.6594504118, -0.0239577144, -0.0450960808, -0.0071282135, 0.0037965439, -0.0012012133, 0.0034824028, 0.0253629088, 0.0131809860, -0.1553338468, 0.7083564401, -0.0489920303, -0.0468063876, -0.0038048958, 0.0047065411, -0.0008596397, 0.0047708568, 0.0232978407, 0.0000000000, -0.1614013463, 0.7478516698, -0.0740769655, -0.0464562289, 0.0000000000, 0.0054914863, -0.0005356151, 0.0057131811, 0.0203715712, -0.0122310519, -0.1600013375, 0.7768620253, -0.0980933905, -0.0439039879, 0.0041435249, 0.0060938913, -0.0002451667, 0.0063002659, 0.0167804975, -0.0230523963, -0.1519452035, 0.7945935130, -0.1198658869, -0.0391003005, 0.0084537705, 0.0064595463 }; +const LC3_FLOAT lp_filter_8[240] = {0.0065408750, 0.0127360141, -0.0320970677, -0.1382038444, 0.8005587459, -0.1382038444, -0.0320970677, 0.0127360141, 0.0065408750, 0.0000000000, 0.0064595463, 0.0084537705, -0.0391003005, -0.1198658869, 0.7945935130, -0.1519452035, -0.0230523963, 0.0167804975, 0.0063002659, -0.0002451667, 0.0060938913, 0.0041435249, -0.0439039879, -0.0980933905, 0.7768620253, -0.1600013375, -0.0122310519, 0.0203715712, 0.0057131811, -0.0005356151, 0.0054914863, 0.0000000000, -0.0464562289, -0.0740769655, 0.7478516698, -0.1614013463, 0.0000000000, 0.0232978407, 0.0047708568, -0.0008596397, 0.0047065411, -0.0038048958, -0.0468063876, -0.0489920303, 0.7083564401, -0.1553338468, 0.0131809860, 0.0253629088, 0.0034824028, -0.0012012133, 0.0037965439, -0.0071282135, -0.0450960808, -0.0239577144, 0.6594504118, -0.1411849856, 0.0267735831, 0.0263961889, 0.0018761361, -0.0015404741, 0.0028190494, -0.0098603060, -0.0415467210, -0.0000000000, 0.6024519205, -0.1185704023, 0.0401797108, 0.0262632743, -0.0000000000, -0.0018545259, 0.0018287648, -0.0119272992, -0.0364444591, 0.0219798349, 0.5388799906, -0.0873604342, 0.0527642742, 0.0248753466, -0.0020790326, -0.0021185349, 0.0008750616, -0.0132916924, -0.0301232301, 0.0412303619, 0.4704038501, -0.0476967618, 0.0638811216, 0.0221970305, -0.0042766319, -0.0023070835, 0.0000000000, -0.0139512215, -0.0229468606, 0.0571681485, 0.3987891078, 0.0000000000, 0.0729012638, 0.0182522610, -0.0064938627, -0.0023957258, -0.0007630716, -0.0139361415, -0.0152910165, 0.0693885013, 0.3258404732, 0.0550325289, 0.0792422444, 0.0131276902, -0.0086209681, -0.0023626641, -0.0013903243, -0.0133052040, -0.0075258445, 0.0776687115, 0.2533447146, 0.1164389849, 0.0823974460, 0.0069732964, -0.0105420630, -0.0021904600, -0.0018676731, -0.0121405739, -0.0000000000, 0.0819641128, 0.1830149740, 0.1830149740, 0.0819641128, -0.0000000000, -0.0121405739, -0.0018676731, -0.0021904600, -0.0105420630, 0.0069732964, 0.0823974460, 0.1164389849, 0.2533447146, 0.0776687115, -0.0075258445, -0.0133052040, -0.0013903243, -0.0023626641, -0.0086209681, 0.0131276902, 0.0792422444, 0.0550325289, 0.3258404732, 0.0693885013, -0.0152910165, -0.0139361415, -0.0007630716, -0.0023957258, -0.0064938627, 0.0182522610, 0.0729012638, 0.0000000000, 0.3987891078, 0.0571681485, -0.0229468606, -0.0139512215, 0.0000000000, -0.0023070835, -0.0042766319, 0.0221970305, 0.0638811216, -0.0476967618, 0.4704038501, 0.0412303619, -0.0301232301, -0.0132916924, 0.0008750616, -0.0021185349, -0.0020790326, 0.0248753466, 0.0527642742, -0.0873604342, 0.5388799906, 0.0219798349, -0.0364444591, -0.0119272992, 0.0018287648, -0.0018545259, -0.0000000000, 0.0262632743, 0.0401797108, -0.1185704023, 0.6024519205, -0.0000000000, -0.0415467210, -0.0098603060, 0.0028190494, -0.0015404741, 0.0018761361, 0.0263961889, 0.0267735831, -0.1411849856, 0.6594504118, -0.0239577144, -0.0450960808, -0.0071282135, 0.0037965439, -0.0012012133, 0.0034824028, 0.0253629088, 0.0131809860, -0.1553338468, 0.7083564401, -0.0489920303, -0.0468063876, -0.0038048958, 0.0047065411, -0.0008596397, 0.0047708568, 0.0232978407, 0.0000000000, -0.1614013463, 0.7478516698, -0.0740769655, -0.0464562289, 0.0000000000, 0.0054914863, -0.0005356151, 0.0057131811, 0.0203715712, -0.0122310519, -0.1600013375, 0.7768620253, -0.0980933905, -0.0439039879, 0.0041435249, 0.0060938913, -0.0002451667, 0.0063002659, 0.0167804975, -0.0230523963, -0.1519452035, 0.7945935130, -0.1198658869, -0.0391003005, 0.0084537705, 0.0064595463}; const LC3_FLOAT lp_filter_16[240] = { - -0.0018676731, 0.0065408750, -0.0121405739, 0.0127360141, -0.0000000000, -0.0320970677, 0.0819641128, -0.1382038444, 0.1830149740, 0.8005587459, 0.1830149740, -0.1382038444, 0.0819641128, -0.0320970677, -0.0000000000, 0.0127360141, -0.0121405739, 0.0065408750, -0.0018676731, 0.0000000000, -0.0021904600, 0.0064595463, -0.0105420630, 0.0084537705, 0.0069732964, -0.0391003005, 0.0823974460, -0.1198658869, 0.1164389849, 0.7945935130, 0.2533447146, -0.1519452035, 0.0776687115, -0.0230523963, -0.0075258445, 0.0167804975, -0.0133052040, 0.0063002659, -0.0013903243, -0.0002451667, -0.0023626641, 0.0060938913, -0.0086209681, 0.0041435249, 0.0131276902, -0.0439039879, 0.0792422444, -0.0980933905, 0.0550325289, 0.7768620253, 0.3258404732, -0.1600013375, 0.0693885013, -0.0122310519, -0.0152910165, 0.0203715712, -0.0139361415, 0.0057131811, -0.0007630716, -0.0005356151, -0.0023957258, 0.0054914863, -0.0064938627, 0.0000000000, 0.0182522610, -0.0464562289, 0.0729012638, -0.0740769655, 0.0000000000, 0.7478516698, 0.3987891078, -0.1614013463, 0.0571681485, 0.0000000000, -0.0229468606, 0.0232978407, -0.0139512215, 0.0047708568, 0.0000000000, -0.0008596397, -0.0023070835, 0.0047065411, -0.0042766319, -0.0038048958, 0.0221970305, -0.0468063876, 0.0638811216, -0.0489920303, -0.0476967618, 0.7083564401, 0.4704038501, -0.1553338468, 0.0412303619, 0.0131809860, -0.0301232301, 0.0253629088, -0.0132916924, 0.0034824028, 0.0008750616, -0.0012012133, -0.0021185349, 0.0037965439, -0.0020790326, -0.0071282135, 0.0248753466, -0.0450960808, 0.0527642742, -0.0239577144, -0.0873604342, 0.6594504118, 0.5388799906, -0.1411849856, 0.0219798349, 0.0267735831, -0.0364444591, 0.0263961889, -0.0119272992, 0.0018761361, 0.0018287648, -0.0015404741, -0.0018545259, 0.0028190494, -0.0000000000, -0.0098603060, 0.0262632743, -0.0415467210, 0.0401797108, -0.0000000000, -0.1185704023, 0.6024519205, 0.6024519205, -0.1185704023, -0.0000000000, 0.0401797108, -0.0415467210, 0.0262632743, -0.0098603060, -0.0000000000, 0.0028190494, -0.0018545259, -0.0015404741, 0.0018287648, 0.0018761361, -0.0119272992, 0.0263961889, -0.0364444591, 0.0267735831, 0.0219798349, -0.1411849856, 0.5388799906, 0.6594504118, -0.0873604342, -0.0239577144, 0.0527642742, -0.0450960808, 0.0248753466, -0.0071282135, -0.0020790326, 0.0037965439, -0.0021185349, -0.0012012133, 0.0008750616, 0.0034824028, -0.0132916924, 0.0253629088, -0.0301232301, 0.0131809860, 0.0412303619, -0.1553338468, 0.4704038501, 0.7083564401, -0.0476967618, -0.0489920303, 0.0638811216, -0.0468063876, 0.0221970305, -0.0038048958, -0.0042766319, 0.0047065411, -0.0023070835, -0.0008596397, 0.0000000000, 0.0047708568, -0.0139512215, 0.0232978407, -0.0229468606, 0.0000000000, 0.0571681485, -0.1614013463, 0.3987891078, 0.7478516698, 0.0000000000, -0.0740769655, 0.0729012638, -0.0464562289, 0.0182522610, 0.0000000000, -0.0064938627, 0.0054914863, -0.0023957258, -0.0005356151, -0.0007630716, 0.0057131811, -0.0139361415, 0.0203715712, -0.0152910165, -0.0122310519, 0.0693885013, -0.1600013375, 0.3258404732, 0.7768620253, 0.0550325289, -0.0980933905, 0.0792422444, -0.0439039879, 0.0131276902, 0.0041435249, -0.0086209681, 0.0060938913, -0.0023626641, -0.0002451667, -0.0013903243, 0.0063002659, -0.0133052040, 0.0167804975, -0.0075258445, -0.0230523963, 0.0776687115, -0.1519452035, 0.2533447146, 0.7945935130, 0.1164389849, -0.1198658869, 0.0823974460, -0.0391003005, 0.0069732964, 0.0084537705, -0.0105420630, 0.0064595463, -0.0021904600 +-0.0018676731, 0.0065408750, -0.0121405739, 0.0127360141, -0.0000000000, -0.0320970677, 0.0819641128, -0.1382038444, 0.1830149740, 0.8005587459, 0.1830149740, -0.1382038444, 0.0819641128, -0.0320970677, -0.0000000000, 0.0127360141, -0.0121405739, 0.0065408750, -0.0018676731, 0.0000000000, -0.0021904600, 0.0064595463, -0.0105420630, 0.0084537705, 0.0069732964, -0.0391003005, 0.0823974460, -0.1198658869, 0.1164389849, 0.7945935130, 0.2533447146, -0.1519452035, 0.0776687115, -0.0230523963, -0.0075258445, 0.0167804975, -0.0133052040, 0.0063002659, -0.0013903243, -0.0002451667, -0.0023626641, 0.0060938913, -0.0086209681, 0.0041435249, 0.0131276902, -0.0439039879, 0.0792422444, -0.0980933905, 0.0550325289, 0.7768620253, 0.3258404732, -0.1600013375, 0.0693885013, -0.0122310519, -0.0152910165, 0.0203715712, -0.0139361415, 0.0057131811, -0.0007630716, -0.0005356151, -0.0023957258, 0.0054914863, -0.0064938627, 0.0000000000, 0.0182522610, -0.0464562289, 0.0729012638, -0.0740769655, 0.0000000000, 0.7478516698, 0.3987891078, -0.1614013463, 0.0571681485, 0.0000000000, -0.0229468606, 0.0232978407, -0.0139512215, 0.0047708568, 0.0000000000, -0.0008596397, -0.0023070835, 0.0047065411, -0.0042766319, -0.0038048958, 0.0221970305, -0.0468063876, 0.0638811216, -0.0489920303, -0.0476967618, 0.7083564401, 0.4704038501, -0.1553338468, 0.0412303619, 0.0131809860, -0.0301232301, 0.0253629088, -0.0132916924, 0.0034824028, 0.0008750616, -0.0012012133, -0.0021185349, 0.0037965439, -0.0020790326, -0.0071282135, 0.0248753466, -0.0450960808, 0.0527642742, -0.0239577144, -0.0873604342, 0.6594504118, 0.5388799906, -0.1411849856, 0.0219798349, 0.0267735831, -0.0364444591, 0.0263961889, -0.0119272992, 0.0018761361, 0.0018287648, -0.0015404741, -0.0018545259, 0.0028190494, -0.0000000000, -0.0098603060, 0.0262632743, -0.0415467210, 0.0401797108, -0.0000000000, -0.1185704023, 0.6024519205, 0.6024519205, -0.1185704023, -0.0000000000, 0.0401797108, -0.0415467210, 0.0262632743, -0.0098603060, -0.0000000000, 0.0028190494, -0.0018545259, -0.0015404741, 0.0018287648, 0.0018761361, -0.0119272992, 0.0263961889, -0.0364444591, 0.0267735831, 0.0219798349, -0.1411849856, 0.5388799906, 0.6594504118, -0.0873604342, -0.0239577144, 0.0527642742, -0.0450960808, 0.0248753466, -0.0071282135, -0.0020790326, 0.0037965439, -0.0021185349, -0.0012012133, 0.0008750616, 0.0034824028, -0.0132916924, 0.0253629088, -0.0301232301, 0.0131809860, 0.0412303619, -0.1553338468, 0.4704038501, 0.7083564401, -0.0476967618, -0.0489920303, 0.0638811216, -0.0468063876, 0.0221970305, -0.0038048958, -0.0042766319, 0.0047065411, -0.0023070835, -0.0008596397, 0.0000000000, 0.0047708568, -0.0139512215, 0.0232978407, -0.0229468606, 0.0000000000, 0.0571681485, -0.1614013463, 0.3987891078, 0.7478516698, 0.0000000000, -0.0740769655, 0.0729012638, -0.0464562289, 0.0182522610, 0.0000000000, -0.0064938627, 0.0054914863, -0.0023957258, -0.0005356151, -0.0007630716, 0.0057131811, -0.0139361415, 0.0203715712, -0.0152910165, -0.0122310519, 0.0693885013, -0.1600013375, 0.3258404732, 0.7768620253, 0.0550325289, -0.0980933905, 0.0792422444, -0.0439039879, 0.0131276902, 0.0041435249, -0.0086209681, 0.0060938913, -0.0023626641, -0.0002451667, -0.0013903243, 0.0063002659, -0.0133052040, 0.0167804975, -0.0075258445, -0.0230523963, 0.0776687115, -0.1519452035, 0.2533447146, 0.7945935130, 0.1164389849, -0.1198658869, 0.0823974460, -0.0391003005, 0.0069732964, 0.0084537705, -0.0105420630, 0.0064595463, -0.0021904600 }; const LC3_FLOAT lp_filter_24[240] = { - -0.0015380557, 0.0005833744, 0.0043605831, -0.0028510878, -0.0088611282, 0.0084906761, 0.0147980200, -0.0200821534, -0.0213980451, 0.0425874144, 0.0274869073, -0.0921358988, -0.0317978412, 0.3136025667, 0.5337058306, 0.3136025667, -0.0317978412, -0.0921358988, 0.0274869073, 0.0425874144, -0.0213980451, -0.0200821534, 0.0147980200, 0.0084906761, -0.0088611282, -0.0028510878, 0.0043605831, 0.0005833744, -0.0015380557, 0.0000000000, -0.0014123565, 0.0000000000, 0.0043063643, -0.0013860217, -0.0093008140, 0.0056358469, 0.0165835638, -0.0152979074, -0.0260668676, 0.0351761840, 0.0381121002, -0.0799105912, -0.0582402907, 0.2658593953, 0.5297290087, 0.3592533171, 0.0000000000, -0.1012968048, 0.0146532226, 0.0486008413, -0.0153682642, -0.0242963061, 0.0121681746, 0.0111869983, -0.0079515325, -0.0043292418, 0.0042001773, 0.0012191766, -0.0015971506, -0.0001634445, -0.0012363506, -0.0005087144, 0.0040625944, -0.0000000000, -0.0092907613, 0.0027623500, 0.0175088495, -0.0101940110, -0.0292693246, 0.0267864745, 0.0462590009, -0.0653955936, -0.0790469348, 0.2172269821, 0.5179080367, 0.4016346335, 0.0366883539, -0.1066675633, -0.0000000000, 0.0528281629, -0.0081540346, -0.0276978146, 0.0087517938, 0.0135810468, -0.0065735374, -0.0057473122, 0.0038087873, 0.0018793662, -0.0015751094, -0.0003570767, -0.0010269828, -0.0009268829, 0.0036609909, 0.0012507574, -0.0088701360, 0.0000000000, 0.0175974593, -0.0050172298, -0.0309708193, 0.0178490561, 0.0517791398, -0.0493846424, -0.0941233262, 0.1688964665, 0.4985677898, 0.4396336079, 0.0776259899, -0.1076008976, -0.0159718096, 0.0549316332, 0.0000000000, -0.0300640538, 0.0046488643, 0.0155318938, -0.0047521424, -0.0070280419, 0.0031805711, 0.0025310293, -0.0014603067, -0.0005730931, -0.0008008089, -0.0012451154, 0.0031376940, 0.0023216018, -0.0080937156, -0.0025365972, 0.0169086065, -0.0000000000, -0.0312042590, 0.0087873237, 0.0546427406, -0.0326613523, -0.1035559028, 0.1220099851, 0.4722376168, 0.4722376168, 0.1220099851, -0.1035559028, -0.0326613523, 0.0546427406, 0.0087873237, -0.0312042590, -0.0000000000, 0.0169086065, -0.0025365972, -0.0080937156, 0.0023216018, 0.0031376940, -0.0012451154, -0.0008008089, -0.0005730931, -0.0014603067, 0.0025310293, 0.0031805711, -0.0070280419, -0.0047521424, 0.0155318938, 0.0046488643, -0.0300640538, 0.0000000000, 0.0549316332, -0.0159718096, -0.1076008976, 0.0776259899, 0.4396336079, 0.4985677898, 0.1688964665, -0.0941233262, -0.0493846424, 0.0517791398, 0.0178490561, -0.0309708193, -0.0050172298, 0.0175974593, 0.0000000000, -0.0088701360, 0.0012507574, 0.0036609909, -0.0009268829, -0.0010269828, -0.0003570767, -0.0015751094, 0.0018793662, 0.0038087873, -0.0057473122, -0.0065735374, 0.0135810468, 0.0087517938, -0.0276978146, -0.0081540346, 0.0528281629, -0.0000000000, -0.1066675633, 0.0366883539, 0.4016346335, 0.5179080367, 0.2172269821, -0.0790469348, -0.0653955936, 0.0462590009, 0.0267864745, -0.0292693246, -0.0101940110, 0.0175088495, 0.0027623500, -0.0092907613, -0.0000000000, 0.0040625944, -0.0005087144, -0.0012363506, -0.0001634445, -0.0015971506, 0.0012191766, 0.0042001773, -0.0043292418, -0.0079515325, 0.0111869983, 0.0121681746, -0.0242963061, -0.0153682642, 0.0486008413, 0.0146532226, -0.1012968048, 0.0000000000, 0.3592533171, 0.5297290087, 0.2658593953, -0.0582402907, -0.0799105912, 0.0381121002, 0.0351761840, -0.0260668676, -0.0152979074, 0.0165835638, 0.0056358469, -0.0093008140, -0.0013860217, 0.0043063643, 0.0000000000, -0.0014123565 +-0.0015380557, 0.0005833744, 0.0043605831, -0.0028510878, -0.0088611282, 0.0084906761, 0.0147980200, -0.0200821534, -0.0213980451, 0.0425874144, 0.0274869073, -0.0921358988, -0.0317978412, 0.3136025667, 0.5337058306, 0.3136025667, -0.0317978412, -0.0921358988, 0.0274869073, 0.0425874144, -0.0213980451, -0.0200821534, 0.0147980200, 0.0084906761, -0.0088611282, -0.0028510878, 0.0043605831, 0.0005833744, -0.0015380557, 0.0000000000, -0.0014123565, 0.0000000000, 0.0043063643, -0.0013860217, -0.0093008140, 0.0056358469, 0.0165835638, -0.0152979074, -0.0260668676, 0.0351761840, 0.0381121002, -0.0799105912, -0.0582402907, 0.2658593953, 0.5297290087, 0.3592533171, 0.0000000000, -0.1012968048, 0.0146532226, 0.0486008413, -0.0153682642, -0.0242963061, 0.0121681746, 0.0111869983, -0.0079515325, -0.0043292418, 0.0042001773, 0.0012191766, -0.0015971506, -0.0001634445, -0.0012363506, -0.0005087144, 0.0040625944, -0.0000000000, -0.0092907613, 0.0027623500, 0.0175088495, -0.0101940110, -0.0292693246, 0.0267864745, 0.0462590009, -0.0653955936, -0.0790469348, 0.2172269821, 0.5179080367, 0.4016346335, 0.0366883539, -0.1066675633, -0.0000000000, 0.0528281629, -0.0081540346, -0.0276978146, 0.0087517938, 0.0135810468, -0.0065735374, -0.0057473122, 0.0038087873, 0.0018793662, -0.0015751094, -0.0003570767, -0.0010269828, -0.0009268829, 0.0036609909, 0.0012507574, -0.0088701360, 0.0000000000, 0.0175974593, -0.0050172298, -0.0309708193, 0.0178490561, 0.0517791398, -0.0493846424, -0.0941233262, 0.1688964665, 0.4985677898, 0.4396336079, 0.0776259899, -0.1076008976, -0.0159718096, 0.0549316332, 0.0000000000, -0.0300640538, 0.0046488643, 0.0155318938, -0.0047521424, -0.0070280419, 0.0031805711, 0.0025310293, -0.0014603067, -0.0005730931, -0.0008008089, -0.0012451154, 0.0031376940, 0.0023216018, -0.0080937156, -0.0025365972, 0.0169086065, -0.0000000000, -0.0312042590, 0.0087873237, 0.0546427406, -0.0326613523, -0.1035559028, 0.1220099851, 0.4722376168, 0.4722376168, 0.1220099851, -0.1035559028, -0.0326613523, 0.0546427406, 0.0087873237, -0.0312042590, -0.0000000000, 0.0169086065, -0.0025365972, -0.0080937156, 0.0023216018, 0.0031376940, -0.0012451154, -0.0008008089, -0.0005730931, -0.0014603067, 0.0025310293, 0.0031805711, -0.0070280419, -0.0047521424, 0.0155318938, 0.0046488643, -0.0300640538, 0.0000000000, 0.0549316332, -0.0159718096, -0.1076008976, 0.0776259899, 0.4396336079, 0.4985677898, 0.1688964665, -0.0941233262, -0.0493846424, 0.0517791398, 0.0178490561, -0.0309708193, -0.0050172298, 0.0175974593, 0.0000000000, -0.0088701360, 0.0012507574, 0.0036609909, -0.0009268829, -0.0010269828, -0.0003570767, -0.0015751094, 0.0018793662, 0.0038087873, -0.0057473122, -0.0065735374, 0.0135810468, 0.0087517938, -0.0276978146, -0.0081540346, 0.0528281629, -0.0000000000, -0.1066675633, 0.0366883539, 0.4016346335, 0.5179080367, 0.2172269821, -0.0790469348, -0.0653955936, 0.0462590009, 0.0267864745, -0.0292693246, -0.0101940110, 0.0175088495, 0.0027623500, -0.0092907613, -0.0000000000, 0.0040625944, -0.0005087144, -0.0012363506, -0.0001634445, -0.0015971506, 0.0012191766, 0.0042001773, -0.0043292418, -0.0079515325, 0.0111869983, 0.0121681746, -0.0242963061, -0.0153682642, 0.0486008413, 0.0146532226, -0.1012968048, 0.0000000000, 0.3592533171, 0.5297290087, 0.2658593953, -0.0582402907, -0.0799105912, 0.0381121002, 0.0351761840, -0.0260668676, -0.0152979074, 0.0165835638, 0.0056358469, -0.0093008140, -0.0013860217, 0.0043063643, 0.0000000000, -0.0014123565 }; const LC3_FLOAT lp_filter_32[240] = { - -0.0009272629, -0.0009338366, 0.0014095247, 0.0032704375, -0.0000000000, -0.0060702870, -0.0049301530, 0.0063680070, 0.0131316371, -0.0000000000, -0.0207733605, -0.0160485338, 0.0200898554, 0.0409820564, -0.0000000000, -0.0691019222, -0.0592852011, 0.0915074870, 0.3012259603, 0.4002793729, 0.3012259603, 0.0915074870, -0.0592852011, -0.0691019222, -0.0000000000, 0.0409820564, 0.0200898554, -0.0160485338, -0.0207733605, -0.0000000000, 0.0131316371, 0.0063680070, -0.0049301530, -0.0060702870, -0.0000000000, 0.0032704375, 0.0014095247, -0.0009338366, -0.0009272629, 0.0000000000, -0.0007702371, -0.0010952300, 0.0009143824, 0.0032297731, 0.0009380680, -0.0052710315, -0.0059636496, 0.0042268853, 0.0131980944, 0.0034866482, -0.0182222296, -0.0195501503, 0.0133867916, 0.0411987230, 0.0109899174, -0.0599329434, -0.0705924928, 0.0582194924, 0.2694399953, 0.3972967565, 0.3297252059, 0.1266723573, -0.0436802171, -0.0759726018, -0.0119788572, 0.0388343558, 0.0263821371, -0.0115261981, -0.0225480404, -0.0037629222, 0.0124376733, 0.0083902488, -0.0035641068, -0.0066526020, -0.0010395163, 0.0031501330, 0.0018982720, -0.0006951622, -0.0010592674, -0.0001225834, -0.0006006067, -0.0011813320, 0.0004375308, 0.0030469457, 0.0017412014, -0.0043104840, -0.0066458462, 0.0020717625, 0.0126814544, 0.0065638451, -0.0150616150, -0.0219519939, 0.0065904930, 0.0396211222, 0.0206151810, -0.0490466952, -0.0776669234, 0.0275162645, 0.2352019250, 0.3884310126, 0.3541782200, 0.1629202366, -0.0238483809, -0.0800006688, -0.0244960152, 0.0346942507, 0.0319405608, -0.0061155260, -0.0234031938, -0.0076455083, 0.0110985152, 0.0101857856, -0.0019024479, -0.0069680708, -0.0021383159, 0.0028565906, 0.0023532705, -0.0003815358, -0.0011535417, -0.0002678075, -0.0004298199, -0.0011978629, 0.0000000000, 0.0027457431, 0.0023854284, -0.0032469314, -0.0069756107, 0.0000000000, 0.0116489204, 0.0091261305, -0.0114734303, -0.0232281145, 0.0000000000, 0.0364506319, 0.0285840742, -0.0370384827, -0.0807006732, 0.0000000000, 0.1993945539, 0.3739258349, 0.3739258349, 0.1993945539, 0.0000000000, -0.0807006732, -0.0370384827, 0.0285840742, 0.0364506319, 0.0000000000, -0.0232281145, -0.0114734303, 0.0091261305, 0.0116489204, 0.0000000000, -0.0069756107, -0.0032469314, 0.0023854284, 0.0027457431, 0.0000000000, -0.0011978629, -0.0004298199, -0.0002678075, -0.0011535417, -0.0003815358, 0.0023532705, 0.0028565906, -0.0021383159, -0.0069680708, -0.0019024479, 0.0101857856, 0.0110985152, -0.0076455083, -0.0234031938, -0.0061155260, 0.0319405608, 0.0346942507, -0.0244960152, -0.0800006688, -0.0238483809, 0.1629202366, 0.3541782200, 0.3884310126, 0.2352019250, 0.0275162645, -0.0776669234, -0.0490466952, 0.0206151810, 0.0396211222, 0.0065904930, -0.0219519939, -0.0150616150, 0.0065638451, 0.0126814544, 0.0020717625, -0.0066458462, -0.0043104840, 0.0017412014, 0.0030469457, 0.0004375308, -0.0011813320, -0.0006006067, -0.0001225834, -0.0010592674, -0.0006951622, 0.0018982720, 0.0031501330, -0.0010395163, -0.0066526020, -0.0035641068, 0.0083902488, 0.0124376733, -0.0037629222, -0.0225480404, -0.0115261981, 0.0263821371, 0.0388343558, -0.0119788572, -0.0759726018, -0.0436802171, 0.1266723573, 0.3297252059, 0.3972967565, 0.2694399953, 0.0582194924, -0.0705924928, -0.0599329434, 0.0109899174, 0.0411987230, 0.0133867916, -0.0195501503, -0.0182222296, 0.0034866482, 0.0131980944, 0.0042268853, -0.0059636496, -0.0052710315, 0.0009380680, 0.0032297731, 0.0009143824, -0.0010952300, -0.0007702371 +-0.0009272629, -0.0009338366, 0.0014095247, 0.0032704375, -0.0000000000, -0.0060702870, -0.0049301530, 0.0063680070, 0.0131316371, -0.0000000000, -0.0207733605, -0.0160485338, 0.0200898554, 0.0409820564, -0.0000000000, -0.0691019222, -0.0592852011, 0.0915074870, 0.3012259603, 0.4002793729, 0.3012259603, 0.0915074870, -0.0592852011, -0.0691019222, -0.0000000000, 0.0409820564, 0.0200898554, -0.0160485338, -0.0207733605, -0.0000000000, 0.0131316371, 0.0063680070, -0.0049301530, -0.0060702870, -0.0000000000, 0.0032704375, 0.0014095247, -0.0009338366, -0.0009272629, 0.0000000000, -0.0007702371, -0.0010952300, 0.0009143824, 0.0032297731, 0.0009380680, -0.0052710315, -0.0059636496, 0.0042268853, 0.0131980944, 0.0034866482, -0.0182222296, -0.0195501503, 0.0133867916, 0.0411987230, 0.0109899174, -0.0599329434, -0.0705924928, 0.0582194924, 0.2694399953, 0.3972967565, 0.3297252059, 0.1266723573, -0.0436802171, -0.0759726018, -0.0119788572, 0.0388343558, 0.0263821371, -0.0115261981, -0.0225480404, -0.0037629222, 0.0124376733, 0.0083902488, -0.0035641068, -0.0066526020, -0.0010395163, 0.0031501330, 0.0018982720, -0.0006951622, -0.0010592674, -0.0001225834, -0.0006006067, -0.0011813320, 0.0004375308, 0.0030469457, 0.0017412014, -0.0043104840, -0.0066458462, 0.0020717625, 0.0126814544, 0.0065638451, -0.0150616150, -0.0219519939, 0.0065904930, 0.0396211222, 0.0206151810, -0.0490466952, -0.0776669234, 0.0275162645, 0.2352019250, 0.3884310126, 0.3541782200, 0.1629202366, -0.0238483809, -0.0800006688, -0.0244960152, 0.0346942507, 0.0319405608, -0.0061155260, -0.0234031938, -0.0076455083, 0.0110985152, 0.0101857856, -0.0019024479, -0.0069680708, -0.0021383159, 0.0028565906, 0.0023532705, -0.0003815358, -0.0011535417, -0.0002678075, -0.0004298199, -0.0011978629, 0.0000000000, 0.0027457431, 0.0023854284, -0.0032469314, -0.0069756107, 0.0000000000, 0.0116489204, 0.0091261305, -0.0114734303, -0.0232281145, 0.0000000000, 0.0364506319, 0.0285840742, -0.0370384827, -0.0807006732, 0.0000000000, 0.1993945539, 0.3739258349, 0.3739258349, 0.1993945539, 0.0000000000, -0.0807006732, -0.0370384827, 0.0285840742, 0.0364506319, 0.0000000000, -0.0232281145, -0.0114734303, 0.0091261305, 0.0116489204, 0.0000000000, -0.0069756107, -0.0032469314, 0.0023854284, 0.0027457431, 0.0000000000, -0.0011978629, -0.0004298199, -0.0002678075, -0.0011535417, -0.0003815358, 0.0023532705, 0.0028565906, -0.0021383159, -0.0069680708, -0.0019024479, 0.0101857856, 0.0110985152, -0.0076455083, -0.0234031938, -0.0061155260, 0.0319405608, 0.0346942507, -0.0244960152, -0.0800006688, -0.0238483809, 0.1629202366, 0.3541782200, 0.3884310126, 0.2352019250, 0.0275162645, -0.0776669234, -0.0490466952, 0.0206151810, 0.0396211222, 0.0065904930, -0.0219519939, -0.0150616150, 0.0065638451, 0.0126814544, 0.0020717625, -0.0066458462, -0.0043104840, 0.0017412014, 0.0030469457, 0.0004375308, -0.0011813320, -0.0006006067, -0.0001225834, -0.0010592674, -0.0006951622, 0.0018982720, 0.0031501330, -0.0010395163, -0.0066526020, -0.0035641068, 0.0083902488, 0.0124376733, -0.0037629222, -0.0225480404, -0.0115261981, 0.0263821371, 0.0388343558, -0.0119788572, -0.0759726018, -0.0436802171, 0.1266723573, 0.3297252059, 0.3972967565, 0.2694399953, 0.0582194924, -0.0705924928, -0.0599329434, 0.0109899174, 0.0411987230, 0.0133867916, -0.0195501503, -0.0182222296, 0.0034866482, 0.0131980944, 0.0042268853, -0.0059636496, -0.0052710315, 0.0009380680, 0.0032297731, 0.0009143824, -0.0010952300, -0.0007702371 }; const LC3_FLOAT lp_filter_48[240] = { - -0.0004004044, -0.0007690279, -0.0006225577, 0.0002916872, 0.0015688470, 0.0021802916, 0.0011608009, -0.0014255439, -0.0040468578, -0.0044305641, -0.0012682986, 0.0042453380, 0.0084543033, 0.0073990100, -0.0000000000, -0.0100410767, -0.0156021295, -0.0106990226, 0.0043936619, 0.0212937072, 0.0273213703, 0.0137434537, -0.0163306762, -0.0460679494, -0.0517779514, -0.0158989206, 0.0610049926, 0.1568012834, 0.2361188084, 0.2668529153, 0.2361188084, 0.1568012834, 0.0610049926, -0.0158989206, -0.0517779514, -0.0460679494, -0.0163306762, 0.0137434537, 0.0273213703, 0.0212937072, 0.0043936619, -0.0106990226, -0.0156021295, -0.0100410767, -0.0000000000, 0.0073990100, 0.0084543033, 0.0042453380, -0.0012682986, -0.0044305641, -0.0040468578, -0.0014255439, 0.0011608009, 0.0021802916, 0.0015688470, 0.0002916872, -0.0006225577, -0.0007690279, -0.0004004044, 0.0000000000, -0.0002865466, -0.0007061783, -0.0007301533, 0.0000000000, 0.0012655146, 0.0021531822, 0.0015902856, -0.0006930109, -0.0035140209, -0.0046504070, -0.0023760712, 0.0028179234, 0.0077659469, 0.0082917819, 0.0023244321, -0.0076489537, -0.0150320269, -0.0130334338, 0.0000000000, 0.0175880920, 0.0274658166, 0.0190560501, -0.0079859048, -0.0399552956, -0.0538004488, -0.0291201454, 0.0388129950, 0.1329296976, 0.2198168039, 0.2648645043, 0.2492838949, 0.1796266586, 0.0844482332, 0.0000000000, -0.0470616631, -0.0506484024, -0.0246923212, 0.0073266113, 0.0258895699, 0.0243004207, 0.0089245280, -0.0076841321, -0.0154854096, -0.0121481530, -0.0025086149, 0.0060840873, 0.0087987296, 0.0055934992, 0.0000000000, -0.0039757662, -0.0044350680, -0.0021646209, 0.0006253787, 0.0021000886, 0.0018304954, 0.0006095883, -0.0004634415, -0.0007985753, -0.0005134914, -0.0000817222, -0.0001785384, -0.0006181753, -0.0007875547, -0.0002543572, 0.0009396831, 0.0020312972, 0.0019043937, -0.0000000000, -0.0028736561, -0.0046453807, -0.0032867687, 0.0013811750, 0.0067905234, 0.0087544248, 0.0043758969, -0.0050970055, -0.0138489073, -0.0146346623, -0.0040770173, 0.0133932373, 0.0264140815, 0.0231295004, -0.0000000000, -0.0326977968, -0.0533337817, -0.0395234674, 0.0183441769, 0.1086134911, 0.2008173168, 0.2589540184, 0.2589540184, 0.2008173168, 0.1086134911, 0.0183441769, -0.0395234674, -0.0533337817, -0.0326977968, -0.0000000000, 0.0231295004, 0.0264140815, 0.0133932373, -0.0040770173, -0.0146346623, -0.0138489073, -0.0050970055, 0.0043758969, 0.0087544248, 0.0067905234, 0.0013811750, -0.0032867687, -0.0046453807, -0.0028736561, -0.0000000000, 0.0019043937, 0.0020312972, 0.0009396831, -0.0002543572, -0.0007875547, -0.0006181753, -0.0001785384, -0.0000817222, -0.0005134914, -0.0007985753, -0.0004634415, 0.0006095883, 0.0018304954, 0.0021000886, 0.0006253787, -0.0021646209, -0.0044350680, -0.0039757662, 0.0000000000, 0.0055934992, 0.0087987296, 0.0060840873, -0.0025086149, -0.0121481530, -0.0154854096, -0.0076841321, 0.0089245280, 0.0243004207, 0.0258895699, 0.0073266113, -0.0246923212, -0.0506484024, -0.0470616631, 0.0000000000, 0.0844482332, 0.1796266586, 0.2492838949, 0.2648645043, 0.2198168039, 0.1329296976, 0.0388129950, -0.0291201454, -0.0538004488, -0.0399552956, -0.0079859048, 0.0190560501, 0.0274658166, 0.0175880920, 0.0000000000, -0.0130334338, -0.0150320269, -0.0076489537, 0.0023244321, 0.0082917819, 0.0077659469, 0.0028179234, -0.0023760712, -0.0046504070, -0.0035140209, -0.0006930109, 0.0015902856, 0.0021531822, 0.0012655146, 0.0000000000, -0.0007301533, -0.0007061783, -0.0002865466 +-0.0004004044, -0.0007690279, -0.0006225577, 0.0002916872, 0.0015688470, 0.0021802916, 0.0011608009, -0.0014255439, -0.0040468578, -0.0044305641, -0.0012682986, 0.0042453380, 0.0084543033, 0.0073990100, -0.0000000000, -0.0100410767, -0.0156021295, -0.0106990226, 0.0043936619, 0.0212937072, 0.0273213703, 0.0137434537, -0.0163306762, -0.0460679494, -0.0517779514, -0.0158989206, 0.0610049926, 0.1568012834, 0.2361188084, 0.2668529153, 0.2361188084, 0.1568012834, 0.0610049926, -0.0158989206, -0.0517779514, -0.0460679494, -0.0163306762, 0.0137434537, 0.0273213703, 0.0212937072, 0.0043936619, -0.0106990226, -0.0156021295, -0.0100410767, -0.0000000000, 0.0073990100, 0.0084543033, 0.0042453380, -0.0012682986, -0.0044305641, -0.0040468578, -0.0014255439, 0.0011608009, 0.0021802916, 0.0015688470, 0.0002916872, -0.0006225577, -0.0007690279, -0.0004004044, 0.0000000000, -0.0002865466, -0.0007061783, -0.0007301533, 0.0000000000, 0.0012655146, 0.0021531822, 0.0015902856, -0.0006930109, -0.0035140209, -0.0046504070, -0.0023760712, 0.0028179234, 0.0077659469, 0.0082917819, 0.0023244321, -0.0076489537, -0.0150320269, -0.0130334338, 0.0000000000, 0.0175880920, 0.0274658166, 0.0190560501, -0.0079859048, -0.0399552956, -0.0538004488, -0.0291201454, 0.0388129950, 0.1329296976, 0.2198168039, 0.2648645043, 0.2492838949, 0.1796266586, 0.0844482332, 0.0000000000, -0.0470616631, -0.0506484024, -0.0246923212, 0.0073266113, 0.0258895699, 0.0243004207, 0.0089245280, -0.0076841321, -0.0154854096, -0.0121481530, -0.0025086149, 0.0060840873, 0.0087987296, 0.0055934992, 0.0000000000, -0.0039757662, -0.0044350680, -0.0021646209, 0.0006253787, 0.0021000886, 0.0018304954, 0.0006095883, -0.0004634415, -0.0007985753, -0.0005134914, -0.0000817222, -0.0001785384, -0.0006181753, -0.0007875547, -0.0002543572, 0.0009396831, 0.0020312972, 0.0019043937, -0.0000000000, -0.0028736561, -0.0046453807, -0.0032867687, 0.0013811750, 0.0067905234, 0.0087544248, 0.0043758969, -0.0050970055, -0.0138489073, -0.0146346623, -0.0040770173, 0.0133932373, 0.0264140815, 0.0231295004, -0.0000000000, -0.0326977968, -0.0533337817, -0.0395234674, 0.0183441769, 0.1086134911, 0.2008173168, 0.2589540184, 0.2589540184, 0.2008173168, 0.1086134911, 0.0183441769, -0.0395234674, -0.0533337817, -0.0326977968, -0.0000000000, 0.0231295004, 0.0264140815, 0.0133932373, -0.0040770173, -0.0146346623, -0.0138489073, -0.0050970055, 0.0043758969, 0.0087544248, 0.0067905234, 0.0013811750, -0.0032867687, -0.0046453807, -0.0028736561, -0.0000000000, 0.0019043937, 0.0020312972, 0.0009396831, -0.0002543572, -0.0007875547, -0.0006181753, -0.0001785384, -0.0000817222, -0.0005134914, -0.0007985753, -0.0004634415, 0.0006095883, 0.0018304954, 0.0021000886, 0.0006253787, -0.0021646209, -0.0044350680, -0.0039757662, 0.0000000000, 0.0055934992, 0.0087987296, 0.0060840873, -0.0025086149, -0.0121481530, -0.0154854096, -0.0076841321, 0.0089245280, 0.0243004207, 0.0258895699, 0.0073266113, -0.0246923212, -0.0506484024, -0.0470616631, 0.0000000000, 0.0844482332, 0.1796266586, 0.2492838949, 0.2648645043, 0.2198168039, 0.1329296976, 0.0388129950, -0.0291201454, -0.0538004488, -0.0399552956, -0.0079859048, 0.0190560501, 0.0274658166, 0.0175880920, 0.0000000000, -0.0130334338, -0.0150320269, -0.0076489537, 0.0023244321, 0.0082917819, 0.0077659469, 0.0028179234, -0.0023760712, -0.0046504070, -0.0035140209, -0.0006930109, 0.0015902856, 0.0021531822, 0.0012655146, 0.0000000000, -0.0007301533, -0.0007061783, -0.0002865466 }; const LC3_FLOAT lp_filter_96[240] = { - -0.0000892692, -0.0002002022, -0.0003090877, -0.0003845139, -0.0003937774, -0.0003112789, -0.0001271786, 0.0001458436, 0.0004698416, 0.0007844235, 0.0010156486, 0.0010901458, 0.0009521968, 0.0005804005, -0.0000000000, -0.0007127720, -0.0014368281, -0.0020234289, -0.0023226903, -0.0022152821, -0.0016433843, -0.0006341493, 0.0006905875, 0.0021226690, 0.0033952617, 0.0042271516, 0.0043772124, 0.0036995050, 0.0021879484, -0.0000000000, -0.0025485028, -0.0050205383, -0.0069244537, -0.0078010648, -0.0073173312, -0.0053495113, -0.0020385087, 0.0021968309, 0.0066966186, 0.0106468536, 0.0132070407, 0.0136606852, 0.0115647502, 0.0068717268, -0.0000000000, -0.0081653381, -0.0163488984, -0.0230339747, -0.0266668908, -0.0258889757, -0.0197617337, -0.0079494603, 0.0091720885, 0.0305024963, 0.0543067455, 0.0784006417, 0.1004086584, 0.1180594042, 0.1294770092, 0.1334264576, 0.1294770092, 0.1180594042, 0.1004086584, 0.0784006417, 0.0543067455, 0.0305024963, 0.0091720885, -0.0079494603, -0.0197617337, -0.0258889757, -0.0266668908, -0.0230339747, -0.0163488984, -0.0081653381, -0.0000000000, 0.0068717268, 0.0115647502, 0.0136606852, 0.0132070407, 0.0106468536, 0.0066966186, 0.0021968309, -0.0020385087, -0.0053495113, -0.0073173312, -0.0078010648, -0.0069244537, -0.0050205383, -0.0025485028, -0.0000000000, 0.0021879484, 0.0036995050, 0.0043772124, 0.0042271516, 0.0033952617, 0.0021226690, 0.0006905875, -0.0006341493, -0.0016433843, -0.0022152821, -0.0023226903, -0.0020234289, -0.0014368281, -0.0007127720, -0.0000000000, 0.0005804005, 0.0009521968, 0.0010901458, 0.0010156486, 0.0007844235, 0.0004698416, 0.0001458436, -0.0001271786, -0.0003112789, -0.0003937774, -0.0003845139, -0.0003090877, -0.0002002022, -0.0000892692, 0.0000000000, -0.0000408611, -0.0001432733, -0.0002567457, -0.0003530891, -0.0003992876, -0.0003650767, -0.0002317207, 0.0000000000, 0.0003047941, 0.0006327573, 0.0009152477, 0.0010765911, 0.0010500443, 0.0007951428, 0.0003126893, -0.0003465054, -0.0010823105, -0.0017570105, -0.0022175340, -0.0023252035, -0.0019878831, -0.0011880356, 0.0000000000, 0.0014089617, 0.0027967496, 0.0038829735, 0.0043993648, 0.0041458909, 0.0030420437, 0.0011622161, -0.0012543075, -0.0038244769, -0.0060740765, -0.0075160135, -0.0077427048, -0.0065167169, -0.0038420660, 0.0000000000, 0.0044622640, 0.0087940460, 0.0121502103, 0.0137329083, 0.0129447849, 0.0095280251, 0.0036633057, -0.0039929524, -0.0123461606, -0.0199776478, -0.0253242012, -0.0269002244, -0.0235308316, -0.0145600727, 0.0000000000, 0.0194064975, 0.0422241166, 0.0664648488, 0.0898133293, 0.1099084020, 0.1246419474, 0.1324322522, 0.1324322522, 0.1246419474, 0.1099084020, 0.0898133293, 0.0664648488, 0.0422241166, 0.0194064975, 0.0000000000, -0.0145600727, -0.0235308316, -0.0269002244, -0.0253242012, -0.0199776478, -0.0123461606, -0.0039929524, 0.0036633057, 0.0095280251, 0.0129447849, 0.0137329083, 0.0121502103, 0.0087940460, 0.0044622640, 0.0000000000, -0.0038420660, -0.0065167169, -0.0077427048, -0.0075160135, -0.0060740765, -0.0038244769, -0.0012543075, 0.0011622161, 0.0030420437, 0.0041458909, 0.0043993648, 0.0038829735, 0.0027967496, 0.0014089617, 0.0000000000, -0.0011880356, -0.0019878831, -0.0023252035, -0.0022175340, -0.0017570105, -0.0010823105, -0.0003465054, 0.0003126893, 0.0007951428, 0.0010500443, 0.0010765911, 0.0009152477, 0.0006327573, 0.0003047941, 0.0000000000, -0.0002317207, -0.0003650767, -0.0003992876, -0.0003530891, -0.0002567457, -0.0001432733, -0.0000408611 +-0.0000892692, -0.0002002022, -0.0003090877, -0.0003845139, -0.0003937774, -0.0003112789, -0.0001271786, 0.0001458436, 0.0004698416, 0.0007844235, 0.0010156486, 0.0010901458, 0.0009521968, 0.0005804005, -0.0000000000, -0.0007127720, -0.0014368281, -0.0020234289, -0.0023226903, -0.0022152821, -0.0016433843, -0.0006341493, 0.0006905875, 0.0021226690, 0.0033952617, 0.0042271516, 0.0043772124, 0.0036995050, 0.0021879484, -0.0000000000, -0.0025485028, -0.0050205383, -0.0069244537, -0.0078010648, -0.0073173312, -0.0053495113, -0.0020385087, 0.0021968309, 0.0066966186, 0.0106468536, 0.0132070407, 0.0136606852, 0.0115647502, 0.0068717268, -0.0000000000, -0.0081653381, -0.0163488984, -0.0230339747, -0.0266668908, -0.0258889757, -0.0197617337, -0.0079494603, 0.0091720885, 0.0305024963, 0.0543067455, 0.0784006417, 0.1004086584, 0.1180594042, 0.1294770092, 0.1334264576, 0.1294770092, 0.1180594042, 0.1004086584, 0.0784006417, 0.0543067455, 0.0305024963, 0.0091720885, -0.0079494603, -0.0197617337, -0.0258889757, -0.0266668908, -0.0230339747, -0.0163488984, -0.0081653381, -0.0000000000, 0.0068717268, 0.0115647502, 0.0136606852, 0.0132070407, 0.0106468536, 0.0066966186, 0.0021968309, -0.0020385087, -0.0053495113, -0.0073173312, -0.0078010648, -0.0069244537, -0.0050205383, -0.0025485028, -0.0000000000, 0.0021879484, 0.0036995050, 0.0043772124, 0.0042271516, 0.0033952617, 0.0021226690, 0.0006905875, -0.0006341493, -0.0016433843, -0.0022152821, -0.0023226903, -0.0020234289, -0.0014368281, -0.0007127720, -0.0000000000, 0.0005804005, 0.0009521968, 0.0010901458, 0.0010156486, 0.0007844235, 0.0004698416, 0.0001458436, -0.0001271786, -0.0003112789, -0.0003937774, -0.0003845139, -0.0003090877, -0.0002002022, -0.0000892692, 0.0000000000, -0.0000408611, -0.0001432733, -0.0002567457, -0.0003530891, -0.0003992876, -0.0003650767, -0.0002317207, 0.0000000000, 0.0003047941, 0.0006327573, 0.0009152477, 0.0010765911, 0.0010500443, 0.0007951428, 0.0003126893, -0.0003465054, -0.0010823105, -0.0017570105, -0.0022175340, -0.0023252035, -0.0019878831, -0.0011880356, 0.0000000000, 0.0014089617, 0.0027967496, 0.0038829735, 0.0043993648, 0.0041458909, 0.0030420437, 0.0011622161, -0.0012543075, -0.0038244769, -0.0060740765, -0.0075160135, -0.0077427048, -0.0065167169, -0.0038420660, 0.0000000000, 0.0044622640, 0.0087940460, 0.0121502103, 0.0137329083, 0.0129447849, 0.0095280251, 0.0036633057, -0.0039929524, -0.0123461606, -0.0199776478, -0.0253242012, -0.0269002244, -0.0235308316, -0.0145600727, 0.0000000000, 0.0194064975, 0.0422241166, 0.0664648488, 0.0898133293, 0.1099084020, 0.1246419474, 0.1324322522, 0.1324322522, 0.1246419474, 0.1099084020, 0.0898133293, 0.0664648488, 0.0422241166, 0.0194064975, 0.0000000000, -0.0145600727, -0.0235308316, -0.0269002244, -0.0253242012, -0.0199776478, -0.0123461606, -0.0039929524, 0.0036633057, 0.0095280251, 0.0129447849, 0.0137329083, 0.0121502103, 0.0087940460, 0.0044622640, 0.0000000000, -0.0038420660, -0.0065167169, -0.0077427048, -0.0075160135, -0.0060740765, -0.0038244769, -0.0012543075, 0.0011622161, 0.0030420437, 0.0041458909, 0.0043993648, 0.0038829735, 0.0027967496, 0.0014089617, 0.0000000000, -0.0011880356, -0.0019878831, -0.0023252035, -0.0022175340, -0.0017570105, -0.0010823105, -0.0003465054, 0.0003126893, 0.0007951428, 0.0010500443, 0.0010765911, 0.0009152477, 0.0006327573, 0.0003047941, 0.0000000000, -0.0002317207, -0.0003650767, -0.0003992876, -0.0003530891, -0.0002567457, -0.0001432733, -0.0000408611 }; -const LC3_FLOAT *lp_filter[] = { lp_filter_8, lp_filter_16, lp_filter_24, lp_filter_32, lp_filter_48, lp_filter_96 }; +const LC3_FLOAT *lp_filter[] = {lp_filter_8, lp_filter_16, lp_filter_24, lp_filter_32, lp_filter_48, lp_filter_96}; -const LC3_INT up_fac[6] = { 24, 12, 8, 6, 4, 2 }; +const LC3_INT up_fac[6] = {24, 12, 8, 6, 4, 2}; /* TNS */ const LC3_INT huff_bits_tns[8][17] = { - { 20480, 15725, 12479, 10334, 8694, 7320, 6964, 6335, 5504, 5637, 6566, 6758, 8433, 11348, 15186, 20480, 20480 }, - { 20480, 20480, 20480, 20480, 12902, 9368, 7057, 5901, 5254, 5485, 5598, 6076, 7608, 10742, 15186, 20480, 20480 }, - { 20480, 20480, 20480, 20480, 13988, 9368, 6702, 4841, 4585, 4682, 5859, 7764, 12109, 20480, 20480, 20480, 20480 }, - { 20480, 20480, 20480, 20480, 18432, 13396, 8982, 4767, 3779, 3658, 6335, 9656, 13988, 20480, 20480, 20480, 20480 }, - { 20480, 20480, 20480, 20480, 20480, 14731, 9437, 4275, 3249, 3493, 8483, 13988, 17234, 20480, 20480, 20480, 20480 }, - { 20480, 20480, 20480, 20480, 20480, 20480, 12902, 4753, 3040, 2953, 9105, 15725, 20480, 20480, 20480, 20480, 20480 }, - { 20480, 20480, 20480, 20480, 20480, 20480, 12902, 3821, 3346, 3000, 12109, 20480, 20480, 20480, 20480, 20480, - 20480 }, - { 20480, 20480, 20480, 20480, 20480, 20480, 15725, 3658, 20480, 1201, 10854, 18432, 20480, 20480, 20480, 20480, - 20480 } -}; - -const LC3_INT order1_tns[8] = { 17234, 13988, 11216, 8694, 6566, 4977, 3961, 3040 }; -const LC3_INT order2_tns[8] = { 12683, 9437, 6874, 5541, 5121, 5170, 5359, 5056 }; - -const LC3_FLOAT lagw_tns[9] = { 1, - 0.998028026020383, - 0.992135405511397, - 0.982391584470799, - 0.968910791191297, - 0.951849807369274, - 0.931404933402306, - 0.907808229996959, - 0.881323136669471 }; + {20480, 15725, 12479, 10334, 8694, 7320, 6964, 6335, 5504, 5637, 6566, 6758, 8433, 11348, 15186, 20480, 20480}, + {20480, 20480, 20480, 20480, 12902, 9368, 7057, 5901, 5254, 5485, 5598, 6076, 7608, 10742, 15186, 20480, 20480}, + {20480, 20480, 20480, 20480, 13988, 9368, 6702, 4841, 4585, 4682, 5859, 7764, 12109, 20480, 20480, 20480, 20480}, + {20480, 20480, 20480, 20480, 18432, 13396, 8982, 4767, 3779, 3658, 6335, 9656, 13988, 20480, 20480, 20480, 20480}, + {20480, 20480, 20480, 20480, 20480, 14731, 9437, 4275, 3249, 3493, 8483, 13988, 17234, 20480, 20480, 20480, 20480}, + {20480, 20480, 20480, 20480, 20480, 20480, 12902, 4753, 3040, 2953, 9105, 15725, 20480, 20480, 20480, 20480, 20480}, + {20480, 20480, 20480, 20480, 20480, 20480, 12902, 3821, 3346, 3000, 12109, 20480, 20480, 20480, 20480, 20480, + 20480}, + {20480, 20480, 20480, 20480, 20480, 20480, 15725, 3658, 20480, 1201, 10854, 18432, 20480, 20480, 20480, 20480, + 20480}}; + +const LC3_INT order1_tns[8] = {17234, 13988, 11216, 8694, 6566, 4977, 3961, 3040}; +const LC3_INT order2_tns[8] = {12683, 9437, 6874, 5541, 5121, 5170, 5359, 5056}; + +const LC3_FLOAT lagw_tns[9] = {1, + 0.998028026020383, + 0.992135405511397, + 0.982391584470799, + 0.968910791191297, + 0.951849807369274, + 0.931404933402306, + 0.907808229996959, + 0.881323136669471}; const LC3_FLOAT quants_pts_tns[17] = { -0.995727539062500, -0.961822509765625, -0.895172119140625, - -0.798004150390625, -0.673706054687500, -0.526428222656250, - -0.361236572265625, -0.183746337890625, 0.000000000000000, - 0.183746337890625, 0.361236572265625, 0.526428222656250, - 0.673706054687500, 0.798004150390625, 0.895172119140625, - 0.961822509765625, 0.995727539062500 }; - -const LC3_FLOAT quants_thr_tns[18] = { -1, - -0.982973099683902, - -0.932472229404356, - -0.850217135729614, - -0.739008917220659, - -0.602634636379256, - -0.445738355776538, - -0.273662990072083, - -0.0922683594633020, - 0.0922683594633020, - 0.273662990072083, - 0.445738355776538, - 0.602634636379256, - 0.739008917220659, - 0.850217135729614, - 0.932472229404356, - 0.982973099683902, - 1 }; + -0.798004150390625, -0.673706054687500, -0.526428222656250, + -0.361236572265625, -0.183746337890625, 0.000000000000000, + 0.183746337890625, 0.361236572265625, 0.526428222656250, + 0.673706054687500, 0.798004150390625, 0.895172119140625, + 0.961822509765625, 0.995727539062500}; + +const LC3_FLOAT quants_thr_tns[18] = {-1, + -0.982973099683902, + -0.932472229404356, + -0.850217135729614, + -0.739008917220659, + -0.602634636379256, + -0.445738355776538, + -0.273662990072083, + -0.0922683594633020, + 0.0922683594633020, + 0.273662990072083, + 0.445738355776538, + 0.602634636379256, + 0.739008917220659, + 0.850217135729614, + 0.932472229404356, + 0.982973099683902, + 1}; /* SNS */ -const LC3_FLOAT sns_vq_far_adj_gains_fl[8] = { 1.05859375000000, 1.23706054687500, 1.43920898437500, 1.98950195312500, - 2.49877929687500, 3.13110351562500, 4.11816406250000, 4.85400390625000 }; +const LC3_FLOAT sns_vq_far_adj_gains_fl[8] = {1.05859375000000, 1.23706054687500, 1.43920898437500, 1.98950195312500, + 2.49877929687500, 3.13110351562500, 4.11816406250000, 4.85400390625000}; -const LC3_FLOAT sns_vq_near_adj_gains_fl[4] = { 1.73315429687500, 2.22949218750000, 2.74731445312500, 3.61523437500000 }; +const LC3_FLOAT sns_vq_near_adj_gains_fl[4] = {1.73315429687500, 2.22949218750000, 2.74731445312500, 3.61523437500000}; -const LC3_FLOAT sns_vq_reg_lf_adj_gains_fl[4] = { 1.52465820312500, 3.67260742187500, 4.36059570312500, - 5.13037109375000 }; +const LC3_FLOAT sns_vq_reg_lf_adj_gains_fl[4] = {1.52465820312500, 3.67260742187500, 4.36059570312500, + 5.13037109375000}; -const LC3_FLOAT q_g_sns[6] = { 2.17651367187500, 2.94287109375000, 1.52465820312500, - 3.67260742187500, 4.36059570312500, 5.13037109375000 }; +const LC3_FLOAT q_g_sns[6] = {2.17651367187500, 2.94287109375000, 1.52465820312500, + 3.67260742187500, 4.36059570312500, 5.13037109375000}; -const LC3_FLOAT sns_vq_reg_adj_gains_fl[2] = { 2.17651367187500, 2.94287109375000 }; +const LC3_FLOAT sns_vq_reg_adj_gains_fl[2] = {2.17651367187500, 2.94287109375000}; /* First element in each row is multiplied with norm2 = 1 / sqrt(2) */ const LC3_FLOAT idct_lookup[M][M] = { - { 0.707106781186547, 0.995184726672197, 0.980785280403230, 0.956940335732209, 0.923879532511287, 0.881921264348355, 0.831469612302545, 0.773010453362737, 0.707106781186548, 0.634393284163646, 0.555570233019602, 0.471396736825998, 0.382683432365090, 0.290284677254462, 0.195090322016128, 0.0980171403295608 }, - { 0.707106781186547, 0.956940335732209, 0.831469612302545, 0.634393284163646, 0.382683432365090, 0.0980171403295608, -0.195090322016128, -0.471396736825998, -0.707106781186548, -0.881921264348355, -0.980785280403230, -0.995184726672197, -0.923879532511287, -0.773010453362737, -0.555570233019602, -0.290284677254462 }, - { 0.707106781186547, 0.881921264348355, 0.555570233019602, 0.0980171403295608, -0.382683432365090, -0.773010453362737, -0.980785280403230, -0.956940335732209, -0.707106781186548, -0.290284677254462, 0.195090322016128, 0.634393284163646, 0.923879532511287, 0.995184726672197, 0.831469612302546, 0.471396736825998 }, - { 0.707106781186547, 0.773010453362737, 0.195090322016128, -0.471396736825998, -0.923879532511287, -0.956940335732209, -0.555570233019602, 0.0980171403295601, 0.707106781186547, 0.995184726672197, 0.831469612302546, 0.290284677254463, -0.382683432365090, -0.881921264348355, -0.980785280403231, -0.634393284163645 }, - { 0.707106781186547, 0.634393284163646, -0.195090322016128, -0.881921264348355, -0.923879532511287, -0.290284677254462, 0.555570233019602, 0.995184726672197, 0.707106781186548, -0.0980171403295600, -0.831469612302545, -0.956940335732209, -0.382683432365091, 0.471396736825997, 0.980785280403230, 0.773010453362738 }, - { 0.707106781186547, 0.471396736825998, -0.555570233019602, -0.995184726672197, -0.382683432365090, 0.634393284163645, 0.980785280403231, 0.290284677254463, -0.707106781186547, -0.956940335732209, -0.195090322016130, 0.773010453362736, 0.923879532511287, 0.0980171403295626, -0.831469612302544, -0.881921264348356 }, - { 0.707106781186547, 0.290284677254462, -0.831469612302545, -0.773010453362737, 0.382683432365090, 0.995184726672197, 0.195090322016128, -0.881921264348356, -0.707106781186547, 0.471396736825997, 0.980785280403230, 0.0980171403295591, -0.923879532511287, -0.634393284163646, 0.555570233019604, 0.956940335732208 }, - { 0.707106781186547, 0.0980171403295608, -0.980785280403230, -0.290284677254463, 0.923879532511287, 0.471396736825998, -0.831469612302544, -0.634393284163647, 0.707106781186547, 0.773010453362738, -0.555570233019602, -0.881921264348356, 0.382683432365086, 0.956940335732209, -0.195090322016125, -0.995184726672197 }, - { 0.707106781186547, -0.0980171403295607, -0.980785280403230, 0.290284677254463, 0.923879532511287, -0.471396736825998, -0.831469612302545, 0.634393284163646, 0.707106781186547, -0.773010453362737, -0.555570233019603, 0.881921264348356, 0.382683432365088, -0.956940335732209, -0.195090322016127, 0.995184726672197 }, - { 0.707106781186547, -0.290284677254462, -0.831469612302546, 0.773010453362737, 0.382683432365090, -0.995184726672197, 0.195090322016127, 0.881921264348356, -0.707106781186547, -0.471396736825998, 0.980785280403230, -0.0980171403295577, -0.923879532511288, 0.634393284163644, 0.555570233019606, -0.956940335732208 }, - { 0.707106781186547, -0.471396736825998, -0.555570233019602, 0.995184726672197, -0.382683432365090, -0.634393284163645, 0.980785280403230, -0.290284677254463, -0.707106781186547, 0.956940335732209, -0.195090322016129, -0.773010453362737, 0.923879532511287, -0.0980171403295610, -0.831469612302545, 0.881921264348355 }, - { 0.707106781186547, -0.634393284163645, -0.195090322016129, 0.881921264348355, -0.923879532511286, 0.290284677254461, 0.555570233019603, -0.995184726672197, 0.707106781186547, 0.0980171403295628, -0.831469612302547, 0.956940335732208, -0.382683432365089, -0.471396736825999, 0.980785280403231, -0.773010453362733 }, - { 0.707106781186547, -0.773010453362737, 0.195090322016128, 0.471396736825998, -0.923879532511287, 0.956940335732209, -0.555570233019602, -0.0980171403295592, 0.707106781186548, -0.995184726672197, 0.831469612302546, -0.290284677254462, -0.382683432365091, 0.881921264348355, -0.980785280403231, 0.634393284163644 }, - { 0.707106781186547, -0.881921264348355, 0.555570233019602, -0.0980171403295600, -0.382683432365091, 0.773010453362738, -0.980785280403231, 0.956940335732208, -0.707106781186546, 0.290284677254462, 0.195090322016130, -0.634393284163649, 0.923879532511288, -0.995184726672197, 0.831469612302542, -0.471396736825993 }, - { 0.707106781186547, -0.956940335732209, 0.831469612302545, -0.634393284163645, 0.382683432365090, -0.0980171403295615, -0.195090322016130, 0.471396736825998, -0.707106781186548, 0.881921264348355, -0.980785280403230, 0.995184726672197, -0.923879532511285, 0.773010453362735, -0.555570233019601, 0.290284677254462 }, - { 0.707106781186547, -0.995184726672197, 0.980785280403230, -0.956940335732209, 0.923879532511286, -0.881921264348355, 0.831469612302544, -0.773010453362736, 0.707106781186546, -0.634393284163644, 0.555570233019601, -0.471396736825994, 0.382683432365086, -0.290284677254458, 0.195090322016124, -0.0980171403295567 } + {0.707106781186547, 0.995184726672197, 0.980785280403230, 0.956940335732209, 0.923879532511287, 0.881921264348355, 0.831469612302545, 0.773010453362737, 0.707106781186548, 0.634393284163646, 0.555570233019602, 0.471396736825998, 0.382683432365090, 0.290284677254462, 0.195090322016128, 0.0980171403295608}, + {0.707106781186547, 0.956940335732209, 0.831469612302545, 0.634393284163646, 0.382683432365090, 0.0980171403295608, -0.195090322016128, -0.471396736825998, -0.707106781186548, -0.881921264348355, -0.980785280403230, -0.995184726672197, -0.923879532511287, -0.773010453362737, -0.555570233019602, -0.290284677254462}, + {0.707106781186547, 0.881921264348355, 0.555570233019602, 0.0980171403295608, -0.382683432365090, -0.773010453362737, -0.980785280403230, -0.956940335732209, -0.707106781186548, -0.290284677254462, 0.195090322016128, 0.634393284163646, 0.923879532511287, 0.995184726672197, 0.831469612302546, 0.471396736825998}, + {0.707106781186547, 0.773010453362737, 0.195090322016128, -0.471396736825998, -0.923879532511287, -0.956940335732209, -0.555570233019602, 0.0980171403295601, 0.707106781186547, 0.995184726672197, 0.831469612302546, 0.290284677254463, -0.382683432365090, -0.881921264348355, -0.980785280403231, -0.634393284163645}, + {0.707106781186547, 0.634393284163646, -0.195090322016128, -0.881921264348355, -0.923879532511287, -0.290284677254462, 0.555570233019602, 0.995184726672197, 0.707106781186548, -0.0980171403295600, -0.831469612302545, -0.956940335732209, -0.382683432365091, 0.471396736825997, 0.980785280403230, 0.773010453362738}, + {0.707106781186547, 0.471396736825998, -0.555570233019602, -0.995184726672197, -0.382683432365090, 0.634393284163645, 0.980785280403231, 0.290284677254463, -0.707106781186547, -0.956940335732209, -0.195090322016130, 0.773010453362736, 0.923879532511287, 0.0980171403295626, -0.831469612302544, -0.881921264348356}, + {0.707106781186547, 0.290284677254462, -0.831469612302545, -0.773010453362737, 0.382683432365090, 0.995184726672197, 0.195090322016128, -0.881921264348356, -0.707106781186547, 0.471396736825997, 0.980785280403230, 0.0980171403295591, -0.923879532511287, -0.634393284163646, 0.555570233019604, 0.956940335732208}, + {0.707106781186547, 0.0980171403295608, -0.980785280403230, -0.290284677254463, 0.923879532511287, 0.471396736825998, -0.831469612302544, -0.634393284163647, 0.707106781186547, 0.773010453362738, -0.555570233019602, -0.881921264348356, 0.382683432365086, 0.956940335732209, -0.195090322016125, -0.995184726672197}, + {0.707106781186547, -0.0980171403295607, -0.980785280403230, 0.290284677254463, 0.923879532511287, -0.471396736825998, -0.831469612302545, 0.634393284163646, 0.707106781186547, -0.773010453362737, -0.555570233019603, 0.881921264348356, 0.382683432365088, -0.956940335732209, -0.195090322016127, 0.995184726672197}, + {0.707106781186547, -0.290284677254462, -0.831469612302546, 0.773010453362737, 0.382683432365090, -0.995184726672197, 0.195090322016127, 0.881921264348356, -0.707106781186547, -0.471396736825998, 0.980785280403230, -0.0980171403295577, -0.923879532511288, 0.634393284163644, 0.555570233019606, -0.956940335732208}, + {0.707106781186547, -0.471396736825998, -0.555570233019602, 0.995184726672197, -0.382683432365090, -0.634393284163645, 0.980785280403230, -0.290284677254463, -0.707106781186547, 0.956940335732209, -0.195090322016129, -0.773010453362737, 0.923879532511287, -0.0980171403295610, -0.831469612302545, 0.881921264348355}, + {0.707106781186547, -0.634393284163645, -0.195090322016129, 0.881921264348355, -0.923879532511286, 0.290284677254461, 0.555570233019603, -0.995184726672197, 0.707106781186547, 0.0980171403295628, -0.831469612302547, 0.956940335732208, -0.382683432365089, -0.471396736825999, 0.980785280403231, -0.773010453362733}, + {0.707106781186547, -0.773010453362737, 0.195090322016128, 0.471396736825998, -0.923879532511287, 0.956940335732209, -0.555570233019602, -0.0980171403295592, 0.707106781186548, -0.995184726672197, 0.831469612302546, -0.290284677254462, -0.382683432365091, 0.881921264348355, -0.980785280403231, 0.634393284163644}, + {0.707106781186547, -0.881921264348355, 0.555570233019602, -0.0980171403295600, -0.382683432365091, 0.773010453362738, -0.980785280403231, 0.956940335732208, -0.707106781186546, 0.290284677254462, 0.195090322016130, -0.634393284163649, 0.923879532511288, -0.995184726672197, 0.831469612302542, -0.471396736825993}, + {0.707106781186547, -0.956940335732209, 0.831469612302545, -0.634393284163645, 0.382683432365090, -0.0980171403295615, -0.195090322016130, 0.471396736825998, -0.707106781186548, 0.881921264348355, -0.980785280403230, 0.995184726672197, -0.923879532511285, 0.773010453362735, -0.555570233019601, 0.290284677254462}, + {0.707106781186547, -0.995184726672197, 0.980785280403230, -0.956940335732209, 0.923879532511286, -0.881921264348355, 0.831469612302544, -0.773010453362736, 0.707106781186546, -0.634393284163644, 0.555570233019601, -0.471396736825994, 0.382683432365086, -0.290284677254458, 0.195090322016124, -0.0980171403295567} }; const LC3_FLOAT sns_dec_gains[4][8] = { - { 2.17651367187500, 2.94287109375000, 0, 0, 0, 0, 0, 0 }, - { 1.52465820312500, 3.67260742187500, 4.36059570312500, 5.13037109375000, 0, 0, 0, 0 }, - { 1.73315429687500, 2.22949218750000, 2.74731445312500, 3.61523437500000, 0, 0, 0, 0 }, - { 1.05859375000000, 1.23706054687500, 1.43920898437500, 1.98950195312500, 2.49877929687500, 3.13110351562500, - 4.11816406250000, 4.85400390625000 } -}; + {2.17651367187500, 2.94287109375000, 0, 0, 0, 0, 0, 0}, + {1.52465820312500, 3.67260742187500, 4.36059570312500, 5.13037109375000, 0, 0, 0, 0}, + {1.73315429687500, 2.22949218750000, 2.74731445312500, 3.61523437500000, 0, 0, 0, 0}, + {1.05859375000000, 1.23706054687500, 1.43920898437500, 1.98950195312500, 2.49877929687500, 3.13110351562500, + 4.11816406250000, 4.85400390625000}}; /* Global Gain */ -const LC3_INT gg_p1[6] = { 80, 230, 380, 530, 680, 830 }; -const LC3_INT gg_p2[6] = { 500, 1025, 1550, 2075, 2600, 3125 }; -const LC3_INT gg_p3[6] = { 850, 1700, 2550, 3400, 4250, 5100 }; +const LC3_INT gg_p1[6] = {80, 230, 380, 530, 680, 830}; +const LC3_INT gg_p2[6] = {500, 1025, 1550, 2075, 2600, 3125}; +const LC3_INT gg_p3[6] = {850, 1700, 2550, 3400, 4250, 5100}; -const LC3_FLOAT gg_c[6] = { 0.00575396825396825, 0.00500524109014675, 0.00473646723646723, - 0.00459816612729234, 0.00451388888888889, 0.004457153231663 }; -const LC3_FLOAT gg_d[6] = { 1310.34482758621, 3241.36125654450, 5267.66917293233, - 7326.39296187684, 9400.00000000000, 11481.67006109979 }; +const LC3_FLOAT gg_c[6] = {0.00575396825396825, 0.00500524109014675, 0.00473646723646723, + 0.00459816612729234, 0.00451388888888889, 0.004457153231663}; +const LC3_FLOAT gg_d[6] = {1310.34482758621, 3241.36125654450, 5267.66917293233, + 7326.39296187684, 9400.00000000000, 11481.67006109979}; /* Olpa */ -const LC3_FLOAT olpa_down2[5] = { 0.1236796411180537, 0.2353512128364889, 0.2819382920909148, 0.2353512128364889, - 0.1236796411180537 }; - -const LC3_FLOAT olpa_acw[98] = { 1.0, - 0.994845360824742, - 0.989690721649485, - 0.984536082474227, - 0.979381443298969, - 0.974226804123711, - 0.969072164948454, - 0.963917525773196, - 0.958762886597938, - 0.953608247422680, - 0.948453608247423, - 0.943298969072165, - 0.938144329896907, - 0.932989690721650, - 0.927835051546392, - 0.922680412371134, - 0.917525773195876, - 0.912371134020619, - 0.907216494845361, - 0.902061855670103, - 0.896907216494845, - 0.891752577319588, - 0.886597938144330, - 0.881443298969072, - 0.876288659793814, - 0.871134020618557, - 0.865979381443299, - 0.860824742268041, - 0.855670103092784, - 0.850515463917526, - 0.845360824742268, - 0.840206185567010, - 0.835051546391753, - 0.829896907216495, - 0.824742268041237, - 0.819587628865979, - 0.814432989690722, - 0.809278350515464, - 0.804123711340206, - 0.798969072164949, - 0.793814432989691, - 0.788659793814433, - 0.783505154639175, - 0.778350515463918, - 0.773195876288660, - 0.768041237113402, - 0.762886597938144, - 0.757731958762887, - 0.752577319587629, - 0.747422680412371, - 0.742268041237113, - 0.737113402061856, - 0.731958762886598, - 0.726804123711340, - 0.721649484536083, - 0.716494845360825, - 0.711340206185567, - 0.706185567010309, - 0.701030927835052, - 0.695876288659794, - 0.690721649484536, - 0.685567010309278, - 0.680412371134021, - 0.675257731958763, - 0.670103092783505, - 0.664948453608247, - 0.659793814432990, - 0.654639175257732, - 0.649484536082474, - 0.644329896907216, - 0.639175257731959, - 0.634020618556701, - 0.628865979381443, - 0.623711340206186, - 0.618556701030928, - 0.613402061855670, - 0.608247422680412, - 0.603092783505155, - 0.597938144329897, - 0.592783505154639, - 0.587628865979382, - 0.582474226804124, - 0.577319587628866, - 0.572164948453608, - 0.567010309278351, - 0.561855670103093, - 0.556701030927835, - 0.551546391752577, - 0.546391752577320, - 0.541237113402062, - 0.536082474226804, - 0.530927835051546, - 0.525773195876289, - 0.520618556701031, - 0.515463917525773, - 0.510309278350515, - 0.505154639175258, - 0.500000000000000 }; +const LC3_FLOAT olpa_down2[5] = {0.1236796411180537, 0.2353512128364889, 0.2819382920909148, 0.2353512128364889, + 0.1236796411180537}; + +const LC3_FLOAT olpa_acw[98] = {1.0, + 0.994845360824742, + 0.989690721649485, + 0.984536082474227, + 0.979381443298969, + 0.974226804123711, + 0.969072164948454, + 0.963917525773196, + 0.958762886597938, + 0.953608247422680, + 0.948453608247423, + 0.943298969072165, + 0.938144329896907, + 0.932989690721650, + 0.927835051546392, + 0.922680412371134, + 0.917525773195876, + 0.912371134020619, + 0.907216494845361, + 0.902061855670103, + 0.896907216494845, + 0.891752577319588, + 0.886597938144330, + 0.881443298969072, + 0.876288659793814, + 0.871134020618557, + 0.865979381443299, + 0.860824742268041, + 0.855670103092784, + 0.850515463917526, + 0.845360824742268, + 0.840206185567010, + 0.835051546391753, + 0.829896907216495, + 0.824742268041237, + 0.819587628865979, + 0.814432989690722, + 0.809278350515464, + 0.804123711340206, + 0.798969072164949, + 0.793814432989691, + 0.788659793814433, + 0.783505154639175, + 0.778350515463918, + 0.773195876288660, + 0.768041237113402, + 0.762886597938144, + 0.757731958762887, + 0.752577319587629, + 0.747422680412371, + 0.742268041237113, + 0.737113402061856, + 0.731958762886598, + 0.726804123711340, + 0.721649484536083, + 0.716494845360825, + 0.711340206185567, + 0.706185567010309, + 0.701030927835052, + 0.695876288659794, + 0.690721649484536, + 0.685567010309278, + 0.680412371134021, + 0.675257731958763, + 0.670103092783505, + 0.664948453608247, + 0.659793814432990, + 0.654639175257732, + 0.649484536082474, + 0.644329896907216, + 0.639175257731959, + 0.634020618556701, + 0.628865979381443, + 0.623711340206186, + 0.618556701030928, + 0.613402061855670, + 0.608247422680412, + 0.603092783505155, + 0.597938144329897, + 0.592783505154639, + 0.587628865979382, + 0.582474226804124, + 0.577319587628866, + 0.572164948453608, + 0.567010309278351, + 0.561855670103093, + 0.556701030927835, + 0.551546391752577, + 0.546391752577320, + 0.541237113402062, + 0.536082474226804, + 0.530927835051546, + 0.525773195876289, + 0.520618556701031, + 0.515463917525773, + 0.510309278350515, + 0.505154639175258, + 0.500000000000000}; /* LTPF */ -const LC3_FLOAT conf_tilt_filter_16[4][3] = { { 6.023618207009578e-01, 4.197609261363617e-01, -1.883424527883687e-02 }, - { 5.994768582584314e-01, 4.197609261363620e-01, -1.594928283631041e-02 }, - { 5.967764663733787e-01, 4.197609261363617e-01, -1.324889095125780e-02 }, - { 5.942410120098895e-01, 4.197609261363618e-01, -1.071343658776831e-02 } }; - -const LC3_FLOAT conf_tilt_filter_24[4][5] = { { 3.989695588963494e-01, 5.142508607708275e-01, 1.004382966157454e-01, - -1.278893956818042e-02, -1.572280075461383e-03 }, - { 3.948634911286333e-01, 5.123819208048688e-01, 1.043194926386267e-01, - -1.091999960222166e-02, -1.347408330627317e-03 }, - { 3.909844475885914e-01, 5.106053522688359e-01, 1.079832524685944e-01, - -9.143431066188848e-03, -1.132124620551895e-03 }, - { 3.873093888199928e-01, 5.089122083363975e-01, 1.114517380217371e-01, - -7.450287133750717e-03, -9.255514050963111e-04 } }; +const LC3_FLOAT conf_tilt_filter_16[4][3] = {{6.023618207009578e-01, 4.197609261363617e-01, -1.883424527883687e-02}, + {5.994768582584314e-01, 4.197609261363620e-01, -1.594928283631041e-02}, + {5.967764663733787e-01, 4.197609261363617e-01, -1.324889095125780e-02}, + {5.942410120098895e-01, 4.197609261363618e-01, -1.071343658776831e-02}}; + +const LC3_FLOAT conf_tilt_filter_24[4][5] = {{3.989695588963494e-01, 5.142508607708275e-01, 1.004382966157454e-01, + -1.278893956818042e-02, -1.572280075461383e-03}, + {3.948634911286333e-01, 5.123819208048688e-01, 1.043194926386267e-01, + -1.091999960222166e-02, -1.347408330627317e-03}, + {3.909844475885914e-01, 5.106053522688359e-01, 1.079832524685944e-01, + -9.143431066188848e-03, -1.132124620551895e-03}, + {3.873093888199928e-01, 5.089122083363975e-01, 1.114517380217371e-01, + -7.450287133750717e-03, -9.255514050963111e-04}}; const LC3_FLOAT conf_tilt_filter_32[4][7] = { - { 2.982379446702096e-01, 4.652809203721290e-01, 2.105997428614279e-01, 3.766780380806063e-02, -1.015696155796564e-02, - -2.535880996101096e-03, -3.182946168719958e-04 }, - { 2.943834154510240e-01, 4.619294002718798e-01, 2.129465770091844e-01, 4.066175002688857e-02, -8.693272297010050e-03, - -2.178307114679820e-03, -2.742888063983188e-04 }, - { 2.907439213122688e-01, 4.587461910960279e-01, 2.151456974108970e-01, 4.350104772529774e-02, -7.295495347716925e-03, - -1.834395637237086e-03, -2.316920186482416e-04 }, - { 2.872975852589158e-01, 4.557148886861379e-01, 2.172126950911401e-01, 4.620088878229615e-02, -5.957463802125952e-03, - -1.502934284345198e-03, -1.903851911308866e-04 } -}; + {2.982379446702096e-01, 4.652809203721290e-01, 2.105997428614279e-01, 3.766780380806063e-02, -1.015696155796564e-02, + -2.535880996101096e-03, -3.182946168719958e-04}, + {2.943834154510240e-01, 4.619294002718798e-01, 2.129465770091844e-01, 4.066175002688857e-02, -8.693272297010050e-03, + -2.178307114679820e-03, -2.742888063983188e-04}, + {2.907439213122688e-01, 4.587461910960279e-01, 2.151456974108970e-01, 4.350104772529774e-02, -7.295495347716925e-03, + -1.834395637237086e-03, -2.316920186482416e-04}, + {2.872975852589158e-01, 4.557148886861379e-01, 2.172126950911401e-01, 4.620088878229615e-02, -5.957463802125952e-03, + -1.502934284345198e-03, -1.903851911308866e-04}}; const LC3_FLOAT conf_tilt_filter_48[4][11] = { - { 1.981363739883217e-01, 3.524494903964904e-01, 2.513695269649414e-01, 1.424146237314458e-01, 5.704731023952599e-02, - 9.293366241586384e-03, -7.226025368953745e-03, -3.172679890356356e-03, -1.121835963567014e-03, - -2.902957238400140e-04, -4.270815593769240e-05 }, - { 1.950709426598375e-01, 3.484660408341632e-01, 2.509988459466574e-01, 1.441167412482088e-01, 5.928947317677285e-02, - 1.108923827452231e-02, -6.192908108653504e-03, -2.726705509251737e-03, -9.667125826217151e-04, - -2.508100923165204e-04, -3.699938766131869e-05 }, - { 1.921810055196015e-01, 3.446945561091513e-01, 2.506220094626024e-01, 1.457102447664837e-01, 6.141132133664525e-02, - 1.279941396562798e-02, -5.203721087886321e-03, -2.297324511109085e-03, -8.165608133217555e-04, - -2.123855748277408e-04, -3.141271330981649e-05 }, - { 1.894485314175868e-01, 3.411139251108252e-01, 2.502406876894361e-01, 1.472065631098081e-01, 6.342477229539051e-02, - 1.443203434150312e-02, -4.254449144657098e-03, -1.883081472613493e-03, -6.709619060722140e-04, - -1.749363341966872e-04, -2.593864735284285e-05 } -}; + {1.981363739883217e-01, 3.524494903964904e-01, 2.513695269649414e-01, 1.424146237314458e-01, 5.704731023952599e-02, + 9.293366241586384e-03, -7.226025368953745e-03, -3.172679890356356e-03, -1.121835963567014e-03, + -2.902957238400140e-04, -4.270815593769240e-05}, + {1.950709426598375e-01, 3.484660408341632e-01, 2.509988459466574e-01, 1.441167412482088e-01, 5.928947317677285e-02, + 1.108923827452231e-02, -6.192908108653504e-03, -2.726705509251737e-03, -9.667125826217151e-04, + -2.508100923165204e-04, -3.699938766131869e-05}, + {1.921810055196015e-01, 3.446945561091513e-01, 2.506220094626024e-01, 1.457102447664837e-01, 6.141132133664525e-02, + 1.279941396562798e-02, -5.203721087886321e-03, -2.297324511109085e-03, -8.165608133217555e-04, + -2.123855748277408e-04, -3.141271330981649e-05}, + {1.894485314175868e-01, 3.411139251108252e-01, 2.502406876894361e-01, 1.472065631098081e-01, 6.342477229539051e-02, + 1.443203434150312e-02, -4.254449144657098e-03, -1.883081472613493e-03, -6.709619060722140e-04, + -1.749363341966872e-04, -2.593864735284285e-05}}; const LC3_FLOAT conf_inter_filter_16[4][4] = { - { 2.098804630681809e-01, 5.835275754221211e-01, 2.098804630681809e-01, 0.000000000000000e+00 }, - { 1.069991860896389e-01, 5.500750019177116e-01, 3.356906254147840e-01, 6.698858366939680e-03 }, - { 3.967114782344967e-02, 4.592209296082350e-01, 4.592209296082350e-01, 3.967114782344967e-02 }, - { 6.698858366939680e-03, 3.356906254147840e-01, 5.500750019177116e-01, 1.069991860896389e-01 } -}; - -const LC3_FLOAT conf_inter_filter_24[4][6] = { { 6.322231627323796e-02, 2.507309606013235e-01, 3.713909428901578e-01, - 2.507309606013235e-01, 6.322231627323796e-02, 0.000000000000000e+00 }, - { 3.459272174099855e-02, 1.986515602645028e-01, 3.626411726581452e-01, - 2.986750548992179e-01, 1.013092873505928e-01, 4.263543712369752e-03 }, - { 1.535746784963907e-02, 1.474344878058222e-01, 3.374259553990717e-01, - 3.374259553990717e-01, 1.474344878058222e-01, 1.535746784963907e-02 }, - { 4.263543712369752e-03, 1.013092873505928e-01, 2.986750548992179e-01, - 3.626411726581452e-01, 1.986515602645028e-01, 3.459272174099855e-02 } }; + {2.098804630681809e-01, 5.835275754221211e-01, 2.098804630681809e-01, 0.000000000000000e+00}, + {1.069991860896389e-01, 5.500750019177116e-01, 3.356906254147840e-01, 6.698858366939680e-03}, + {3.967114782344967e-02, 4.592209296082350e-01, 4.592209296082350e-01, 3.967114782344967e-02}, + {6.698858366939680e-03, 3.356906254147840e-01, 5.500750019177116e-01, 1.069991860896389e-01}}; + +const LC3_FLOAT conf_inter_filter_24[4][6] = {{6.322231627323796e-02, 2.507309606013235e-01, 3.713909428901578e-01, + 2.507309606013235e-01, 6.322231627323796e-02, 0.000000000000000e+00}, + {3.459272174099855e-02, 1.986515602645028e-01, 3.626411726581452e-01, + 2.986750548992179e-01, 1.013092873505928e-01, 4.263543712369752e-03}, + {1.535746784963907e-02, 1.474344878058222e-01, 3.374259553990717e-01, + 3.374259553990717e-01, 1.474344878058222e-01, 1.535746784963907e-02}, + {4.263543712369752e-03, 1.013092873505928e-01, 2.986750548992179e-01, + 3.626411726581452e-01, 1.986515602645028e-01, 3.459272174099855e-02}}; const LC3_FLOAT conf_inter_filter_32[4][8] = { - { 2.900401878228730e-02, 1.129857420560927e-01, 2.212024028097570e-01, 2.723909472446145e-01, 2.212024028097570e-01, - 1.129857420560927e-01, 2.900401878228730e-02, 0.000000000000000e+00 }, - { 1.703153418385261e-02, 8.722503785537784e-02, 1.961407762232199e-01, 2.689237982237257e-01, 2.424999102756389e-01, - 1.405773364650031e-01, 4.474877169485788e-02, 3.127030243100724e-03 }, - { 8.563673748488349e-03, 6.426222944493845e-02, 1.687676705918012e-01, 2.587445937795505e-01, 2.587445937795505e-01, - 1.687676705918012e-01, 6.426222944493845e-02, 8.563673748488349e-03 }, - { 3.127030243100724e-03, 4.474877169485788e-02, 1.405773364650031e-01, 2.424999102756389e-01, 2.689237982237257e-01, - 1.961407762232199e-01, 8.722503785537784e-02, 1.703153418385261e-02 } -}; + {2.900401878228730e-02, 1.129857420560927e-01, 2.212024028097570e-01, 2.723909472446145e-01, 2.212024028097570e-01, + 1.129857420560927e-01, 2.900401878228730e-02, 0.000000000000000e+00}, + {1.703153418385261e-02, 8.722503785537784e-02, 1.961407762232199e-01, 2.689237982237257e-01, 2.424999102756389e-01, + 1.405773364650031e-01, 4.474877169485788e-02, 3.127030243100724e-03}, + {8.563673748488349e-03, 6.426222944493845e-02, 1.687676705918012e-01, 2.587445937795505e-01, 2.587445937795505e-01, + 1.687676705918012e-01, 6.426222944493845e-02, 8.563673748488349e-03}, + {3.127030243100724e-03, 4.474877169485788e-02, 1.405773364650031e-01, 2.424999102756389e-01, 2.689237982237257e-01, + 1.961407762232199e-01, 8.722503785537784e-02, 1.703153418385261e-02}}; const LC3_FLOAT conf_inter_filter_48[4][12] = { - { 1.082359386659387e-02, 3.608969221303979e-02, 7.676401468099964e-02, 1.241530577501703e-01, 1.627596438300696e-01, - 1.776771417779109e-01, 1.627596438300696e-01, 1.241530577501703e-01, 7.676401468099964e-02, 3.608969221303979e-02, - 1.082359386659387e-02, 0.000000000000000e+00 }, - { 7.041404930459358e-03, 2.819702319820420e-02, 6.547044935127551e-02, 1.124647986743299e-01, 1.548418956489015e-01, - 1.767122381341857e-01, 1.691507213057663e-01, 1.352901577989766e-01, 8.851425011427483e-02, 4.499353848562444e-02, - 1.557613714732002e-02, 2.039721956502016e-03 }, - { 4.146998467444788e-03, 2.135757310741917e-02, 5.482735584552816e-02, 1.004971444643720e-01, 1.456060342830002e-01, - 1.738439838565869e-01, 1.738439838565869e-01, 1.456060342830002e-01, 1.004971444643720e-01, 5.482735584552816e-02, - 2.135757310741917e-02, 4.146998467444788e-03 }, - { 2.039721956502016e-03, 1.557613714732002e-02, 4.499353848562444e-02, 8.851425011427483e-02, 1.352901577989766e-01, - 1.691507213057663e-01, 1.767122381341857e-01, 1.548418956489015e-01, 1.124647986743299e-01, 6.547044935127551e-02, - 2.819702319820420e-02, 7.041404930459358e-03 } -}; - -const LC3_FLOAT inter4_1[33] = { 0, - -2.874561161519444e-03, - -3.001251025861499e-03, - +2.745471654059321e-03, - +1.535727698935322e-02, - +2.868234046665657e-02, - +2.950385026557377e-02, - +4.598334491135473e-03, - -4.729632459043440e-02, - -1.058359163062837e-01, - -1.303050213607112e-01, - -7.544046357555201e-02, - +8.357885725250529e-02, - +3.301825710764459e-01, - +6.032970076366158e-01, - +8.174886856243178e-01, - +8.986382851273982e-01, - +8.174886856243178e-01, - +6.032970076366158e-01, - +3.301825710764459e-01, - +8.357885725250529e-02, - -7.544046357555201e-02, - -1.303050213607112e-01, - -1.058359163062837e-01, - -4.729632459043440e-02, - +4.598334491135473e-03, - +2.950385026557377e-02, - +2.868234046665657e-02, - +1.535727698935322e-02, - +2.745471654059321e-03, - -3.001251025861499e-03, - -2.874561161519444e-03, - 0 }; + {1.082359386659387e-02, 3.608969221303979e-02, 7.676401468099964e-02, 1.241530577501703e-01, 1.627596438300696e-01, + 1.776771417779109e-01, 1.627596438300696e-01, 1.241530577501703e-01, 7.676401468099964e-02, 3.608969221303979e-02, + 1.082359386659387e-02, 0.000000000000000e+00}, + {7.041404930459358e-03, 2.819702319820420e-02, 6.547044935127551e-02, 1.124647986743299e-01, 1.548418956489015e-01, + 1.767122381341857e-01, 1.691507213057663e-01, 1.352901577989766e-01, 8.851425011427483e-02, 4.499353848562444e-02, + 1.557613714732002e-02, 2.039721956502016e-03}, + {4.146998467444788e-03, 2.135757310741917e-02, 5.482735584552816e-02, 1.004971444643720e-01, 1.456060342830002e-01, + 1.738439838565869e-01, 1.738439838565869e-01, 1.456060342830002e-01, 1.004971444643720e-01, 5.482735584552816e-02, + 2.135757310741917e-02, 4.146998467444788e-03}, + {2.039721956502016e-03, 1.557613714732002e-02, 4.499353848562444e-02, 8.851425011427483e-02, 1.352901577989766e-01, + 1.691507213057663e-01, 1.767122381341857e-01, 1.548418956489015e-01, 1.124647986743299e-01, 6.547044935127551e-02, + 2.819702319820420e-02, 7.041404930459358e-03}}; + +const LC3_FLOAT inter4_1[33] = {0, + -2.874561161519444e-03, + -3.001251025861499e-03, + +2.745471654059321e-03, + +1.535727698935322e-02, + +2.868234046665657e-02, + +2.950385026557377e-02, + +4.598334491135473e-03, + -4.729632459043440e-02, + -1.058359163062837e-01, + -1.303050213607112e-01, + -7.544046357555201e-02, + +8.357885725250529e-02, + +3.301825710764459e-01, + +6.032970076366158e-01, + +8.174886856243178e-01, + +8.986382851273982e-01, + +8.174886856243178e-01, + +6.032970076366158e-01, + +3.301825710764459e-01, + +8.357885725250529e-02, + -7.544046357555201e-02, + -1.303050213607112e-01, + -1.058359163062837e-01, + -4.729632459043440e-02, + +4.598334491135473e-03, + +2.950385026557377e-02, + +2.868234046665657e-02, + +1.535727698935322e-02, + +2.745471654059321e-03, + -3.001251025861499e-03, + -2.874561161519444e-03, + 0}; const LC3_FLOAT enc_inter_filter[4][4] = { - { +2.098804630681809e-01, +5.835275754221211e-01, +2.098804630681809e-01, 0 }, - { +1.069991860896389e-01, +5.500750019177116e-01, +3.356906254147840e-01, +6.698858366939680e-03 }, - { +3.967114782344967e-02, +4.592209296082350e-01, +4.592209296082350e-01, +3.967114782344967e-02 }, - { +6.698858366939680e-03, +3.356906254147840e-01, +5.500750019177116e-01, +1.069991860896389e-01 } -}; + {+2.098804630681809e-01, +5.835275754221211e-01, +2.098804630681809e-01, 0}, + {+1.069991860896389e-01, +5.500750019177116e-01, +3.356906254147840e-01, +6.698858366939680e-03}, + {+3.967114782344967e-02, +4.592209296082350e-01, +4.592209296082350e-01, +3.967114782344967e-02}, + {+6.698858366939680e-03, +3.356906254147840e-01, +5.500750019177116e-01, +1.069991860896389e-01}}; /* Bandwidth Detector */ -const LC3_INT threshold_quiet[4] = { 20, 10, 10, 10 }; -const LC3_INT threshold_brickwall[4] = { 15, 23, 20, 20 }; -const LC3_INT brickwall_dist[4] = { 4, 4, 3, 1 }; -const LC3_INT BW_warp_idx_start_16k[4] = { 53, 0, 0, 0 }; -const LC3_INT BW_warp_idx_stop_16k[4] = { 63, 0, 0, 0 }; -const LC3_INT BW_warp_idx_start_24k[4] = { 47, 59, 0, 0 }; -const LC3_INT BW_warp_idx_stop_24k[4] = { 56, 63, 0, 0 }; -const LC3_INT BW_warp_idx_start_32k[4] = { 44, 54, 60, 0 }; -const LC3_INT BW_warp_idx_stop_32k[4] = { 52, 59, 63, 0 }; -const LC3_INT BW_warp_idx_start_48k[4] = { 41, 51, 57, 61 }; -const LC3_INT BW_warp_idx_stop_48k[4] = { 49, 55, 60, 63 }; -const LC3_INT *BW_warp_idx_start_all[4] = { BW_warp_idx_start_16k, BW_warp_idx_start_24k, BW_warp_idx_start_32k, - BW_warp_idx_start_48k }; -const LC3_INT *BW_warp_idx_stop_all[4] = { BW_warp_idx_stop_16k, BW_warp_idx_stop_24k, BW_warp_idx_stop_32k, - BW_warp_idx_stop_48k }; - -const LC3_INT BW_warp_idx_start_16k_2_5ms[4] = { 24, 0, 0, 0 }; -const LC3_INT BW_warp_idx_stop_16k_2_5ms[4] = { 34, 0, 0, 0 }; -const LC3_INT BW_warp_idx_start_24k_2_5ms[4] = { 24, 35, 0, 0 }; -const LC3_INT BW_warp_idx_stop_24k_2_5ms[4] = { 32, 39, 0, 0 }; -const LC3_INT BW_warp_idx_start_32k_2_5ms[4] = { 24, 33, 39, 0 }; -const LC3_INT BW_warp_idx_stop_32k_2_5ms[4] = { 31, 38, 42, 0 }; -const LC3_INT BW_warp_idx_start_48k_2_5ms[4] = { 22, 31, 37, 41 }; -const LC3_INT BW_warp_idx_stop_48k_2_5ms[4] = { 29, 35, 40, 43 }; - -const LC3_INT *BW_warp_idx_start_all_2_5ms[4] = { BW_warp_idx_start_16k_2_5ms, BW_warp_idx_start_24k_2_5ms, - BW_warp_idx_start_32k_2_5ms, BW_warp_idx_start_48k_2_5ms }; -const LC3_INT *BW_warp_idx_stop_all_2_5ms[4] = { BW_warp_idx_stop_16k_2_5ms, BW_warp_idx_stop_24k_2_5ms, - BW_warp_idx_stop_32k_2_5ms, BW_warp_idx_stop_48k_2_5ms }; - -const LC3_INT bands_number_2_5ms_HR[6] = { 20, 35, 40, 43, 45, 49 }; - -const LC3_INT bands_number_2_5ms[5] = { 20, 35, 40, 43, 44 }; - - -const LC3_INT BW_warp_idx_start_16k_5ms[4] = { 39, 0, 0, 0 }; -const LC3_INT BW_warp_idx_stop_16k_5ms[4] = { 49, 0, 0, 0 }; -const LC3_INT BW_warp_idx_start_24k_5ms[4] = { 35, 47, 0, 0 }; -const LC3_INT BW_warp_idx_stop_24k_5ms[4] = { 44, 51, 0, 0 }; -const LC3_INT BW_warp_idx_start_32k_5ms[4] = { 34, 44, 50, 0 }; -const LC3_INT BW_warp_idx_stop_32k_5ms[4] = { 42, 49, 53, 0 }; -const LC3_INT BW_warp_idx_start_48k_5ms[4] = { 32, 42, 48, 52 }; -const LC3_INT BW_warp_idx_stop_48k_5ms[4] = { 40, 46, 51, 54 }; - -const LC3_INT *BW_warp_idx_start_all_5ms[4] = { BW_warp_idx_start_16k_5ms, BW_warp_idx_start_24k_5ms, - BW_warp_idx_start_32k_5ms, BW_warp_idx_start_48k_5ms }; -const LC3_INT *BW_warp_idx_stop_all_5ms[4] = { BW_warp_idx_stop_16k_5ms, BW_warp_idx_stop_24k_5ms, - BW_warp_idx_stop_32k_5ms, BW_warp_idx_stop_48k_5ms }; - -const LC3_INT bands_number_5ms[6] = { 39, 50, 52, 54, 55, 58 }; - - -const LC3_INT BW_cutoff_bin_all[MAX_BW_BANDS_NUMBER] = { 80, 160, 240, 320, 400, 400 }; -const LC3_INT BW_cutoff_bits_all[MAX_BW_BANDS_NUMBER] = { 0, 1, 2, 2, 3, 0 }; - -const LC3_INT BW_cutoff_bin_all_5ms[MAX_BW_BANDS_NUMBER] = { 40, 80, 120, 160, 200, 200 }; -const LC3_INT BW_cutoff_bin_all_2_5ms[MAX_BW_BANDS_NUMBER] = { 20, 40, 60, 80, 100, 100 }; +const LC3_INT threshold_quiet[4] = {20, 10, 10, 10}; +const LC3_INT threshold_brickwall[4] = {15, 23, 20, 20}; +const LC3_INT brickwall_dist[4] = {4, 4, 3, 1}; +const LC3_INT BW_warp_idx_start_16k[4] = {53, 0, 0, 0}; +const LC3_INT BW_warp_idx_stop_16k[4] = {63, 0, 0, 0}; +const LC3_INT BW_warp_idx_start_24k[4] = {47, 59, 0, 0}; +const LC3_INT BW_warp_idx_stop_24k[4] = {56, 63, 0, 0}; +const LC3_INT BW_warp_idx_start_32k[4] = {44, 54, 60, 0}; +const LC3_INT BW_warp_idx_stop_32k[4] = {52, 59, 63, 0}; +const LC3_INT BW_warp_idx_start_48k[4] = {41, 51, 57, 61}; +const LC3_INT BW_warp_idx_stop_48k[4] = {49, 55, 60, 63}; +const LC3_INT* BW_warp_idx_start_all[4] = {BW_warp_idx_start_16k, BW_warp_idx_start_24k, BW_warp_idx_start_32k, + BW_warp_idx_start_48k}; +const LC3_INT* BW_warp_idx_stop_all[4] = {BW_warp_idx_stop_16k, BW_warp_idx_stop_24k, BW_warp_idx_stop_32k, + BW_warp_idx_stop_48k}; + +const LC3_INT BW_warp_idx_start_16k_2_5ms[4] = {24, 0, 0, 0}; +const LC3_INT BW_warp_idx_stop_16k_2_5ms[4] = {34, 0, 0, 0}; +const LC3_INT BW_warp_idx_start_24k_2_5ms[4] = {24, 35, 0, 0}; +const LC3_INT BW_warp_idx_stop_24k_2_5ms[4] = {32, 39, 0, 0}; +const LC3_INT BW_warp_idx_start_32k_2_5ms[4] = {24, 33, 39, 0}; +const LC3_INT BW_warp_idx_stop_32k_2_5ms[4] = {31, 38, 42, 0}; +const LC3_INT BW_warp_idx_start_48k_2_5ms[4] = {22, 31, 37, 41}; +const LC3_INT BW_warp_idx_stop_48k_2_5ms[4] = {29, 35, 40, 43}; + +const LC3_INT* BW_warp_idx_start_all_2_5ms[4] = {BW_warp_idx_start_16k_2_5ms, BW_warp_idx_start_24k_2_5ms, + BW_warp_idx_start_32k_2_5ms, BW_warp_idx_start_48k_2_5ms}; +const LC3_INT* BW_warp_idx_stop_all_2_5ms[4] = {BW_warp_idx_stop_16k_2_5ms, BW_warp_idx_stop_24k_2_5ms, + BW_warp_idx_stop_32k_2_5ms, BW_warp_idx_stop_48k_2_5ms}; + +const LC3_INT bands_number_2_5ms_HR[6] = {20, 35, 40, 43, 45, 49}; + +const LC3_INT bands_number_2_5ms[5] = {20, 35, 40, 43, 44}; + + +const LC3_INT BW_warp_idx_start_16k_5ms[4] = {39, 0, 0, 0}; +const LC3_INT BW_warp_idx_stop_16k_5ms[4] = {49, 0, 0, 0}; +const LC3_INT BW_warp_idx_start_24k_5ms[4] = {35, 47, 0, 0}; +const LC3_INT BW_warp_idx_stop_24k_5ms[4] = {44, 51, 0, 0}; +const LC3_INT BW_warp_idx_start_32k_5ms[4] = {34, 44, 50, 0}; +const LC3_INT BW_warp_idx_stop_32k_5ms[4] = {42, 49, 53, 0}; +const LC3_INT BW_warp_idx_start_48k_5ms[4] = {32, 42, 48, 52}; +const LC3_INT BW_warp_idx_stop_48k_5ms[4] = {40, 46, 51, 54}; + +const LC3_INT* BW_warp_idx_start_all_5ms[4] = {BW_warp_idx_start_16k_5ms, BW_warp_idx_start_24k_5ms, + BW_warp_idx_start_32k_5ms, BW_warp_idx_start_48k_5ms}; +const LC3_INT* BW_warp_idx_stop_all_5ms[4] = {BW_warp_idx_stop_16k_5ms, BW_warp_idx_stop_24k_5ms, + BW_warp_idx_stop_32k_5ms, BW_warp_idx_stop_48k_5ms}; + +const LC3_INT bands_number_5ms[6] = {39, 50, 52, 54, 55, 58}; + + +const LC3_INT BW_cutoff_bin_all[MAX_BW_BANDS_NUMBER] = {80, 160, 240, 320, 400, 400}; +const LC3_INT BW_cutoff_bits_all[MAX_BW_BANDS_NUMBER] = {0, 1, 2, 2, 3, 0}; + +const LC3_INT BW_cutoff_bin_all_5ms[MAX_BW_BANDS_NUMBER] = {40, 80, 120, 160, 200, 200}; +const LC3_INT BW_cutoff_bin_all_2_5ms[MAX_BW_BANDS_NUMBER] = {20, 40, 60, 80, 100, 100}; /* Arithmetic coding */ -const LC3_INT tns_cf[8][18] = { { 0, 1, 6, 21, 52, 106, 192, 289, 409, 568, 720, 831, 935, 994, 1016, 1022, 1023, 1024 }, - { 0, 1, 2, 3, 4, 17, 60, 154, 293, 466, 626, 780, 911, 989, 1016, 1022, 1023, 1024 }, - { 0, 1, 2, 3, 4, 13, 56, 162, 361, 578, 788, 929, 1003, 1020, 1021, 1022, 1023, 1024 }, - { 0, 1, 2, 3, 4, 6, 17, 66, 270, 555, 852, 972, 1011, 1020, 1021, 1022, 1023, 1024 }, - { 0, 1, 2, 3, 4, 5, 12, 54, 295, 636, 950, 1008, 1017, 1020, 1021, 1022, 1023, 1024 }, - { 0, 1, 2, 3, 4, 5, 6, 19, 224, 590, 967, 1014, 1019, 1020, 1021, 1022, 1023, 1024 }, - { 0, 1, 2, 3, 4, 5, 6, 19, 300, 630, 1001, 1018, 1019, 1020, 1021, 1022, 1023, 1024 }, - { 0, 1, 2, 3, 4, 5, 6, 11, 308, 309, 991, 1017, 1019, 1020, 1021, 1022, 1023, 1024 } }; +const LC3_INT tns_cf[8][18] = {{0, 1, 6, 21, 52, 106, 192, 289, 409, 568, 720, 831, 935, 994, 1016, 1022, 1023, 1024}, + {0, 1, 2, 3, 4, 17, 60, 154, 293, 466, 626, 780, 911, 989, 1016, 1022, 1023, 1024}, + {0, 1, 2, 3, 4, 13, 56, 162, 361, 578, 788, 929, 1003, 1020, 1021, 1022, 1023, 1024}, + {0, 1, 2, 3, 4, 6, 17, 66, 270, 555, 852, 972, 1011, 1020, 1021, 1022, 1023, 1024}, + {0, 1, 2, 3, 4, 5, 12, 54, 295, 636, 950, 1008, 1017, 1020, 1021, 1022, 1023, 1024}, + {0, 1, 2, 3, 4, 5, 6, 19, 224, 590, 967, 1014, 1019, 1020, 1021, 1022, 1023, 1024}, + {0, 1, 2, 3, 4, 5, 6, 19, 300, 630, 1001, 1018, 1019, 1020, 1021, 1022, 1023, 1024}, + {0, 1, 2, 3, 4, 5, 6, 11, 308, 309, 991, 1017, 1019, 1020, 1021, 1022, 1023, 1024}}; -const LC3_INT tns_freq_cf[2][9] = { { 0, 3, 12, 35, 89, 200, 390, 658, 1024 }, { 0, 14, 56, 156, 313, 494, 672, 839, 1024 } }; +const LC3_INT tns_freq_cf[2][9] = {{0, 3, 12, 35, 89, 200, 390, 658, 1024}, {0, 14, 56, 156, 313, 494, 672, 839, 1024}}; /* MDCT Windows */ @@ -1068,8 +1006,7 @@ const LC3_FLOAT MDCT_WINDOW_80_2_5ms[40] = { 9.999772999978698e-01, 9.996266599807562e-01, 9.980987183772584e-01, 9.937180643904148e-01, 9.839026370225886e-01, 9.654056798094166e-01, 9.348747871791264e-01, 8.895849967038094e-01, 8.281382099997300e-01, 7.509434386216048e-01, 6.603665285212146e-01, 5.605239559005871e-01, 4.567696724165073e-01, 3.549776504187033e-01, 2.607525136824537e-01, - 1.787053464784875e-01, 1.119125037883055e-01, 6.163560962361236e-02, 2.732289618100209e-02, 6.737914289329320e-03 -}; + 1.787053464784875e-01, 1.119125037883055e-01, 6.163560962361236e-02, 2.732289618100209e-02, 6.737914289329320e-03}; const LC3_FLOAT MDCT_WINDOW_160_2_5ms[80] = { 4.764416154578566e-03, 1.204636278996989e-02, 2.226396539371650e-02, 3.580223111285056e-02, 5.299054649961241e-02, @@ -1087,8 +1024,7 @@ const LC3_FLOAT MDCT_WINDOW_160_2_5ms[80] = { 6.841360194558924e-01, 6.363019156559162e-01, 5.864570980113353e-01, 5.352743274612082e-01, 4.834713159013930e-01, 4.317862022264749e-01, 3.809524578920635e-01, 3.316743228466244e-01, 2.846038181323611e-01, 2.403202823615340e-01, 1.993132407013812e-01, 1.619692437449073e-01, 1.285631180041137e-01, 9.925385917916330e-02, 7.408518398076024e-02, - 5.299054649961241e-02, 3.580223111285056e-02, 2.226396539371650e-02, 1.204636278996989e-02, 4.764416154578566e-03 -}; + 5.299054649961241e-02, 3.580223111285056e-02, 2.226396539371650e-02, 1.204636278996989e-02, 4.764416154578566e-03}; const LC3_FLOAT MDCT_WINDOW_240_2_5ms[120] = { 3.890134207235998e-03, 8.202595078385781e-03, 1.370235555340779e-02, 2.052968531182845e-02, 2.880307728389693e-02, @@ -1114,8 +1050,7 @@ const LC3_FLOAT MDCT_WINDOW_240_2_5ms[120] = { 3.562772881250116e-01, 3.238754496100354e-01, 2.924999908279060e-01, 2.623227204239969e-01, 2.334981807379911e-01, 2.061617274373514e-01, 1.804279808512455e-01, 1.563896708020576e-01, 1.341168883357315e-01, 1.136567491769230e-01, 9.503346510857243e-02, 7.824881086160715e-02, 6.328296540190831e-02, 5.009569719921809e-02, 3.862785141889536e-02, - 2.880307728389693e-02, 2.052968531182845e-02, 1.370235555340779e-02, 8.202595078385781e-03, 3.890134207235998e-03 -}; + 2.880307728389693e-02, 2.052968531182845e-02, 1.370235555340779e-02, 8.202595078385781e-03, 3.890134207235998e-03}; const LC3_FLOAT MDCT_WINDOW_320_2_5ms[160] = { 3.368958353152859e-03, 6.455557414799749e-03, 1.014308076237845e-02, 1.452126850237346e-02, 1.965076732239952e-02, @@ -1149,8 +1084,7 @@ const LC3_FLOAT MDCT_WINDOW_320_2_5ms[160] = { 2.095824125414741e-01, 1.899744548998832e-01, 1.713020663983868e-01, 1.535996228917228e-01, 1.368942751980506e-01, 1.212058930254449e-01, 1.065470811378728e-01, 9.292326595333501e-02, 8.033284980531531e-02, 6.876742903793599e-02, 5.821207082124419e-02, 4.864564178753818e-02, 4.004117865352276e-02, 3.236628529621430e-02, 2.558352795411825e-02, - 1.965076732239952e-02, 1.452126850237346e-02, 1.014308076237845e-02, 6.455557414799749e-03, 3.368958353152859e-03 -}; + 1.965076732239952e-02, 1.452126850237346e-02, 1.014308076237845e-02, 6.455557414799749e-03, 3.368958353152859e-03}; const LC3_FLOAT MDCT_WINDOW_480_2_5ms[240] = { 2.750746382614873e-03, 4.775245154322467e-03, 6.991265476184880e-03, 9.470118155887091e-03, 1.224415763156159e-02, @@ -1200,8 +1134,7 @@ const LC3_FLOAT MDCT_WINDOW_480_2_5ms[240] = { 9.966673316465058e-02, 9.081309669365416e-02, 8.241826576309315e-02, 7.447973421347953e-02, 6.699369195627566e-02, 5.995506493224793e-02, 5.335755875796826e-02, 4.719370517091751e-02, 4.145491000214293e-02, 3.613150075407039e-02, 3.121277069249126e-02, 2.668701415521377e-02, 2.254154337372088e-02, 1.876266772162453e-02, 1.533559472880042e-02, - 1.224415763156159e-02, 9.470118155887091e-03, 6.991265476184880e-03, 4.775245154322467e-03, 2.750746382614873e-03 -}; + 1.224415763156159e-02, 9.470118155887091e-03, 6.991265476184880e-03, 4.775245154322467e-03, 2.750746382614873e-03}; const LC3_FLOAT MDCT_WINDOW_80[160] = { -7.078546706512391e-04, -2.098197727900724e-03, -4.525198076002370e-03, -8.233976327300612e-03, @@ -1210,41 +1143,40 @@ const LC3_FLOAT MDCT_WINDOW_80[160] = { -8.859705468085925e-02, -9.688303623049199e-02, -1.034961241263523e-01, -1.080766457616878e-01, -1.103242262600913e-01, -1.099809851424550e-01, -1.068172142230882e-01, -1.006190418791648e-01, -9.116452506492527e-02, -7.820617483254730e-02, -6.146688124166948e-02, -4.063362855701623e-02, - -1.536329520788766e-02, 1.470155068746303e-02, 4.989736509080558e-02, 9.050369257152079e-02, - 1.366911019414417e-01, 1.884686389218322e-01, 2.456456803467095e-01, 3.077789078889820e-01, - 3.741642373060188e-01, 4.438114799213576e-01, 5.154735456539700e-01, 5.876661722564289e-01, - 6.587619767809000e-01, 7.270576699841359e-01, 7.908752989295335e-01, 8.486643364959733e-01, - 8.991320235484349e-01, 9.413348145272842e-01, 9.747634827941575e-01, 9.994114730415857e-01, - 1.015760373791603e+00, 1.024736164069697e+00, 1.027634294456205e+00, 1.025991493983836e+00, - 1.021427210603284e+00, 1.015439859549357e+00, 1.009366925499550e+00, 1.003508162416449e+00, - 9.988898206257559e-01, 9.953133902427869e-01, 9.925943919208190e-01, 9.905771957917731e-01, - 9.891371616557014e-01, 9.881790747212391e-01, 9.876249269174586e-01, 9.874056275509585e-01, - 9.874524849192456e-01, 9.876951134084213e-01, 9.880640617030884e-01, 9.884926873551375e-01, - 9.889230031022089e-01, 9.893074965384659e-01, 9.896146331889107e-01, 9.898319269347060e-01, - 9.899693102025342e-01, 9.900603352632121e-01, 9.901575015155720e-01, 9.903255289051605e-01, - 9.906303787150326e-01, 9.911298894709990e-01, 9.918665491182922e-01, 9.928619727154252e-01, - 9.941156069136238e-01, 9.956033775539884e-01, 9.972793109558521e-01, 9.990784840729244e-01, - 1.000922365901945e+00, 1.002728111386909e+00, 1.004416038098237e+00, 1.005919224127911e+00, - 1.007189345025525e+00, 1.008200146369426e+00, 1.008949493525753e+00, 1.009458241425143e+00, - 1.009768980817384e+00, 1.009940336228694e+00, 1.010039453539107e+00, 1.010132323996401e+00, - 1.010272524848519e+00, 1.010494354532353e+00, 1.010808068774316e+00, 1.011201071127927e+00, - 1.011641272406023e+00, 1.012080125934687e+00, 1.012458183122033e+00, 1.012706955800289e+00, - 1.012755013843985e+00, 1.012530134411619e+00, 1.011962331100864e+00, 1.010982135506986e+00, - 1.009512438049510e+00, 1.007460860286395e+00, 1.004708677491086e+00, 1.001111413242302e+00, - 9.965041017623596e-01, 9.907199995730845e-01, 9.823765865983288e-01, 9.708821747608998e-01, - 9.546732976073705e-01, 9.321553861564006e-01, 9.018003682081348e-01, 8.623984077953557e-01, - 8.132817365236141e-01, 7.544551974836834e-01, 6.866580716267418e-01, 6.113488038789190e-01, - 5.306181649316597e-01, 4.471309850999502e-01, 3.639114681156236e-01, 2.841647033392408e-01, - 2.110209448747969e-01, 1.472287968327703e-01, 9.482665349502291e-02, 5.482436608328477e-02, - 2.701461405056264e-02, 9.996743588367519e-03, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 -}; + -1.536329520788766e-02, 1.470155068746303e-02, 4.989736509080558e-02, 9.050369257152079e-02, + 1.366911019414417e-01, 1.884686389218322e-01, 2.456456803467095e-01, 3.077789078889820e-01, + 3.741642373060188e-01, 4.438114799213576e-01, 5.154735456539700e-01, 5.876661722564289e-01, + 6.587619767809000e-01, 7.270576699841359e-01, 7.908752989295335e-01, 8.486643364959733e-01, + 8.991320235484349e-01, 9.413348145272842e-01, 9.747634827941575e-01, 9.994114730415857e-01, + 1.015760373791603e+00, 1.024736164069697e+00, 1.027634294456205e+00, 1.025991493983836e+00, + 1.021427210603284e+00, 1.015439859549357e+00, 1.009366925499550e+00, 1.003508162416449e+00, + 9.988898206257559e-01, 9.953133902427869e-01, 9.925943919208190e-01, 9.905771957917731e-01, + 9.891371616557014e-01, 9.881790747212391e-01, 9.876249269174586e-01, 9.874056275509585e-01, + 9.874524849192456e-01, 9.876951134084213e-01, 9.880640617030884e-01, 9.884926873551375e-01, + 9.889230031022089e-01, 9.893074965384659e-01, 9.896146331889107e-01, 9.898319269347060e-01, + 9.899693102025342e-01, 9.900603352632121e-01, 9.901575015155720e-01, 9.903255289051605e-01, + 9.906303787150326e-01, 9.911298894709990e-01, 9.918665491182922e-01, 9.928619727154252e-01, + 9.941156069136238e-01, 9.956033775539884e-01, 9.972793109558521e-01, 9.990784840729244e-01, + 1.000922365901945e+00, 1.002728111386909e+00, 1.004416038098237e+00, 1.005919224127911e+00, + 1.007189345025525e+00, 1.008200146369426e+00, 1.008949493525753e+00, 1.009458241425143e+00, + 1.009768980817384e+00, 1.009940336228694e+00, 1.010039453539107e+00, 1.010132323996401e+00, + 1.010272524848519e+00, 1.010494354532353e+00, 1.010808068774316e+00, 1.011201071127927e+00, + 1.011641272406023e+00, 1.012080125934687e+00, 1.012458183122033e+00, 1.012706955800289e+00, + 1.012755013843985e+00, 1.012530134411619e+00, 1.011962331100864e+00, 1.010982135506986e+00, + 1.009512438049510e+00, 1.007460860286395e+00, 1.004708677491086e+00, 1.001111413242302e+00, + 9.965041017623596e-01, 9.907199995730845e-01, 9.823765865983288e-01, 9.708821747608998e-01, + 9.546732976073705e-01, 9.321553861564006e-01, 9.018003682081348e-01, 8.623984077953557e-01, + 8.132817365236141e-01, 7.544551974836834e-01, 6.866580716267418e-01, 6.113488038789190e-01, + 5.306181649316597e-01, 4.471309850999502e-01, 3.639114681156236e-01, 2.841647033392408e-01, + 2.110209448747969e-01, 1.472287968327703e-01, 9.482665349502291e-02, 5.482436608328477e-02, + 2.701461405056264e-02, 9.996743588367519e-03, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; const LC3_FLOAT MDCT_WINDOW_160[320] = { -4.619898752628163e-04, -9.747166718929050e-04, -1.664473096973725e-03, -2.597106916737789e-03, @@ -1259,75 +1191,74 @@ const LC3_FLOAT MDCT_WINDOW_160[320] = { -1.078834293141886e-01, -1.055612509762041e-01, -1.024650162703341e-01, -9.857014566194629e-02, -9.384684920715425e-02, -8.826309993000785e-02, -8.178792716809512e-02, -7.438785600211463e-02, -6.602189797715241e-02, -5.665655641133161e-02, -4.624456893420224e-02, -3.474585776145929e-02, - -2.211581608120528e-02, -8.310425696208936e-03, 6.717697635290676e-03, 2.300642061077823e-02, - 4.060106462625085e-02, 5.953239090915557e-02, 7.983354189816511e-02, 1.015233140203748e-01, - 1.246171387327525e-01, 1.491152519299797e-01, 1.750067399059861e-01, 2.022699854906251e-01, - 2.308655379767671e-01, 2.607365124918583e-01, 2.918144694729168e-01, 3.240095704645023e-01, - 3.572175180786021e-01, 3.913146885756875e-01, 4.261571642320424e-01, 4.615925445090212e-01, - 4.974471592901086e-01, 5.335326819631583e-01, 5.696546730080154e-01, 6.056083823929643e-01, - 6.411830842823245e-01, 6.761653499550255e-01, 7.103400549562944e-01, 7.434943718765665e-01, - 7.754281892901473e-01, 8.059437233154637e-01, 8.348589373399948e-01, 8.620108336276733e-01, - 8.872599706865123e-01, 9.104863121445679e-01, 9.315962496426278e-01, 9.505220861927248e-01, - 9.672366712325431e-01, 9.817397501303696e-01, 9.940557180662704e-01, 1.004247514102417e+00, - 1.012407428282884e+00, 1.018650990561848e+00, 1.023118841384460e+00, 1.025972450969440e+00, - 1.027397523939210e+00, 1.027585830688143e+00, 1.026738673647482e+00, 1.025061777648234e+00, - 1.022756514615106e+00, 1.020009139549275e+00, 1.016996499560845e+00, 1.013915946100629e+00, - 1.011044869639164e+00, 1.007773858455400e+00, 1.004848753962734e+00, 1.002245009135684e+00, - 9.999393169239009e-01, 9.979055415627330e-01, 9.961203379971326e-01, 9.945597525471822e-01, - 9.932031606606762e-01, 9.920297273323891e-01, 9.910230654424902e-01, 9.901668953434221e-01, - 9.894488374513719e-01, 9.888556356037892e-01, 9.883778520531268e-01, 9.880051626345804e-01, - 9.877295459610343e-01, 9.875412739766566e-01, 9.874329809802893e-01, 9.873949921033299e-01, - 9.874197049003676e-01, 9.874973205882319e-01, 9.876201238703241e-01, 9.877781920433015e-01, - 9.879637979933339e-01, 9.881678007807095e-01, 9.883835200189653e-01, 9.886022219397892e-01, - 9.888182771263505e-01, 9.890247977602895e-01, 9.892178658748239e-01, 9.893923680007577e-01, - 9.895463342815009e-01, 9.896772011542693e-01, 9.897859195209235e-01, 9.898725363809847e-01, - 9.899410789223559e-01, 9.899945557067980e-01, 9.900394023736973e-01, 9.900814722948890e-01, - 9.901293790312005e-01, 9.901902265696609e-01, 9.902734448815004e-01, 9.903862280081246e-01, - 9.905379830873822e-01, 9.907348826312993e-01, 9.909842592301273e-01, 9.912905118607647e-01, - 9.916586940166509e-01, 9.920906151219310e-01, 9.925887208794144e-01, 9.931516528513824e-01, - 9.937790866568735e-01, 9.944668184371617e-01, 9.952116634297566e-01, 9.960068616185641e-01, - 9.968461329825753e-01, 9.977203369515556e-01, 9.986213520769593e-01, 9.995382582242990e-01, - 1.000461955079660e+00, 1.001380551217109e+00, 1.002284871786226e+00, 1.003163845364970e+00, - 1.004009147462043e+00, 1.004811375053364e+00, 1.005563968008037e+00, 1.006259855360867e+00, - 1.006895570408563e+00, 1.007466616298057e+00, 1.007972441990187e+00, 1.008411468616852e+00, - 1.008786009787269e+00, 1.009097763850333e+00, 1.009351762546296e+00, 1.009552401900961e+00, - 1.009707093778162e+00, 1.009822090220407e+00, 1.009906958448099e+00, 1.009969021400474e+00, - 1.010017890428877e+00, 1.010060809299530e+00, 1.010106564965965e+00, 1.010161131093372e+00, - 1.010231078494249e+00, 1.010319484524512e+00, 1.010430470494512e+00, 1.010564099281000e+00, - 1.010721360243234e+00, 1.010899655674578e+00, 1.011096993993037e+00, 1.011308167670753e+00, - 1.011529185153809e+00, 1.011753008569803e+00, 1.011973876511603e+00, 1.012182837094955e+00, - 1.012373028737774e+00, 1.012535058602453e+00, 1.012660975529858e+00, 1.012740575296603e+00, - 1.012765922449960e+00, 1.012726958954961e+00, 1.012615904116265e+00, 1.012422888521601e+00, - 1.012140460211194e+00, 1.011758810583150e+00, 1.011269960947744e+00, 1.010663676735228e+00, - 1.009930754807923e+00, 1.009058249873833e+00, 1.008034308295421e+00, 1.006843352506855e+00, - 1.005470005637052e+00, 1.003894772403371e+00, 1.002098854400575e+00, 1.000060686758758e+00, - 9.977600196406868e-01, 9.951746430061121e-01, 9.922861082472264e-01, 9.890757868707590e-01, - 9.847362453480265e-01, 9.798613526271561e-01, 9.741378617337759e-01, 9.673331975559332e-01, - 9.592539757044516e-01, 9.496984081652284e-01, 9.384634163826711e-01, 9.253567968750328e-01, - 9.101986790930605e-01, 8.928338316495705e-01, 8.731437835983047e-01, 8.510420440685049e-01, - 8.264839911291133e-01, 7.994681492797084e-01, 7.700431275216928e-01, 7.383028603058783e-01, - 7.043814340356083e-01, 6.684616478236647e-01, 6.307755329382612e-01, 5.915799587176216e-01, - 5.511703155400274e-01, 5.098915423728179e-01, 4.681017110047964e-01, 4.261772971493010e-01, - 3.845172335531009e-01, 3.435228672445613e-01, 3.036004651973099e-01, 2.651434678028531e-01, - 2.285283969438072e-01, 1.941021906320984e-01, 1.621735416384830e-01, 1.330015240938615e-01, - 1.067840430193724e-01, 8.365057236623041e-02, 6.365188111381356e-02, 4.676538412257621e-02, - 3.288072750732215e-02, 2.183057564646270e-02, 1.336381425803019e-02, 6.758124889697787e-03, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 -}; + -2.211581608120528e-02, -8.310425696208936e-03, 6.717697635290676e-03, 2.300642061077823e-02, + 4.060106462625085e-02, 5.953239090915557e-02, 7.983354189816511e-02, 1.015233140203748e-01, + 1.246171387327525e-01, 1.491152519299797e-01, 1.750067399059861e-01, 2.022699854906251e-01, + 2.308655379767671e-01, 2.607365124918583e-01, 2.918144694729168e-01, 3.240095704645023e-01, + 3.572175180786021e-01, 3.913146885756875e-01, 4.261571642320424e-01, 4.615925445090212e-01, + 4.974471592901086e-01, 5.335326819631583e-01, 5.696546730080154e-01, 6.056083823929643e-01, + 6.411830842823245e-01, 6.761653499550255e-01, 7.103400549562944e-01, 7.434943718765665e-01, + 7.754281892901473e-01, 8.059437233154637e-01, 8.348589373399948e-01, 8.620108336276733e-01, + 8.872599706865123e-01, 9.104863121445679e-01, 9.315962496426278e-01, 9.505220861927248e-01, + 9.672366712325431e-01, 9.817397501303696e-01, 9.940557180662704e-01, 1.004247514102417e+00, + 1.012407428282884e+00, 1.018650990561848e+00, 1.023118841384460e+00, 1.025972450969440e+00, + 1.027397523939210e+00, 1.027585830688143e+00, 1.026738673647482e+00, 1.025061777648234e+00, + 1.022756514615106e+00, 1.020009139549275e+00, 1.016996499560845e+00, 1.013915946100629e+00, + 1.011044869639164e+00, 1.007773858455400e+00, 1.004848753962734e+00, 1.002245009135684e+00, + 9.999393169239009e-01, 9.979055415627330e-01, 9.961203379971326e-01, 9.945597525471822e-01, + 9.932031606606762e-01, 9.920297273323891e-01, 9.910230654424902e-01, 9.901668953434221e-01, + 9.894488374513719e-01, 9.888556356037892e-01, 9.883778520531268e-01, 9.880051626345804e-01, + 9.877295459610343e-01, 9.875412739766566e-01, 9.874329809802893e-01, 9.873949921033299e-01, + 9.874197049003676e-01, 9.874973205882319e-01, 9.876201238703241e-01, 9.877781920433015e-01, + 9.879637979933339e-01, 9.881678007807095e-01, 9.883835200189653e-01, 9.886022219397892e-01, + 9.888182771263505e-01, 9.890247977602895e-01, 9.892178658748239e-01, 9.893923680007577e-01, + 9.895463342815009e-01, 9.896772011542693e-01, 9.897859195209235e-01, 9.898725363809847e-01, + 9.899410789223559e-01, 9.899945557067980e-01, 9.900394023736973e-01, 9.900814722948890e-01, + 9.901293790312005e-01, 9.901902265696609e-01, 9.902734448815004e-01, 9.903862280081246e-01, + 9.905379830873822e-01, 9.907348826312993e-01, 9.909842592301273e-01, 9.912905118607647e-01, + 9.916586940166509e-01, 9.920906151219310e-01, 9.925887208794144e-01, 9.931516528513824e-01, + 9.937790866568735e-01, 9.944668184371617e-01, 9.952116634297566e-01, 9.960068616185641e-01, + 9.968461329825753e-01, 9.977203369515556e-01, 9.986213520769593e-01, 9.995382582242990e-01, + 1.000461955079660e+00, 1.001380551217109e+00, 1.002284871786226e+00, 1.003163845364970e+00, + 1.004009147462043e+00, 1.004811375053364e+00, 1.005563968008037e+00, 1.006259855360867e+00, + 1.006895570408563e+00, 1.007466616298057e+00, 1.007972441990187e+00, 1.008411468616852e+00, + 1.008786009787269e+00, 1.009097763850333e+00, 1.009351762546296e+00, 1.009552401900961e+00, + 1.009707093778162e+00, 1.009822090220407e+00, 1.009906958448099e+00, 1.009969021400474e+00, + 1.010017890428877e+00, 1.010060809299530e+00, 1.010106564965965e+00, 1.010161131093372e+00, + 1.010231078494249e+00, 1.010319484524512e+00, 1.010430470494512e+00, 1.010564099281000e+00, + 1.010721360243234e+00, 1.010899655674578e+00, 1.011096993993037e+00, 1.011308167670753e+00, + 1.011529185153809e+00, 1.011753008569803e+00, 1.011973876511603e+00, 1.012182837094955e+00, + 1.012373028737774e+00, 1.012535058602453e+00, 1.012660975529858e+00, 1.012740575296603e+00, + 1.012765922449960e+00, 1.012726958954961e+00, 1.012615904116265e+00, 1.012422888521601e+00, + 1.012140460211194e+00, 1.011758810583150e+00, 1.011269960947744e+00, 1.010663676735228e+00, + 1.009930754807923e+00, 1.009058249873833e+00, 1.008034308295421e+00, 1.006843352506855e+00, + 1.005470005637052e+00, 1.003894772403371e+00, 1.002098854400575e+00, 1.000060686758758e+00, + 9.977600196406868e-01, 9.951746430061121e-01, 9.922861082472264e-01, 9.890757868707590e-01, + 9.847362453480265e-01, 9.798613526271561e-01, 9.741378617337759e-01, 9.673331975559332e-01, + 9.592539757044516e-01, 9.496984081652284e-01, 9.384634163826711e-01, 9.253567968750328e-01, + 9.101986790930605e-01, 8.928338316495705e-01, 8.731437835983047e-01, 8.510420440685049e-01, + 8.264839911291133e-01, 7.994681492797084e-01, 7.700431275216928e-01, 7.383028603058783e-01, + 7.043814340356083e-01, 6.684616478236647e-01, 6.307755329382612e-01, 5.915799587176216e-01, + 5.511703155400274e-01, 5.098915423728179e-01, 4.681017110047964e-01, 4.261772971493010e-01, + 3.845172335531009e-01, 3.435228672445613e-01, 3.036004651973099e-01, 2.651434678028531e-01, + 2.285283969438072e-01, 1.941021906320984e-01, 1.621735416384830e-01, 1.330015240938615e-01, + 1.067840430193724e-01, 8.365057236623041e-02, 6.365188111381356e-02, 4.676538412257621e-02, + 3.288072750732215e-02, 2.183057564646270e-02, 1.336381425803019e-02, 6.758124889697787e-03, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; const LC3_FLOAT MDCT_WINDOW_240[480] = { -3.613496418928369e-04, -7.078546706512391e-04, -1.074443637110903e-03, -1.533478537964509e-03, @@ -1349,108 +1280,107 @@ const LC3_FLOAT MDCT_WINDOW_240[480] = { -7.820617483254730e-02, -7.306142427456862e-02, -6.748468182105991e-02, -6.146688124166948e-02, -5.499497258200362e-02, -4.805444424454820e-02, -4.063362855701623e-02, -3.272045590229335e-02, -2.430122582451853e-02, -1.536329520788766e-02, -5.891434269890659e-03, 4.126595858583295e-03, - 1.470155068746303e-02, 2.584738191459814e-02, 3.757652772246801e-02, 4.989736509080558e-02, - 6.282034030592902e-02, 7.635397728566121e-02, 9.050369257152079e-02, 1.052747118478660e-01, - 1.206703467513333e-01, 1.366911019414417e-01, 1.533343890681390e-01, 1.705954709184399e-01, - 1.884686389218322e-01, 2.069449962574092e-01, 2.260093000067393e-01, 2.456456803467095e-01, - 2.658346019332584e-01, 2.865543814049772e-01, 3.077789078889820e-01, 3.294769437072290e-01, - 3.516171481750350e-01, 3.741642373060188e-01, 3.970739591211551e-01, 4.203043046885219e-01, - 4.438114799213576e-01, 4.675442291623012e-01, 4.914498631045615e-01, 5.154735456539700e-01, - 5.395557644293222e-01, 5.636399817032525e-01, 5.876661722564289e-01, 6.115695310143157e-01, - 6.352890592874099e-01, 6.587619767809000e-01, 6.819230974423550e-01, 7.047092819314779e-01, - 7.270576699841359e-01, 7.489068963384272e-01, 7.701990187606995e-01, 7.908752989295335e-01, - 8.108788692151807e-01, 8.301579139160681e-01, 8.486643364959733e-01, 8.663548164329093e-01, - 8.831896853053627e-01, 8.991320235484349e-01, 9.141540563656075e-01, 9.282282546151819e-01, - 9.413348145272842e-01, 9.534619388400459e-01, 9.646048250501910e-01, 9.747634827941575e-01, - 9.839435385219192e-01, 9.921529097154242e-01, 9.994114730415857e-01, 1.005746084650236e+00, - 1.011183971347815e+00, 1.015760373791603e+00, 1.019515072412387e+00, 1.022490937034641e+00, - 1.024736164069697e+00, 1.026304095700693e+00, 1.027250978292214e+00, 1.027634294456205e+00, - 1.027511063644843e+00, 1.026942795115598e+00, 1.025991493983836e+00, 1.024716149969084e+00, - 1.023175976163407e+00, 1.021427210603284e+00, 1.019521566634239e+00, 1.017510118327508e+00, - 1.015439859549357e+00, 1.013460916839174e+00, 1.011654901040475e+00, 1.009366925499550e+00, - 1.007263182132894e+00, 1.005313192386866e+00, 1.003508162416449e+00, 1.001840787319378e+00, - 1.000303927234380e+00, 9.988898206257559e-01, 9.975915283480670e-01, 9.964015284765968e-01, - 9.953133902427869e-01, 9.943201078053212e-01, 9.934158959186011e-01, 9.925943919208190e-01, - 9.918510277326026e-01, 9.911797988363887e-01, 9.905771957917731e-01, 9.900381047643838e-01, - 9.895594394179152e-01, 9.891371616557014e-01, 9.887684373604154e-01, 9.884497924570929e-01, - 9.881790747212391e-01, 9.879528358230726e-01, 9.877691368590689e-01, 9.876249269174586e-01, - 9.875179947346887e-01, 9.874458127312921e-01, 9.874056275509585e-01, 9.873951115886979e-01, - 9.874115368168944e-01, 9.874524849192456e-01, 9.875149888347144e-01, 9.875968894760857e-01, - 9.876951134084213e-01, 9.878075819424549e-01, 9.879311998177238e-01, 9.880640617030884e-01, - 9.882032571565917e-01, 9.883471084085503e-01, 9.884926873551375e-01, 9.886386592120545e-01, - 9.887825578295630e-01, 9.889230031022089e-01, 9.890581715933395e-01, 9.891867674284610e-01, - 9.893074965384659e-01, 9.894196399062921e-01, 9.895220757174378e-01, 9.896146331889107e-01, - 9.896970346678272e-01, 9.897692596535289e-01, 9.898319269347060e-01, 9.898852572653667e-01, - 9.899307640365727e-01, 9.899693102025343e-01, 9.900025692522435e-01, 9.900321562263099e-01, - 9.900603352632121e-01, 9.900889812894406e-01, 9.901206586012907e-01, 9.901575015155720e-01, - 9.902023946214220e-01, 9.902575406142213e-01, 9.903255289051605e-01, 9.904087914462694e-01, - 9.905096491583045e-01, 9.906303787150326e-01, 9.907727108894024e-01, 9.909387444078919e-01, - 9.911298894709990e-01, 9.913476318763218e-01, 9.915928560402563e-01, 9.918665491182922e-01, - 9.921691315380984e-01, 9.925010851461232e-01, 9.928619727154252e-01, 9.932519181564613e-01, - 9.936700207375173e-01, 9.941156069136238e-01, 9.945873147903244e-01, 9.950837402063278e-01, - 9.956033775539884e-01, 9.961439922621166e-01, 9.967034533921340e-01, 9.972793109558521e-01, - 9.978690858367024e-01, 9.984697087896268e-01, 9.990784840729244e-01, 9.996919011206490e-01, - 1.000308193833526e+00, 1.000922365901945e+00, 1.001532636590676e+00, 1.002135464655177e+00, - 1.002728111386909e+00, 1.003307449770187e+00, 1.003870934089686e+00, 1.004416038098237e+00, - 1.004940548815171e+00, 1.005442141810160e+00, 1.005919224127911e+00, 1.006370303149314e+00, - 1.006793927824538e+00, 1.007189345025525e+00, 1.007555573455895e+00, 1.007892674961336e+00, - 1.008200146369426e+00, 1.008478423284851e+00, 1.008727884997619e+00, 1.008949493525753e+00, - 1.009144112734761e+00, 1.009313224929575e+00, 1.009458241425143e+00, 1.009581280555682e+00, - 1.009684090687164e+00, 1.009768980817384e+00, 1.009838308708799e+00, 1.009894548257807e+00, - 1.009940336228694e+00, 1.009977916643680e+00, 1.010010230290263e+00, 1.010039453539107e+00, - 1.010068202038694e+00, 1.010098388689342e+00, 1.010132323996401e+00, 1.010171656775640e+00, - 1.010218096148412e+00, 1.010272524848519e+00, 1.010336490294771e+00, 1.010410221483215e+00, - 1.010494354532353e+00, 1.010588873699422e+00, 1.010693501186928e+00, 1.010808068774316e+00, - 1.010931436739342e+00, 1.011062876503041e+00, 1.011201071127927e+00, 1.011344700694417e+00, - 1.011491904228184e+00, 1.011641272406023e+00, 1.011790282474963e+00, 1.011937567254485e+00, - 1.012080125934687e+00, 1.012216235487353e+00, 1.012342907951334e+00, 1.012458183122033e+00, - 1.012558879696851e+00, 1.012642857380847e+00, 1.012706955800289e+00, 1.012748952907404e+00, - 1.012765799894453e+00, 1.012755013843985e+00, 1.012713798678211e+00, 1.012639775003457e+00, - 1.012530134411619e+00, 1.012382309473470e+00, 1.012194068117524e+00, 1.011962331100864e+00, - 1.011685173724601e+00, 1.011359143572147e+00, 1.010982135506986e+00, 1.010550715971368e+00, - 1.010062133151922e+00, 1.009512438049510e+00, 1.008898689394160e+00, 1.008215923600973e+00, - 1.007460860286395e+00, 1.006627741823389e+00, 1.005712337656749e+00, 1.004708677491086e+00, - 1.003611467285588e+00, 1.002414286392268e+00, 1.001111413242302e+00, 9.996961651093181e-01, - 9.981625949525345e-01, 9.965041017623596e-01, 9.947148884277037e-01, 9.927891912841345e-01, - 9.907199995730845e-01, 9.884793707533194e-01, 9.855347660016696e-01, 9.823765865983286e-01, - 9.789747333404933e-01, 9.751623811486372e-01, 9.708821747608998e-01, 9.660805524695870e-01, - 9.606976399184645e-01, 9.546732976073706e-01, 9.479479345282376e-01, 9.404609052933396e-01, - 9.321553861564006e-01, 9.229775478442888e-01, 9.128745354570823e-01, 9.018003682081348e-01, - 8.897163275605041e-01, 8.765908974996186e-01, 8.623984077953557e-01, 8.471200801854385e-01, - 8.307479727020245e-01, 8.132817365236141e-01, 7.947291447585267e-01, 7.751108841891807e-01, - 7.544551974836834e-01, 7.327963552921717e-01, 7.101790843209148e-01, 6.866580716267418e-01, - 6.622962432368731e-01, 6.371684119604742e-01, 6.113488038789190e-01, 5.849206604934815e-01, - 5.579747428663487e-01, 5.306181649316717e-01, 5.029523957059122e-01, 4.750868825511614e-01, - 4.471309850999535e-01, 4.192049917945288e-01, 3.914252910998820e-01, 3.639114681156252e-01, - 3.367837772954476e-01, 3.101627843160973e-01, 2.841647033392418e-01, 2.589033711808454e-01, - 2.344880603710975e-01, 2.110209448747974e-01, 1.885997642296488e-01, 1.673100807904834e-01, - 1.472287968327706e-01, 1.284223074167396e-01, 1.109422548710344e-01, 9.482665349502306e-02, - 8.009914366829558e-02, 6.676765847398403e-02, 5.482436608328485e-02, 4.424588851571281e-02, - 3.499361000717621e-02, 2.701461405056267e-02, 2.024370180670145e-02, 1.460796755137538e-02, - 9.996743588367531e-03, 5.305235098871444e-03, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 -}; + 1.470155068746303e-02, 2.584738191459814e-02, 3.757652772246801e-02, 4.989736509080558e-02, + 6.282034030592902e-02, 7.635397728566121e-02, 9.050369257152079e-02, 1.052747118478660e-01, + 1.206703467513333e-01, 1.366911019414417e-01, 1.533343890681390e-01, 1.705954709184399e-01, + 1.884686389218322e-01, 2.069449962574092e-01, 2.260093000067393e-01, 2.456456803467095e-01, + 2.658346019332584e-01, 2.865543814049772e-01, 3.077789078889820e-01, 3.294769437072290e-01, + 3.516171481750350e-01, 3.741642373060188e-01, 3.970739591211551e-01, 4.203043046885219e-01, + 4.438114799213576e-01, 4.675442291623012e-01, 4.914498631045615e-01, 5.154735456539700e-01, + 5.395557644293222e-01, 5.636399817032525e-01, 5.876661722564289e-01, 6.115695310143157e-01, + 6.352890592874099e-01, 6.587619767809000e-01, 6.819230974423550e-01, 7.047092819314779e-01, + 7.270576699841359e-01, 7.489068963384272e-01, 7.701990187606995e-01, 7.908752989295335e-01, + 8.108788692151807e-01, 8.301579139160681e-01, 8.486643364959733e-01, 8.663548164329093e-01, + 8.831896853053627e-01, 8.991320235484349e-01, 9.141540563656075e-01, 9.282282546151819e-01, + 9.413348145272842e-01, 9.534619388400459e-01, 9.646048250501910e-01, 9.747634827941575e-01, + 9.839435385219192e-01, 9.921529097154242e-01, 9.994114730415857e-01, 1.005746084650236e+00, + 1.011183971347815e+00, 1.015760373791603e+00, 1.019515072412387e+00, 1.022490937034641e+00, + 1.024736164069697e+00, 1.026304095700693e+00, 1.027250978292214e+00, 1.027634294456205e+00, + 1.027511063644843e+00, 1.026942795115598e+00, 1.025991493983836e+00, 1.024716149969084e+00, + 1.023175976163407e+00, 1.021427210603284e+00, 1.019521566634239e+00, 1.017510118327508e+00, + 1.015439859549357e+00, 1.013460916839174e+00, 1.011654901040475e+00, 1.009366925499550e+00, + 1.007263182132894e+00, 1.005313192386866e+00, 1.003508162416449e+00, 1.001840787319378e+00, + 1.000303927234380e+00, 9.988898206257559e-01, 9.975915283480670e-01, 9.964015284765968e-01, + 9.953133902427869e-01, 9.943201078053212e-01, 9.934158959186011e-01, 9.925943919208190e-01, + 9.918510277326026e-01, 9.911797988363887e-01, 9.905771957917731e-01, 9.900381047643838e-01, + 9.895594394179152e-01, 9.891371616557014e-01, 9.887684373604154e-01, 9.884497924570929e-01, + 9.881790747212391e-01, 9.879528358230726e-01, 9.877691368590689e-01, 9.876249269174586e-01, + 9.875179947346887e-01, 9.874458127312921e-01, 9.874056275509585e-01, 9.873951115886979e-01, + 9.874115368168944e-01, 9.874524849192456e-01, 9.875149888347144e-01, 9.875968894760857e-01, + 9.876951134084213e-01, 9.878075819424549e-01, 9.879311998177238e-01, 9.880640617030884e-01, + 9.882032571565917e-01, 9.883471084085503e-01, 9.884926873551375e-01, 9.886386592120545e-01, + 9.887825578295630e-01, 9.889230031022089e-01, 9.890581715933395e-01, 9.891867674284610e-01, + 9.893074965384659e-01, 9.894196399062921e-01, 9.895220757174378e-01, 9.896146331889107e-01, + 9.896970346678272e-01, 9.897692596535289e-01, 9.898319269347060e-01, 9.898852572653667e-01, + 9.899307640365727e-01, 9.899693102025343e-01, 9.900025692522435e-01, 9.900321562263099e-01, + 9.900603352632121e-01, 9.900889812894406e-01, 9.901206586012907e-01, 9.901575015155720e-01, + 9.902023946214220e-01, 9.902575406142213e-01, 9.903255289051605e-01, 9.904087914462694e-01, + 9.905096491583045e-01, 9.906303787150326e-01, 9.907727108894024e-01, 9.909387444078919e-01, + 9.911298894709990e-01, 9.913476318763218e-01, 9.915928560402563e-01, 9.918665491182922e-01, + 9.921691315380984e-01, 9.925010851461232e-01, 9.928619727154252e-01, 9.932519181564613e-01, + 9.936700207375173e-01, 9.941156069136238e-01, 9.945873147903244e-01, 9.950837402063278e-01, + 9.956033775539884e-01, 9.961439922621166e-01, 9.967034533921340e-01, 9.972793109558521e-01, + 9.978690858367024e-01, 9.984697087896268e-01, 9.990784840729244e-01, 9.996919011206490e-01, + 1.000308193833526e+00, 1.000922365901945e+00, 1.001532636590676e+00, 1.002135464655177e+00, + 1.002728111386909e+00, 1.003307449770187e+00, 1.003870934089686e+00, 1.004416038098237e+00, + 1.004940548815171e+00, 1.005442141810160e+00, 1.005919224127911e+00, 1.006370303149314e+00, + 1.006793927824538e+00, 1.007189345025525e+00, 1.007555573455895e+00, 1.007892674961336e+00, + 1.008200146369426e+00, 1.008478423284851e+00, 1.008727884997619e+00, 1.008949493525753e+00, + 1.009144112734761e+00, 1.009313224929575e+00, 1.009458241425143e+00, 1.009581280555682e+00, + 1.009684090687164e+00, 1.009768980817384e+00, 1.009838308708799e+00, 1.009894548257807e+00, + 1.009940336228694e+00, 1.009977916643680e+00, 1.010010230290263e+00, 1.010039453539107e+00, + 1.010068202038694e+00, 1.010098388689342e+00, 1.010132323996401e+00, 1.010171656775640e+00, + 1.010218096148412e+00, 1.010272524848519e+00, 1.010336490294771e+00, 1.010410221483215e+00, + 1.010494354532353e+00, 1.010588873699422e+00, 1.010693501186928e+00, 1.010808068774316e+00, + 1.010931436739342e+00, 1.011062876503041e+00, 1.011201071127927e+00, 1.011344700694417e+00, + 1.011491904228184e+00, 1.011641272406023e+00, 1.011790282474963e+00, 1.011937567254485e+00, + 1.012080125934687e+00, 1.012216235487353e+00, 1.012342907951334e+00, 1.012458183122033e+00, + 1.012558879696851e+00, 1.012642857380847e+00, 1.012706955800289e+00, 1.012748952907404e+00, + 1.012765799894453e+00, 1.012755013843985e+00, 1.012713798678211e+00, 1.012639775003457e+00, + 1.012530134411619e+00, 1.012382309473470e+00, 1.012194068117524e+00, 1.011962331100864e+00, + 1.011685173724601e+00, 1.011359143572147e+00, 1.010982135506986e+00, 1.010550715971368e+00, + 1.010062133151922e+00, 1.009512438049510e+00, 1.008898689394160e+00, 1.008215923600973e+00, + 1.007460860286395e+00, 1.006627741823389e+00, 1.005712337656749e+00, 1.004708677491086e+00, + 1.003611467285588e+00, 1.002414286392268e+00, 1.001111413242302e+00, 9.996961651093181e-01, + 9.981625949525345e-01, 9.965041017623596e-01, 9.947148884277037e-01, 9.927891912841345e-01, + 9.907199995730845e-01, 9.884793707533194e-01, 9.855347660016696e-01, 9.823765865983286e-01, + 9.789747333404933e-01, 9.751623811486372e-01, 9.708821747608998e-01, 9.660805524695870e-01, + 9.606976399184645e-01, 9.546732976073706e-01, 9.479479345282376e-01, 9.404609052933396e-01, + 9.321553861564006e-01, 9.229775478442888e-01, 9.128745354570823e-01, 9.018003682081348e-01, + 8.897163275605041e-01, 8.765908974996186e-01, 8.623984077953557e-01, 8.471200801854385e-01, + 8.307479727020245e-01, 8.132817365236141e-01, 7.947291447585267e-01, 7.751108841891807e-01, + 7.544551974836834e-01, 7.327963552921717e-01, 7.101790843209148e-01, 6.866580716267418e-01, + 6.622962432368731e-01, 6.371684119604742e-01, 6.113488038789190e-01, 5.849206604934815e-01, + 5.579747428663487e-01, 5.306181649316717e-01, 5.029523957059122e-01, 4.750868825511614e-01, + 4.471309850999535e-01, 4.192049917945288e-01, 3.914252910998820e-01, 3.639114681156252e-01, + 3.367837772954476e-01, 3.101627843160973e-01, 2.841647033392418e-01, 2.589033711808454e-01, + 2.344880603710975e-01, 2.110209448747974e-01, 1.885997642296488e-01, 1.673100807904834e-01, + 1.472287968327706e-01, 1.284223074167396e-01, 1.109422548710344e-01, 9.482665349502306e-02, + 8.009914366829558e-02, 6.676765847398403e-02, 5.482436608328485e-02, 4.424588851571281e-02, + 3.499361000717621e-02, 2.701461405056267e-02, 2.024370180670145e-02, 1.460796755137538e-02, + 9.996743588367531e-03, 5.305235098871444e-03, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; const LC3_FLOAT MDCT_WINDOW_320[640] = { -3.021153494057143e-04, -5.867737487939294e-04, -8.366504004139796e-04, -1.126635355725494e-03, @@ -1478,142 +1408,141 @@ const LC3_FLOAT MDCT_WINDOW_320[640] = { -6.820576796149519e-02, -6.377611429172260e-02, -5.909386001558149e-02, -5.415316322402774e-02, -4.894812724598650e-02, -4.347347112195197e-02, -3.772461300253332e-02, -3.169587609244436e-02, -2.538179830690266e-02, -1.877689096555516e-02, -1.187461378850388e-02, -4.669099247423082e-03, - 2.844096748870385e-03, 1.066976124794342e-02, 1.881355950582949e-02, 2.728156010437695e-02, - 3.607810469851272e-02, 4.520702759803914e-02, 5.467238802204326e-02, 6.447866054615346e-02, - 7.462862199422061e-02, 8.512490568723846e-02, 9.596983987496970e-02, 1.071650779014335e-01, - 1.187115850305241e-01, 1.306101067250375e-01, 1.428596447589721e-01, 1.554584725339102e-01, - 1.684041609371527e-01, 1.816947894623263e-01, 1.953273880886783e-01, 2.092963206850239e-01, - 2.235945635254679e-01, 2.382160219461597e-01, 2.531529721334063e-01, 2.683961570569586e-01, - 2.839361392493072e-01, 2.997624255177811e-01, 3.158619077906196e-01, 3.322210551086769e-01, - 3.488264676990591e-01, 3.656640377499646e-01, 3.827152968157059e-01, 3.999611859760947e-01, - 4.173843265025887e-01, 4.349669624916473e-01, 4.526876397402144e-01, 4.705242008503956e-01, - 4.884539254831315e-01, 5.064545550235134e-01, 5.245006748662190e-01, 5.425674372882107e-01, - 5.606312044701524e-01, 5.786672646386708e-01, 5.966477035050948e-01, 6.145458904162185e-01, - 6.323361944662236e-01, 6.499926319211774e-01, 6.674874032292857e-01, 6.847932667399612e-01, - 7.018835463513400e-01, 7.187322544823347e-01, 7.353128213893310e-01, 7.516001985652684e-01, - 7.675699252273948e-01, 7.831974571624924e-01, 7.984583859818390e-01, 8.133295347030278e-01, - 8.277892271515950e-01, 8.418178561101360e-01, 8.553961300139363e-01, 8.685068980898102e-01, - 8.811334436653052e-01, 8.932596784799233e-01, 9.048748835980528e-01, 9.159657608120536e-01, - 9.265215299450000e-01, 9.365339988633418e-01, 9.459977028429117e-01, 9.549088408436811e-01, - 9.632658122557368e-01, 9.710688896122810e-01, 9.783204156360773e-01, 9.850226760127131e-01, - 9.911792082081333e-01, 9.967989944502682e-01, 1.001894024615659e+00, 1.006474342231823e+00, - 1.010552057109195e+00, 1.014142538208007e+00, 1.017262593268930e+00, 1.019928842669923e+00, - 1.022159867011177e+00, 1.023976320927187e+00, 1.025400734608122e+00, 1.026455340400072e+00, - 1.027164510654160e+00, 1.027552729180790e+00, 1.027644462380432e+00, 1.027463246660797e+00, - 1.027035903410657e+00, 1.026389068000259e+00, 1.025548201799728e+00, 1.024537134749709e+00, - 1.023380803775376e+00, 1.022103695693341e+00, 1.020728359657958e+00, 1.019275334687329e+00, - 1.017765178792830e+00, 1.016217355867531e+00, 1.014665311686846e+00, 1.013249071090664e+00, - 1.011948006992127e+00, 1.010189090179223e+00, 1.008557961167850e+00, 1.007011287608451e+00, - 1.005548764575910e+00, 1.004168417268956e+00, 1.002867268893035e+00, 1.001641769115897e+00, - 1.000489068954641e+00, 9.994060799749374e-01, 9.983898865406841e-01, 9.974370849972721e-01, - 9.965444836911705e-01, 9.957098545943852e-01, 9.949302413030897e-01, 9.942024045863540e-01, - 9.935241604969254e-01, 9.928930430130044e-01, 9.923068103443909e-01, 9.917633778190438e-01, - 9.912597642374404e-01, 9.907954498484041e-01, 9.903677893656558e-01, 9.899751611066148e-01, - 9.896160337369861e-01, 9.892890160408989e-01, 9.889928511129679e-01, 9.887260333430423e-01, - 9.884868721088945e-01, 9.882751039537586e-01, 9.880892168751595e-01, 9.879277114724612e-01, - 9.877898261218510e-01, 9.876743442038471e-01, 9.875807496078497e-01, 9.875072021876561e-01, - 9.874529447589979e-01, 9.874169741527905e-01, 9.873984685207834e-01, 9.873958301311858e-01, - 9.874080027710336e-01, 9.874343401290739e-01, 9.874736235387018e-01, 9.875243137719285e-01, - 9.875856201221135e-01, 9.876563785063032e-01, 9.877358921155149e-01, 9.878225576787804e-01, - 9.879150968481590e-01, 9.880132731565830e-01, 9.881156946084619e-01, 9.882211314188272e-01, - 9.883289032519310e-01, 9.884378310018685e-01, 9.885476787868710e-01, 9.886568414746639e-01, - 9.887645868459630e-01, 9.888708540445242e-01, 9.889744320992592e-01, 9.890747269455915e-01, - 9.891710038703801e-01, 9.892631024032380e-01, 9.893507219573624e-01, 9.894330645494204e-01, - 9.895096919388534e-01, 9.895810813422480e-01, 9.896467469067676e-01, 9.897067365020641e-01, - 9.897606930400666e-01, 9.898094478563998e-01, 9.898530133261707e-01, 9.898914705684924e-01, - 9.899254194103574e-01, 9.899554202030650e-01, 9.899824494486951e-01, 9.900065116928948e-01, - 9.900284805353695e-01, 9.900497484789281e-01, 9.900709561632662e-01, 9.900928358611601e-01, - 9.901163920607219e-01, 9.901427479709606e-01, 9.901734275350572e-01, 9.902087332329851e-01, - 9.902498637985275e-01, 9.902983686695558e-01, 9.903548501470234e-01, 9.904205084933333e-01, - 9.904959297726740e-01, 9.905825150202904e-01, 9.906812569810133e-01, 9.907922087340426e-01, - 9.909165464981378e-01, 9.910550740962871e-01, 9.912084614290896e-01, 9.913768610980639e-01, - 9.915605826937839e-01, 9.917604214872976e-01, 9.919767175562684e-01, 9.922091101818779e-01, - 9.924579135466506e-01, 9.927231225056266e-01, 9.930049538427406e-01, 9.933027281437943e-01, - 9.936161084869942e-01, 9.939453714404443e-01, 9.942895145656371e-01, 9.946481676207727e-01, - 9.950203031067961e-01, 9.954058173659507e-01, 9.958038713694317e-01, 9.962130271017117e-01, - 9.966324689957675e-01, 9.970615306490058e-01, 9.974990583293081e-01, 9.979437430375855e-01, - 9.983940572002874e-01, 9.988493116887893e-01, 9.993083430214909e-01, 9.997689221333534e-01, - 1.000231131275969e+00, 1.000692135698996e+00, 1.001152013920163e+00, 1.001608526000461e+00, - 1.002060493867275e+00, 1.002507212061815e+00, 1.002947129400411e+00, 1.003378909587027e+00, - 1.003801368578070e+00, 1.004213810320699e+00, 1.004615386562846e+00, 1.005004618375781e+00, - 1.005380628601598e+00, 1.005743282364652e+00, 1.006091510392348e+00, 1.006424907424988e+00, - 1.006742427727669e+00, 1.007044321511378e+00, 1.007330218597112e+00, 1.007599401798709e+00, - 1.007852064386603e+00, 1.008088176165563e+00, 1.008308033204578e+00, 1.008511247273756e+00, - 1.008698144207627e+00, 1.008869515256392e+00, 1.009025659761512e+00, 1.009166718967367e+00, - 1.009293362609020e+00, 1.009406398832440e+00, 1.009507017171120e+00, 1.009595264293017e+00, - 1.009672145744679e+00, 1.009739084785160e+00, 1.009796675060142e+00, 1.009846137382005e+00, - 1.009888083631667e+00, 1.009924092276850e+00, 1.009955384765721e+00, 1.009982268770147e+00, - 1.010006298177305e+00, 1.010028618428735e+00, 1.010050254076988e+00, 1.010071952131355e+00, - 1.010094366238073e+00, 1.010118917317053e+00, 1.010146497096682e+00, 1.010177110711677e+00, - 1.010211755260102e+00, 1.010251003469427e+00, 1.010295468653759e+00, 1.010345234996637e+00, - 1.010400316698172e+00, 1.010461564316351e+00, 1.010528615445659e+00, 1.010601521285347e+00, - 1.010679788081867e+00, 1.010763905869062e+00, 1.010853429760676e+00, 1.010947547074519e+00, - 1.011045953108263e+00, 1.011148486293359e+00, 1.011254397791134e+00, 1.011363082075863e+00, - 1.011473302008831e+00, 1.011584996312149e+00, 1.011697416504599e+00, 1.011808919793469e+00, - 1.011919264025716e+00, 1.012027240794153e+00, 1.012132151631041e+00, 1.012232734564333e+00, - 1.012327560477901e+00, 1.012416383754384e+00, 1.012497890726292e+00, 1.012570434021054e+00, - 1.012633295255708e+00, 1.012685277016726e+00, 1.012725564992284e+00, 1.012752577651415e+00, - 1.012765062889864e+00, 1.012762356719162e+00, 1.012743376077777e+00, 1.012706484200181e+00, - 1.012650842226435e+00, 1.012575427778520e+00, 1.012479473490919e+00, 1.012361105121003e+00, - 1.012219809594718e+00, 1.012054359992419e+00, 1.011864000215460e+00, 1.011647223869087e+00, - 1.011402518267713e+00, 1.011129654652857e+00, 1.010826951260377e+00, 1.010492924436361e+00, - 1.010126353960416e+00, 1.009725892479312e+00, 1.009290060983833e+00, 1.008817301052548e+00, - 1.008305027555130e+00, 1.007752833675443e+00, 1.007157827358150e+00, 1.006518049344503e+00, - 1.005831403532018e+00, 1.005095592119373e+00, 1.004308630055050e+00, 1.003467498305776e+00, - 1.002569500413888e+00, 1.001612710105563e+00, 1.000594272975683e+00, 9.995111701168786e-01, - 9.983609218719522e-01, 9.971409288327860e-01, 9.958488863050556e-01, 9.944818543153893e-01, - 9.930375282832211e-01, 9.915146560759479e-01, 9.899136802423638e-01, 9.881930623810997e-01, - 9.859422591203311e-01, 9.835667898378924e-01, 9.811423034808365e-01, 9.785214441250228e-01, - 9.756636036109838e-01, 9.725453442532574e-01, 9.691456634185092e-01, 9.654406178310209e-01, - 9.614043615076308e-01, 9.570113065179300e-01, 9.522367669696690e-01, 9.470548839544214e-01, - 9.414403740008491e-01, 9.353691612846549e-01, 9.288190093977164e-01, 9.217662887169115e-01, - 9.141896283466009e-01, 9.060694681113471e-01, 8.973891675497357e-01, 8.881332000806269e-01, - 8.782893885841422e-01, 8.678469565343039e-01, 8.567970644671067e-01, 8.451334654019180e-01, - 8.328542805780399e-01, 8.199594783897041e-01, 8.064511006873497e-01, 7.923346478686025e-01, - 7.776204488292163e-01, 7.623206183595970e-01, 7.464486491227057e-01, 7.300205729992958e-01, - 7.130567383226717e-01, 6.955805444755916e-01, 6.776173229836567e-01, 6.591955305148172e-01, - 6.403486426892321e-01, 6.211072197441818e-01, 6.015049275244730e-01, 5.815787608870452e-01, - 5.613674511156324e-01, 5.409188627354076e-01, 5.202736834971303e-01, 4.994780733459294e-01, - 4.785774177949064e-01, 4.576172599874928e-01, 4.366490208265804e-01, 4.157221460415995e-01, - 3.948856590950757e-01, 3.741903189229770e-01, 3.536868899553974e-01, 3.334260017756462e-01, - 3.134586473252229e-01, 2.938337904395871e-01, 2.745992637590817e-01, 2.558030636168172e-01, - 2.374902188466697e-01, 2.197036032185785e-01, 2.024855415115456e-01, 1.858749915117319e-01, - 1.699067802117410e-01, 1.546132267478873e-01, 1.400238206749695e-01, 1.261637395672913e-01, - 1.130534434072719e-01, 1.007084973747940e-01, 8.914024389873081e-02, 7.835612100141792e-02, - 6.835821233920988e-02, 5.914211536028976e-02, 5.069893012340832e-02, 4.301717763585550e-02, - 3.608020726673359e-02, 2.986316337017630e-02, 2.433722657129812e-02, 1.947675241971700e-02, - 1.525710171255895e-02, 1.163787492636240e-02, 8.433087782643718e-03, 4.449668997344735e-03, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 -}; + 2.844096748870385e-03, 1.066976124794342e-02, 1.881355950582949e-02, 2.728156010437695e-02, + 3.607810469851272e-02, 4.520702759803914e-02, 5.467238802204326e-02, 6.447866054615346e-02, + 7.462862199422061e-02, 8.512490568723846e-02, 9.596983987496970e-02, 1.071650779014335e-01, + 1.187115850305241e-01, 1.306101067250375e-01, 1.428596447589721e-01, 1.554584725339102e-01, + 1.684041609371527e-01, 1.816947894623263e-01, 1.953273880886783e-01, 2.092963206850239e-01, + 2.235945635254679e-01, 2.382160219461597e-01, 2.531529721334063e-01, 2.683961570569586e-01, + 2.839361392493072e-01, 2.997624255177811e-01, 3.158619077906196e-01, 3.322210551086769e-01, + 3.488264676990591e-01, 3.656640377499646e-01, 3.827152968157059e-01, 3.999611859760947e-01, + 4.173843265025887e-01, 4.349669624916473e-01, 4.526876397402144e-01, 4.705242008503956e-01, + 4.884539254831315e-01, 5.064545550235134e-01, 5.245006748662190e-01, 5.425674372882107e-01, + 5.606312044701524e-01, 5.786672646386708e-01, 5.966477035050948e-01, 6.145458904162185e-01, + 6.323361944662236e-01, 6.499926319211774e-01, 6.674874032292857e-01, 6.847932667399612e-01, + 7.018835463513400e-01, 7.187322544823347e-01, 7.353128213893310e-01, 7.516001985652684e-01, + 7.675699252273948e-01, 7.831974571624924e-01, 7.984583859818390e-01, 8.133295347030278e-01, + 8.277892271515950e-01, 8.418178561101360e-01, 8.553961300139363e-01, 8.685068980898102e-01, + 8.811334436653052e-01, 8.932596784799233e-01, 9.048748835980528e-01, 9.159657608120536e-01, + 9.265215299450000e-01, 9.365339988633418e-01, 9.459977028429117e-01, 9.549088408436811e-01, + 9.632658122557368e-01, 9.710688896122810e-01, 9.783204156360773e-01, 9.850226760127131e-01, + 9.911792082081333e-01, 9.967989944502682e-01, 1.001894024615659e+00, 1.006474342231823e+00, + 1.010552057109195e+00, 1.014142538208007e+00, 1.017262593268930e+00, 1.019928842669923e+00, + 1.022159867011177e+00, 1.023976320927187e+00, 1.025400734608122e+00, 1.026455340400072e+00, + 1.027164510654160e+00, 1.027552729180790e+00, 1.027644462380432e+00, 1.027463246660797e+00, + 1.027035903410657e+00, 1.026389068000259e+00, 1.025548201799728e+00, 1.024537134749709e+00, + 1.023380803775376e+00, 1.022103695693341e+00, 1.020728359657958e+00, 1.019275334687329e+00, + 1.017765178792830e+00, 1.016217355867531e+00, 1.014665311686846e+00, 1.013249071090664e+00, + 1.011948006992127e+00, 1.010189090179223e+00, 1.008557961167850e+00, 1.007011287608451e+00, + 1.005548764575910e+00, 1.004168417268956e+00, 1.002867268893035e+00, 1.001641769115897e+00, + 1.000489068954641e+00, 9.994060799749374e-01, 9.983898865406841e-01, 9.974370849972721e-01, + 9.965444836911705e-01, 9.957098545943852e-01, 9.949302413030897e-01, 9.942024045863540e-01, + 9.935241604969254e-01, 9.928930430130044e-01, 9.923068103443909e-01, 9.917633778190438e-01, + 9.912597642374404e-01, 9.907954498484041e-01, 9.903677893656558e-01, 9.899751611066148e-01, + 9.896160337369861e-01, 9.892890160408989e-01, 9.889928511129679e-01, 9.887260333430423e-01, + 9.884868721088945e-01, 9.882751039537586e-01, 9.880892168751595e-01, 9.879277114724612e-01, + 9.877898261218510e-01, 9.876743442038471e-01, 9.875807496078497e-01, 9.875072021876561e-01, + 9.874529447589979e-01, 9.874169741527905e-01, 9.873984685207834e-01, 9.873958301311858e-01, + 9.874080027710336e-01, 9.874343401290739e-01, 9.874736235387018e-01, 9.875243137719285e-01, + 9.875856201221135e-01, 9.876563785063032e-01, 9.877358921155149e-01, 9.878225576787804e-01, + 9.879150968481590e-01, 9.880132731565830e-01, 9.881156946084619e-01, 9.882211314188272e-01, + 9.883289032519310e-01, 9.884378310018685e-01, 9.885476787868710e-01, 9.886568414746639e-01, + 9.887645868459630e-01, 9.888708540445242e-01, 9.889744320992592e-01, 9.890747269455915e-01, + 9.891710038703801e-01, 9.892631024032380e-01, 9.893507219573624e-01, 9.894330645494204e-01, + 9.895096919388534e-01, 9.895810813422480e-01, 9.896467469067676e-01, 9.897067365020641e-01, + 9.897606930400666e-01, 9.898094478563998e-01, 9.898530133261707e-01, 9.898914705684924e-01, + 9.899254194103574e-01, 9.899554202030650e-01, 9.899824494486951e-01, 9.900065116928948e-01, + 9.900284805353695e-01, 9.900497484789281e-01, 9.900709561632662e-01, 9.900928358611601e-01, + 9.901163920607219e-01, 9.901427479709606e-01, 9.901734275350572e-01, 9.902087332329851e-01, + 9.902498637985275e-01, 9.902983686695558e-01, 9.903548501470234e-01, 9.904205084933333e-01, + 9.904959297726740e-01, 9.905825150202904e-01, 9.906812569810133e-01, 9.907922087340426e-01, + 9.909165464981378e-01, 9.910550740962871e-01, 9.912084614290896e-01, 9.913768610980639e-01, + 9.915605826937839e-01, 9.917604214872976e-01, 9.919767175562684e-01, 9.922091101818779e-01, + 9.924579135466506e-01, 9.927231225056266e-01, 9.930049538427406e-01, 9.933027281437943e-01, + 9.936161084869942e-01, 9.939453714404443e-01, 9.942895145656371e-01, 9.946481676207727e-01, + 9.950203031067961e-01, 9.954058173659507e-01, 9.958038713694317e-01, 9.962130271017117e-01, + 9.966324689957675e-01, 9.970615306490058e-01, 9.974990583293081e-01, 9.979437430375855e-01, + 9.983940572002874e-01, 9.988493116887893e-01, 9.993083430214909e-01, 9.997689221333534e-01, + 1.000231131275969e+00, 1.000692135698996e+00, 1.001152013920163e+00, 1.001608526000461e+00, + 1.002060493867275e+00, 1.002507212061815e+00, 1.002947129400411e+00, 1.003378909587027e+00, + 1.003801368578070e+00, 1.004213810320699e+00, 1.004615386562846e+00, 1.005004618375781e+00, + 1.005380628601598e+00, 1.005743282364652e+00, 1.006091510392348e+00, 1.006424907424988e+00, + 1.006742427727669e+00, 1.007044321511378e+00, 1.007330218597112e+00, 1.007599401798709e+00, + 1.007852064386603e+00, 1.008088176165563e+00, 1.008308033204578e+00, 1.008511247273756e+00, + 1.008698144207627e+00, 1.008869515256392e+00, 1.009025659761512e+00, 1.009166718967367e+00, + 1.009293362609020e+00, 1.009406398832440e+00, 1.009507017171120e+00, 1.009595264293017e+00, + 1.009672145744679e+00, 1.009739084785160e+00, 1.009796675060142e+00, 1.009846137382005e+00, + 1.009888083631667e+00, 1.009924092276850e+00, 1.009955384765721e+00, 1.009982268770147e+00, + 1.010006298177305e+00, 1.010028618428735e+00, 1.010050254076988e+00, 1.010071952131355e+00, + 1.010094366238073e+00, 1.010118917317053e+00, 1.010146497096682e+00, 1.010177110711677e+00, + 1.010211755260102e+00, 1.010251003469427e+00, 1.010295468653759e+00, 1.010345234996637e+00, + 1.010400316698172e+00, 1.010461564316351e+00, 1.010528615445659e+00, 1.010601521285347e+00, + 1.010679788081867e+00, 1.010763905869062e+00, 1.010853429760676e+00, 1.010947547074519e+00, + 1.011045953108263e+00, 1.011148486293359e+00, 1.011254397791134e+00, 1.011363082075863e+00, + 1.011473302008831e+00, 1.011584996312149e+00, 1.011697416504599e+00, 1.011808919793469e+00, + 1.011919264025716e+00, 1.012027240794153e+00, 1.012132151631041e+00, 1.012232734564333e+00, + 1.012327560477901e+00, 1.012416383754384e+00, 1.012497890726292e+00, 1.012570434021054e+00, + 1.012633295255708e+00, 1.012685277016726e+00, 1.012725564992284e+00, 1.012752577651415e+00, + 1.012765062889864e+00, 1.012762356719162e+00, 1.012743376077777e+00, 1.012706484200181e+00, + 1.012650842226435e+00, 1.012575427778520e+00, 1.012479473490919e+00, 1.012361105121003e+00, + 1.012219809594718e+00, 1.012054359992419e+00, 1.011864000215460e+00, 1.011647223869087e+00, + 1.011402518267713e+00, 1.011129654652857e+00, 1.010826951260377e+00, 1.010492924436361e+00, + 1.010126353960416e+00, 1.009725892479312e+00, 1.009290060983833e+00, 1.008817301052548e+00, + 1.008305027555130e+00, 1.007752833675443e+00, 1.007157827358150e+00, 1.006518049344503e+00, + 1.005831403532018e+00, 1.005095592119373e+00, 1.004308630055050e+00, 1.003467498305776e+00, + 1.002569500413888e+00, 1.001612710105563e+00, 1.000594272975683e+00, 9.995111701168786e-01, + 9.983609218719522e-01, 9.971409288327860e-01, 9.958488863050556e-01, 9.944818543153893e-01, + 9.930375282832211e-01, 9.915146560759479e-01, 9.899136802423638e-01, 9.881930623810997e-01, + 9.859422591203311e-01, 9.835667898378924e-01, 9.811423034808365e-01, 9.785214441250228e-01, + 9.756636036109838e-01, 9.725453442532574e-01, 9.691456634185092e-01, 9.654406178310209e-01, + 9.614043615076308e-01, 9.570113065179300e-01, 9.522367669696690e-01, 9.470548839544214e-01, + 9.414403740008491e-01, 9.353691612846549e-01, 9.288190093977164e-01, 9.217662887169115e-01, + 9.141896283466009e-01, 9.060694681113471e-01, 8.973891675497357e-01, 8.881332000806269e-01, + 8.782893885841422e-01, 8.678469565343039e-01, 8.567970644671067e-01, 8.451334654019180e-01, + 8.328542805780399e-01, 8.199594783897041e-01, 8.064511006873497e-01, 7.923346478686025e-01, + 7.776204488292163e-01, 7.623206183595970e-01, 7.464486491227057e-01, 7.300205729992958e-01, + 7.130567383226717e-01, 6.955805444755916e-01, 6.776173229836567e-01, 6.591955305148172e-01, + 6.403486426892321e-01, 6.211072197441818e-01, 6.015049275244730e-01, 5.815787608870452e-01, + 5.613674511156324e-01, 5.409188627354076e-01, 5.202736834971303e-01, 4.994780733459294e-01, + 4.785774177949064e-01, 4.576172599874928e-01, 4.366490208265804e-01, 4.157221460415995e-01, + 3.948856590950757e-01, 3.741903189229770e-01, 3.536868899553974e-01, 3.334260017756462e-01, + 3.134586473252229e-01, 2.938337904395871e-01, 2.745992637590817e-01, 2.558030636168172e-01, + 2.374902188466697e-01, 2.197036032185785e-01, 2.024855415115456e-01, 1.858749915117319e-01, + 1.699067802117410e-01, 1.546132267478873e-01, 1.400238206749695e-01, 1.261637395672913e-01, + 1.130534434072719e-01, 1.007084973747940e-01, 8.914024389873081e-02, 7.835612100141792e-02, + 6.835821233920988e-02, 5.914211536028976e-02, 5.069893012340832e-02, 4.301717763585550e-02, + 3.608020726673359e-02, 2.986316337017630e-02, 2.433722657129812e-02, 1.947675241971700e-02, + 1.525710171255895e-02, 1.163787492636240e-02, 8.433087782643718e-03, 4.449668997344735e-03, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; const LC3_FLOAT MDCT_WINDOW_480[960] = { -2.353032150516754e-04, -4.619898752628163e-04, -6.262931535610879e-04, -7.929180432976445e-04, @@ -1653,210 +1582,209 @@ const LC3_FLOAT MDCT_WINDOW_480[960] = { -5.665655641133161e-02, -5.330406164482222e-02, -4.983427241976235e-02, -4.624456893420224e-02, -4.253455686336916e-02, -3.870195772538443e-02, -3.474585776145929e-02, -3.066341518682682e-02, -2.645425077642105e-02, -2.211581608120528e-02, -1.764740541599136e-02, -1.304581363895818e-02, - -8.310425696208936e-03, -3.438268661133170e-03, 1.570315476576933e-03, 6.717697635290676e-03, - 1.200477020244778e-02, 1.743398319747869e-02, 2.300642061077823e-02, 2.872481423270595e-02, - 3.458896350634671e-02, 4.060106462625085e-02, 4.676102915752826e-02, 5.307133911821893e-02, - 5.953239090915557e-02, 6.614647812869151e-02, 7.291293184312803e-02, 7.983354189816511e-02, - 8.690807412770696e-02, 9.413813765275064e-02, 1.015233140203748e-01, 1.090651518336202e-01, - 1.167626546016197e-01, 1.246171387327525e-01, 1.326272948938113e-01, 1.407938190608664e-01, - 1.491152519299797e-01, 1.575921408388593e-01, 1.662224799248571e-01, 1.750067399059861e-01, - 1.839431938620024e-01, 1.930318183054904e-01, 2.022699854906251e-01, 2.116567430906184e-01, - 2.211888523410642e-01, 2.308655379767671e-01, 2.406837992341654e-01, 2.506420640291662e-01, - 2.607365124918583e-01, 2.709659073501196e-01, 2.813259021832532e-01, 2.918144694729168e-01, - 3.024270279840051e-01, 3.131603499997996e-01, 3.240095704645023e-01, 3.349719592361666e-01, - 3.460422935204829e-01, 3.572175180786021e-01, 3.684915649120530e-01, 3.798595119591716e-01, - 3.913146885756875e-01, 4.028532873867052e-01, 4.144688328137527e-01, 4.261571642320424e-01, - 4.379113897565727e-01, 4.497256320417501e-01, 4.615925445090212e-01, 4.735067030065239e-01, - 4.854600184866710e-01, 4.974471592901086e-01, 5.094597228333853e-01, 5.214909841729947e-01, - 5.335326819631583e-01, 5.455789811615239e-01, 5.576217157959890e-01, 5.696546730080154e-01, - 5.816685576268035e-01, 5.936560624526468e-01, 6.056083823929643e-01, 6.175192060085208e-01, - 6.293796611336280e-01, 6.411830842823245e-01, 6.529203544876097e-01, 6.645840786371451e-01, - 6.761653499550255e-01, 6.876573952173626e-01, 6.990511539119996e-01, 7.103400549562944e-01, - 7.215149331458728e-01, 7.325691772738999e-01, 7.434943718765665e-01, 7.542846327442048e-01, - 7.649313654540612e-01, 7.754281892901473e-01, 7.857670170752049e-01, 7.959414651061612e-01, - 8.059437233154637e-01, 8.157687070715176e-01, 8.254086223972127e-01, 8.348589373399948e-01, - 8.441125827416620e-01, 8.531651194538425e-01, 8.620108336276733e-01, 8.706456337542150e-01, - 8.790631561061171e-01, 8.872599706865123e-01, 8.952313288619367e-01, 9.029751680353524e-01, - 9.104863121445679e-01, 9.177625550620636e-01, 9.247997426966093e-01, 9.315962496426278e-01, - 9.381494858921667e-01, 9.444588390359354e-01, 9.505220861927248e-01, 9.563402921286364e-01, - 9.619114522936701e-01, 9.672366712325431e-01, 9.723156637834687e-01, 9.771501187120180e-01, - 9.817397501303696e-01, 9.860865871353246e-01, 9.901906380163595e-01, 9.940557180662704e-01, - 9.976842395284637e-01, 1.001080961257010e+00, 1.004247514102417e+00, 1.007188578458507e+00, - 1.009906654565108e+00, 1.012407428282884e+00, 1.014694702432600e+00, 1.016774659209400e+00, - 1.018650990561848e+00, 1.020330464463111e+00, 1.021817328911793e+00, 1.023118841384460e+00, - 1.024240262467000e+00, 1.025189721888128e+00, 1.025972450969440e+00, 1.026596938589443e+00, - 1.027069179375841e+00, 1.027397523939210e+00, 1.027587902203109e+00, 1.027648951922701e+00, - 1.027585830688143e+00, 1.027408519661012e+00, 1.027122986826984e+00, 1.026738673647482e+00, - 1.026261663878092e+00, 1.025701002415063e+00, 1.025061777648234e+00, 1.024353980976701e+00, - 1.023582385618774e+00, 1.022756514615106e+00, 1.021880604350422e+00, 1.020963871317665e+00, - 1.020009139549275e+00, 1.019027285501251e+00, 1.018019442784231e+00, 1.016996499560845e+00, - 1.015957433206324e+00, 1.014923441259795e+00, 1.013915946100629e+00, 1.013047565149327e+00, - 1.012216130365610e+00, 1.011044869639164e+00, 1.009914592130044e+00, 1.008824888092573e+00, - 1.007773858455400e+00, 1.006761700412993e+00, 1.005786648810854e+00, 1.004848753962734e+00, - 1.003946083413733e+00, 1.003078846506546e+00, 1.002245009135684e+00, 1.001444733905817e+00, - 1.000676188436651e+00, 9.999393169239009e-01, 9.992320848298057e-01, 9.985548127155425e-01, - 9.979055415627330e-01, 9.972842679758880e-01, 9.966890948441745e-01, 9.961203379971326e-01, - 9.955761256313581e-01, 9.950565724564597e-01, 9.945597525471822e-01, 9.940860378486615e-01, - 9.936337788972491e-01, 9.932031606606759e-01, 9.927921871265732e-01, 9.924015177880798e-01, - 9.920297273323891e-01, 9.916767775088281e-01, 9.913408767719142e-01, 9.910230654424902e-01, - 9.907216425865902e-01, 9.904366799536263e-01, 9.901668953434221e-01, 9.899131011580791e-01, - 9.896735637374597e-01, 9.894488374513719e-01, 9.892374835404283e-01, 9.890401927796704e-01, - 9.888556356037892e-01, 9.886843467692753e-01, 9.885247606051014e-01, 9.883778520531268e-01, - 9.882423270582524e-01, 9.881185638915363e-01, 9.880051626345804e-01, 9.879032023766432e-01, - 9.878111744348976e-01, 9.877295459610343e-01, 9.876571983429736e-01, 9.875949843246187e-01, - 9.875412739766566e-01, 9.874969061399389e-01, 9.874606249127551e-01, 9.874329809802893e-01, - 9.874126414437681e-01, 9.874004750404033e-01, 9.873949921033299e-01, 9.873969162747074e-01, - 9.874049060317581e-01, 9.874197049003676e-01, 9.874399717110517e-01, 9.874663281231737e-01, - 9.874973205882319e-01, 9.875338926695315e-01, 9.875746535410983e-01, 9.876201238703241e-01, - 9.876689801932402e-01, 9.877221556193183e-01, 9.877781920433015e-01, 9.878376489591358e-01, - 9.878991990245439e-01, 9.879637979933339e-01, 9.880300303653743e-01, 9.880984675859855e-01, - 9.881678007807095e-01, 9.882390300097154e-01, 9.883107693992456e-01, 9.883835200189653e-01, - 9.884560159878955e-01, 9.885294200392185e-01, 9.886022219397892e-01, 9.886749404176028e-01, - 9.887466261142505e-01, 9.888182771263505e-01, 9.888882480852147e-01, 9.889574384705896e-01, - 9.890247977602895e-01, 9.890911247701029e-01, 9.891551701556196e-01, 9.892178658748239e-01, - 9.892779555818088e-01, 9.893365186903538e-01, 9.893923680007577e-01, 9.894462830852175e-01, - 9.894972124952000e-01, 9.895463342815009e-01, 9.895923617530382e-01, 9.896362652966239e-01, - 9.896772011542693e-01, 9.897162195263046e-01, 9.897520286480039e-01, 9.897859195209235e-01, - 9.898170267411330e-01, 9.898462068764986e-01, 9.898725363809847e-01, 9.898975138787787e-01, - 9.899200050208486e-01, 9.899410789223559e-01, 9.899600605054418e-01, 9.899782261038060e-01, - 9.899945557067980e-01, 9.900103500807507e-01, 9.900248320990181e-01, 9.900394023736973e-01, - 9.900532105829365e-01, 9.900674746047259e-01, 9.900814722948890e-01, 9.900966926051257e-01, - 9.901122448734595e-01, 9.901293790312005e-01, 9.901474648912307e-01, 9.901680598867444e-01, - 9.901902265696609e-01, 9.902151896501201e-01, 9.902424418296485e-01, 9.902734448815004e-01, - 9.903071270768942e-01, 9.903448913950654e-01, 9.903862280081246e-01, 9.904324484666853e-01, - 9.904825650601110e-01, 9.905379830873822e-01, 9.905980602136440e-01, 9.906640366554630e-01, - 9.907348826312993e-01, 9.908120376822228e-01, 9.908947858311721e-01, 9.909842592301273e-01, - 9.910795247770178e-01, 9.911819240108124e-01, 9.912905118607647e-01, 9.914064705361564e-01, - 9.915288011543961e-01, 9.916586940166509e-01, 9.917952720685562e-01, 9.919396217291009e-01, - 9.920906151219310e-01, 9.922495028313456e-01, 9.924152398352751e-01, 9.925887208794144e-01, - 9.927688708468421e-01, 9.929569112537944e-01, 9.931516528513824e-01, 9.933539244159140e-01, - 9.935626893131695e-01, 9.937790866568735e-01, 9.940016434044485e-01, 9.942312024833810e-01, - 9.944668184371617e-01, 9.947093441694513e-01, 9.949572854565533e-01, 9.952116634297566e-01, - 9.954712635321227e-01, 9.957367951478069e-01, 9.960068616185641e-01, 9.962823025614079e-01, - 9.965617986382630e-01, 9.968461329825753e-01, 9.971338271912752e-01, 9.974256691222113e-01, - 9.977203369515556e-01, 9.980185087055744e-01, 9.983185871761977e-01, 9.986213520769593e-01, - 9.989255426466267e-01, 9.992317314100975e-01, 9.995382582242990e-01, 9.998461160718275e-01, - 1.000153907612080e+00, 1.000461955079660e+00, 1.000768859280338e+00, 1.001075613053728e+00, - 1.001380551217109e+00, 1.001684244734497e+00, 1.001985425397567e+00, 1.002284871786226e+00, - 1.002580975161843e+00, 1.002874411368430e+00, 1.003163845364970e+00, 1.003450063374329e+00, - 1.003731570287893e+00, 1.004009147462043e+00, 1.004281457582935e+00, 1.004549339226336e+00, - 1.004811375053364e+00, 1.005068272394360e+00, 1.005318795748286e+00, 1.005563968008037e+00, - 1.005802269635282e+00, 1.006034554002353e+00, 1.006259855360867e+00, 1.006479018139540e+00, - 1.006690541428116e+00, 1.006895570408563e+00, 1.007093045696527e+00, 1.007283799246233e+00, - 1.007466616298057e+00, 1.007642728426847e+00, 1.007811036585595e+00, 1.007972441990187e+00, - 1.008125875904472e+00, 1.008272602383284e+00, 1.008411468616852e+00, 1.008543573152632e+00, - 1.008668018334797e+00, 1.008786009787269e+00, 1.008896526233555e+00, 1.009000766336071e+00, - 1.009097763850333e+00, 1.009188880897370e+00, 1.009273163797313e+00, 1.009351762546296e+00, - 1.009423944949143e+00, 1.009491175244507e+00, 1.009552401900961e+00, 1.009608886895764e+00, - 1.009659973830751e+00, 1.009707093778162e+00, 1.009749238562067e+00, 1.009787744284661e+00, - 1.009822090220407e+00, 1.009853706282597e+00, 1.009881498943010e+00, 1.009906958448099e+00, - 1.009929567021562e+00, 1.009950573483366e+00, 1.009969021400474e+00, 1.009986499185054e+00, - 1.010002363879044e+00, 1.010017890428877e+00, 1.010032170180360e+00, 1.010046722045583e+00, - 1.010060809299530e+00, 1.010075674445289e+00, 1.010090449982098e+00, 1.010106564965965e+00, - 1.010123226584120e+00, 1.010141762173145e+00, 1.010161131093372e+00, 1.010182635897876e+00, - 1.010205587931660e+00, 1.010231078494249e+00, 1.010257950227988e+00, 1.010287732968580e+00, - 1.010319484524512e+00, 1.010354079663767e+00, 1.010390635488037e+00, 1.010430470494512e+00, - 1.010472266495074e+00, 1.010517096381509e+00, 1.010564099281000e+00, 1.010614266894512e+00, - 1.010666285876455e+00, 1.010721360243234e+00, 1.010778416755264e+00, 1.010838252644461e+00, - 1.010899655674578e+00, 1.010963729626641e+00, 1.011029191301694e+00, 1.011096993993037e+00, - 1.011165861239173e+00, 1.011236610341260e+00, 1.011308167670753e+00, 1.011381453638912e+00, - 1.011454785713102e+00, 1.011529185153809e+00, 1.011603680910505e+00, 1.011678803938046e+00, - 1.011753008569803e+00, 1.011827484797985e+00, 1.011900936547881e+00, 1.011973876511603e+00, - 1.012044885003304e+00, 1.012114985644919e+00, 1.012182837094955e+00, 1.012249023976742e+00, - 1.012312095063070e+00, 1.012373028737774e+00, 1.012430463679316e+00, 1.012484972246822e+00, - 1.012535058602453e+00, 1.012581678169188e+00, 1.012623472898504e+00, 1.012660975529858e+00, - 1.012692758750213e+00, 1.012719789201144e+00, 1.012740575296603e+00, 1.012755753887085e+00, - 1.012763948841204e+00, 1.012765922449960e+00, 1.012760298661069e+00, 1.012747819936584e+00, - 1.012726958954961e+00, 1.012698607692183e+00, 1.012661400539405e+00, 1.012615904116265e+00, - 1.012560833005713e+00, 1.012497050269805e+00, 1.012422888521601e+00, 1.012339226241367e+00, - 1.012244921966297e+00, 1.012140460211194e+00, 1.012024302085441e+00, 1.011897560567707e+00, - 1.011758810583150e+00, 1.011608449127642e+00, 1.011445162723270e+00, 1.011269960947744e+00, - 1.011081255645969e+00, 1.010879608424312e+00, 1.010663676735228e+00, 1.010434184200640e+00, - 1.010189681124657e+00, 1.009930754807923e+00, 1.009655660215271e+00, 1.009365251564694e+00, - 1.009058249873833e+00, 1.008734758578989e+00, 1.008393079963091e+00, 1.008034308295421e+00, - 1.007656661215973e+00, 1.007260142622887e+00, 1.006843352506855e+00, 1.006407009542103e+00, - 1.005949145170711e+00, 1.005470005637052e+00, 1.004967986424467e+00, 1.004443531995945e+00, - 1.003894772403371e+00, 1.003321903663793e+00, 1.002723127308148e+00, 1.002098854400575e+00, - 1.001447278873483e+00, 1.000768505317086e+00, 1.000060686758758e+00, 9.993242684851855e-01, - 9.985573503390627e-01, 9.977600196406868e-01, 9.969306036935497e-01, 9.960694269553644e-01, - 9.951746430061121e-01, 9.942466438407230e-01, 9.932837131068657e-01, 9.922861082472264e-01, - 9.912523092989319e-01, 9.901827419790691e-01, 9.890757868707590e-01, 9.879313024174022e-01, - 9.863553220272523e-01, 9.847362453480265e-01, 9.831750948772566e-01, 9.815583336011345e-01, - 9.798613526271561e-01, 9.780617486993630e-01, 9.761574317374303e-01, 9.741378617337759e-01, - 9.719990112065752e-01, 9.697327413658168e-01, 9.673331975559332e-01, 9.647915124057732e-01, - 9.621011497566145e-01, 9.592539757044516e-01, 9.562427177295731e-01, 9.530600909726344e-01, - 9.496984081652284e-01, 9.461498120176854e-01, 9.424071613625743e-01, 9.384634163826711e-01, - 9.343112966094085e-01, 9.299449872197452e-01, 9.253567968750328e-01, 9.205404627076625e-01, - 9.154896280575360e-01, 9.101986790930605e-01, 9.046620597741508e-01, 8.988755194372424e-01, - 8.928338316495705e-01, 8.865337190368053e-01, 8.799712722567934e-01, 8.731437835983047e-01, - 8.660476534563131e-01, 8.586812520174252e-01, 8.510420440685049e-01, 8.431297226886574e-01, - 8.349435141989714e-01, 8.264839911291133e-01, 8.177505366573690e-01, 8.087449817124315e-01, - 7.994681492797084e-01, 7.899235162194718e-01, 7.801137731566502e-01, 7.700431275216928e-01, - 7.597145736971065e-01, 7.491330971820804e-01, 7.383028603058783e-01, 7.272298755824693e-01, - 7.159201919962611e-01, 7.043814340356083e-01, 6.926196927377140e-01, 6.806438831866077e-01, - 6.684616478236647e-01, 6.560830137986515e-01, 6.435179268559957e-01, 6.307755329382612e-01, - 6.178641647786525e-01, 6.047954625702541e-01, 5.915799587176216e-01, 5.782289366005894e-01, - 5.647535885752191e-01, 5.511703155400274e-01, 5.374905090437071e-01, 5.237263500445715e-01, - 5.098915423728255e-01, 4.960008074926423e-01, 4.820662943337458e-01, 4.681017110048007e-01, - 4.541216995958746e-01, 4.401421815729068e-01, 4.261772971493010e-01, 4.122417888542512e-01, - 3.983499612526493e-01, 3.845172335531009e-01, 3.707583717376236e-01, 3.570886786795506e-01, - 3.435228672445627e-01, 3.300763764703638e-01, 3.167640325043893e-01, 3.036004651973109e-01, - 2.905996158436682e-01, 2.777758503744847e-01, 2.651434678028531e-01, 2.527161881181577e-01, - 2.405069849650012e-01, 2.285283969438072e-01, 2.167933432162879e-01, 2.053139897833021e-01, - 1.941021906320988e-01, 1.831680872008943e-01, 1.725221947208913e-01, 1.621735416384834e-01, - 1.521320683467849e-01, 1.424052801149985e-01, 1.330015240938615e-01, 1.239260664828526e-01, - 1.151858295527293e-01, 1.067840430193724e-01, 9.872637505002878e-02, 9.101379000888035e-02, - 8.365057236623055e-02, 7.663508305536153e-02, 6.997033405748826e-02, 6.365188111381365e-02, - 5.768176015814392e-02, 5.205244216987966e-02, 4.676538412257621e-02, 4.180950541438362e-02, - 3.718640251368464e-02, 3.288072750732215e-02, 2.889548499582958e-02, 2.520980565928884e-02, - 2.183057564646272e-02, 1.872896194002638e-02, 1.592127815153420e-02, 1.336381425803020e-02, - 1.108558877807282e-02, 8.943474189364638e-03, 6.758124889697787e-03, 3.504438130619497e-03, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 -}; + -8.310425696208936e-03, -3.438268661133170e-03, 1.570315476576933e-03, 6.717697635290676e-03, + 1.200477020244778e-02, 1.743398319747869e-02, 2.300642061077823e-02, 2.872481423270595e-02, + 3.458896350634671e-02, 4.060106462625085e-02, 4.676102915752826e-02, 5.307133911821893e-02, + 5.953239090915557e-02, 6.614647812869151e-02, 7.291293184312803e-02, 7.983354189816511e-02, + 8.690807412770696e-02, 9.413813765275064e-02, 1.015233140203748e-01, 1.090651518336202e-01, + 1.167626546016197e-01, 1.246171387327525e-01, 1.326272948938113e-01, 1.407938190608664e-01, + 1.491152519299797e-01, 1.575921408388593e-01, 1.662224799248571e-01, 1.750067399059861e-01, + 1.839431938620024e-01, 1.930318183054904e-01, 2.022699854906251e-01, 2.116567430906184e-01, + 2.211888523410642e-01, 2.308655379767671e-01, 2.406837992341654e-01, 2.506420640291662e-01, + 2.607365124918583e-01, 2.709659073501196e-01, 2.813259021832532e-01, 2.918144694729168e-01, + 3.024270279840051e-01, 3.131603499997996e-01, 3.240095704645023e-01, 3.349719592361666e-01, + 3.460422935204829e-01, 3.572175180786021e-01, 3.684915649120530e-01, 3.798595119591716e-01, + 3.913146885756875e-01, 4.028532873867052e-01, 4.144688328137527e-01, 4.261571642320424e-01, + 4.379113897565727e-01, 4.497256320417501e-01, 4.615925445090212e-01, 4.735067030065239e-01, + 4.854600184866710e-01, 4.974471592901086e-01, 5.094597228333853e-01, 5.214909841729947e-01, + 5.335326819631583e-01, 5.455789811615239e-01, 5.576217157959890e-01, 5.696546730080154e-01, + 5.816685576268035e-01, 5.936560624526468e-01, 6.056083823929643e-01, 6.175192060085208e-01, + 6.293796611336280e-01, 6.411830842823245e-01, 6.529203544876097e-01, 6.645840786371451e-01, + 6.761653499550255e-01, 6.876573952173626e-01, 6.990511539119996e-01, 7.103400549562944e-01, + 7.215149331458728e-01, 7.325691772738999e-01, 7.434943718765665e-01, 7.542846327442048e-01, + 7.649313654540612e-01, 7.754281892901473e-01, 7.857670170752049e-01, 7.959414651061612e-01, + 8.059437233154637e-01, 8.157687070715176e-01, 8.254086223972127e-01, 8.348589373399948e-01, + 8.441125827416620e-01, 8.531651194538425e-01, 8.620108336276733e-01, 8.706456337542150e-01, + 8.790631561061171e-01, 8.872599706865123e-01, 8.952313288619367e-01, 9.029751680353524e-01, + 9.104863121445679e-01, 9.177625550620636e-01, 9.247997426966093e-01, 9.315962496426278e-01, + 9.381494858921667e-01, 9.444588390359354e-01, 9.505220861927248e-01, 9.563402921286364e-01, + 9.619114522936701e-01, 9.672366712325431e-01, 9.723156637834687e-01, 9.771501187120180e-01, + 9.817397501303696e-01, 9.860865871353246e-01, 9.901906380163595e-01, 9.940557180662704e-01, + 9.976842395284637e-01, 1.001080961257010e+00, 1.004247514102417e+00, 1.007188578458507e+00, + 1.009906654565108e+00, 1.012407428282884e+00, 1.014694702432600e+00, 1.016774659209400e+00, + 1.018650990561848e+00, 1.020330464463111e+00, 1.021817328911793e+00, 1.023118841384460e+00, + 1.024240262467000e+00, 1.025189721888128e+00, 1.025972450969440e+00, 1.026596938589443e+00, + 1.027069179375841e+00, 1.027397523939210e+00, 1.027587902203109e+00, 1.027648951922701e+00, + 1.027585830688143e+00, 1.027408519661012e+00, 1.027122986826984e+00, 1.026738673647482e+00, + 1.026261663878092e+00, 1.025701002415063e+00, 1.025061777648234e+00, 1.024353980976701e+00, + 1.023582385618774e+00, 1.022756514615106e+00, 1.021880604350422e+00, 1.020963871317665e+00, + 1.020009139549275e+00, 1.019027285501251e+00, 1.018019442784231e+00, 1.016996499560845e+00, + 1.015957433206324e+00, 1.014923441259795e+00, 1.013915946100629e+00, 1.013047565149327e+00, + 1.012216130365610e+00, 1.011044869639164e+00, 1.009914592130044e+00, 1.008824888092573e+00, + 1.007773858455400e+00, 1.006761700412993e+00, 1.005786648810854e+00, 1.004848753962734e+00, + 1.003946083413733e+00, 1.003078846506546e+00, 1.002245009135684e+00, 1.001444733905817e+00, + 1.000676188436651e+00, 9.999393169239009e-01, 9.992320848298057e-01, 9.985548127155425e-01, + 9.979055415627330e-01, 9.972842679758880e-01, 9.966890948441745e-01, 9.961203379971326e-01, + 9.955761256313581e-01, 9.950565724564597e-01, 9.945597525471822e-01, 9.940860378486615e-01, + 9.936337788972491e-01, 9.932031606606759e-01, 9.927921871265732e-01, 9.924015177880798e-01, + 9.920297273323891e-01, 9.916767775088281e-01, 9.913408767719142e-01, 9.910230654424902e-01, + 9.907216425865902e-01, 9.904366799536263e-01, 9.901668953434221e-01, 9.899131011580791e-01, + 9.896735637374597e-01, 9.894488374513719e-01, 9.892374835404283e-01, 9.890401927796704e-01, + 9.888556356037892e-01, 9.886843467692753e-01, 9.885247606051014e-01, 9.883778520531268e-01, + 9.882423270582524e-01, 9.881185638915363e-01, 9.880051626345804e-01, 9.879032023766432e-01, + 9.878111744348976e-01, 9.877295459610343e-01, 9.876571983429736e-01, 9.875949843246187e-01, + 9.875412739766566e-01, 9.874969061399389e-01, 9.874606249127551e-01, 9.874329809802893e-01, + 9.874126414437681e-01, 9.874004750404033e-01, 9.873949921033299e-01, 9.873969162747074e-01, + 9.874049060317581e-01, 9.874197049003676e-01, 9.874399717110517e-01, 9.874663281231737e-01, + 9.874973205882319e-01, 9.875338926695315e-01, 9.875746535410983e-01, 9.876201238703241e-01, + 9.876689801932402e-01, 9.877221556193183e-01, 9.877781920433015e-01, 9.878376489591358e-01, + 9.878991990245439e-01, 9.879637979933339e-01, 9.880300303653743e-01, 9.880984675859855e-01, + 9.881678007807095e-01, 9.882390300097154e-01, 9.883107693992456e-01, 9.883835200189653e-01, + 9.884560159878955e-01, 9.885294200392185e-01, 9.886022219397892e-01, 9.886749404176028e-01, + 9.887466261142505e-01, 9.888182771263505e-01, 9.888882480852147e-01, 9.889574384705896e-01, + 9.890247977602895e-01, 9.890911247701029e-01, 9.891551701556196e-01, 9.892178658748239e-01, + 9.892779555818088e-01, 9.893365186903538e-01, 9.893923680007577e-01, 9.894462830852175e-01, + 9.894972124952000e-01, 9.895463342815009e-01, 9.895923617530382e-01, 9.896362652966239e-01, + 9.896772011542693e-01, 9.897162195263046e-01, 9.897520286480039e-01, 9.897859195209235e-01, + 9.898170267411330e-01, 9.898462068764986e-01, 9.898725363809847e-01, 9.898975138787787e-01, + 9.899200050208486e-01, 9.899410789223559e-01, 9.899600605054418e-01, 9.899782261038060e-01, + 9.899945557067980e-01, 9.900103500807507e-01, 9.900248320990181e-01, 9.900394023736973e-01, + 9.900532105829365e-01, 9.900674746047259e-01, 9.900814722948890e-01, 9.900966926051257e-01, + 9.901122448734595e-01, 9.901293790312005e-01, 9.901474648912307e-01, 9.901680598867444e-01, + 9.901902265696609e-01, 9.902151896501201e-01, 9.902424418296485e-01, 9.902734448815004e-01, + 9.903071270768942e-01, 9.903448913950654e-01, 9.903862280081246e-01, 9.904324484666853e-01, + 9.904825650601110e-01, 9.905379830873822e-01, 9.905980602136440e-01, 9.906640366554630e-01, + 9.907348826312993e-01, 9.908120376822228e-01, 9.908947858311721e-01, 9.909842592301273e-01, + 9.910795247770178e-01, 9.911819240108124e-01, 9.912905118607647e-01, 9.914064705361564e-01, + 9.915288011543961e-01, 9.916586940166509e-01, 9.917952720685562e-01, 9.919396217291009e-01, + 9.920906151219310e-01, 9.922495028313456e-01, 9.924152398352751e-01, 9.925887208794144e-01, + 9.927688708468421e-01, 9.929569112537944e-01, 9.931516528513824e-01, 9.933539244159140e-01, + 9.935626893131695e-01, 9.937790866568735e-01, 9.940016434044485e-01, 9.942312024833810e-01, + 9.944668184371617e-01, 9.947093441694513e-01, 9.949572854565533e-01, 9.952116634297566e-01, + 9.954712635321227e-01, 9.957367951478069e-01, 9.960068616185641e-01, 9.962823025614079e-01, + 9.965617986382630e-01, 9.968461329825753e-01, 9.971338271912752e-01, 9.974256691222113e-01, + 9.977203369515556e-01, 9.980185087055744e-01, 9.983185871761977e-01, 9.986213520769593e-01, + 9.989255426466267e-01, 9.992317314100975e-01, 9.995382582242990e-01, 9.998461160718275e-01, + 1.000153907612080e+00, 1.000461955079660e+00, 1.000768859280338e+00, 1.001075613053728e+00, + 1.001380551217109e+00, 1.001684244734497e+00, 1.001985425397567e+00, 1.002284871786226e+00, + 1.002580975161843e+00, 1.002874411368430e+00, 1.003163845364970e+00, 1.003450063374329e+00, + 1.003731570287893e+00, 1.004009147462043e+00, 1.004281457582935e+00, 1.004549339226336e+00, + 1.004811375053364e+00, 1.005068272394360e+00, 1.005318795748286e+00, 1.005563968008037e+00, + 1.005802269635282e+00, 1.006034554002353e+00, 1.006259855360867e+00, 1.006479018139540e+00, + 1.006690541428116e+00, 1.006895570408563e+00, 1.007093045696527e+00, 1.007283799246233e+00, + 1.007466616298057e+00, 1.007642728426847e+00, 1.007811036585595e+00, 1.007972441990187e+00, + 1.008125875904472e+00, 1.008272602383284e+00, 1.008411468616852e+00, 1.008543573152632e+00, + 1.008668018334797e+00, 1.008786009787269e+00, 1.008896526233555e+00, 1.009000766336071e+00, + 1.009097763850333e+00, 1.009188880897370e+00, 1.009273163797313e+00, 1.009351762546296e+00, + 1.009423944949143e+00, 1.009491175244507e+00, 1.009552401900961e+00, 1.009608886895764e+00, + 1.009659973830751e+00, 1.009707093778162e+00, 1.009749238562067e+00, 1.009787744284661e+00, + 1.009822090220407e+00, 1.009853706282597e+00, 1.009881498943010e+00, 1.009906958448099e+00, + 1.009929567021562e+00, 1.009950573483366e+00, 1.009969021400474e+00, 1.009986499185054e+00, + 1.010002363879044e+00, 1.010017890428877e+00, 1.010032170180360e+00, 1.010046722045583e+00, + 1.010060809299530e+00, 1.010075674445289e+00, 1.010090449982098e+00, 1.010106564965965e+00, + 1.010123226584120e+00, 1.010141762173145e+00, 1.010161131093372e+00, 1.010182635897876e+00, + 1.010205587931660e+00, 1.010231078494249e+00, 1.010257950227988e+00, 1.010287732968580e+00, + 1.010319484524512e+00, 1.010354079663767e+00, 1.010390635488037e+00, 1.010430470494512e+00, + 1.010472266495074e+00, 1.010517096381509e+00, 1.010564099281000e+00, 1.010614266894512e+00, + 1.010666285876455e+00, 1.010721360243234e+00, 1.010778416755264e+00, 1.010838252644461e+00, + 1.010899655674578e+00, 1.010963729626641e+00, 1.011029191301694e+00, 1.011096993993037e+00, + 1.011165861239173e+00, 1.011236610341260e+00, 1.011308167670753e+00, 1.011381453638912e+00, + 1.011454785713102e+00, 1.011529185153809e+00, 1.011603680910505e+00, 1.011678803938046e+00, + 1.011753008569803e+00, 1.011827484797985e+00, 1.011900936547881e+00, 1.011973876511603e+00, + 1.012044885003304e+00, 1.012114985644919e+00, 1.012182837094955e+00, 1.012249023976742e+00, + 1.012312095063070e+00, 1.012373028737774e+00, 1.012430463679316e+00, 1.012484972246822e+00, + 1.012535058602453e+00, 1.012581678169188e+00, 1.012623472898504e+00, 1.012660975529858e+00, + 1.012692758750213e+00, 1.012719789201144e+00, 1.012740575296603e+00, 1.012755753887085e+00, + 1.012763948841204e+00, 1.012765922449960e+00, 1.012760298661069e+00, 1.012747819936584e+00, + 1.012726958954961e+00, 1.012698607692183e+00, 1.012661400539405e+00, 1.012615904116265e+00, + 1.012560833005713e+00, 1.012497050269805e+00, 1.012422888521601e+00, 1.012339226241367e+00, + 1.012244921966297e+00, 1.012140460211194e+00, 1.012024302085441e+00, 1.011897560567707e+00, + 1.011758810583150e+00, 1.011608449127642e+00, 1.011445162723270e+00, 1.011269960947744e+00, + 1.011081255645969e+00, 1.010879608424312e+00, 1.010663676735228e+00, 1.010434184200640e+00, + 1.010189681124657e+00, 1.009930754807923e+00, 1.009655660215271e+00, 1.009365251564694e+00, + 1.009058249873833e+00, 1.008734758578989e+00, 1.008393079963091e+00, 1.008034308295421e+00, + 1.007656661215973e+00, 1.007260142622887e+00, 1.006843352506855e+00, 1.006407009542103e+00, + 1.005949145170711e+00, 1.005470005637052e+00, 1.004967986424467e+00, 1.004443531995945e+00, + 1.003894772403371e+00, 1.003321903663793e+00, 1.002723127308148e+00, 1.002098854400575e+00, + 1.001447278873483e+00, 1.000768505317086e+00, 1.000060686758758e+00, 9.993242684851855e-01, + 9.985573503390627e-01, 9.977600196406868e-01, 9.969306036935497e-01, 9.960694269553644e-01, + 9.951746430061121e-01, 9.942466438407230e-01, 9.932837131068657e-01, 9.922861082472264e-01, + 9.912523092989319e-01, 9.901827419790691e-01, 9.890757868707590e-01, 9.879313024174022e-01, + 9.863553220272523e-01, 9.847362453480265e-01, 9.831750948772566e-01, 9.815583336011345e-01, + 9.798613526271561e-01, 9.780617486993630e-01, 9.761574317374303e-01, 9.741378617337759e-01, + 9.719990112065752e-01, 9.697327413658168e-01, 9.673331975559332e-01, 9.647915124057732e-01, + 9.621011497566145e-01, 9.592539757044516e-01, 9.562427177295731e-01, 9.530600909726344e-01, + 9.496984081652284e-01, 9.461498120176854e-01, 9.424071613625743e-01, 9.384634163826711e-01, + 9.343112966094085e-01, 9.299449872197452e-01, 9.253567968750328e-01, 9.205404627076625e-01, + 9.154896280575360e-01, 9.101986790930605e-01, 9.046620597741508e-01, 8.988755194372424e-01, + 8.928338316495705e-01, 8.865337190368053e-01, 8.799712722567934e-01, 8.731437835983047e-01, + 8.660476534563131e-01, 8.586812520174252e-01, 8.510420440685049e-01, 8.431297226886574e-01, + 8.349435141989714e-01, 8.264839911291133e-01, 8.177505366573690e-01, 8.087449817124315e-01, + 7.994681492797084e-01, 7.899235162194718e-01, 7.801137731566502e-01, 7.700431275216928e-01, + 7.597145736971065e-01, 7.491330971820804e-01, 7.383028603058783e-01, 7.272298755824693e-01, + 7.159201919962611e-01, 7.043814340356083e-01, 6.926196927377140e-01, 6.806438831866077e-01, + 6.684616478236647e-01, 6.560830137986515e-01, 6.435179268559957e-01, 6.307755329382612e-01, + 6.178641647786525e-01, 6.047954625702541e-01, 5.915799587176216e-01, 5.782289366005894e-01, + 5.647535885752191e-01, 5.511703155400274e-01, 5.374905090437071e-01, 5.237263500445715e-01, + 5.098915423728255e-01, 4.960008074926423e-01, 4.820662943337458e-01, 4.681017110048007e-01, + 4.541216995958746e-01, 4.401421815729068e-01, 4.261772971493010e-01, 4.122417888542512e-01, + 3.983499612526493e-01, 3.845172335531009e-01, 3.707583717376236e-01, 3.570886786795506e-01, + 3.435228672445627e-01, 3.300763764703638e-01, 3.167640325043893e-01, 3.036004651973109e-01, + 2.905996158436682e-01, 2.777758503744847e-01, 2.651434678028531e-01, 2.527161881181577e-01, + 2.405069849650012e-01, 2.285283969438072e-01, 2.167933432162879e-01, 2.053139897833021e-01, + 1.941021906320988e-01, 1.831680872008943e-01, 1.725221947208913e-01, 1.621735416384834e-01, + 1.521320683467849e-01, 1.424052801149985e-01, 1.330015240938615e-01, 1.239260664828526e-01, + 1.151858295527293e-01, 1.067840430193724e-01, 9.872637505002878e-02, 9.101379000888035e-02, + 8.365057236623055e-02, 7.663508305536153e-02, 6.997033405748826e-02, 6.365188111381365e-02, + 5.768176015814392e-02, 5.205244216987966e-02, 4.676538412257621e-02, 4.180950541438362e-02, + 3.718640251368464e-02, 3.288072750732215e-02, 2.889548499582958e-02, 2.520980565928884e-02, + 2.183057564646272e-02, 1.872896194002638e-02, 1.592127815153420e-02, 1.336381425803020e-02, + 1.108558877807282e-02, 8.943474189364638e-03, 6.758124889697787e-03, 3.504438130619497e-03, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; const LC3_FLOAT MDCT_WINDOW_80_5ms[80] = { 9.959086585790517e-04, 3.819056787237678e-03, 9.540832613229890e-03, 1.921659800166160e-02, 3.382719081038548e-02, @@ -1874,8 +1802,7 @@ const LC3_FLOAT MDCT_WINDOW_80_5ms[80] = { 5.282077505750667e-01, 4.486552956056635e-01, 3.691875990296312e-01, 2.924566408966777e-01, 2.210718537110463e-01, 1.573148583944309e-01, 1.030525757797768e-01, 5.982732244758054e-02, 2.871831923385133e-02, 9.683884928956490e-03, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 -}; + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; const LC3_FLOAT MDCT_WINDOW_160_5ms[160] = { 6.143388180964179e-04, 1.489582832987000e-03, 2.884104959764029e-03, 4.934298832466617e-03, 7.779130464154915e-03, @@ -1909,8 +1836,7 @@ const LC3_FLOAT MDCT_WINDOW_160_5ms[160] = { 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 -}; + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; const LC3_FLOAT MDCT_WINDOW_240_5ms[240] = { 5.087227626168386e-04, 9.959086585790517e-04, 1.682208006328800e-03, 2.609697259047744e-03, 3.819056787237678e-03, @@ -1960,8 +1886,7 @@ const LC3_FLOAT MDCT_WINDOW_240_5ms[240] = { 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 -}; + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; const LC3_FLOAT MDCT_WINDOW_320_5ms[320] = { 4.595886345493055e-04, 7.919323614002698e-04, 1.227927169310031e-03, 1.783653266717233e-03, 2.479549413444207e-03, @@ -2027,8 +1952,7 @@ const LC3_FLOAT MDCT_WINDOW_320_5ms[320] = { 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 -}; + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; const LC3_FLOAT MDCT_WINDOW_480_5ms[480] = { 4.090106504820579e-04, 6.143388180964179e-04, 8.571759876954877e-04, 1.147015057857495e-03, 1.489582832987000e-03, @@ -2126,8 +2050,7 @@ const LC3_FLOAT MDCT_WINDOW_480_5ms[480] = { 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 -}; + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; const LC3_FLOAT MDCT_HRA_WINDOW_480_2_5ms[240] = { @@ -2178,8 +2101,7 @@ const LC3_FLOAT MDCT_HRA_WINDOW_480_2_5ms[240] = { 5.471161958930394e-03, 4.249438341364304e-03, 3.263433520599239e-03, 2.475952111493295e-03, 1.853994056678125e-03, 1.368596596909542e-03, 9.946180283333026e-04, 7.104774789034889e-04, 4.978641589703932e-04, 3.414283510010364e-04, 2.284649445606105e-04, 1.485987233730432e-04, 9.347897725317759e-05, 5.648942347847280e-05, 3.247793542861785e-05, - 1.750922386335714e-05, 8.642407336226362e-06, 3.734302301245202e-06, 1.267861256795911e-06, 1.927766981311251e-07 -}; + 1.750922386335714e-05, 8.642407336226362e-06, 3.734302301245202e-06, 1.267861256795911e-06, 1.927766981311251e-07}; const LC3_FLOAT MDCT_HRA_WINDOW_960_2_5ms[480] = { 1.363353492760669e-07, 4.577676005269251e-07, 9.975675168391671e-07, 1.840776229085288e-06, 3.092248230077047e-06, @@ -2277,8 +2199,7 @@ const LC3_FLOAT MDCT_HRA_WINDOW_960_2_5ms[480] = { 2.557066633705375e-04, 2.078978198736850e-04, 1.678018145436083e-04, 1.343753481649133e-04, 1.066879390562912e-04, 8.391313553401788e-05, 6.532005529093359e-05, 5.026527605947520e-05, 3.818509710338716e-05, 2.858818657228189e-05, 2.104862555598476e-05, 1.519935578579325e-05, 1.072603433419925e-05, 7.361295334616452e-06, 4.879415604699819e-06, - 3.091377877253446e-06, 1.840321200267112e-06, 9.973582966273186e-07, 4.576899867970956e-07, 1.363156993327630e-07 -}; + 3.091377877253446e-06, 1.840321200267112e-06, 9.973582966273186e-07, 4.576899867970956e-07, 1.363156993327630e-07}; const LC3_FLOAT MDCT_HRA_WINDOW_480_5ms[480] = { 9.752475122178133e-08, 6.413568706385488e-07, 1.888722582859778e-06, 4.370037451432268e-06, 8.850535239285388e-06, @@ -2376,8 +2297,7 @@ const LC3_FLOAT MDCT_HRA_WINDOW_480_5ms[480] = { 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 -}; + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; const LC3_FLOAT MDCT_HRA_WINDOW_960_5ms[960] = { 6.895487963711672e-08, 2.315162529310440e-07, 5.044776791712418e-07, 9.307951082662299e-07, 1.563406927329763e-06, @@ -2571,8 +2491,7 @@ const LC3_FLOAT MDCT_HRA_WINDOW_960_5ms[960] = { 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 -}; + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; const LC3_FLOAT MDCT_HRA_WINDOW_480_10ms[960] = { 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, @@ -2766,8 +2685,7 @@ const LC3_FLOAT MDCT_HRA_WINDOW_480_10ms[960] = { 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 -}; + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; const LC3_FLOAT MDCT_HRA_WINDOW_960_10ms[1920] = { 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, @@ -3153,765 +3071,733 @@ const LC3_FLOAT MDCT_HRA_WINDOW_960_10ms[1920] = { 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, - 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00 -}; + 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00}; -const LC3_FLOAT *MDCT_WINS_10ms[2][6] = { - { MDCT_WINDOW_80, MDCT_WINDOW_160, MDCT_WINDOW_240, MDCT_WINDOW_320, MDCT_WINDOW_480, NULL }, - { NULL, NULL, NULL, NULL, MDCT_HRA_WINDOW_480_10ms, MDCT_HRA_WINDOW_960_10ms } -}; -const LC3_INT MDCT_la_zeroes[6] = { 30, 60, 90, 120, 180, 360 }; +const LC3_FLOAT* MDCT_WINS_10ms[2][6] = { + {MDCT_WINDOW_80, MDCT_WINDOW_160, MDCT_WINDOW_240, MDCT_WINDOW_320, MDCT_WINDOW_480, NULL}, + {NULL, NULL, NULL, NULL, MDCT_HRA_WINDOW_480_10ms, MDCT_HRA_WINDOW_960_10ms}}; +const LC3_INT MDCT_la_zeroes[6] = {30, 60, 90, 120, 180, 360}; -const LC3_FLOAT *MDCT_WINS_2_5ms[2][6] = { - { MDCT_WINDOW_80_2_5ms, MDCT_WINDOW_160_2_5ms, MDCT_WINDOW_240_2_5ms, MDCT_WINDOW_320_2_5ms, MDCT_WINDOW_480_2_5ms, - NULL }, - { NULL, NULL, NULL, NULL, MDCT_HRA_WINDOW_480_2_5ms, MDCT_HRA_WINDOW_960_2_5ms } -}; -const LC3_INT MDCT_la_zeroes_2_5ms[6] = { 0, 0, 0, 0, 0, 0 }; -const LC3_FLOAT *MDCT_WINS_5ms[2][6] = { - { MDCT_WINDOW_80_5ms, MDCT_WINDOW_160_5ms, MDCT_WINDOW_240_5ms, MDCT_WINDOW_320_5ms, MDCT_WINDOW_480_5ms, NULL }, - { NULL, NULL, NULL, NULL, MDCT_HRA_WINDOW_480_5ms, MDCT_HRA_WINDOW_960_5ms } -}; -const LC3_INT MDCT_la_zeroes_5ms[6] = { 10, 20, 30, 40, 60, 120 }; +const LC3_FLOAT* MDCT_WINS_2_5ms[2][6] = { + {MDCT_WINDOW_80_2_5ms, MDCT_WINDOW_160_2_5ms, MDCT_WINDOW_240_2_5ms, MDCT_WINDOW_320_2_5ms, MDCT_WINDOW_480_2_5ms, + NULL}, + {NULL, NULL, NULL, NULL, MDCT_HRA_WINDOW_480_2_5ms, MDCT_HRA_WINDOW_960_2_5ms}}; +const LC3_INT MDCT_la_zeroes_2_5ms[6] = {0, 0, 0, 0, 0, 0}; -const LC3_INT MDCT_WINDOWS_LENGTHS_10ms[6] = { 160, 320, 480, 640, 960, 1920 }; /* Last 960 dummy */ +const LC3_FLOAT* MDCT_WINS_5ms[2][6] = { + {MDCT_WINDOW_80_5ms, MDCT_WINDOW_160_5ms, MDCT_WINDOW_240_5ms, MDCT_WINDOW_320_5ms, MDCT_WINDOW_480_5ms, NULL}, + {NULL, NULL, NULL, NULL, MDCT_HRA_WINDOW_480_5ms, MDCT_HRA_WINDOW_960_5ms}}; +const LC3_INT MDCT_la_zeroes_5ms[6] = {10, 20, 30, 40, 60, 120}; -const LC3_INT MDCT_WINDOWS_LENGTHS_2_5ms[6] = { 40, 80, 120, 160, 240, 480 }; +const LC3_INT MDCT_WINDOWS_LENGTHS_10ms[6] = {160, 320, 480, 640, 960, 1920}; /* Last 960 dummy */ +const LC3_INT MDCT_WINDOWS_LENGTHS_2_5ms[6] = {40, 80, 120, 160, 240, 480}; -const LC3_INT MDCT_WINDOWS_LENGTHS_5ms[6] = { 80, 160, 240, 320, 480, 960 }; + +const LC3_INT MDCT_WINDOWS_LENGTHS_5ms[6] = {80, 160, 240, 320, 480, 960}; /* Per band energy */ -const LC3_INT ACC_COEFF_PER_BAND_8[65] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 51, - 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 80 }; +const LC3_INT ACC_COEFF_PER_BAND_8[65] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 51, + 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 80}; -const LC3_INT ACC_COEFF_PER_BAND_16[65] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 32, 34, 36, 38, - 40, 42, 44, 46, 48, 50, 52, 55, 58, 61, 64, 67, 70, 73, 76, 80, 84, - 88, 92, 96, 101, 106, 111, 116, 121, 127, 133, 139, 146, 153, 160 }; +const LC3_INT ACC_COEFF_PER_BAND_16[65] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 32, 34, 36, 38, + 40, 42, 44, 46, 48, 50, 52, 55, 58, 61, 64, 67, 70, 73, 76, 80, 84, + 88, 92, 96, 101, 106, 111, 116, 121, 127, 133, 139, 146, 153, 160}; const LC3_INT ACC_COEFF_PER_BAND_24[65] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, - 22, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 46, 49, 52, 55, 58, 61, 64, 68, 72, 76, - 80, 85, 90, 95, 100, 106, 112, 118, 125, 132, 139, 147, 155, 164, 173, 183, 193, 204, 215, 227, 240 -}; + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 46, 49, 52, 55, 58, 61, 64, 68, 72, 76, + 80, 85, 90, 95, 100, 106, 112, 118, 125, 132, 139, 147, 155, 164, 173, 183, 193, 204, 215, 227, 240}; const LC3_INT ACC_COEFF_PER_BAND_32[65] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, - 24, 26, 28, 30, 32, 34, 36, 38, 41, 44, 47, 50, 53, 56, 60, 64, 68, 72, 76, 81, 86, 91, - 97, 103, 109, 116, 123, 131, 139, 148, 157, 166, 176, 187, 199, 211, 224, 238, 252, 268, 284, 302, 320 -}; + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, + 24, 26, 28, 30, 32, 34, 36, 38, 41, 44, 47, 50, 53, 56, 60, 64, 68, 72, 76, 81, 86, 91, + 97, 103, 109, 116, 123, 131, 139, 148, 157, 166, 176, 187, 199, 211, 224, 238, 252, 268, 284, 302, 320}; const LC3_INT ACC_COEFF_PER_BAND_48[65] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 24, - 26, 28, 30, 32, 34, 36, 39, 42, 45, 48, 51, 55, 59, 63, 67, 71, 76, 81, 86, 92, 98, 105, - 112, 119, 127, 135, 144, 154, 164, 175, 186, 198, 211, 225, 240, 256, 273, 291, 310, 330, 352, 375, 400 -}; + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 24, + 26, 28, 30, 32, 34, 36, 39, 42, 45, 48, 51, 55, 59, 63, 67, 71, 76, 81, 86, 92, 98, 105, + 112, 119, 127, 135, 144, 154, 164, 175, 186, 198, 211, 225, 240, 256, 273, 291, 310, 330, 352, 375, 400}; -const LC3_INT ACC_COEFF_PER_BAND_8_2_5ms[21] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }; +const LC3_INT ACC_COEFF_PER_BAND_8_2_5ms[21] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}; -const LC3_INT ACC_COEFF_PER_BAND_16_2_5ms[36] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 32, 34, 36, 38, 40 }; +const LC3_INT ACC_COEFF_PER_BAND_16_2_5ms[36] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 32, 34, 36, 38, 40}; -const LC3_INT ACC_COEFF_PER_BAND_24_2_5ms[41] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, - 30, 32, 34, 36, 38, 40, 42, 44, 47, 50, 53, 56, 60 }; +const LC3_INT ACC_COEFF_PER_BAND_24_2_5ms[41] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, + 30, 32, 34, 36, 38, 40, 42, 44, 47, 50, 53, 56, 60}; -const LC3_INT ACC_COEFF_PER_BAND_32_2_5ms[44] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 28, 30, 32, 34, - 36, 38, 40, 43, 46, 49, 52, 55, 59, 63, 67, 71, 75, 80 }; +const LC3_INT ACC_COEFF_PER_BAND_32_2_5ms[44] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 28, 30, 32, 34, + 36, 38, 40, 43, 46, 49, 52, 55, 59, 63, 67, 71, 75, 80}; -const LC3_INT ACC_COEFF_PER_BAND_48_2_5ms[45] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 23, 25, 27, 29, 31, 33, 35, 37, - 40, 43, 46, 49, 52, 56, 60, 64, 68, 72, 77, 82, 87, 93, 100 }; +const LC3_INT ACC_COEFF_PER_BAND_48_2_5ms[45] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 23, 25, 27, 29, 31, 33, 35, 37, + 40, 43, 46, 49, 52, 56, 60, 64, 68, 72, 77, 82, 87, 93, 100}; -const LC3_INT ACC_COEFF_PER_BAND_48_2_5ms_HR[46] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 40, 43, 46, - 49, 53, 57, 61, 65, 69, 74, 79, 85, 91, 97, 104, 112, 120 }; +const LC3_INT ACC_COEFF_PER_BAND_48_2_5ms_HR[46] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 40, 43, 46, + 49, 53, 57, 61, 65, 69, 74, 79, 85, 91, 97, 104, 112, 120}; const LC3_INT ACC_COEFF_PER_BAND_96_2_5ms_HR[50] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 22, 24, 26, 28, 30, 32, - 35, 38, 41, 45, 49, 53, 57, 62, 67, 73, 79, 85, 92, 100, 108, 117, 127, 137, 149, 161, 174, 189, 204, 221, 240 -}; + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 22, 24, 26, 28, 30, 32, + 35, 38, 41, 45, 49, 53, 57, 62, 67, 73, 79, 85, 92, 100, 108, 117, 127, 137, 149, 161, 174, 189, 204, 221, 240}; -const LC3_INT ACC_COEFF_PER_BAND_8_5ms[40] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 40 }; +const LC3_INT ACC_COEFF_PER_BAND_8_5ms[40] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 40}; -const LC3_INT ACC_COEFF_PER_BAND_16_5ms[51] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 32, 34, 36, - 38, 40, 42, 44, 46, 48, 50, 52, 54, 57, 60, 63, 66, 69, 72, 76, 80 }; +const LC3_INT ACC_COEFF_PER_BAND_16_5ms[51] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 32, 34, 36, + 38, 40, 42, 44, 46, 48, 50, 52, 54, 57, 60, 63, 66, 69, 72, 76, 80}; const LC3_INT ACC_COEFF_PER_BAND_24_5ms[53] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 28, - 30, 32, 34, 36, 38, 40, 42, 44, 47, 50, 53, 56, 59, 62, 65, 69, 73, 77, 81, 86, 91, 96, 101, 107, 113, 120 -}; - -const LC3_INT ACC_COEFF_PER_BAND_32_5ms[55] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 26, 28, 30, 32, - 34, 36, 38, 40, 42, 45, 48, 51, 54, 57, 61, 65, 69, 73, - 78, 83, 88, 93, 99, 105, 112, 119, 126, 134, 142, 151, 160 }; -const LC3_INT ACC_COEFF_PER_BAND_48_5ms_HR[56] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 21, 23, 25, 27, 29, 31, 33, 35, - 38, 41, 44, 47, 50, 54, 58, 62, 66, 71, 76, 81, 87, 93, - 100, 107, 114, 122, 131, 140, 149, 160, 171, 183, 196, 209, 224, 240 }; -const LC3_INT ACC_COEFF_PER_BAND_48_5ms[56] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 23, 25, 27, 29, 31, 33, - 35, 37, 40, 43, 46, 49, 52, 55, 59, 63, 67, 72, 77, 82, - 87, 93, 99, 105, 112, 120, 128, 136, 145, 155, 165, 176, 187, 200 }; + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 28, + 30, 32, 34, 36, 38, 40, 42, 44, 47, 50, 53, 56, 59, 62, 65, 69, 73, 77, 81, 86, 91, 96, 101, 107, 113, 120}; + +const LC3_INT ACC_COEFF_PER_BAND_32_5ms[55] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 26, 28, 30, 32, + 34, 36, 38, 40, 42, 45, 48, 51, 54, 57, 61, 65, 69, 73, + 78, 83, 88, 93, 99, 105, 112, 119, 126, 134, 142, 151, 160}; +const LC3_INT ACC_COEFF_PER_BAND_48_5ms_HR[56] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 21, 23, 25, 27, 29, 31, 33, 35, + 38, 41, 44, 47, 50, 54, 58, 62, 66, 71, 76, 81, 87, 93, + 100, 107, 114, 122, 131, 140, 149, 160, 171, 183, 196, 209, 224, 240}; +const LC3_INT ACC_COEFF_PER_BAND_48_5ms[56] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 23, 25, 27, 29, 31, 33, + 35, 37, 40, 43, 46, 49, 52, 55, 59, 63, 67, 72, 77, 82, + 87, 93, 99, 105, 112, 120, 128, 136, 145, 155, 165, 176, 187, 200}; const LC3_INT ACC_COEFF_PER_BAND_96_5ms_HR[59] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 21, - 23, 25, 27, 29, 31, 34, 37, 40, 44, 48, 52, 56, 61, 66, 71, 77, 83, 90, 98, 106, - 115, 124, 135, 146, 158, 171, 185, 200, 217, 235, 254, 275, 298, 323, 349, 378, 409, 443, 480 -}; + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 21, + 23, 25, 27, 29, 31, 34, 37, 40, 44, 48, 52, 56, 61, 66, 71, 77, 83, 90, 98, 106, + 115, 124, 135, 146, 158, 171, 185, 200, 217, 235, 254, 275, 298, 323, 349, 378, 409, 443, 480}; const LC3_INT ACC_COEFF_PER_BAND_48_HR[65] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 21, 23, 25, - 27, 29, 31, 33, 36, 39, 42, 45, 48, 51, 55, 59, 63, 67, 72, 77, 83, 89, 95, 101, 108, 116, - 124, 133, 142, 152, 163, 174, 187, 200, 214, 229, 244, 262, 280, 299, 320, 343, 367, 392, 419, 449, 480 -}; + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 21, 23, 25, + 27, 29, 31, 33, 36, 39, 42, 45, 48, 51, 55, 59, 63, 67, 72, 77, 83, 89, 95, 101, 108, 116, + 124, 133, 142, 152, 163, 174, 187, 200, 214, 229, 244, 262, 280, 299, 320, 343, 367, 392, 419, 449, 480}; -const LC3_INT ACC_COEFF_PER_BAND_96_HR[65] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 33, 36, 39, 42, 46, 50, 54, 59, 64, 69, 75, 82, 89, 96, 104, 113, 122, 132, 143, 155, 168, 181, 196, 213, 230, 249, 270, 292, 316, 342, 371, 401, 434, 470, 509, 551, 596, 646, 699, 757, 819, 887, 960 }; +const LC3_INT ACC_COEFF_PER_BAND_96_HR[65] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 33, 36, 39, 42, 46, 50, 54, 59, 64, 69, 75, 82, 89, 96, 104, 113, 122, 132, 143, 155, 168, 181, 196, 213, 230, 249, 270, 292, 316, 342, 371, 401, 434, 470, 509, 551, 596, 646, 699, 757, 819, 887, 960}; -const LC3_INT *ACC_COEFF_PER_BAND_HR[6] = { NULL, NULL, NULL, NULL, ACC_COEFF_PER_BAND_48_HR, ACC_COEFF_PER_BAND_96_HR }; +const LC3_INT* ACC_COEFF_PER_BAND_HR[6] = {NULL, NULL, NULL, NULL, ACC_COEFF_PER_BAND_48_HR, ACC_COEFF_PER_BAND_96_HR}; -const LC3_INT *ACC_COEFF_PER_BAND[6] = { ACC_COEFF_PER_BAND_8, ACC_COEFF_PER_BAND_16, ACC_COEFF_PER_BAND_24, - ACC_COEFF_PER_BAND_32, ACC_COEFF_PER_BAND_48, NULL }; +const LC3_INT* ACC_COEFF_PER_BAND[6] = {ACC_COEFF_PER_BAND_8, ACC_COEFF_PER_BAND_16, ACC_COEFF_PER_BAND_24, + ACC_COEFF_PER_BAND_32, ACC_COEFF_PER_BAND_48, NULL}; -const LC3_INT *ACC_COEFF_PER_BAND_2_5ms_HR[6] = { - NULL, NULL, NULL, NULL, ACC_COEFF_PER_BAND_48_2_5ms_HR, ACC_COEFF_PER_BAND_96_2_5ms_HR -}; +const LC3_INT* ACC_COEFF_PER_BAND_2_5ms_HR[6] = { + NULL, NULL, NULL, NULL, ACC_COEFF_PER_BAND_48_2_5ms_HR, ACC_COEFF_PER_BAND_96_2_5ms_HR}; -const LC3_INT *ACC_COEFF_PER_BAND_2_5ms[5] = { ACC_COEFF_PER_BAND_8_2_5ms, ACC_COEFF_PER_BAND_16_2_5ms, - ACC_COEFF_PER_BAND_24_2_5ms, ACC_COEFF_PER_BAND_32_2_5ms, - ACC_COEFF_PER_BAND_48_2_5ms }; +const LC3_INT* ACC_COEFF_PER_BAND_2_5ms[5] = {ACC_COEFF_PER_BAND_8_2_5ms, ACC_COEFF_PER_BAND_16_2_5ms, + ACC_COEFF_PER_BAND_24_2_5ms, ACC_COEFF_PER_BAND_32_2_5ms, + ACC_COEFF_PER_BAND_48_2_5ms}; -const LC3_INT *ACC_COEFF_PER_BAND_5ms_HR[6] = { - NULL, NULL, NULL, NULL, ACC_COEFF_PER_BAND_48_5ms_HR, ACC_COEFF_PER_BAND_96_5ms_HR -}; +const LC3_INT* ACC_COEFF_PER_BAND_5ms_HR[6] = { + NULL, NULL, NULL, NULL, ACC_COEFF_PER_BAND_48_5ms_HR, ACC_COEFF_PER_BAND_96_5ms_HR}; -const LC3_INT *ACC_COEFF_PER_BAND_5ms[5] = { ACC_COEFF_PER_BAND_8_5ms, ACC_COEFF_PER_BAND_16_5ms, - ACC_COEFF_PER_BAND_24_5ms, ACC_COEFF_PER_BAND_32_5ms, - ACC_COEFF_PER_BAND_48_5ms }; +const LC3_INT* ACC_COEFF_PER_BAND_5ms[5] = {ACC_COEFF_PER_BAND_8_5ms, ACC_COEFF_PER_BAND_16_5ms, + ACC_COEFF_PER_BAND_24_5ms, ACC_COEFF_PER_BAND_32_5ms, + ACC_COEFF_PER_BAND_48_5ms}; /* Near Nyquist detector */ const LC3_INT NN_thresh = 30; -const LC3_INT32 xavg_N_grp[5] = { 4, 5, 6, 7, 8 }; - - -const LC3_INT32 gwlpr[MAX_LGW + 1] = { 1, 3 * QUOT_LPR_LTR, 5 * QUOT_LPR_LTR, 9 * QUOT_LPR_LTR, 17 * QUOT_LPR_LTR, 33 * QUOT_LPR_LTR, 49 * QUOT_LPR_LTR, 65 * QUOT_LPR_LTR, 81 * QUOT_LPR_LTR, 97 * QUOT_LPR_LTR }; - - -const LC3_FLOAT PhECU_whr16ms_NB[128] = { - 8.000000000000002e-02, 8.393536376804722e-02, 9.567411990702857e-02, 1.150154150448081e-01, 1.416283142591582e-01, - 1.750574634660318e-01, 2.147308806541882e-01, 2.599697426559885e-01, 3.099999999999999e-01, 3.639656211120587e-01, - 4.209432392528405e-01, 4.799579515787762e-01, 5.400000000000000e-01, 6.000420484212237e-01, 6.590567607471596e-01, - 7.160343788879413e-01, 7.699999999999999e-01, 8.200302573440115e-01, 8.652691193458119e-01, 9.049425365339682e-01, - 9.383716857408418e-01, 9.649845849551919e-01, 9.843258800929715e-01, 9.960646362319528e-01, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 9.960646362319528e-01, 9.843258800929715e-01, 9.649845849551919e-01, 9.383716857408418e-01, 9.049425365339682e-01, - 8.652691193458119e-01, 8.200302573440115e-01, 7.699999999999999e-01, 7.160343788879413e-01, 6.590567607471596e-01, - 6.000420484212237e-01, 5.400000000000000e-01, 4.799579515787762e-01, 4.209432392528405e-01, 3.639656211120587e-01, - 3.099999999999999e-01, 2.599697426559885e-01, 2.147308806541882e-01, 1.750574634660318e-01, 1.416283142591582e-01, - 1.150154150448081e-01, 9.567411990702857e-02, 8.393536376804722e-02 -}; -const LC3_FLOAT PhECU_whr16ms_WB[256] = { - 8.000000000000002e-02, 8.098489531024239e-02, 8.393536376804722e-02, 8.883877101451404e-02, 9.567411990702857e-02, - 1.044121404322514e-01, 1.150154150448081e-01, 1.274385388949634e-01, 1.416283142591582e-01, 1.575239783408292e-01, - 1.750574634660318e-01, 1.941536885596704e-01, 2.147308806541882e-01, 2.367009250539683e-01, 2.599697426559885e-01, - 2.844376928109830e-01, 3.099999999999999e-01, 3.365472024992595e-01, 3.639656211120587e-01, 3.921378459605457e-01, - 4.209432392528405e-01, 4.502584518725810e-01, 4.799579515787762e-01, 5.099145605541342e-01, 5.400000000000000e-01, - 5.700854394458659e-01, 6.000420484212237e-01, 6.297415481274190e-01, 6.590567607471596e-01, 6.878621540394543e-01, - 7.160343788879413e-01, 7.434527975007406e-01, 7.699999999999999e-01, 7.955623071890170e-01, 8.200302573440115e-01, - 8.432990749460317e-01, 8.652691193458119e-01, 8.858463114403297e-01, 9.049425365339682e-01, 9.224760216591710e-01, - 9.383716857408418e-01, 9.525614611050366e-01, 9.649845849551919e-01, 9.755878595677486e-01, 9.843258800929715e-01, - 9.911612289854861e-01, 9.960646362319528e-01, 9.990151046897577e-01, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 9.990151046897577e-01, - 9.960646362319528e-01, 9.911612289854861e-01, 9.843258800929715e-01, 9.755878595677486e-01, 9.649845849551919e-01, - 9.525614611050366e-01, 9.383716857408418e-01, 9.224760216591710e-01, 9.049425365339682e-01, 8.858463114403297e-01, - 8.652691193458119e-01, 8.432990749460317e-01, 8.200302573440115e-01, 7.955623071890170e-01, 7.699999999999999e-01, - 7.434527975007406e-01, 7.160343788879413e-01, 6.878621540394543e-01, 6.590567607471596e-01, 6.297415481274190e-01, - 6.000420484212237e-01, 5.700854394458659e-01, 5.400000000000000e-01, 5.099145605541342e-01, 4.799579515787762e-01, - 4.502584518725810e-01, 4.209432392528405e-01, 3.921378459605457e-01, 3.639656211120587e-01, 3.365472024992595e-01, - 3.099999999999999e-01, 2.844376928109830e-01, 2.599697426559885e-01, 2.367009250539683e-01, 2.147308806541882e-01, - 1.941536885596704e-01, 1.750574634660318e-01, 1.575239783408292e-01, 1.416283142591582e-01, 1.274385388949634e-01, - 1.150154150448081e-01, 1.044121404322514e-01, 9.567411990702857e-02, 8.883877101451404e-02, 8.393536376804722e-02, - 8.098489531024239e-02 -}; -const LC3_FLOAT PhECU_whr16ms_SSWB[384] = { - 8.000000000000002e-02, 8.043781807234540e-02, 8.175043887779704e-02, 8.393536376804722e-02, 8.698843361438435e-02, - 9.090383672483066e-02, 9.567411990702857e-02, 1.012902026558156e-01, 1.077413944384821e-01, 1.150154150448081e-01, - 1.230984179631410e-01, 1.319750167380180e-01, 1.416283142591582e-01, 1.520399349260726e-01, 1.631900596270638e-01, - 1.750574634660318e-01, 1.876195561652702e-01, 2.008524250673430e-01, 2.147308806541882e-01, 2.292285044967963e-01, - 2.443176995441919e-01, 2.599697426559885e-01, 2.761548392785189e-01, 2.928421801604610e-01, 3.099999999999999e-01, - 3.275956379118843e-01, 3.455955995992783e-01, 3.639656211120587e-01, 3.826707340701924e-01, 4.016753322280344e-01, - 4.209432392528405e-01, 4.404377775884727e-01, 4.601218382732121e-01, 4.799579515787762e-01, 4.999083583360772e-01, - 5.199350818119455e-01, 5.400000000000000e-01, 5.600649181880546e-01, 5.800916416639228e-01, 6.000420484212237e-01, - 6.198781617267880e-01, 6.395622224115274e-01, 6.590567607471596e-01, 6.783246677719657e-01, 6.973292659298076e-01, - 7.160343788879413e-01, 7.344044004007217e-01, 7.524043620881156e-01, 7.699999999999999e-01, 7.871578198395390e-01, - 8.038451607214812e-01, 8.200302573440115e-01, 8.356823004558082e-01, 8.507714955032037e-01, 8.652691193458119e-01, - 8.791475749326572e-01, 8.923804438347298e-01, 9.049425365339682e-01, 9.168099403729364e-01, 9.279600650739274e-01, - 9.383716857408418e-01, 9.480249832619820e-01, 9.569015820368590e-01, 9.649845849551919e-01, 9.722586055615179e-01, - 9.787097973441844e-01, 9.843258800929715e-01, 9.890961632751694e-01, 9.930115663856157e-01, 9.960646362319528e-01, - 9.982495611222031e-01, 9.995621819276547e-01, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 9.995621819276547e-01, 9.982495611222031e-01, - 9.960646362319528e-01, 9.930115663856157e-01, 9.890961632751694e-01, 9.843258800929715e-01, 9.787097973441844e-01, - 9.722586055615179e-01, 9.649845849551919e-01, 9.569015820368590e-01, 9.480249832619820e-01, 9.383716857408418e-01, - 9.279600650739274e-01, 9.168099403729364e-01, 9.049425365339682e-01, 8.923804438347298e-01, 8.791475749326572e-01, - 8.652691193458119e-01, 8.507714955032037e-01, 8.356823004558082e-01, 8.200302573440115e-01, 8.038451607214812e-01, - 7.871578198395390e-01, 7.699999999999999e-01, 7.524043620881156e-01, 7.344044004007217e-01, 7.160343788879413e-01, - 6.973292659298076e-01, 6.783246677719657e-01, 6.590567607471596e-01, 6.395622224115274e-01, 6.198781617267880e-01, - 6.000420484212237e-01, 5.800916416639228e-01, 5.600649181880546e-01, 5.400000000000000e-01, 5.199350818119455e-01, - 4.999083583360772e-01, 4.799579515787762e-01, 4.601218382732121e-01, 4.404377775884727e-01, 4.209432392528405e-01, - 4.016753322280344e-01, 3.826707340701924e-01, 3.639656211120587e-01, 3.455955995992783e-01, 3.275956379118843e-01, - 3.099999999999999e-01, 2.928421801604610e-01, 2.761548392785189e-01, 2.599697426559885e-01, 2.443176995441919e-01, - 2.292285044967963e-01, 2.147308806541882e-01, 2.008524250673430e-01, 1.876195561652702e-01, 1.750574634660318e-01, - 1.631900596270638e-01, 1.520399349260726e-01, 1.416283142591582e-01, 1.319750167380180e-01, 1.230984179631410e-01, - 1.150154150448081e-01, 1.077413944384821e-01, 1.012902026558156e-01, 9.567411990702857e-02, 9.090383672483066e-02, - 8.698843361438435e-02, 8.393536376804722e-02, 8.175043887779704e-02, 8.043781807234540e-02 -}; -const LC3_FLOAT PhECU_whr16ms_SWB[512] = { - 8.000000000000002e-02, 8.024628976087178e-02, 8.098489531024239e-02, 8.221502573078943e-02, 8.393536376804722e-02, - 8.614406724095569e-02, 8.883877101451404e-02, 9.201658953242653e-02, 9.567411990702857e-02, 9.980744556318394e-02, - 1.044121404322514e-01, 1.094832736916302e-01, 1.150154150448081e-01, 1.210026405362591e-01, 1.274385388949634e-01, - 1.343162183997567e-01, 1.416283142591582e-01, 1.493669964977737e-01, 1.575239783408292e-01, 1.660905250878570e-01, - 1.750574634660318e-01, 1.844151914531410e-01, 1.941536885596704e-01, 2.042625265589956e-01, 2.147308806541882e-01, - 2.255475410694793e-01, 2.367009250539683e-01, 2.481790892847231e-01, 2.599697426559885e-01, 2.720602594408110e-01, - 2.844376928109830e-01, 2.970887887008307e-01, 3.099999999999999e-01, 3.231575010600410e-01, 3.365472024992595e-01, - 3.501547662899784e-01, 3.639656211120587e-01, 3.779649779562326e-01, 3.921378459605457e-01, 4.064690484629473e-01, - 4.209432392528405e-01, 4.355449190041883e-01, 4.502584518725810e-01, 4.650680822384892e-01, 4.799579515787762e-01, - 4.949121154484021e-01, 5.099145605541342e-01, 5.249492219019830e-01, 5.400000000000000e-01, 5.550507780980171e-01, - 5.700854394458659e-01, 5.850878845515979e-01, 6.000420484212237e-01, 6.149319177615109e-01, 6.297415481274190e-01, - 6.444550809958116e-01, 6.590567607471596e-01, 6.735309515370527e-01, 6.878621540394543e-01, 7.020350220437674e-01, - 7.160343788879413e-01, 7.298452337100215e-01, 7.434527975007406e-01, 7.568424989399589e-01, 7.699999999999999e-01, - 7.829112112991693e-01, 7.955623071890170e-01, 8.079397405591890e-01, 8.200302573440115e-01, 8.318209107152770e-01, - 8.432990749460317e-01, 8.544524589305209e-01, 8.652691193458119e-01, 8.757374734410044e-01, 8.858463114403297e-01, - 8.955848085468591e-01, 9.049425365339682e-01, 9.139094749121430e-01, 9.224760216591710e-01, 9.306330035022263e-01, - 9.383716857408418e-01, 9.456837816002432e-01, 9.525614611050366e-01, 9.589973594637410e-01, 9.649845849551919e-01, - 9.705167263083698e-01, 9.755878595677486e-01, 9.801925544368162e-01, 9.843258800929715e-01, 9.879834104675735e-01, - 9.911612289854861e-01, 9.938559327590444e-01, 9.960646362319528e-01, 9.977849742692106e-01, 9.990151046897577e-01, - 9.997537102391283e-01, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 9.997537102391283e-01, 9.990151046897577e-01, 9.977849742692106e-01, - 9.960646362319528e-01, 9.938559327590444e-01, 9.911612289854861e-01, 9.879834104675735e-01, 9.843258800929715e-01, - 9.801925544368162e-01, 9.755878595677486e-01, 9.705167263083698e-01, 9.649845849551919e-01, 9.589973594637410e-01, - 9.525614611050366e-01, 9.456837816002432e-01, 9.383716857408418e-01, 9.306330035022263e-01, 9.224760216591710e-01, - 9.139094749121430e-01, 9.049425365339682e-01, 8.955848085468591e-01, 8.858463114403297e-01, 8.757374734410044e-01, - 8.652691193458119e-01, 8.544524589305209e-01, 8.432990749460317e-01, 8.318209107152770e-01, 8.200302573440115e-01, - 8.079397405591890e-01, 7.955623071890170e-01, 7.829112112991693e-01, 7.699999999999999e-01, 7.568424989399589e-01, - 7.434527975007406e-01, 7.298452337100215e-01, 7.160343788879413e-01, 7.020350220437674e-01, 6.878621540394543e-01, - 6.735309515370527e-01, 6.590567607471596e-01, 6.444550809958116e-01, 6.297415481274190e-01, 6.149319177615109e-01, - 6.000420484212237e-01, 5.850878845515979e-01, 5.700854394458659e-01, 5.550507780980171e-01, 5.400000000000000e-01, - 5.249492219019830e-01, 5.099145605541342e-01, 4.949121154484021e-01, 4.799579515787762e-01, 4.650680822384892e-01, - 4.502584518725810e-01, 4.355449190041883e-01, 4.209432392528405e-01, 4.064690484629473e-01, 3.921378459605457e-01, - 3.779649779562326e-01, 3.639656211120587e-01, 3.501547662899784e-01, 3.365472024992595e-01, 3.231575010600410e-01, - 3.099999999999999e-01, 2.970887887008307e-01, 2.844376928109830e-01, 2.720602594408110e-01, 2.599697426559885e-01, - 2.481790892847231e-01, 2.367009250539683e-01, 2.255475410694793e-01, 2.147308806541882e-01, 2.042625265589956e-01, - 1.941536885596704e-01, 1.844151914531410e-01, 1.750574634660318e-01, 1.660905250878570e-01, 1.575239783408292e-01, - 1.493669964977737e-01, 1.416283142591582e-01, 1.343162183997567e-01, 1.274385388949634e-01, 1.210026405362591e-01, - 1.150154150448081e-01, 1.094832736916302e-01, 1.044121404322514e-01, 9.980744556318394e-02, 9.567411990702857e-02, - 9.201658953242653e-02, 8.883877101451404e-02, 8.614406724095569e-02, 8.393536376804722e-02, 8.221502573078943e-02, - 8.098489531024239e-02, 8.024628976087178e-02 -}; -const LC3_FLOAT PhECU_whr16ms_FB[768] = { - 8.000000000000002e-02, 8.010946754324183e-02, 8.043781807234540e-02, 8.098489531024239e-02, 8.175043887779704e-02, - 8.273408441773300e-02, 8.393536376804722e-02, 8.535370518483010e-02, 8.698843361438435e-02, 8.883877101451404e-02, - 9.090383672483066e-02, 9.318264788589975e-02, 9.567411990702857e-02, 9.837706698247278e-02, 1.012902026558156e-01, - 1.044121404322514e-01, 1.077413944384821e-01, 1.112763801299127e-01, 1.150154150448081e-01, 1.189567196050543e-01, - 1.230984179631410e-01, 1.274385388949634e-01, 1.319750167380180e-01, 1.367056923745465e-01, 1.416283142591582e-01, - 1.467405394904446e-01, 1.520399349260726e-01, 1.575239783408292e-01, 1.631900596270638e-01, 1.690354820369581e-01, - 1.750574634660318e-01, 1.812531377772744e-01, 1.876195561652702e-01, 1.941536885596704e-01, 2.008524250673430e-01, - 2.077125774525124e-01, 2.147308806541882e-01, 2.219039943401561e-01, 2.292285044967963e-01, 2.367009250539683e-01, - 2.443176995441919e-01, 2.520752027953329e-01, 2.599697426559885e-01, 2.679975617527521e-01, 2.761548392785189e-01, - 2.844376928109830e-01, 2.928421801604610e-01, 3.013643012461601e-01, 3.099999999999999e-01, 3.187451662970817e-01, - 3.275956379118843e-01, 3.365472024992595e-01, 3.455955995992783e-01, 3.547365226649809e-01, 3.639656211120587e-01, - 3.732785023894972e-01, 3.826707340701924e-01, 3.921378459605457e-01, 4.016753322280344e-01, 4.112786535457436e-01, - 4.209432392528405e-01, 4.306644895299604e-01, 4.404377775884727e-01, 4.502584518725810e-01, 4.601218382732121e-01, - 4.700232423526383e-01, 4.799579515787762e-01, 4.899212375680964e-01, 4.999083583360772e-01, 5.099145605541342e-01, - 5.199350818119455e-01, 5.299651528841020e-01, 5.400000000000000e-01, 5.500348471158981e-01, 5.600649181880546e-01, - 5.700854394458659e-01, 5.800916416639228e-01, 5.900787624319037e-01, 6.000420484212237e-01, 6.099767576473617e-01, - 6.198781617267880e-01, 6.297415481274190e-01, 6.395622224115274e-01, 6.493355104700396e-01, 6.590567607471596e-01, - 6.687213464542564e-01, 6.783246677719657e-01, 6.878621540394543e-01, 6.973292659298076e-01, 7.067214976105027e-01, - 7.160343788879413e-01, 7.252634773350191e-01, 7.344044004007217e-01, 7.434527975007406e-01, 7.524043620881156e-01, - 7.612548337029182e-01, 7.699999999999999e-01, 7.786356987538400e-01, 7.871578198395390e-01, 7.955623071890170e-01, - 8.038451607214812e-01, 8.120024382472478e-01, 8.200302573440115e-01, 8.279247972046673e-01, 8.356823004558082e-01, - 8.432990749460317e-01, 8.507714955032037e-01, 8.580960056598439e-01, 8.652691193458119e-01, 8.722874225474876e-01, - 8.791475749326572e-01, 8.858463114403297e-01, 8.923804438347298e-01, 8.987468622227257e-01, 9.049425365339682e-01, - 9.109645179630421e-01, 9.168099403729364e-01, 9.224760216591710e-01, 9.279600650739274e-01, 9.332594605095554e-01, - 9.383716857408418e-01, 9.432943076254536e-01, 9.480249832619820e-01, 9.525614611050366e-01, 9.569015820368590e-01, - 9.610432803949458e-01, 9.649845849551919e-01, 9.687236198700873e-01, 9.722586055615179e-01, 9.755878595677486e-01, - 9.787097973441844e-01, 9.816229330175272e-01, 9.843258800929715e-01, 9.868173521141004e-01, 9.890961632751694e-01, - 9.911612289854861e-01, 9.930115663856157e-01, 9.946462948151700e-01, 9.960646362319528e-01, 9.972659155822671e-01, - 9.982495611222031e-01, 9.990151046897577e-01, 9.995621819276547e-01, 9.998905324567582e-01, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, - 9.998905324567582e-01, 9.995621819276547e-01, 9.990151046897577e-01, 9.982495611222031e-01, 9.972659155822671e-01, - 9.960646362319528e-01, 9.946462948151700e-01, 9.930115663856157e-01, 9.911612289854861e-01, 9.890961632751694e-01, - 9.868173521141004e-01, 9.843258800929715e-01, 9.816229330175272e-01, 9.787097973441844e-01, 9.755878595677486e-01, - 9.722586055615179e-01, 9.687236198700873e-01, 9.649845849551919e-01, 9.610432803949458e-01, 9.569015820368590e-01, - 9.525614611050366e-01, 9.480249832619820e-01, 9.432943076254536e-01, 9.383716857408418e-01, 9.332594605095554e-01, - 9.279600650739274e-01, 9.224760216591710e-01, 9.168099403729364e-01, 9.109645179630421e-01, 9.049425365339682e-01, - 8.987468622227257e-01, 8.923804438347298e-01, 8.858463114403297e-01, 8.791475749326572e-01, 8.722874225474876e-01, - 8.652691193458119e-01, 8.580960056598439e-01, 8.507714955032037e-01, 8.432990749460317e-01, 8.356823004558082e-01, - 8.279247972046673e-01, 8.200302573440115e-01, 8.120024382472478e-01, 8.038451607214812e-01, 7.955623071890170e-01, - 7.871578198395390e-01, 7.786356987538400e-01, 7.699999999999999e-01, 7.612548337029182e-01, 7.524043620881156e-01, - 7.434527975007406e-01, 7.344044004007217e-01, 7.252634773350191e-01, 7.160343788879413e-01, 7.067214976105027e-01, - 6.973292659298076e-01, 6.878621540394543e-01, 6.783246677719657e-01, 6.687213464542564e-01, 6.590567607471596e-01, - 6.493355104700396e-01, 6.395622224115274e-01, 6.297415481274190e-01, 6.198781617267880e-01, 6.099767576473617e-01, - 6.000420484212237e-01, 5.900787624319037e-01, 5.800916416639228e-01, 5.700854394458659e-01, 5.600649181880546e-01, - 5.500348471158981e-01, 5.400000000000000e-01, 5.299651528841020e-01, 5.199350818119455e-01, 5.099145605541342e-01, - 4.999083583360772e-01, 4.899212375680964e-01, 4.799579515787762e-01, 4.700232423526383e-01, 4.601218382732121e-01, - 4.502584518725810e-01, 4.404377775884727e-01, 4.306644895299604e-01, 4.209432392528405e-01, 4.112786535457436e-01, - 4.016753322280344e-01, 3.921378459605457e-01, 3.826707340701924e-01, 3.732785023894972e-01, 3.639656211120587e-01, - 3.547365226649809e-01, 3.455955995992783e-01, 3.365472024992595e-01, 3.275956379118843e-01, 3.187451662970817e-01, - 3.099999999999999e-01, 3.013643012461601e-01, 2.928421801604610e-01, 2.844376928109830e-01, 2.761548392785189e-01, - 2.679975617527521e-01, 2.599697426559885e-01, 2.520752027953329e-01, 2.443176995441919e-01, 2.367009250539683e-01, - 2.292285044967963e-01, 2.219039943401561e-01, 2.147308806541882e-01, 2.077125774525124e-01, 2.008524250673430e-01, - 1.941536885596704e-01, 1.876195561652702e-01, 1.812531377772744e-01, 1.750574634660318e-01, 1.690354820369581e-01, - 1.631900596270638e-01, 1.575239783408292e-01, 1.520399349260726e-01, 1.467405394904446e-01, 1.416283142591582e-01, - 1.367056923745465e-01, 1.319750167380180e-01, 1.274385388949634e-01, 1.230984179631410e-01, 1.189567196050543e-01, - 1.150154150448081e-01, 1.112763801299127e-01, 1.077413944384821e-01, 1.044121404322514e-01, 1.012902026558156e-01, - 9.837706698247278e-02, 9.567411990702857e-02, 9.318264788589975e-02, 9.090383672483066e-02, 8.883877101451404e-02, - 8.698843361438435e-02, 8.535370518483010e-02, 8.393536376804722e-02, 8.273408441773300e-02, 8.175043887779704e-02, - 8.098489531024239e-02, 8.043781807234540e-02, 8.010946754324183e-02 -}; - -const LC3_FLOAT *PhECU_whr16ms_wins[5] = { - PhECU_whr16ms_NB, PhECU_whr16ms_WB, PhECU_whr16ms_SSWB, PhECU_whr16ms_SWB, PhECU_whr16ms_FB +const LC3_INT32 xavg_N_grp[5] = { 4, 5, 6, 7, 8 }; + + +const LC3_INT32 gwlpr[MAX_LGW+1] = { 1, 3*QUOT_LPR_LTR, 5*QUOT_LPR_LTR, 9*QUOT_LPR_LTR, 17*QUOT_LPR_LTR, 33*QUOT_LPR_LTR, 49*QUOT_LPR_LTR, 65*QUOT_LPR_LTR, 81*QUOT_LPR_LTR, 97*QUOT_LPR_LTR}; + + +const LC3_FLOAT PhECU_whr16ms_NB[128]={ +8.000000000000002e-02, 8.393536376804722e-02, 9.567411990702857e-02, 1.150154150448081e-01, 1.416283142591582e-01, +1.750574634660318e-01, 2.147308806541882e-01, 2.599697426559885e-01, 3.099999999999999e-01, 3.639656211120587e-01, +4.209432392528405e-01, 4.799579515787762e-01, 5.400000000000000e-01, 6.000420484212237e-01, 6.590567607471596e-01, +7.160343788879413e-01, 7.699999999999999e-01, 8.200302573440115e-01, 8.652691193458119e-01, 9.049425365339682e-01, +9.383716857408418e-01, 9.649845849551919e-01, 9.843258800929715e-01, 9.960646362319528e-01, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +9.960646362319528e-01, 9.843258800929715e-01, 9.649845849551919e-01, 9.383716857408418e-01, 9.049425365339682e-01, +8.652691193458119e-01, 8.200302573440115e-01, 7.699999999999999e-01, 7.160343788879413e-01, 6.590567607471596e-01, +6.000420484212237e-01, 5.400000000000000e-01, 4.799579515787762e-01, 4.209432392528405e-01, 3.639656211120587e-01, +3.099999999999999e-01, 2.599697426559885e-01, 2.147308806541882e-01, 1.750574634660318e-01, 1.416283142591582e-01, +1.150154150448081e-01, 9.567411990702857e-02, 8.393536376804722e-02 +}; +const LC3_FLOAT PhECU_whr16ms_WB[256]={ +8.000000000000002e-02, 8.098489531024239e-02, 8.393536376804722e-02, 8.883877101451404e-02, 9.567411990702857e-02, +1.044121404322514e-01, 1.150154150448081e-01, 1.274385388949634e-01, 1.416283142591582e-01, 1.575239783408292e-01, +1.750574634660318e-01, 1.941536885596704e-01, 2.147308806541882e-01, 2.367009250539683e-01, 2.599697426559885e-01, +2.844376928109830e-01, 3.099999999999999e-01, 3.365472024992595e-01, 3.639656211120587e-01, 3.921378459605457e-01, +4.209432392528405e-01, 4.502584518725810e-01, 4.799579515787762e-01, 5.099145605541342e-01, 5.400000000000000e-01, +5.700854394458659e-01, 6.000420484212237e-01, 6.297415481274190e-01, 6.590567607471596e-01, 6.878621540394543e-01, +7.160343788879413e-01, 7.434527975007406e-01, 7.699999999999999e-01, 7.955623071890170e-01, 8.200302573440115e-01, +8.432990749460317e-01, 8.652691193458119e-01, 8.858463114403297e-01, 9.049425365339682e-01, 9.224760216591710e-01, +9.383716857408418e-01, 9.525614611050366e-01, 9.649845849551919e-01, 9.755878595677486e-01, 9.843258800929715e-01, +9.911612289854861e-01, 9.960646362319528e-01, 9.990151046897577e-01, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 9.990151046897577e-01, +9.960646362319528e-01, 9.911612289854861e-01, 9.843258800929715e-01, 9.755878595677486e-01, 9.649845849551919e-01, +9.525614611050366e-01, 9.383716857408418e-01, 9.224760216591710e-01, 9.049425365339682e-01, 8.858463114403297e-01, +8.652691193458119e-01, 8.432990749460317e-01, 8.200302573440115e-01, 7.955623071890170e-01, 7.699999999999999e-01, +7.434527975007406e-01, 7.160343788879413e-01, 6.878621540394543e-01, 6.590567607471596e-01, 6.297415481274190e-01, +6.000420484212237e-01, 5.700854394458659e-01, 5.400000000000000e-01, 5.099145605541342e-01, 4.799579515787762e-01, +4.502584518725810e-01, 4.209432392528405e-01, 3.921378459605457e-01, 3.639656211120587e-01, 3.365472024992595e-01, +3.099999999999999e-01, 2.844376928109830e-01, 2.599697426559885e-01, 2.367009250539683e-01, 2.147308806541882e-01, +1.941536885596704e-01, 1.750574634660318e-01, 1.575239783408292e-01, 1.416283142591582e-01, 1.274385388949634e-01, +1.150154150448081e-01, 1.044121404322514e-01, 9.567411990702857e-02, 8.883877101451404e-02, 8.393536376804722e-02, +8.098489531024239e-02 +}; +const LC3_FLOAT PhECU_whr16ms_SSWB[384]={ +8.000000000000002e-02, 8.043781807234540e-02, 8.175043887779704e-02, 8.393536376804722e-02, 8.698843361438435e-02, +9.090383672483066e-02, 9.567411990702857e-02, 1.012902026558156e-01, 1.077413944384821e-01, 1.150154150448081e-01, +1.230984179631410e-01, 1.319750167380180e-01, 1.416283142591582e-01, 1.520399349260726e-01, 1.631900596270638e-01, +1.750574634660318e-01, 1.876195561652702e-01, 2.008524250673430e-01, 2.147308806541882e-01, 2.292285044967963e-01, +2.443176995441919e-01, 2.599697426559885e-01, 2.761548392785189e-01, 2.928421801604610e-01, 3.099999999999999e-01, +3.275956379118843e-01, 3.455955995992783e-01, 3.639656211120587e-01, 3.826707340701924e-01, 4.016753322280344e-01, +4.209432392528405e-01, 4.404377775884727e-01, 4.601218382732121e-01, 4.799579515787762e-01, 4.999083583360772e-01, +5.199350818119455e-01, 5.400000000000000e-01, 5.600649181880546e-01, 5.800916416639228e-01, 6.000420484212237e-01, +6.198781617267880e-01, 6.395622224115274e-01, 6.590567607471596e-01, 6.783246677719657e-01, 6.973292659298076e-01, +7.160343788879413e-01, 7.344044004007217e-01, 7.524043620881156e-01, 7.699999999999999e-01, 7.871578198395390e-01, +8.038451607214812e-01, 8.200302573440115e-01, 8.356823004558082e-01, 8.507714955032037e-01, 8.652691193458119e-01, +8.791475749326572e-01, 8.923804438347298e-01, 9.049425365339682e-01, 9.168099403729364e-01, 9.279600650739274e-01, +9.383716857408418e-01, 9.480249832619820e-01, 9.569015820368590e-01, 9.649845849551919e-01, 9.722586055615179e-01, +9.787097973441844e-01, 9.843258800929715e-01, 9.890961632751694e-01, 9.930115663856157e-01, 9.960646362319528e-01, +9.982495611222031e-01, 9.995621819276547e-01, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 9.995621819276547e-01, 9.982495611222031e-01, +9.960646362319528e-01, 9.930115663856157e-01, 9.890961632751694e-01, 9.843258800929715e-01, 9.787097973441844e-01, +9.722586055615179e-01, 9.649845849551919e-01, 9.569015820368590e-01, 9.480249832619820e-01, 9.383716857408418e-01, +9.279600650739274e-01, 9.168099403729364e-01, 9.049425365339682e-01, 8.923804438347298e-01, 8.791475749326572e-01, +8.652691193458119e-01, 8.507714955032037e-01, 8.356823004558082e-01, 8.200302573440115e-01, 8.038451607214812e-01, +7.871578198395390e-01, 7.699999999999999e-01, 7.524043620881156e-01, 7.344044004007217e-01, 7.160343788879413e-01, +6.973292659298076e-01, 6.783246677719657e-01, 6.590567607471596e-01, 6.395622224115274e-01, 6.198781617267880e-01, +6.000420484212237e-01, 5.800916416639228e-01, 5.600649181880546e-01, 5.400000000000000e-01, 5.199350818119455e-01, +4.999083583360772e-01, 4.799579515787762e-01, 4.601218382732121e-01, 4.404377775884727e-01, 4.209432392528405e-01, +4.016753322280344e-01, 3.826707340701924e-01, 3.639656211120587e-01, 3.455955995992783e-01, 3.275956379118843e-01, +3.099999999999999e-01, 2.928421801604610e-01, 2.761548392785189e-01, 2.599697426559885e-01, 2.443176995441919e-01, +2.292285044967963e-01, 2.147308806541882e-01, 2.008524250673430e-01, 1.876195561652702e-01, 1.750574634660318e-01, +1.631900596270638e-01, 1.520399349260726e-01, 1.416283142591582e-01, 1.319750167380180e-01, 1.230984179631410e-01, +1.150154150448081e-01, 1.077413944384821e-01, 1.012902026558156e-01, 9.567411990702857e-02, 9.090383672483066e-02, +8.698843361438435e-02, 8.393536376804722e-02, 8.175043887779704e-02, 8.043781807234540e-02 +}; +const LC3_FLOAT PhECU_whr16ms_SWB[512]={ +8.000000000000002e-02, 8.024628976087178e-02, 8.098489531024239e-02, 8.221502573078943e-02, 8.393536376804722e-02, +8.614406724095569e-02, 8.883877101451404e-02, 9.201658953242653e-02, 9.567411990702857e-02, 9.980744556318394e-02, +1.044121404322514e-01, 1.094832736916302e-01, 1.150154150448081e-01, 1.210026405362591e-01, 1.274385388949634e-01, +1.343162183997567e-01, 1.416283142591582e-01, 1.493669964977737e-01, 1.575239783408292e-01, 1.660905250878570e-01, +1.750574634660318e-01, 1.844151914531410e-01, 1.941536885596704e-01, 2.042625265589956e-01, 2.147308806541882e-01, +2.255475410694793e-01, 2.367009250539683e-01, 2.481790892847231e-01, 2.599697426559885e-01, 2.720602594408110e-01, +2.844376928109830e-01, 2.970887887008307e-01, 3.099999999999999e-01, 3.231575010600410e-01, 3.365472024992595e-01, +3.501547662899784e-01, 3.639656211120587e-01, 3.779649779562326e-01, 3.921378459605457e-01, 4.064690484629473e-01, +4.209432392528405e-01, 4.355449190041883e-01, 4.502584518725810e-01, 4.650680822384892e-01, 4.799579515787762e-01, +4.949121154484021e-01, 5.099145605541342e-01, 5.249492219019830e-01, 5.400000000000000e-01, 5.550507780980171e-01, +5.700854394458659e-01, 5.850878845515979e-01, 6.000420484212237e-01, 6.149319177615109e-01, 6.297415481274190e-01, +6.444550809958116e-01, 6.590567607471596e-01, 6.735309515370527e-01, 6.878621540394543e-01, 7.020350220437674e-01, +7.160343788879413e-01, 7.298452337100215e-01, 7.434527975007406e-01, 7.568424989399589e-01, 7.699999999999999e-01, +7.829112112991693e-01, 7.955623071890170e-01, 8.079397405591890e-01, 8.200302573440115e-01, 8.318209107152770e-01, +8.432990749460317e-01, 8.544524589305209e-01, 8.652691193458119e-01, 8.757374734410044e-01, 8.858463114403297e-01, +8.955848085468591e-01, 9.049425365339682e-01, 9.139094749121430e-01, 9.224760216591710e-01, 9.306330035022263e-01, +9.383716857408418e-01, 9.456837816002432e-01, 9.525614611050366e-01, 9.589973594637410e-01, 9.649845849551919e-01, +9.705167263083698e-01, 9.755878595677486e-01, 9.801925544368162e-01, 9.843258800929715e-01, 9.879834104675735e-01, +9.911612289854861e-01, 9.938559327590444e-01, 9.960646362319528e-01, 9.977849742692106e-01, 9.990151046897577e-01, +9.997537102391283e-01, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 9.997537102391283e-01, 9.990151046897577e-01, 9.977849742692106e-01, +9.960646362319528e-01, 9.938559327590444e-01, 9.911612289854861e-01, 9.879834104675735e-01, 9.843258800929715e-01, +9.801925544368162e-01, 9.755878595677486e-01, 9.705167263083698e-01, 9.649845849551919e-01, 9.589973594637410e-01, +9.525614611050366e-01, 9.456837816002432e-01, 9.383716857408418e-01, 9.306330035022263e-01, 9.224760216591710e-01, +9.139094749121430e-01, 9.049425365339682e-01, 8.955848085468591e-01, 8.858463114403297e-01, 8.757374734410044e-01, +8.652691193458119e-01, 8.544524589305209e-01, 8.432990749460317e-01, 8.318209107152770e-01, 8.200302573440115e-01, +8.079397405591890e-01, 7.955623071890170e-01, 7.829112112991693e-01, 7.699999999999999e-01, 7.568424989399589e-01, +7.434527975007406e-01, 7.298452337100215e-01, 7.160343788879413e-01, 7.020350220437674e-01, 6.878621540394543e-01, +6.735309515370527e-01, 6.590567607471596e-01, 6.444550809958116e-01, 6.297415481274190e-01, 6.149319177615109e-01, +6.000420484212237e-01, 5.850878845515979e-01, 5.700854394458659e-01, 5.550507780980171e-01, 5.400000000000000e-01, +5.249492219019830e-01, 5.099145605541342e-01, 4.949121154484021e-01, 4.799579515787762e-01, 4.650680822384892e-01, +4.502584518725810e-01, 4.355449190041883e-01, 4.209432392528405e-01, 4.064690484629473e-01, 3.921378459605457e-01, +3.779649779562326e-01, 3.639656211120587e-01, 3.501547662899784e-01, 3.365472024992595e-01, 3.231575010600410e-01, +3.099999999999999e-01, 2.970887887008307e-01, 2.844376928109830e-01, 2.720602594408110e-01, 2.599697426559885e-01, +2.481790892847231e-01, 2.367009250539683e-01, 2.255475410694793e-01, 2.147308806541882e-01, 2.042625265589956e-01, +1.941536885596704e-01, 1.844151914531410e-01, 1.750574634660318e-01, 1.660905250878570e-01, 1.575239783408292e-01, +1.493669964977737e-01, 1.416283142591582e-01, 1.343162183997567e-01, 1.274385388949634e-01, 1.210026405362591e-01, +1.150154150448081e-01, 1.094832736916302e-01, 1.044121404322514e-01, 9.980744556318394e-02, 9.567411990702857e-02, +9.201658953242653e-02, 8.883877101451404e-02, 8.614406724095569e-02, 8.393536376804722e-02, 8.221502573078943e-02, +8.098489531024239e-02, 8.024628976087178e-02 +}; +const LC3_FLOAT PhECU_whr16ms_FB[768]={ +8.000000000000002e-02, 8.010946754324183e-02, 8.043781807234540e-02, 8.098489531024239e-02, 8.175043887779704e-02, +8.273408441773300e-02, 8.393536376804722e-02, 8.535370518483010e-02, 8.698843361438435e-02, 8.883877101451404e-02, +9.090383672483066e-02, 9.318264788589975e-02, 9.567411990702857e-02, 9.837706698247278e-02, 1.012902026558156e-01, +1.044121404322514e-01, 1.077413944384821e-01, 1.112763801299127e-01, 1.150154150448081e-01, 1.189567196050543e-01, +1.230984179631410e-01, 1.274385388949634e-01, 1.319750167380180e-01, 1.367056923745465e-01, 1.416283142591582e-01, +1.467405394904446e-01, 1.520399349260726e-01, 1.575239783408292e-01, 1.631900596270638e-01, 1.690354820369581e-01, +1.750574634660318e-01, 1.812531377772744e-01, 1.876195561652702e-01, 1.941536885596704e-01, 2.008524250673430e-01, +2.077125774525124e-01, 2.147308806541882e-01, 2.219039943401561e-01, 2.292285044967963e-01, 2.367009250539683e-01, +2.443176995441919e-01, 2.520752027953329e-01, 2.599697426559885e-01, 2.679975617527521e-01, 2.761548392785189e-01, +2.844376928109830e-01, 2.928421801604610e-01, 3.013643012461601e-01, 3.099999999999999e-01, 3.187451662970817e-01, +3.275956379118843e-01, 3.365472024992595e-01, 3.455955995992783e-01, 3.547365226649809e-01, 3.639656211120587e-01, +3.732785023894972e-01, 3.826707340701924e-01, 3.921378459605457e-01, 4.016753322280344e-01, 4.112786535457436e-01, +4.209432392528405e-01, 4.306644895299604e-01, 4.404377775884727e-01, 4.502584518725810e-01, 4.601218382732121e-01, +4.700232423526383e-01, 4.799579515787762e-01, 4.899212375680964e-01, 4.999083583360772e-01, 5.099145605541342e-01, +5.199350818119455e-01, 5.299651528841020e-01, 5.400000000000000e-01, 5.500348471158981e-01, 5.600649181880546e-01, +5.700854394458659e-01, 5.800916416639228e-01, 5.900787624319037e-01, 6.000420484212237e-01, 6.099767576473617e-01, +6.198781617267880e-01, 6.297415481274190e-01, 6.395622224115274e-01, 6.493355104700396e-01, 6.590567607471596e-01, +6.687213464542564e-01, 6.783246677719657e-01, 6.878621540394543e-01, 6.973292659298076e-01, 7.067214976105027e-01, +7.160343788879413e-01, 7.252634773350191e-01, 7.344044004007217e-01, 7.434527975007406e-01, 7.524043620881156e-01, +7.612548337029182e-01, 7.699999999999999e-01, 7.786356987538400e-01, 7.871578198395390e-01, 7.955623071890170e-01, +8.038451607214812e-01, 8.120024382472478e-01, 8.200302573440115e-01, 8.279247972046673e-01, 8.356823004558082e-01, +8.432990749460317e-01, 8.507714955032037e-01, 8.580960056598439e-01, 8.652691193458119e-01, 8.722874225474876e-01, +8.791475749326572e-01, 8.858463114403297e-01, 8.923804438347298e-01, 8.987468622227257e-01, 9.049425365339682e-01, +9.109645179630421e-01, 9.168099403729364e-01, 9.224760216591710e-01, 9.279600650739274e-01, 9.332594605095554e-01, +9.383716857408418e-01, 9.432943076254536e-01, 9.480249832619820e-01, 9.525614611050366e-01, 9.569015820368590e-01, +9.610432803949458e-01, 9.649845849551919e-01, 9.687236198700873e-01, 9.722586055615179e-01, 9.755878595677486e-01, +9.787097973441844e-01, 9.816229330175272e-01, 9.843258800929715e-01, 9.868173521141004e-01, 9.890961632751694e-01, +9.911612289854861e-01, 9.930115663856157e-01, 9.946462948151700e-01, 9.960646362319528e-01, 9.972659155822671e-01, +9.982495611222031e-01, 9.990151046897577e-01, 9.995621819276547e-01, 9.998905324567582e-01, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, 1.000000000000000e+00, +9.998905324567582e-01, 9.995621819276547e-01, 9.990151046897577e-01, 9.982495611222031e-01, 9.972659155822671e-01, +9.960646362319528e-01, 9.946462948151700e-01, 9.930115663856157e-01, 9.911612289854861e-01, 9.890961632751694e-01, +9.868173521141004e-01, 9.843258800929715e-01, 9.816229330175272e-01, 9.787097973441844e-01, 9.755878595677486e-01, +9.722586055615179e-01, 9.687236198700873e-01, 9.649845849551919e-01, 9.610432803949458e-01, 9.569015820368590e-01, +9.525614611050366e-01, 9.480249832619820e-01, 9.432943076254536e-01, 9.383716857408418e-01, 9.332594605095554e-01, +9.279600650739274e-01, 9.224760216591710e-01, 9.168099403729364e-01, 9.109645179630421e-01, 9.049425365339682e-01, +8.987468622227257e-01, 8.923804438347298e-01, 8.858463114403297e-01, 8.791475749326572e-01, 8.722874225474876e-01, +8.652691193458119e-01, 8.580960056598439e-01, 8.507714955032037e-01, 8.432990749460317e-01, 8.356823004558082e-01, +8.279247972046673e-01, 8.200302573440115e-01, 8.120024382472478e-01, 8.038451607214812e-01, 7.955623071890170e-01, +7.871578198395390e-01, 7.786356987538400e-01, 7.699999999999999e-01, 7.612548337029182e-01, 7.524043620881156e-01, +7.434527975007406e-01, 7.344044004007217e-01, 7.252634773350191e-01, 7.160343788879413e-01, 7.067214976105027e-01, +6.973292659298076e-01, 6.878621540394543e-01, 6.783246677719657e-01, 6.687213464542564e-01, 6.590567607471596e-01, +6.493355104700396e-01, 6.395622224115274e-01, 6.297415481274190e-01, 6.198781617267880e-01, 6.099767576473617e-01, +6.000420484212237e-01, 5.900787624319037e-01, 5.800916416639228e-01, 5.700854394458659e-01, 5.600649181880546e-01, +5.500348471158981e-01, 5.400000000000000e-01, 5.299651528841020e-01, 5.199350818119455e-01, 5.099145605541342e-01, +4.999083583360772e-01, 4.899212375680964e-01, 4.799579515787762e-01, 4.700232423526383e-01, 4.601218382732121e-01, +4.502584518725810e-01, 4.404377775884727e-01, 4.306644895299604e-01, 4.209432392528405e-01, 4.112786535457436e-01, +4.016753322280344e-01, 3.921378459605457e-01, 3.826707340701924e-01, 3.732785023894972e-01, 3.639656211120587e-01, +3.547365226649809e-01, 3.455955995992783e-01, 3.365472024992595e-01, 3.275956379118843e-01, 3.187451662970817e-01, +3.099999999999999e-01, 3.013643012461601e-01, 2.928421801604610e-01, 2.844376928109830e-01, 2.761548392785189e-01, +2.679975617527521e-01, 2.599697426559885e-01, 2.520752027953329e-01, 2.443176995441919e-01, 2.367009250539683e-01, +2.292285044967963e-01, 2.219039943401561e-01, 2.147308806541882e-01, 2.077125774525124e-01, 2.008524250673430e-01, +1.941536885596704e-01, 1.876195561652702e-01, 1.812531377772744e-01, 1.750574634660318e-01, 1.690354820369581e-01, +1.631900596270638e-01, 1.575239783408292e-01, 1.520399349260726e-01, 1.467405394904446e-01, 1.416283142591582e-01, +1.367056923745465e-01, 1.319750167380180e-01, 1.274385388949634e-01, 1.230984179631410e-01, 1.189567196050543e-01, +1.150154150448081e-01, 1.112763801299127e-01, 1.077413944384821e-01, 1.044121404322514e-01, 1.012902026558156e-01, +9.837706698247278e-02, 9.567411990702857e-02, 9.318264788589975e-02, 9.090383672483066e-02, 8.883877101451404e-02, +8.698843361438435e-02, 8.535370518483010e-02, 8.393536376804722e-02, 8.273408441773300e-02, 8.175043887779704e-02, +8.098489531024239e-02, 8.043781807234540e-02, 8.010946754324183e-02 +}; + +const LC3_FLOAT* PhECU_whr16ms_wins[5] = { + PhECU_whr16ms_NB,PhECU_whr16ms_WB,PhECU_whr16ms_SSWB,PhECU_whr16ms_SWB, PhECU_whr16ms_FB }; const LC3_FLOAT hannOla_8k[28 / 2 + 1] = { - 0.0000000000, 0.0125360439, 0.0495155660, 0.1090842588, 0.1882550991, 0.2830581304, 0.3887395330, 0.5000000000, 0.6112604670, 0.7169418696, 0.8117449009, 0.8909157412, 0.9504844340, - 0.9874639561, 1.0000000000 -}; + 0.0000000000, 0.0125360439, 0.0495155660, 0.1090842588, 0.1882550991, 0.2830581304, 0.3887395330, 0.5000000000, 0.6112604670, 0.7169418696, 0.8117449009, 0.8909157412, 0.9504844340, + 0.9874639561, 1.0000000000 }; const LC3_FLOAT hannOla_16k[56 / 2 + 1] = { - 0.0000000000, 0.0031438951, 0.0125360439, 0.0280583348, 0.0495155660, 0.0766379004, 0.1090842588, 0.1464466094, 0.1882550991, 0.2339839617, 0.2830581304, 0.3348604690, 0.3887395330, - 0.4440177619, 0.5000000000, 0.5559822381, 0.6112604670, 0.6651395310, 0.7169418696, 0.7660160383, 0.8117449009, 0.8535533906, 0.8909157412, 0.9233620996, 0.9504844340, 0.9719416652, - 0.9874639561, 0.9968561049, 1.0000000000 -}; + 0.0000000000, 0.0031438951, 0.0125360439, 0.0280583348, 0.0495155660, 0.0766379004, 0.1090842588, 0.1464466094, 0.1882550991, 0.2339839617, 0.2830581304, 0.3348604690, 0.3887395330, + 0.4440177619, 0.5000000000, 0.5559822381, 0.6112604670, 0.6651395310, 0.7169418696, 0.7660160383, 0.8117449009, 0.8535533906, 0.8909157412, 0.9233620996, 0.9504844340, 0.9719416652, + 0.9874639561, 0.9968561049, 1.0000000000 }; const LC3_FLOAT hannOla_24k[84 / 2 + 1] = { - 0.0000000000, 0.0013981014, 0.0055845869, 0.0125360439, 0.0222135971, 0.0345631257, 0.0495155660, 0.0669872981, 0.0868806128, 0.1090842588, 0.1334740641, 0.1599136311, 0.1882550991, - 0.2183399710, 0.2500000000, 0.2830581304, 0.3173294878, 0.3526224128, 0.3887395330, 0.4254788669, 0.4626349532, 0.5000000000, 0.5373650468, 0.5745211331, 0.6112604670, 0.6473775872, - 0.6826705122, 0.7169418696, 0.7500000000, 0.7816600290, 0.8117449009, 0.8400863689, 0.8665259359, 0.8909157412, 0.9131193872, 0.9330127019, 0.9504844340, 0.9654368743, 0.9777864029, - 0.9874639561, 0.9944154131, 0.9986018986, 1.0000000000 -}; + 0.0000000000, 0.0013981014, 0.0055845869, 0.0125360439, 0.0222135971, 0.0345631257, 0.0495155660, 0.0669872981, 0.0868806128, 0.1090842588, 0.1334740641, 0.1599136311, 0.1882550991, + 0.2183399710, 0.2500000000, 0.2830581304, 0.3173294878, 0.3526224128, 0.3887395330, 0.4254788669, 0.4626349532, 0.5000000000, 0.5373650468, 0.5745211331, 0.6112604670, 0.6473775872, + 0.6826705122, 0.7169418696, 0.7500000000, 0.7816600290, 0.8117449009, 0.8400863689, 0.8665259359, 0.8909157412, 0.9131193872, 0.9330127019, 0.9504844340, 0.9654368743, 0.9777864029, + 0.9874639561, 0.9944154131, 0.9986018986, 1.0000000000 }; const LC3_FLOAT hannOla_32k[112 / 2 + 1] = { - 0.0000000000, 0.0007865925, 0.0031438951, 0.0070644907, 0.0125360439, 0.0195413390, 0.0280583348, 0.0380602337, 0.0495155660, 0.0623882890, 0.0766379004, 0.0922195655, 0.1090842588, - 0.1271789176, 0.1464466094, 0.1668267110, 0.1882550991, 0.2106643519, 0.2339839617, 0.2581405564, 0.2830581304, 0.3086582838, 0.3348604690, 0.3615822443, 0.3887395330, 0.4162468883, - 0.4440177619, 0.4719647764, 0.5000000000, 0.5280352236, 0.5559822381, 0.5837531117, 0.6112604670, 0.6384177557, 0.6651395310, 0.6913417162, 0.7169418696, 0.7418594436, 0.7660160383, - 0.7893356481, 0.8117449009, 0.8331732890, 0.8535533906, 0.8728210824, 0.8909157412, 0.9077804345, 0.9233620996, 0.9376117110, 0.9504844340, 0.9619397663, 0.9719416652, 0.9804586610, - 0.9874639561, 0.9929355093, 0.9968561049, 0.9992134075, 1.0000000000 -}; - -const LC3_FLOAT hannOla_48k[168 / 2 + 1] = { - 0.0000000000, 0.0003496476, 0.0013981014, 0.0031438951, 0.0055845869, 0.0087167634, 0.0125360439, 0.0170370869, 0.0222135971, 0.0280583348, 0.0345631257, 0.0417188721, 0.0495155660, - 0.0579423032, 0.0669872981, 0.0766379004, 0.0868806128, 0.0977011101, 0.1090842588, 0.1210141384, 0.1334740641, 0.1464466094, 0.1599136311, 0.1738562944, 0.1882550991, 0.2030899072, - 0.2183399710, 0.2339839617, 0.2500000000, 0.2663656859, 0.2830581304, 0.3000539878, 0.3173294878, 0.3348604690, 0.3526224128, 0.3705904774, 0.3887395330, 0.4070441964, 0.4254788669, - 0.4440177619, 0.4626349532, 0.4813044029, 0.5000000000, 0.5186955971, 0.5373650468, 0.5559822381, 0.5745211331, 0.5929558036, 0.6112604670, 0.6294095226, 0.6473775872, 0.6651395310, - 0.6826705122, 0.6999460122, 0.7169418696, 0.7336343141, 0.7500000000, 0.7660160383, 0.7816600290, 0.7969100928, 0.8117449009, 0.8261437056, 0.8400863689, 0.8535533906, 0.8665259359, - 0.8789858616, 0.8909157412, 0.9022988899, 0.9131193872, 0.9233620996, 0.9330127019, 0.9420576968, 0.9504844340, 0.9582811279, 0.9654368743, 0.9719416652, 0.9777864029, 0.9829629131, - 0.9874639561, 0.9912832366, 0.9944154131, 0.9968561049, 0.9986018986, 0.9996503524, 1.0000000000 -}; + 0.0000000000, 0.0007865925, 0.0031438951, 0.0070644907, 0.0125360439, 0.0195413390, 0.0280583348, 0.0380602337, 0.0495155660, 0.0623882890, 0.0766379004, 0.0922195655, 0.1090842588, + 0.1271789176, 0.1464466094, 0.1668267110, 0.1882550991, 0.2106643519, 0.2339839617, 0.2581405564, 0.2830581304, 0.3086582838, 0.3348604690, 0.3615822443, 0.3887395330, 0.4162468883, + 0.4440177619, 0.4719647764, 0.5000000000, 0.5280352236, 0.5559822381, 0.5837531117, 0.6112604670, 0.6384177557, 0.6651395310, 0.6913417162, 0.7169418696, 0.7418594436, 0.7660160383, + 0.7893356481, 0.8117449009, 0.8331732890, 0.8535533906, 0.8728210824, 0.8909157412, 0.9077804345, 0.9233620996, 0.9376117110, 0.9504844340, 0.9619397663, 0.9719416652, 0.9804586610, + 0.9874639561, 0.9929355093, 0.9968561049, 0.9992134075, 1.0000000000 }; + +const LC3_FLOAT hannOla_48k[168 / 2 + 1] = { + 0.0000000000, 0.0003496476, 0.0013981014, 0.0031438951, 0.0055845869, 0.0087167634, 0.0125360439, 0.0170370869, 0.0222135971, 0.0280583348, 0.0345631257, 0.0417188721, 0.0495155660, + 0.0579423032, 0.0669872981, 0.0766379004, 0.0868806128, 0.0977011101, 0.1090842588, 0.1210141384, 0.1334740641, 0.1464466094, 0.1599136311, 0.1738562944, 0.1882550991, 0.2030899072, + 0.2183399710, 0.2339839617, 0.2500000000, 0.2663656859, 0.2830581304, 0.3000539878, 0.3173294878, 0.3348604690, 0.3526224128, 0.3705904774, 0.3887395330, 0.4070441964, 0.4254788669, + 0.4440177619, 0.4626349532, 0.4813044029, 0.5000000000, 0.5186955971, 0.5373650468, 0.5559822381, 0.5745211331, 0.5929558036, 0.6112604670, 0.6294095226, 0.6473775872, 0.6651395310, + 0.6826705122, 0.6999460122, 0.7169418696, 0.7336343141, 0.7500000000, 0.7660160383, 0.7816600290, 0.7969100928, 0.8117449009, 0.8261437056, 0.8400863689, 0.8535533906, 0.8665259359, + 0.8789858616, 0.8909157412, 0.9022988899, 0.9131193872, 0.9233620996, 0.9330127019, 0.9420576968, 0.9504844340, 0.9582811279, 0.9654368743, 0.9719416652, 0.9777864029, 0.9829629131, + 0.9874639561, 0.9912832366, 0.9944154131, 0.9968561049, 0.9986018986, 0.9996503524, 1.0000000000 }; const LC3_FLOAT *hannOla_wins[5] = { hannOla_8k, hannOla_16k, hannOla_24k, hannOla_32k, hannOla_48k }; -const LC3_FLOAT plc_tdc_lpc_8[17] = { 1, 0.998890285693703, 0.995568526105076, 0.990056789412169, 0.982391584470799, 0.972623458066693, 0.960816439805232, 0.947047343167065, 0.931404933402306, 0.913988974871173, 0.894909172128633, 0.874284020464791, 0.852239582727672, 0.828908210053904, 0.804427224606163, 0.778937582561901, 0.752582535420797 }; +const LC3_FLOAT plc_tdc_lpc_8[17] = {1, 0.998890285693703, 0.995568526105076, 0.990056789412169, 0.982391584470799, 0.972623458066693, 0.960816439805232, 0.947047343167065, 0.931404933402306, 0.913988974871173, 0.894909172128633, 0.874284020464791, 0.852239582727672, 0.828908210053904, 0.804427224606163, 0.778937582561901, 0.752582535420797}; -const LC3_FLOAT plc_tdc_lpc_16[17] = { 1, 0.999722455898711, 0.998890285693703, 0.997504874399492, 0.995568526105076, 0.993084457588532, 0.990056789412169, 0.986490534532745, 0.982391584470799, 0.977766693092529, 0.972623458066693, 0.966970300067793, 0.960816439805232, 0.954171872966123, 0.947047343167065, 0.939454313017299, 0.931404933402306 }; +const LC3_FLOAT plc_tdc_lpc_16[17] = {1, 0.999722455898711, 0.998890285693703, 0.997504874399492, 0.995568526105076, 0.993084457588532, 0.990056789412169, 0.986490534532745, 0.982391584470799, 0.977766693092529, 0.972623458066693, 0.966970300067793, 0.960816439805232, 0.954171872966123, 0.947047343167065, 0.939454313017299, 0.931404933402306}; -const LC3_FLOAT plc_tdc_lpc_24[17] = { 1, 0.999876637554759, 0.999506641521283, 0.998890285693703, 0.998028026020383, 0.996920500041823, 0.995568526105076, 0.993973102356048, 0.992135405511397, 0.990056789412169, 0.987738783361644, 0.985183090250255, 0.982391584470799, 0.979366309627507, 0.976109476042902, 0.972623458066693, 0.968910791191297 }; +const LC3_FLOAT plc_tdc_lpc_24[17] = {1, 0.999876637554759, 0.999506641521283, 0.998890285693703, 0.998028026020383, 0.996920500041823, 0.995568526105076, 0.993973102356048, 0.992135405511397, 0.990056789412169, 0.987738783361644, 0.985183090250255, 0.982391584470799, 0.979366309627507, 0.976109476042902, 0.972623458066693, 0.968910791191297}; -const LC3_FLOAT plc_tdc_lpc_32[17] = { 1, 0.999930606751878, 0.999722455898711, 0.999375634094057, 0.998890285693703, 0.998266612655538, 0.997504874399492, 0.996605387627705, 0.995568526105076, 0.994394720400431, 0.993084457588532, 0.991638280913245, 0.990056789412169, 0.988340637503103, 0.986490534532745, 0.984507244288062, 0.982391584470799 }; +const LC3_FLOAT plc_tdc_lpc_32[17] = {1, 0.999930606751878, 0.999722455898711, 0.999375634094057, 0.998890285693703, 0.998266612655538, 0.997504874399492, 0.996605387627705, 0.995568526105076, 0.994394720400431, 0.993084457588532, 0.991638280913245, 0.990056789412169, 0.988340637503103, 0.986490534532745, 0.984507244288062, 0.982391584470799}; -const LC3_FLOAT plc_tdc_lpc_48[17] = { 1, 0.999969157961872, 0.999876637554759, 0.999722455898711, 0.999506641521283, 0.999229234348730, 0.998890285693703, 0.998489858239427, 0.998028026020383, 0.997504874399492, 0.996920500041823, 0.996275010884819, 0.995568526105076, 0.994801176081669, 0.993973102356048, 0.993084457588532, 0.992135405511397 }; +const LC3_FLOAT plc_tdc_lpc_48[17] = {1, 0.999969157961872, 0.999876637554759, 0.999722455898711, 0.999506641521283, 0.999229234348730, 0.998890285693703, 0.998489858239427, 0.998028026020383, 0.997504874399492, 0.996920500041823, 0.996275010884819, 0.995568526105076, 0.994801176081669, 0.993973102356048, 0.993084457588532, 0.992135405511397}; -const LC3_FLOAT plc_tdc_lpc_96[17] = { 1, 0.999992289401289, 0.999969157961872, 0.999930606751878, 0.999876637554759, 0.999807252867157, 0.999722455898711, 0.999622250571809, 0.999506641521283, 0.999375634094057, 0.999229234348730, 0.999067449055113, 0.998890285693703, 0.998697752455111, 0.998489858239427, 0.998266612655538, 0.998028026020383 }; +const LC3_FLOAT plc_tdc_lpc_96[17] = {1, 0.999992289401289, 0.999969157961872, 0.999930606751878, 0.999876637554759, 0.999807252867157, 0.999722455898711, 0.999622250571809, 0.999506641521283, 0.999375634094057, 0.999229234348730, 0.999067449055113, 0.998890285693703, 0.998697752455111, 0.998489858239427, 0.998266612655538, 0.998028026020383}; -const LC3_FLOAT *plc_tdc_lpc_all[6] = { plc_tdc_lpc_8, plc_tdc_lpc_16, plc_tdc_lpc_24, plc_tdc_lpc_32, plc_tdc_lpc_48, plc_tdc_lpc_96 }; +const LC3_FLOAT *plc_tdc_lpc_all[6] = {plc_tdc_lpc_8, plc_tdc_lpc_16, plc_tdc_lpc_24, plc_tdc_lpc_32, plc_tdc_lpc_48, plc_tdc_lpc_96}; -const LC3_FLOAT plc_tdc_lpc_8_25ms[9] = { 1, 0.998890285693703, 0.995568526105076, 0.990056789412169, 0.982391584470799, 0.972623458066693, 0.960816439805232, 0.947047343167065, 0.931404933402306 }; +const LC3_FLOAT plc_tdc_lpc_8_25ms[9] = {1, 0.998890285693703, 0.995568526105076, 0.990056789412169, 0.982391584470799, 0.972623458066693, 0.960816439805232, 0.947047343167065, 0.931404933402306}; -const LC3_FLOAT plc_preemph_fac[] = { 0.62, 0.72, 0.82, 0.92, 0.92, 0.92 }; +const LC3_FLOAT plc_preemph_fac[] = {0.62, 0.72, 0.82, 0.92, 0.92, 0.92}; const LC3_INT ACC_COEFF_PER_BAND_PLC_8_10ms[81] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80 -}; + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80}; const LC3_INT ACC_COEFF_PER_BAND_PLC_16_10ms[81] = { - 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, - 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, - 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, - 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160 -}; + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, + 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, + 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, + 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160}; const LC3_INT ACC_COEFF_PER_BAND_PLC_24_10ms[81] = { - 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, - 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120, 123, + 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, + 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120, 123, 126, 129, 132, 135, 138, 141, 144, 147, 150, 153, 156, 159, 162, 165, 168, 171, 174, 177, 180, 183, 186, - 189, 192, 195, 198, 201, 204, 207, 210, 213, 216, 219, 222, 225, 228, 231, 234, 237, 240 -}; + 189, 192, 195, 198, 201, 204, 207, 210, 213, 216, 219, 222, 225, 228, 231, 234, 237, 240}; const LC3_INT ACC_COEFF_PER_BAND_PLC_32_10ms[81] = { - 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, - 84, 88, 92, 96, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 148, 152, 156, 160, 164, + 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, + 84, 88, 92, 96, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 148, 152, 156, 160, 164, 168, 172, 176, 180, 184, 188, 192, 196, 200, 204, 208, 212, 216, 220, 224, 228, 232, 236, 240, 244, 248, - 252, 256, 260, 264, 268, 272, 276, 280, 284, 288, 292, 296, 300, 304, 308, 312, 316, 320 -}; + 252, 256, 260, 264, 268, 272, 276, 280, 284, 288, 292, 296, 300, 304, 308, 312, 316, 320}; const LC3_INT ACC_COEFF_PER_BAND_PLC_48_10ms[81] = { - 0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, + 0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, 126, 132, 138, 144, 150, 156, 162, 168, 174, 180, 186, 192, 198, 204, 210, 216, 222, 228, 234, 240, 246, 252, 258, 264, 270, 276, 282, 288, 294, 300, 306, 312, 318, 324, 330, 336, 342, 348, 354, 360, 366, 372, - 378, 384, 390, 396, 402, 408, 414, 420, 426, 432, 438, 444, 450, 456, 462, 468, 474, 480 -}; + 378, 384, 390, 396 , 402, 408, 414, 420, 426, 432, 438, 444, 450, 456, 462, 468, 474, 480}; const LC3_INT ACC_COEFF_PER_BAND_PLC_96_10ms[81] = { - 0, 12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240, + 0, 12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240, 252, 264, 276, 288, 300, 312, 324, 336, 348, 360, 372, 384, 396, 408, 420, 432, 444, 456, 468, 480, 492, 504, 516, 528, 540, 552, 564, 576, 588, 600, 612, 624, 636, 648, 660, 672, 684, 696, 708, 720, 732, 744, - 756, 768, 780, 792, 804, 816, 828, 840, 852, 864, 876, 888, 900, 912, 924, 936, 948, 960 -}; + 756, 768, 780, 792, 804, 816, 828, 840, 852, 864, 876, 888, 900, 912, 924, 936, 948, 960}; -const LC3_INT *ACC_COEFF_PER_BAND_PLC[] = { - ACC_COEFF_PER_BAND_PLC_8_10ms, ACC_COEFF_PER_BAND_PLC_16_10ms, ACC_COEFF_PER_BAND_PLC_24_10ms, - ACC_COEFF_PER_BAND_PLC_32_10ms, ACC_COEFF_PER_BAND_PLC_48_10ms, ACC_COEFF_PER_BAND_PLC_96_10ms -}; +const LC3_INT* ACC_COEFF_PER_BAND_PLC[] = { + ACC_COEFF_PER_BAND_PLC_8_10ms, ACC_COEFF_PER_BAND_PLC_16_10ms, ACC_COEFF_PER_BAND_PLC_24_10ms, + ACC_COEFF_PER_BAND_PLC_32_10ms, ACC_COEFF_PER_BAND_PLC_48_10ms, ACC_COEFF_PER_BAND_PLC_96_10ms}; -const LC3_INT ACC_COEFF_PER_BAND_PLC_8_2_5ms[21] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }; +const LC3_INT ACC_COEFF_PER_BAND_PLC_8_2_5ms[21] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}; -const LC3_INT ACC_COEFF_PER_BAND_PLC_16_2_5ms[41] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 }; +const LC3_INT ACC_COEFF_PER_BAND_PLC_16_2_5ms[41] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40}; -const LC3_INT ACC_COEFF_PER_BAND_PLC_24_2_5ms[61] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60 }; +const LC3_INT ACC_COEFF_PER_BAND_PLC_24_2_5ms[61] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60}; const LC3_INT ACC_COEFF_PER_BAND_PLC_32_2_5ms[81] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80 -}; + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80}; const LC3_INT ACC_COEFF_PER_BAND_PLC_48_2_5ms[61] = { - 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, - 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, - 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120 -}; + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, + 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, + 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120}; const LC3_INT ACC_COEFF_PER_BAND_PLC_96_2_5ms[81] = { - 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, - 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120, 123, + 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, + 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120, 123, 126, 129, 132, 135, 138, 141, 144, 147, 150, 153, 156, 159, 162, 165, 168, 171, 174, 177, 180, 183, 186, - 189, 192, 195, 198, 201, 204, 207, 210, 213, 216, 219, 222, 225, 228, 231, 234, 237, 240 -}; + 189, 192, 195, 198, 201, 204, 207, 210, 213, 216, 219, 222, 225, 228, 231, 234, 237, 240}; -const LC3_INT *ACC_COEFF_PER_BAND_PLC_2_5ms[] = { - ACC_COEFF_PER_BAND_PLC_8_2_5ms, ACC_COEFF_PER_BAND_PLC_16_2_5ms, ACC_COEFF_PER_BAND_PLC_24_2_5ms, - ACC_COEFF_PER_BAND_PLC_32_2_5ms, ACC_COEFF_PER_BAND_PLC_48_2_5ms, ACC_COEFF_PER_BAND_PLC_96_2_5ms -}; +const LC3_INT* ACC_COEFF_PER_BAND_PLC_2_5ms[] = { + ACC_COEFF_PER_BAND_PLC_8_2_5ms, ACC_COEFF_PER_BAND_PLC_16_2_5ms, ACC_COEFF_PER_BAND_PLC_24_2_5ms, + ACC_COEFF_PER_BAND_PLC_32_2_5ms, ACC_COEFF_PER_BAND_PLC_48_2_5ms, ACC_COEFF_PER_BAND_PLC_96_2_5ms}; -const LC3_INT ACC_COEFF_PER_BAND_PLC_8_5ms[41] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 }; +const LC3_INT ACC_COEFF_PER_BAND_PLC_8_5ms[41] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40}; const LC3_INT ACC_COEFF_PER_BAND_PLC_16_5ms[81] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80 -}; + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80}; -const LC3_INT ACC_COEFF_PER_BAND_PLC_24_5ms[41] = { 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, - 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, - 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120 }; +const LC3_INT ACC_COEFF_PER_BAND_PLC_24_5ms[41] = {0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, + 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, + 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120}; const LC3_INT ACC_COEFF_PER_BAND_PLC_32_5ms[81] = { - 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, - 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, - 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, - 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160 -}; + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, + 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, + 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, + 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160}; const LC3_INT ACC_COEFF_PER_BAND_PLC_48_5ms[81] = { - 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, - 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120, 123, + 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, + 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120, 123, 126, 129, 132, 135, 138, 141, 144, 147, 150, 153, 156, 159, 162, 165, 168, 171, 174, 177, 180, 183, 186, - 189, 192, 195, 198, 201, 204, 207, 210, 213, 216, 219, 222, 225, 228, 231, 234, 237, 240 -}; + 189, 192, 195, 198, 201, 204, 207, 210, 213, 216, 219, 222, 225, 228, 231, 234, 237, 240}; const LC3_INT ACC_COEFF_PER_BAND_PLC_96_5ms[81] = { - 0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, + 0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, 126, 132, 138, 144, 150, 156, 162, 168, 174, 180, 186, 192, 198, 204, 210, 216, 222, 228, 234, 240, 246, 252, 258, 264, 270, 276, 282, 288, 294, 300, 306, 312, 318, 324, 330, 336, 342, 348, 354, 360, 366, 372, - 378, 384, 390, 396, 402, 408, 414, 420, 426, 432, 438, 444, 450, 456, 462, 468, 474, 480 -}; + 378, 384, 390, 396, 402, 408, 414, 420, 426, 432, 438, 444, 450, 456, 462, 468, 474, 480}; -const LC3_INT *ACC_COEFF_PER_BAND_PLC_5ms[] = { - ACC_COEFF_PER_BAND_PLC_8_5ms, ACC_COEFF_PER_BAND_PLC_16_5ms, ACC_COEFF_PER_BAND_PLC_24_5ms, - ACC_COEFF_PER_BAND_PLC_32_5ms, ACC_COEFF_PER_BAND_PLC_48_5ms, ACC_COEFF_PER_BAND_PLC_96_5ms -}; +const LC3_INT* ACC_COEFF_PER_BAND_PLC_5ms[] = { + ACC_COEFF_PER_BAND_PLC_8_5ms, ACC_COEFF_PER_BAND_PLC_16_5ms, ACC_COEFF_PER_BAND_PLC_24_5ms, + ACC_COEFF_PER_BAND_PLC_32_5ms, ACC_COEFF_PER_BAND_PLC_48_5ms, ACC_COEFF_PER_BAND_PLC_96_5ms}; const LC3_INT32 mdct_grp_bins[10] = { 4, 14, 24, 44, 84, 164, 244, 324, 404, 484 }; + diff --git a/lib_lc3plus/constants.h b/lib_lc3plus/constants.h index de3e093df5..c0c9e286e5 100644 --- a/lib_lc3plus/constants.h +++ b/lib_lc3plus/constants.h @@ -1,12 +1,12 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #ifndef CONSTANTS_H #define CONSTANTS_H @@ -27,7 +27,7 @@ extern const LC3_INT ari_spec_bits_fl[64][17]; /* SNS */ extern const LC3_FLOAT sns_LFCB[8][32]; extern const LC3_FLOAT sns_HFCB[8][32]; -extern const LC3_INT pvq_enc_A[16][11]; +extern const LC3_INT pvq_enc_A[16][11]; extern const LC3_FLOAT idct_lookup[M][M]; /* 12.8 kHz resampler */ @@ -35,15 +35,15 @@ extern const LC3_FLOAT lp_scale_factors[6]; extern const LC3_INT32 resamp_params[][4]; extern const LC3_FLOAT *lp_filter[6]; -extern const LC3_FLOAT highpass50_filt_b[3]; -extern const LC3_FLOAT highpass50_filt_a[3]; -extern const LC3_INT up_fac[6]; +extern const LC3_FLOAT highpass50_filt_b[3]; +extern const LC3_FLOAT highpass50_filt_a[3]; +extern const LC3_INT up_fac[6]; /* TNS */ extern const LC3_FLOAT quants_pts_tns[17]; -extern const LC3_INT huff_bits_tns[8][17]; -extern const LC3_INT order1_tns[8]; -extern const LC3_INT order2_tns[8]; +extern const LC3_INT huff_bits_tns[8][17]; +extern const LC3_INT order1_tns[8]; +extern const LC3_INT order2_tns[8]; extern const LC3_FLOAT lagw_tns[9]; extern const LC3_FLOAT quants_pts_tns[17]; extern const LC3_FLOAT quants_thr_tns[18]; @@ -57,9 +57,9 @@ extern const LC3_FLOAT sns_vq_reg_adj_gains_fl[2]; extern const LC3_FLOAT sns_dec_gains[4][8]; /* Global Gain */ -extern const LC3_INT gg_p1[6]; -extern const LC3_INT gg_p2[6]; -extern const LC3_INT gg_p3[6]; +extern const LC3_INT gg_p1[6]; +extern const LC3_INT gg_p2[6]; +extern const LC3_INT gg_p3[6]; extern const LC3_FLOAT gg_c[6]; extern const LC3_FLOAT gg_d[6]; @@ -82,28 +82,28 @@ extern const LC3_FLOAT enc_inter_filter[4][4]; /* Bandwidth Detector */ extern const LC3_INT threshold_quiet[4]; extern const LC3_INT threshold_brickwall[4]; -extern const LC3_INT brickwall_dist[4]; -extern const LC3_INT BW_warp_idx_start_16k[4]; -extern const LC3_INT BW_warp_idx_stop_16k[4]; -extern const LC3_INT BW_warp_idx_start_24k[4]; -extern const LC3_INT BW_warp_idx_stop_24k[4]; -extern const LC3_INT BW_warp_idx_start_32k[4]; -extern const LC3_INT BW_warp_idx_stop_32k[4]; -extern const LC3_INT BW_warp_idx_start_48k[4]; -extern const LC3_INT BW_warp_idx_stop_48k[4]; -extern const LC3_INT *BW_warp_idx_start_all[4]; -extern const LC3_INT *BW_warp_idx_stop_all[4]; - -extern const LC3_INT BW_warp_idx_start_16k_2_5ms[4]; -extern const LC3_INT BW_warp_idx_stop_16k_2_5ms[4]; -extern const LC3_INT BW_warp_idx_start_24k_2_5ms[4]; -extern const LC3_INT BW_warp_idx_stop_24k_2_5ms[4]; -extern const LC3_INT BW_warp_idx_start_32k_2_5ms[4]; -extern const LC3_INT BW_warp_idx_stop_32k_2_5ms[4]; -extern const LC3_INT BW_warp_idx_start_48k_2_5ms[4]; -extern const LC3_INT BW_warp_idx_stop_48k_2_5ms[4]; -extern const LC3_INT *BW_warp_idx_start_all_2_5ms[4]; -extern const LC3_INT *BW_warp_idx_stop_all_2_5ms[4]; +extern const LC3_INT brickwall_dist[4]; +extern const LC3_INT BW_warp_idx_start_16k[4]; +extern const LC3_INT BW_warp_idx_stop_16k[4]; +extern const LC3_INT BW_warp_idx_start_24k[4]; +extern const LC3_INT BW_warp_idx_stop_24k[4]; +extern const LC3_INT BW_warp_idx_start_32k[4]; +extern const LC3_INT BW_warp_idx_stop_32k[4]; +extern const LC3_INT BW_warp_idx_start_48k[4]; +extern const LC3_INT BW_warp_idx_stop_48k[4]; +extern const LC3_INT* BW_warp_idx_start_all[4]; +extern const LC3_INT* BW_warp_idx_stop_all[4]; + +extern const LC3_INT BW_warp_idx_start_16k_2_5ms[4]; +extern const LC3_INT BW_warp_idx_stop_16k_2_5ms[4]; +extern const LC3_INT BW_warp_idx_start_24k_2_5ms[4]; +extern const LC3_INT BW_warp_idx_stop_24k_2_5ms[4]; +extern const LC3_INT BW_warp_idx_start_32k_2_5ms[4]; +extern const LC3_INT BW_warp_idx_stop_32k_2_5ms[4]; +extern const LC3_INT BW_warp_idx_start_48k_2_5ms[4]; +extern const LC3_INT BW_warp_idx_stop_48k_2_5ms[4]; +extern const LC3_INT* BW_warp_idx_start_all_2_5ms[4]; +extern const LC3_INT* BW_warp_idx_stop_all_2_5ms[4]; extern const LC3_INT BW_cutoff_bin_all_2_5ms_HR[MAX_BW_BANDS_NUMBER]; extern const LC3_INT bands_number_2_5ms_HR[6]; @@ -111,17 +111,17 @@ extern const LC3_INT BW_cutoff_bin_all_2_5ms[MAX_BW_BANDS_NUMBER]; extern const LC3_INT bands_number_2_5ms[5]; -extern const LC3_INT BW_warp_idx_start_16k_5ms[4]; -extern const LC3_INT BW_warp_idx_stop_16k_5ms[4]; -extern const LC3_INT BW_warp_idx_start_24k_5ms[4]; -extern const LC3_INT BW_warp_idx_stop_24k_5ms[4]; -extern const LC3_INT BW_warp_idx_start_32k_5ms[4]; -extern const LC3_INT BW_warp_idx_stop_32k_5ms[4]; -extern const LC3_INT BW_warp_idx_start_48k_5ms[4]; -extern const LC3_INT BW_warp_idx_stop_48k_5ms[4]; -extern const LC3_INT *BW_warp_idx_start_all_5ms[4]; -extern const LC3_INT *BW_warp_idx_stop_all_5ms[4]; -extern const LC3_INT BW_cutoff_bin_all_5ms[MAX_BW_BANDS_NUMBER]; +extern const LC3_INT BW_warp_idx_start_16k_5ms[4]; +extern const LC3_INT BW_warp_idx_stop_16k_5ms[4]; +extern const LC3_INT BW_warp_idx_start_24k_5ms[4]; +extern const LC3_INT BW_warp_idx_stop_24k_5ms[4]; +extern const LC3_INT BW_warp_idx_start_32k_5ms[4]; +extern const LC3_INT BW_warp_idx_stop_32k_5ms[4]; +extern const LC3_INT BW_warp_idx_start_48k_5ms[4]; +extern const LC3_INT BW_warp_idx_stop_48k_5ms[4]; +extern const LC3_INT* BW_warp_idx_start_all_5ms[4]; +extern const LC3_INT* BW_warp_idx_stop_all_5ms[4]; +extern const LC3_INT BW_cutoff_bin_all_5ms[MAX_BW_BANDS_NUMBER]; extern const LC3_INT bands_number_5ms[6]; extern const LC3_INT BW_cutoff_bin_all_HR[MAX_BW_BANDS_NUMBER]; extern const LC3_INT BW_cutoff_bin_all_5ms_HR[MAX_BW_BANDS_NUMBER]; @@ -139,16 +139,16 @@ extern const LC3_FLOAT MDCT_WINDOW_240[480]; extern const LC3_FLOAT MDCT_WINDOW_320[640]; extern const LC3_FLOAT MDCT_WINDOW_480[960]; extern const LC3_FLOAT MDCT_WINDOW_960[1920]; -extern const LC3_FLOAT *MDCT_WINS_10ms[2][6]; -extern const LC3_INT MDCT_la_zeroes[6]; +extern const LC3_FLOAT* MDCT_WINS_10ms[2][6]; +extern const LC3_INT MDCT_la_zeroes[6]; extern const LC3_FLOAT MDCT_WINDOW_80_2_5ms[40]; extern const LC3_FLOAT MDCT_WINDOW_160_2_5ms[80]; extern const LC3_FLOAT MDCT_WINDOW_240_2_5ms[120]; extern const LC3_FLOAT MDCT_WINDOW_320_2_5ms[160]; extern const LC3_FLOAT MDCT_WINDOW_480_2_5ms[240]; -extern const LC3_FLOAT *MDCT_WINS_2_5ms[2][6]; -extern const LC3_INT MDCT_la_zeroes_2_5ms[6]; +extern const LC3_FLOAT* MDCT_WINS_2_5ms[2][6]; +extern const LC3_INT MDCT_la_zeroes_2_5ms[6]; extern const LC3_FLOAT MDCT_WINDOW_80_5ms[80]; @@ -156,8 +156,8 @@ extern const LC3_FLOAT MDCT_WINDOW_160_5ms[160]; extern const LC3_FLOAT MDCT_WINDOW_240_5ms[240]; extern const LC3_FLOAT MDCT_WINDOW_320_5ms[320]; extern const LC3_FLOAT MDCT_WINDOW_480_5ms[480]; -extern const LC3_FLOAT *MDCT_WINS_5ms[2][6]; -extern const LC3_INT MDCT_la_zeroes_5ms[6]; +extern const LC3_FLOAT* MDCT_WINS_5ms[2][6]; +extern const LC3_INT MDCT_la_zeroes_5ms[6]; extern const LC3_INT MDCT_WINDOWS_LENGTHS_10ms[6]; @@ -167,15 +167,15 @@ extern const LC3_INT MDCT_WINDOWS_LENGTHS_2_5ms[6]; extern const LC3_INT MDCT_WINDOWS_LENGTHS_5ms[6]; /* Per band energy */ -extern const LC3_INT *ACC_COEFF_PER_BAND[6]; -extern const LC3_INT *ACC_COEFF_PER_BAND_HR[6]; +extern const LC3_INT* ACC_COEFF_PER_BAND[6]; +extern const LC3_INT* ACC_COEFF_PER_BAND_HR[6]; -extern const LC3_INT *ACC_COEFF_PER_BAND_2_5ms_HR[6]; -extern const LC3_INT *ACC_COEFF_PER_BAND_2_5ms[5]; +extern const LC3_INT* ACC_COEFF_PER_BAND_2_5ms_HR[6]; +extern const LC3_INT* ACC_COEFF_PER_BAND_2_5ms[5]; -extern const LC3_INT *ACC_COEFF_PER_BAND_5ms_HR[6]; -extern const LC3_INT *ACC_COEFF_PER_BAND_5ms[5]; +extern const LC3_INT* ACC_COEFF_PER_BAND_5ms_HR[6]; +extern const LC3_INT* ACC_COEFF_PER_BAND_5ms[5]; /* Near Nyquist detector */ extern const LC3_INT NN_thresh; @@ -183,14 +183,14 @@ extern const LC3_INT NN_thresh; extern const LC3_INT32 xavg_N_grp[5]; extern const LC3_FLOAT *hannOla_wins[5]; -extern const LC3_INT32 gwlpr[MAX_LGW + 1]; +extern const LC3_INT32 gwlpr[MAX_LGW+1]; extern const LC3_INT32 mdct_grp_bins[10]; -extern const LC3_FLOAT *PhECU_whr16ms_wins[5]; +extern const LC3_FLOAT* PhECU_whr16ms_wins[5]; extern const LC3_FLOAT plc_preemph_fac[]; -extern const LC3_INT *ACC_COEFF_PER_BAND_PLC[]; -extern const LC3_INT *ACC_COEFF_PER_BAND_PLC_2_5ms[]; -extern const LC3_INT *ACC_COEFF_PER_BAND_PLC_5ms[]; +extern const LC3_INT* ACC_COEFF_PER_BAND_PLC[]; +extern const LC3_INT* ACC_COEFF_PER_BAND_PLC_2_5ms[]; +extern const LC3_INT* ACC_COEFF_PER_BAND_PLC_5ms[]; extern const LC3_FLOAT *plc_tdc_lpc_all[6]; extern const LC3_FLOAT plc_tdc_lpc_8[17]; extern const LC3_FLOAT plc_tdc_lpc_16[17]; diff --git a/lib_lc3plus/cutoff_bandwidth.c b/lib_lc3plus/cutoff_bandwidth.c index 3bfa6278b3..642b2afda2 100644 --- a/lib_lc3plus/cutoff_bandwidth.c +++ b/lib_lc3plus/cutoff_bandwidth.c @@ -1,30 +1,27 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -void process_cutoff_bandwidth( LC3_FLOAT *d_fl, LC3_INT len, LC3_INT bw_bin ) +void process_cutoff_bandwidth(LC3_FLOAT *d_fl, LC3_INT len, LC3_INT bw_bin) { LC3_INT i = 0; - - if ( len > bw_bin ) - { - for ( i = -1; i < 3; i++ ) - { - d_fl[bw_bin + i] = d_fl[bw_bin + i] * LC3_POW( 2, -( i + 2 ) ); + + if (len > bw_bin){ + for (i = -1; i < 3; i++) { + d_fl[bw_bin + i] = d_fl[bw_bin + i] * LC3_POW(2, -(i + 2)); } - for ( i = bw_bin + 3; i < len; i++ ) - { + for (i = bw_bin + 3; i < len; i++) { d_fl[i] = 0; - } + } } } diff --git a/lib_lc3plus/dct4.c b/lib_lc3plus/dct4.c index a9b146a2af..8fd5784b28 100644 --- a/lib_lc3plus/dct4.c +++ b/lib_lc3plus/dct4.c @@ -1,102 +1,95 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -void dct2_init( Dct2 *dct, int length ) +void dct2_init(Dct2* dct, int length) { - assert( length <= MAX_LEN ); + assert(length <= MAX_LEN); dct->length = length; - fft_init( &dct->fft, length ); + fft_init(&dct->fft, length); } -void dct2_free( Dct2 *dct ) +void dct2_free(Dct2* dct) { - if ( dct ) - { - fft_free( &dct->fft ); - memset( dct, 0, sizeof( *dct ) ); + if (dct) { + fft_free(&dct->fft); + memset(dct, 0, sizeof(*dct)); } } -void dct2_apply( Dct2 *dct, const LC3_FLOAT *input, LC3_FLOAT *output ) +void dct2_apply(Dct2* dct, const LC3_FLOAT* input, LC3_FLOAT* output) { - Complex tmp1[MAX_LEN]; - Complex tmp2[MAX_LEN]; - int i = 0; + Complex tmp1[MAX_LEN]; + Complex tmp2[MAX_LEN]; + int i = 0; const int len = dct->length; - assert( input != output ); + assert(input != output); - for ( i = 0; i < len / 2; i++ ) - { - tmp1[i] = cmplx( input[i * 2], 0 ); - tmp1[len - i - 1] = cmplx( input[i * 2 + 1], 0 ); + for (i = 0; i < len / 2; i++) { + tmp1[i] = cmplx(input[i * 2], 0); + tmp1[len - i - 1] = cmplx(input[i * 2 + 1], 0); } - fft_apply( &dct->fft, tmp1, tmp2 ); + fft_apply(&dct->fft, tmp1, tmp2); - for ( i = 0; i < len; i++ ) - { - output[i] = cmul( tmp2[i], dct2_16[i] ).r; + for (i = 0; i < len; i++) { + output[i] = cmul(tmp2[i], dct2_16[i]).r; } - output[0] /= (LC3_FLOAT) 1.414213562373095; /* SQRT(2) */ + output[0] /= (LC3_FLOAT)1.414213562373095; /* SQRT(2) */ } -void dct4_init( Dct4 *dct, int length ) +void dct4_init(Dct4* dct, int length) { - int i = 0; - assert( length <= MAX_LEN ); + int i = 0; + assert(length <= MAX_LEN); dct->length = length; - dct->twid1 = calloc( sizeof( *dct->twid1 ), length / 2 ); - dct->twid2 = calloc( sizeof( *dct->twid2 ), length / 2 ); - for ( i = 0; i < length / 2; i++ ) - { - dct->twid1[i] = cexpi( -(LC3_FLOAT) M_PI * ( i + (LC3_FLOAT) 0.25 ) / length ); - dct->twid2[i] = cexpi( -(LC3_FLOAT) M_PI * i / length ); + dct->twid1 = calloc(sizeof(*dct->twid1), length / 2); + dct->twid2 = calloc(sizeof(*dct->twid2), length / 2); + for (i = 0; i < length / 2; i++) { + dct->twid1[i] = cexpi(-(LC3_FLOAT)M_PI * (i + (LC3_FLOAT)0.25) / length); + dct->twid2[i] = cexpi(-(LC3_FLOAT)M_PI * i / length); } - fft_init( &dct->fft, length / 2 ); + fft_init(&dct->fft, length / 2); } -void dct4_free( Dct4 *dct ) +void dct4_free(Dct4* dct) { - if ( dct ) - { - free( dct->twid1 ); - free( dct->twid2 ); - fft_free( &dct->fft ); - memset( dct, 0, sizeof( *dct ) ); + if (dct) { + free(dct->twid1); + free(dct->twid2); + fft_free(&dct->fft); + memset(dct, 0, sizeof(*dct)); } } -void dct4_apply( Dct4 *dct, const LC3_FLOAT *input, LC3_FLOAT *output ) +void dct4_apply(Dct4* dct, const LC3_FLOAT* input, LC3_FLOAT* output) { - Complex tmp2[MAX_LEN / 2]; - int i = 0; - Complex *tmp1 = (Complex *) output; - const int len = dct->length; - const LC3_FLOAT norm = (LC3_FLOAT) 1.0 / LC3_SQRT( (LC3_FLOAT) ( len >> 1 ) ); - assert( input != output ); + Complex tmp2[MAX_LEN / 2]; + int i = 0; + Complex* tmp1 = (Complex*)output; + const int len = dct->length; + const LC3_FLOAT norm = (LC3_FLOAT)1.0 / LC3_SQRT((LC3_FLOAT)(len >> 1)); + assert(input != output); - for ( i = 0; i < len / 2; i++ ) - { - tmp1[i] = cmul( cmplx( input[i * 2], input[len - i * 2 - 1] ), dct->twid1[i] ); + for (i = 0; i < len / 2; i++) { + tmp1[i] = cmul(cmplx(input[i * 2], input[len - i * 2 - 1]), dct->twid1[i]); } - fft_apply( &dct->fft, tmp1, tmp2 ); + fft_apply(&dct->fft, tmp1, tmp2); - for ( i = 0; i < len / 2; i++ ) - { - Complex t = cmul( tmp2[i], dct->twid2[i] ); - output[i * 2] = t.r * norm; + for (i = 0; i < len / 2; i++) { + Complex t = cmul(tmp2[i], dct->twid2[i]); + output[i * 2] = t.r * norm; output[len - i * 2 - 1] = -t.i * norm; } } diff --git a/lib_lc3plus/dec_entropy.c b/lib_lc3plus/dec_entropy.c index 38f8f76a8d..d8512a1068 100644 --- a/lib_lc3plus/dec_entropy.c +++ b/lib_lc3plus/dec_entropy.c @@ -1,284 +1,253 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -static void read_bit_fl( LC3_UINT8 *ptr, LC3_INT *mask_side, LC3_INT *bp_side, LC3_INT *bit ); -static void read_uint_fl( LC3_INT nbits, LC3_UINT8 *ptr, LC3_INT *mask_side, LC3_INT *bp_side, LC3_INT *val ); +static void read_bit_fl(LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* bit); +static void read_uint_fl(LC3_INT nbits, LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* val); -void read_bit_fl( LC3_UINT8 *ptr, LC3_INT *mask_side, LC3_INT *bp_side, LC3_INT *bit ) +void read_bit_fl(LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* bit) { - if ( ptr[*bp_side] & *mask_side ) - { + if (ptr[*bp_side] & *mask_side) { *bit = 1; - } - else - { + } else { *bit = 0; } - if ( *mask_side == 128 ) - { + if (*mask_side == 128) { *mask_side = 1; - *bp_side = *bp_side - 1; - } - else - { + *bp_side = *bp_side - 1; + } else { *mask_side = *mask_side * 2; } } -void read_uint_fl( LC3_INT nbits, LC3_UINT8 *ptr, LC3_INT *mask_side, LC3_INT *bp_side, LC3_INT *val ) +void read_uint_fl(LC3_INT nbits, LC3_UINT8* ptr, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT* val) { LC3_INT bit = 0, i = 0; - read_bit_fl( ptr, mask_side, bp_side, val ); + read_bit_fl(ptr, mask_side, bp_side, val); - for ( i = 1; i < nbits; i++ ) - { - read_bit_fl( ptr, mask_side, bp_side, &bit ); - *val = *val + ( bit << i ); + for (i = 1; i < nbits; i++) { + read_bit_fl(ptr, mask_side, bp_side, &bit); + *val = *val + (bit << i); } } #ifdef ENABLE_PADDING -LC3_INT paddingDec_fl( LC3_UINT8 *bytes, LC3_INT nbbits, LC3_INT L_spec, LC3_INT bw_cutoff_bits, LC3_INT ep_enabled, LC3_INT *total_padding, LC3_INT *np_zero ) +LC3_INT paddingDec_fl(LC3_UINT8* bytes, LC3_INT nbbits, LC3_INT L_spec, LC3_INT bw_cutoff_bits, LC3_INT ep_enabled, LC3_INT* total_padding, LC3_INT *np_zero) { LC3_INT lastnz_threshold; LC3_INT val, padding_len_bits, padding_len; LC3_INT bp_side; - LC3_INT mask_side; - LC3_UINT8 *ptr = bytes; + LC3_INT mask_side; + LC3_UINT8* ptr = bytes; LC3_INT nbbytes = nbbits >> 3; LC3_INT lastnz; LC3_INT bw_cutoff_idx; - LC3_INT nbits = ceil( LC3_LOGTWO( L_spec / 2 ) ); - - if ( nbits > nbbits ) + LC3_INT nbits = ceil(LC3_LOGTWO(L_spec / 2)); + + if (nbits > nbbits) { return 1; } - + *np_zero = 0; *total_padding = 0; - bp_side = ( nbbits - 1 ) >> 3; - mask_side = 1 << ( 8 - ( nbbits - ( bp_side << 3 ) ) ); + bp_side = (nbbits - 1) >> 3; + mask_side = 1 << (8 - (nbbits - (bp_side << 3))); - if ( bp_side < 19 || bp_side >= LC3PLUS_MAX_BYTES ) - { + if (bp_side < 19 || bp_side >= LC3PLUS_MAX_BYTES) { return 1; } - + ptr = bytes; - if ( bw_cutoff_bits > 0 ) - { - read_uint_fl( bw_cutoff_bits, ptr, &mask_side, &bp_side, &bw_cutoff_idx ); + if (bw_cutoff_bits > 0) { + read_uint_fl(bw_cutoff_bits, ptr, &mask_side, &bp_side, &bw_cutoff_idx); } - read_uint_fl( nbits, ptr, &mask_side, &bp_side, &lastnz ); + read_uint_fl(nbits, ptr, &mask_side, &bp_side, &lastnz); - lastnz_threshold = ( 1 << nbits ) - 1 - 1; + lastnz_threshold = (1 << nbits) - 1 - 1; - while ( lastnz == lastnz_threshold ) - { + while (lastnz == lastnz_threshold) { padding_len_bits = 16 - nbits - bw_cutoff_bits - 4; /*Read padding length*/ - read_uint_fl( padding_len_bits, ptr, &mask_side, &bp_side, &padding_len ); + read_uint_fl(padding_len_bits, ptr, &mask_side, &bp_side, &padding_len); /* Read 4 reserved bits */ - read_uint_fl( 4, ptr, &mask_side, &bp_side, &val ); - - if ( ep_enabled == 0 ) + read_uint_fl(4, ptr, &mask_side, &bp_side, &val); + + if (ep_enabled == 0) { /* Discard padding length bytes */ - bp_side = bp_side - padding_len; + bp_side = bp_side - padding_len; *total_padding = *total_padding + padding_len + 2; } else { *total_padding = *total_padding + 2; - *np_zero = *np_zero + padding_len; + *np_zero = *np_zero + padding_len; } - + /* check if minimum payload size is reached */ - if ( ( nbbytes - ( *total_padding + *np_zero ) ) < 20 ) - { + if ((nbbytes - (*total_padding + *np_zero)) < 20) { return 1; } /* Read bandwidth bits */ - if ( bw_cutoff_bits > 0 ) - { - read_uint_fl( bw_cutoff_bits, ptr, &mask_side, &bp_side, &bw_cutoff_idx ); + if (bw_cutoff_bits > 0) { + read_uint_fl(bw_cutoff_bits, ptr, &mask_side, &bp_side, &bw_cutoff_idx); } - read_uint_fl( nbits, ptr, &mask_side, &bp_side, &lastnz ); + read_uint_fl(nbits, ptr, &mask_side, &bp_side, &lastnz); } - - if ( ep_enabled != 0 ) + + if (ep_enabled != 0) { *total_padding = *total_padding + *np_zero; } - + return 0; } #endif -void processDecoderEntropy_fl( LC3_UINT8 *bytes, LC3_INT numbytes, LC3_INT *mask_side, LC3_INT *bp_side, LC3_INT N, LC3_INT fs_idx, LC3_INT bw_cutoff_bits, LC3_INT *bfi, LC3_INT *gg_idx, LC3_INT *scf_idx, LC3_INT *fac_ns_idx, LC3_INT *tns_numfilters, LC3_INT *tns_order, LC3_INT *ltpf_idx, LC3_INT *bw_cutoff_idx, LC3_INT *lastnz, LC3_INT *lsbMode, LC3_INT frame_dms ) +void processDecoderEntropy_fl(LC3_UINT8* bytes, LC3_INT numbytes, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT N, LC3_INT fs_idx, + LC3_INT bw_cutoff_bits, LC3_INT* bfi, LC3_INT* gg_idx, LC3_INT* scf_idx, LC3_INT* fac_ns_idx, + LC3_INT* tns_numfilters, LC3_INT* tns_order, LC3_INT* ltpf_idx, LC3_INT* bw_cutoff_idx, LC3_INT* lastnz, + LC3_INT* lsbMode, LC3_INT frame_dms) { LC3_INT plc_trigger_bw = 0, plc_trigger_last_nz = 0, plc_trigger_SNS1 = 0, plc_trigger_SNS2 = 0, tmp = 0, bit = 0, - submodeMSB = 0, i = 0, ltpf_tmp[3] = { 0 }, ind = 0, submodeLSB = 0, bp_side_local = 0, mask_side_local = 0; - LC3_UINT8 *ptr; - LC3_INT gainMSBbits[4] = { 1, 1, 2, 2 }; + submodeMSB = 0, i = 0, ltpf_tmp[3] = {0}, ind = 0, submodeLSB = 0, bp_side_local = 0, mask_side_local = 0; + LC3_UINT8* ptr; + LC3_INT gainMSBbits[4] = {1, 1, 2, 2}; *bp_side = -1; - bp_side_local = numbytes - 1; /* Matlab offset by 1 */ + bp_side_local = numbytes - 1; /* Matlab offset by 1 */ mask_side_local = 1; *mask_side = -1; - ptr = bytes; + ptr = bytes; *lsbMode = -1; *lastnz = -1; - plc_trigger_bw = 1; /* Bandwidth */ + plc_trigger_bw = 1; /* Bandwidth */ plc_trigger_last_nz = 1; /* Last non-zero tuple */ - plc_trigger_SNS1 = 1; /* SNS-VQ 2nd stage MPVQ data (24-25 bits) */ - plc_trigger_SNS2 = 1; /* SNS-VQ 2nd stage MPVQ data (24-25 bits) */ - + plc_trigger_SNS1 = 1; /* SNS-VQ 2nd stage MPVQ data (24-25 bits) */ + plc_trigger_SNS2 = 1; /* SNS-VQ 2nd stage MPVQ data (24-25 bits) */ + + /* Bandwidth */ - if ( bw_cutoff_bits > 0 ) - { - read_uint_fl( bw_cutoff_bits, ptr, &mask_side_local, &bp_side_local, bw_cutoff_idx ); + if (bw_cutoff_bits > 0) { + read_uint_fl(bw_cutoff_bits, ptr, &mask_side_local, &bp_side_local, bw_cutoff_idx); - if ( fs_idx < *bw_cutoff_idx ) - { + if (fs_idx < *bw_cutoff_idx) { *bfi = plc_trigger_bw; - if ( *bfi ) - { + if (*bfi) { return; } } - } - else - { + } else { *bw_cutoff_idx = fs_idx; } /* Number of TNS filters */ - if ( *bw_cutoff_idx < 3 || frame_dms == 25 ) - { + if (*bw_cutoff_idx < 3 || frame_dms == 25) { *tns_numfilters = 1; - } - else - { + } else { *tns_numfilters = 2; } /* Last non-zero tuple */ - read_uint_fl( ceil( LC3_LOGTWO( N / 2 ) ), ptr, &mask_side_local, &bp_side_local, lastnz ); - *lastnz = ( *lastnz + 1 ) * 2; + read_uint_fl(ceil(LC3_LOGTWO(N / 2)), ptr, &mask_side_local, &bp_side_local, lastnz); + *lastnz = (*lastnz + 1) * 2; - if ( *lastnz > N ) - { + if (*lastnz > N) { *bfi = plc_trigger_last_nz; - if ( *bfi ) - { + if (*bfi) { return; } } /* LSB mode bit */ - read_bit_fl( ptr, &mask_side_local, &bp_side_local, lsbMode ); + read_bit_fl(ptr, &mask_side_local, &bp_side_local, lsbMode); /* Global gain */ - read_uint_fl( 8, ptr, &mask_side_local, &bp_side_local, gg_idx ); + read_uint_fl(8, ptr, &mask_side_local, &bp_side_local, gg_idx); /* TNS activation flag */ - for ( i = 0; i < *tns_numfilters; i++ ) - { - read_bit_fl( ptr, &mask_side_local, &bp_side_local, &bit ); + for (i = 0; i < *tns_numfilters; i++) { + read_bit_fl(ptr, &mask_side_local, &bp_side_local, &bit); tns_order[i] = bit; } /* LTPF activation flag */ - read_bit_fl( ptr, &mask_side_local, &bp_side_local, <pf_tmp[0] ); + read_bit_fl(ptr, &mask_side_local, &bp_side_local, <pf_tmp[0]); /* SNS-VQ 1st stage */ - read_uint_fl( 5, ptr, &mask_side_local, &bp_side_local, &scf_idx[0] ); - read_uint_fl( 5, ptr, &mask_side_local, &bp_side_local, &scf_idx[1] ); + read_uint_fl(5, ptr, &mask_side_local, &bp_side_local, &scf_idx[0]); + read_uint_fl(5, ptr, &mask_side_local, &bp_side_local, &scf_idx[1]); /* SNS-VQ 2nd stage side-info (3-4 bits) */ - read_bit_fl( ptr, &mask_side_local, &bp_side_local, &submodeMSB ); + read_bit_fl(ptr, &mask_side_local, &bp_side_local, &submodeMSB); scf_idx[2] = submodeMSB * 2; - read_uint_fl( gainMSBbits[scf_idx[2]], ptr, &mask_side_local, &bp_side_local, &scf_idx[3] ); - read_bit_fl( ptr, &mask_side_local, &bp_side_local, &scf_idx[4] ); + read_uint_fl(gainMSBbits[scf_idx[2]], ptr, &mask_side_local, &bp_side_local, &scf_idx[3]); + read_bit_fl(ptr, &mask_side_local, &bp_side_local, &scf_idx[4]); /* SNS-VQ 2nd stage MPVQ data (24-25 bits) */ - if ( submodeMSB == 0 ) - { - read_uint_fl( 25, ptr, &mask_side_local, &bp_side_local, &tmp ); - if ( tmp >= 33460056 ) - { + if (submodeMSB == 0) { + read_uint_fl(25, ptr, &mask_side_local, &bp_side_local, &tmp); + if (tmp >= 33460056) { *bfi = plc_trigger_SNS1; - if ( *bfi ) - { + if (*bfi) { return; } } - ind = floor( tmp / 2390004 ); + ind = floor(tmp / 2390004); scf_idx[5] = tmp - ind * 2390004; - if ( ind < 2 ) - { + if (ind < 2) { submodeLSB = 1; scf_idx[3] = scf_idx[3] * 2 + ind; scf_idx[6] = -2; - } - else - { + } else { submodeLSB = 0; scf_idx[6] = ind - 2; } - } - else - { - read_uint_fl( 24, ptr, &mask_side_local, &bp_side_local, &tmp ); - if ( tmp >= 16708096 ) - { + } else { + read_uint_fl(24, ptr, &mask_side_local, &bp_side_local, &tmp); + + if (tmp >= 16708096) { *bfi = plc_trigger_SNS2; - if ( *bfi ) - { + if (*bfi) { return; } } - if ( tmp >= 15158272 ) - { + if (tmp >= 15158272) { submodeLSB = 1; - scf_idx[3] = scf_idx[3] * 2 + ( ( tmp - 15158272 ) & 1 ); - scf_idx[5] = floor( ( tmp - 15158272 ) / 2 ); + scf_idx[3] = scf_idx[3] * 2 + ((tmp - 15158272) & 1); + scf_idx[5] = floor((tmp - 15158272) / 2); scf_idx[6] = -2; - } - else - { + } else { submodeLSB = 0; scf_idx[5] = tmp; scf_idx[6] = -1; @@ -288,25 +257,21 @@ void processDecoderEntropy_fl( LC3_UINT8 *bytes, LC3_INT numbytes, LC3_INT *mask scf_idx[2] = scf_idx[2] + submodeLSB; /* LTPF data */ - if ( ltpf_tmp[0] == 1 ) - { - read_bit_fl( ptr, &mask_side_local, &bp_side_local, <pf_tmp[1] ); - read_uint_fl( 9, ptr, &mask_side_local, &bp_side_local, <pf_tmp[2] ); - } - else - { + if (ltpf_tmp[0] == 1) { + read_bit_fl(ptr, &mask_side_local, &bp_side_local, <pf_tmp[1]); + read_uint_fl(9, ptr, &mask_side_local, &bp_side_local, <pf_tmp[2]); + } else { ltpf_tmp[1] = 0; ltpf_tmp[2] = 0; } - for ( i = 0; i < 3; i++ ) - { + for (i = 0; i < 3; i++) { ltpf_idx[i] = ltpf_tmp[i]; } /* Noise factor */ - read_uint_fl( 3, ptr, &mask_side_local, &bp_side_local, fac_ns_idx ); - + read_uint_fl(3, ptr, &mask_side_local, &bp_side_local, fac_ns_idx); + *bp_side = bp_side_local; *mask_side = mask_side_local; } diff --git a/lib_lc3plus/dec_lc3_fl.c b/lib_lc3plus/dec_lc3_fl.c index 995e710f9d..88c528b0f6 100644 --- a/lib_lc3plus/dec_lc3_fl.c +++ b/lib_lc3plus/dec_lc3_fl.c @@ -1,286 +1,282 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -static int Dec_LC3PLUS_Channel_fl( LC3PLUS_Dec *decoder, int channel, uint8_t *bs_in, void *s_out, int bps, int bfi_ext ) +static int Dec_LC3PLUS_Channel_fl(LC3PLUS_Dec* decoder, int channel, uint8_t* bs_in, void* s_out, int bps, int bfi_ext) { - DecSetup *h_DecSetup; - LC3_INT mask_side = 0, bp_side = 0, bfi = 0, gg_idx = 0, fac_ns_idx = 0, tns_numfilters = 0, bw_cutoff_idx = 0, - lastnz = 0, lsbMode = 0, nf_seed = 0, zero_frame = 0, residualPresent = 0, nbits_residual = 0, bitsRead = 0, - i = 0, tns_order[2] = { 0 }, sqQdec[MAX_LEN] = { 0 }; + DecSetup* h_DecSetup; + LC3_INT mask_side = 0, bp_side = 0, bfi = 0, gg_idx = 0, fac_ns_idx = 0, tns_numfilters = 0, bw_cutoff_idx = 0, + lastnz = 0, lsbMode = 0, nf_seed = 0, zero_frame = 0, residualPresent = 0, nbits_residual = 0, bitsRead = 0, + i = 0, tns_order[2] = {0}, sqQdec[MAX_LEN] = {0}; LC3_INT b_left; LC3_FLOAT stab_fac = 0; h_DecSetup = decoder->channel_setup[channel]; - - memset( h_DecSetup->tns_idx, 0, sizeof( *h_DecSetup->tns_idx ) * TNS_NUMFILTERS_MAX * MAXLAG ); + + memset(h_DecSetup->tns_idx, 0, sizeof(*h_DecSetup->tns_idx) * TNS_NUMFILTERS_MAX * MAXLAG); bfi = bfi_ext; decoder->rframe = 0; - if ( bfi == 3 ) + if (bfi == 3) { bfi = 2; decoder->rframe = 1; } /* Entropy decoding */ - if ( bfi != 1 ) - { - processDecoderEntropy_fl( bs_in, h_DecSetup->targetBytes, &mask_side, &bp_side, decoder->yLen, decoder->fs_idx, - decoder->BW_cutoff_bits, &bfi, &gg_idx, h_DecSetup->scf_idx, &fac_ns_idx, - &tns_numfilters, tns_order, h_DecSetup->ltpf_param, &bw_cutoff_idx, &lastnz, &lsbMode, decoder->frame_dms ); + if (bfi != 1) { + processDecoderEntropy_fl(bs_in, h_DecSetup->targetBytes, &mask_side, &bp_side, decoder->yLen, decoder->fs_idx, + decoder->BW_cutoff_bits, &bfi, &gg_idx, h_DecSetup->scf_idx, &fac_ns_idx, + &tns_numfilters, tns_order, h_DecSetup->ltpf_param, &bw_cutoff_idx, &lastnz, &lsbMode, decoder->frame_dms + ); h_DecSetup->BW_cutoff_idx_nf = bw_cutoff_idx; } - + /* Arithmetic decoding */ - if ( bfi != 1 ) - { - processAriDecoder_fl( bs_in, bp_side, mask_side, decoder->yLen, decoder->fs_idx, - h_DecSetup->enable_lpc_weighting, tns_numfilters, lsbMode, lastnz, &bfi, tns_order, fac_ns_idx, gg_idx, h_DecSetup->resBits, - sqQdec, &nf_seed, h_DecSetup->tns_idx, &zero_frame, h_DecSetup->targetBytes, &nbits_residual, &residualPresent, decoder->frame_dms, - decoder->n_pc, decoder->be_bp_left, decoder->be_bp_right, 0, &b_left, &h_DecSetup->spec_inv_idx, - decoder->hrmode ); - - if ( decoder->rframe == 1 && zero_frame == 0 && bfi != 1 ) + if (bfi != 1) { + processAriDecoder_fl(bs_in, bp_side, mask_side, decoder->yLen, decoder->fs_idx, + h_DecSetup->enable_lpc_weighting, tns_numfilters, lsbMode, lastnz, &bfi, tns_order, fac_ns_idx, gg_idx, h_DecSetup->resBits, + sqQdec, &nf_seed, h_DecSetup->tns_idx, &zero_frame, h_DecSetup->targetBytes, &nbits_residual, &residualPresent, decoder->frame_dms, + decoder->n_pc, decoder->be_bp_left, decoder->be_bp_right, 0, &b_left, &h_DecSetup->spec_inv_idx, + decoder->hrmode + ); + + if (decoder->rframe == 1 && zero_frame == 0 && bfi != 1) { LC3_INT32 max_bw_stopband = BW_cutoff_bin_all[bw_cutoff_idx]; bfi = 2; - switch ( decoder->frame_dms ) + switch (decoder->frame_dms) { -#ifdef ENABLE_025_DMS_MODE - case 25: - max_bw_stopband = max_bw_stopband >> 2; - break; -#endif -#ifdef ENABLE_050_DMS_MODE - case 50: - max_bw_stopband = max_bw_stopband >> 1; - break; -#endif -#ifdef ENABLE_075_DMS_MODE - case 75: - max_bw_stopband = 3 * ( max_bw_stopband >> 2 ); - break; -#endif - case 100: - break; +# ifdef ENABLE_025_DMS_MODE + case 25: + max_bw_stopband = max_bw_stopband >> 2; + break; +# endif +# ifdef ENABLE_050_DMS_MODE + case 50: + max_bw_stopband = max_bw_stopband >> 1; + break; +# endif +# ifdef ENABLE_075_DMS_MODE + case 75: + max_bw_stopband = 3 * (max_bw_stopband >> 2); + break; +# endif + case 100: + break; } - - h_DecSetup->spec_inv_idx = MAX( lastnz, max_bw_stopband ); + + h_DecSetup->spec_inv_idx = MAX(lastnz, max_bw_stopband); } /* Cast from int to float */ - for ( i = 0; i < decoder->yLen; i++ ) - { - h_DecSetup->sqQdec_fl[i] = (LC3_FLOAT) sqQdec[i]; + for (i = 0; i < decoder->yLen; i++) { + h_DecSetup->sqQdec_fl[i] = (LC3_FLOAT)sqQdec[i]; } } - - if ( bfi != 1 ) + + if (bfi != 1) { /* SNS Quantize Decoder */ - process_snsQuantizesScf_Dec( h_DecSetup->scf_idx, h_DecSetup->scf_q ); + process_snsQuantizesScf_Dec(h_DecSetup->scf_idx, h_DecSetup->scf_q); } - if ( h_DecSetup->PlcAdvSetup ) + if (h_DecSetup->PlcAdvSetup) { - processPlcComputeStabFacMain_fl( h_DecSetup->scf_q, h_DecSetup->PlcAdvSetup->scf_q_old, h_DecSetup->PlcAdvSetup->scf_q_old_old, bfi, h_DecSetup->PlcSetup.prevBfi, - h_DecSetup->PlcSetup.prevprevBfi, &h_DecSetup->PlcAdvSetup->stabFac ); + processPlcComputeStabFacMain_fl(h_DecSetup->scf_q, h_DecSetup->PlcAdvSetup->scf_q_old, h_DecSetup->PlcAdvSetup->scf_q_old_old, bfi, h_DecSetup->PlcSetup.prevBfi, + h_DecSetup->PlcSetup.prevprevBfi, &h_DecSetup->PlcAdvSetup->stabFac); } - + if ( bfi != 1 ) { stab_fac = 1; - if ( h_DecSetup->PlcAdvSetup ) + if (h_DecSetup->PlcAdvSetup) { stab_fac = h_DecSetup->PlcAdvSetup->stabFac; } /* Partial Concealment */ - processPcMain_fl( &bfi, decoder, h_DecSetup->sqQdec_fl, h_DecSetup, h_DecSetup->ltpf_param[0], stab_fac, gg_idx, h_DecSetup->quantizedGainOff, - fac_ns_idx, &h_DecSetup->statePC, h_DecSetup->spec_inv_idx, decoder->yLen ); + processPcMain_fl(&bfi, decoder, h_DecSetup->sqQdec_fl, h_DecSetup, h_DecSetup->ltpf_param[0], stab_fac, gg_idx, h_DecSetup->quantizedGainOff, + fac_ns_idx, &h_DecSetup->statePC, h_DecSetup->spec_inv_idx, decoder->yLen); } /* Decoding only if no bit error detected */ - if ( bfi != 1 ) - { + if (bfi != 1) { /* Residual decoding */ - if ( residualPresent ) - { - processResidualDecoding_fl( &bitsRead, h_DecSetup->sqQdec_fl, decoder->yLen, h_DecSetup->resBits, - nbits_residual, decoder->hrmode ); + if (residualPresent) { + processResidualDecoding_fl(&bitsRead, h_DecSetup->sqQdec_fl, decoder->yLen, h_DecSetup->resBits, + nbits_residual + , decoder->hrmode + ); } - - + + /* Noise filling */ - if ( zero_frame == 0 ) - { - processNoiseFilling_fl( h_DecSetup->sqQdec_fl, nf_seed, fac_ns_idx, decoder->cutoffBins[h_DecSetup->BW_cutoff_idx_nf], decoder->frame_dms, h_DecSetup->prev_fac_ns, h_DecSetup->spec_inv_idx ); + if (zero_frame == 0) { + processNoiseFilling_fl(h_DecSetup->sqQdec_fl, nf_seed, fac_ns_idx, decoder->cutoffBins[h_DecSetup->BW_cutoff_idx_nf], decoder->frame_dms, h_DecSetup->prev_fac_ns, h_DecSetup->spec_inv_idx); } - + /* Application of global gain */ - processApplyGlobalGain_fl( h_DecSetup->sqQdec_fl, decoder->yLen, gg_idx, h_DecSetup->quantizedGainOff ); + processApplyGlobalGain_fl(h_DecSetup->sqQdec_fl, decoder->yLen, gg_idx, h_DecSetup->quantizedGainOff); /* TNS decoder */ - processTnsDecoder_fl( h_DecSetup->sqQdec_fl, h_DecSetup->tns_idx, tns_order, tns_numfilters, - decoder->cutoffBins[bw_cutoff_idx], h_DecSetup->N_red_tns, h_DecSetup->fs_red_tns ); + processTnsDecoder_fl(h_DecSetup->sqQdec_fl, h_DecSetup->tns_idx, tns_order, tns_numfilters, + decoder->cutoffBins[bw_cutoff_idx], h_DecSetup->N_red_tns, h_DecSetup->fs_red_tns); /* SNS interpolation */ - processSnsInterpolateScf_fl( h_DecSetup->scf_q, 0, decoder->bands_number, h_DecSetup->int_scf ); + processSnsInterpolateScf_fl(h_DecSetup->scf_q, 0, decoder->bands_number, h_DecSetup->int_scf); /* MDCT shaping */ - processMdctShaping_fl( h_DecSetup->sqQdec_fl, h_DecSetup->int_scf, decoder->bands_offset, decoder->bands_number ); + processMdctShaping_fl(h_DecSetup->sqQdec_fl, h_DecSetup->int_scf, decoder->bands_offset, decoder->bands_number); } - + /* PLC */ - processPlcMain_fl( h_DecSetup->sqQdec_fl, h_DecSetup->x_fl, decoder, h_DecSetup, bfi, h_DecSetup->PlcAdvSetup, &h_DecSetup->PlcSetup, - decoder->plcMeth, h_DecSetup->ltpf_mem_pitch, h_DecSetup->ltpf_mem_pitch_fr, decoder->tilt, decoder->bands_offset, - decoder->bands_number, decoder->bands_offsetPLC, decoder->n_bandsPLC, decoder->hrmode, &h_DecSetup->statePC ); - - processPlcDampingScramblingMain_fl( &h_DecSetup->PlcNsSetup.seed, - &h_DecSetup->statePC.seed, h_DecSetup->statePC.ns_nbLostCmpt_pc, - h_DecSetup->PlcSetup.nbLostCmpt, &h_DecSetup->PlcAdvSetup->stabFac, - &h_DecSetup->PlcAdvSetup->cum_fading_slow, &h_DecSetup->PlcAdvSetup->cum_fading_fast, - h_DecSetup->PlcSetup.q_d_prev, h_DecSetup->sqQdec_fl, h_DecSetup->spec_inv_idx, decoder->yLen, bfi, - decoder->frame_dms, h_DecSetup->concealMethod, h_DecSetup->ltpf_mem_pitch, h_DecSetup->ltpf_param[0], - &h_DecSetup->PlcAdvSetup->cum_fflcAtten ); - + processPlcMain_fl(h_DecSetup->sqQdec_fl, h_DecSetup->x_fl, decoder, h_DecSetup, bfi, h_DecSetup->PlcAdvSetup, &h_DecSetup->PlcSetup, + decoder->plcMeth, h_DecSetup->ltpf_mem_pitch, h_DecSetup->ltpf_mem_pitch_fr, decoder->tilt, decoder->bands_offset, + decoder->bands_number, decoder->bands_offsetPLC, decoder->n_bandsPLC, decoder->hrmode, &h_DecSetup->statePC); + + processPlcDampingScramblingMain_fl(&h_DecSetup->PlcNsSetup.seed, + &h_DecSetup->statePC.seed, h_DecSetup->statePC.ns_nbLostCmpt_pc, + h_DecSetup->PlcSetup.nbLostCmpt, &h_DecSetup->PlcAdvSetup->stabFac, + &h_DecSetup->PlcAdvSetup->cum_fading_slow, &h_DecSetup->PlcAdvSetup->cum_fading_fast, + h_DecSetup->PlcSetup.q_d_prev, h_DecSetup->sqQdec_fl, h_DecSetup->spec_inv_idx, decoder->yLen, bfi, + decoder->frame_dms, h_DecSetup->concealMethod, h_DecSetup->ltpf_mem_pitch, h_DecSetup->ltpf_param[0], + &h_DecSetup->PlcAdvSetup->cum_fflcAtten); + /* IMDCT */ - if ( h_DecSetup->concealMethod == 4 || bfi != 1 ) + if (h_DecSetup->concealMethod == 4 || bfi != 1 ) { - ProcessingIMDCT_fl( h_DecSetup->sqQdec_fl, decoder->frame_length, decoder->imdct_win, decoder->imdct_winLen, decoder->imdct_laZeros, - h_DecSetup->imdct_mem, h_DecSetup->x_fl, &h_DecSetup->dct4structImdct ); + ProcessingIMDCT_fl(h_DecSetup->sqQdec_fl, decoder->frame_length, decoder->imdct_win, decoder->imdct_winLen, decoder->imdct_laZeros, + h_DecSetup->imdct_mem, h_DecSetup->x_fl, &h_DecSetup->dct4structImdct); } - processPlcUpdate_fl( h_DecSetup->PlcAdvSetup, decoder->frame_length, h_DecSetup->x_fl, h_DecSetup->scf_q, - &h_DecSetup->PlcSetup.nbLostCmpt, &h_DecSetup->PlcNsSetup.cum_alpha, bfi, &h_DecSetup->PlcSetup.prevBfi, &h_DecSetup->PlcSetup.prevprevBfi ); - + processPlcUpdate_fl(h_DecSetup->PlcAdvSetup + , decoder->frame_length, h_DecSetup->x_fl, h_DecSetup->scf_q, + &h_DecSetup->PlcSetup.nbLostCmpt, &h_DecSetup->PlcNsSetup.cum_alpha, bfi, &h_DecSetup->PlcSetup.prevBfi, &h_DecSetup->PlcSetup.prevprevBfi); + /* LTPF decoder */ - process_ltpf_decoder_fl( h_DecSetup->x_fl, decoder->frame_length, h_DecSetup->x_fl, decoder->fs, - h_DecSetup->ltpf_mem_x, h_DecSetup->ltpf_mem_y, &h_DecSetup->ltpf_mem_pitch, - &h_DecSetup->ltpf_mem_pitch_fr, &h_DecSetup->ltpf_mem_gain, &h_DecSetup->ltpf_mem_beta_idx, - bfi, h_DecSetup->ltpf_param, h_DecSetup->ltpf_param_mem, h_DecSetup->ltpf_conf_beta_idx, - h_DecSetup->ltpf_conf_beta, h_DecSetup->concealMethod, h_DecSetup->alpha, &h_DecSetup->ltpf_mem_active ); + process_ltpf_decoder_fl(h_DecSetup->x_fl, decoder->frame_length, h_DecSetup->x_fl, decoder->fs, + h_DecSetup->ltpf_mem_x, h_DecSetup->ltpf_mem_y, &h_DecSetup->ltpf_mem_pitch, + &h_DecSetup->ltpf_mem_pitch_fr, &h_DecSetup->ltpf_mem_gain, &h_DecSetup->ltpf_mem_beta_idx, + bfi, h_DecSetup->ltpf_param, h_DecSetup->ltpf_param_mem, h_DecSetup->ltpf_conf_beta_idx, + h_DecSetup->ltpf_conf_beta, h_DecSetup->concealMethod, h_DecSetup->alpha + , &h_DecSetup->ltpf_mem_active + ); { /* Round, scale and copy output to output buffer */ - if ( bps == 16 ) - { - for ( i = 0; i < decoder->frame_length; i++ ) - { - LC3_FLOAT tmp = round( h_DecSetup->x_fl[i] ); - ( (int16_t *) s_out )[i] = (int16_t) fmaxf( fminf( tmp, 32767 ), -32768 ); + if (bps == 16) { + for (i = 0; i < decoder->frame_length; i++) { + LC3_FLOAT tmp = round(h_DecSetup->x_fl[i]); + ((int16_t*)s_out)[i] = (int16_t)fmaxf(fminf(tmp, 32767), -32768); } - } - else - { - for ( i = 0; i < decoder->frame_length; i++ ) - { - LC3_FLOAT tmp = round( LC3_CONST_POW_2_23 * LC3_CONST_POW_2_M15 * h_DecSetup->x_fl[i] ); - ( (int32_t *) s_out )[i] = (int32_t) fmaxf( fminf( tmp, LC3_CONST_POW_2_23_RED ), LC3_CONST_POW_2_23_NEG ); + } else { + for (i = 0; i < decoder->frame_length; i++) { + LC3_FLOAT tmp = round(LC3_CONST_POW_2_23 * LC3_CONST_POW_2_M15 * h_DecSetup->x_fl[i]); + ((int32_t*)s_out)[i] = (int32_t)fmaxf(fminf(tmp, LC3_CONST_POW_2_23_RED), LC3_CONST_POW_2_23_NEG); } } } return bfi; } -LC3PLUS_Error Dec_LC3PLUS_fl( LC3PLUS_Dec *decoder, uint8_t *input, LC3_INT32 num_bytes, void **output, LC3_INT32 bps, LC3_INT32 bfi_ext ) +LC3PLUS_Error Dec_LC3PLUS_fl(LC3PLUS_Dec* decoder, uint8_t* input, LC3_INT32 num_bytes, void** output, LC3_INT32 bps, LC3_INT32 bfi_ext) { - LC3_INT32 ch, bfi, lc3_num_bytes; - LC3PLUS_Error err; - LC3_INT32 fec_num_bytes; - LC3_INT32 lc3_channel_num_bytes; - LC3_INT32 channel_bfi, out_bfi; - LC3PLUS_EpModeRequest channel_epmr; - + LC3_INT32 ch, bfi, lc3_num_bytes; + LC3PLUS_Error err; + LC3_INT32 fec_num_bytes; + LC3_INT32 lc3_channel_num_bytes; + LC3_INT32 channel_bfi, out_bfi; + LC3PLUS_EpModeRequest channel_epmr; + bfi = bfi_ext; lc3_num_bytes = 0; err = LC3PLUS_OK; - - if ( bfi == 0 ) + + if (bfi == 0) { bfi = !num_bytes; } - - if ( decoder->ep_enabled ) + + if (decoder->ep_enabled) { decoder->combined_channel_coding = decoder->channels > 1 && num_bytes <= 160; - if ( decoder->combined_channel_coding ) + if (decoder->combined_channel_coding) { fec_num_bytes = num_bytes; decoder->error_report = - fec_decoder( input, fec_num_bytes, &lc3_num_bytes, (LC3PLUS_EpModeRequest *) &decoder->epmr, decoder->combined_channel_coding, - &decoder->n_pccw, &bfi, &decoder->be_bp_left, &decoder->be_bp_right, &decoder->n_pc, &decoder->m_fec ); + fec_decoder(input, fec_num_bytes, &lc3_num_bytes, (LC3PLUS_EpModeRequest*)&decoder->epmr, decoder->combined_channel_coding, + &decoder->n_pccw, &bfi, &decoder->be_bp_left, &decoder->be_bp_right, &decoder->n_pc, &decoder->m_fec); - for ( ch = 0; ch < decoder->channels; ch++ ) + for (ch = 0; ch < decoder->channels; ch++) { - lc3_channel_num_bytes = lc3_num_bytes / decoder->channels + ( ch < ( lc3_num_bytes % decoder->channels ) ); + lc3_channel_num_bytes = lc3_num_bytes / decoder->channels + (ch < (lc3_num_bytes % decoder->channels)); - if ( bfi != 1 && lc3_channel_num_bytes != decoder->channel_setup[ch]->last_size ) + if (bfi != 1 && lc3_channel_num_bytes != decoder->channel_setup[ch]->last_size) { - err = update_dec_bitrate( decoder, ch, lc3_channel_num_bytes ); - if ( err ) + err = update_dec_bitrate(decoder, ch, lc3_channel_num_bytes); + if (err) { bfi = 1; decoder->last_error = err; } else { - decoder->channel_setup[ch]->last_size = lc3_channel_num_bytes; + decoder->channel_setup[ch]->last_size = lc3_channel_num_bytes; } } - bfi = Dec_LC3PLUS_Channel_fl( decoder, ch, input, output[ch], bps, bfi ); + bfi = Dec_LC3PLUS_Channel_fl(decoder, ch, input, output[ch], bps, bfi); input += decoder->channel_setup[ch]->targetBytes; } } else { decoder->epmr = LC3PLUS_EPMR_HIGH_NC; - out_bfi = 0; + out_bfi = 0; - for ( ch = 0; ch < decoder->channels; ch++ ) + for (ch = 0; ch < decoder->channels; ch++) { - fec_num_bytes = num_bytes / decoder->channels + ( ch < ( num_bytes % decoder->channels ) ); + fec_num_bytes = num_bytes / decoder->channels + (ch < (num_bytes % decoder->channels)); - channel_bfi = bfi; + channel_bfi = bfi; - decoder->error_report = fec_decoder( input, fec_num_bytes, &lc3_num_bytes, &channel_epmr, - decoder->combined_channel_coding, &decoder->n_pccw, &channel_bfi, - &decoder->be_bp_left, &decoder->be_bp_right, &decoder->n_pc, &decoder->m_fec ); - - decoder->epmr = MIN( (LC3PLUS_EpModeRequest) decoder->epmr, channel_epmr ); + decoder->error_report = fec_decoder(input, fec_num_bytes, &lc3_num_bytes, &channel_epmr, + decoder->combined_channel_coding, &decoder->n_pccw, &channel_bfi, + &decoder->be_bp_left, &decoder->be_bp_right, &decoder->n_pc, &decoder->m_fec); + decoder->epmr = MIN((LC3PLUS_EpModeRequest) decoder->epmr, channel_epmr); + #ifdef ENABLE_PADDING - if ( channel_bfi != 1 ) + if (channel_bfi != 1) { LC3_INT32 padding_len = 0, np_zero = 0; - if ( paddingDec_fl( input, ( lc3_num_bytes << 3 ), decoder->yLen, decoder->BW_cutoff_bits, decoder->ep_enabled, &padding_len, &np_zero ) ) + if (paddingDec_fl(input, (lc3_num_bytes << 3), decoder->yLen, decoder->BW_cutoff_bits, decoder->ep_enabled, &padding_len, &np_zero)) { channel_bfi = 1; } - input = input + np_zero; - decoder->n_pc = MAX( decoder->n_pc - ( 2 * np_zero ), 0 ); - - if ( channel_bfi == 2 ) + input = input + np_zero; + decoder->n_pc = MAX(decoder->n_pc - (2 * np_zero), 0); + + if (channel_bfi == 2) { - if ( decoder->be_bp_right < ( 8 * np_zero ) ) + if (decoder->be_bp_right < (8 * np_zero)) { channel_bfi = 0; decoder->be_bp_left = -1; @@ -288,18 +284,18 @@ LC3PLUS_Error Dec_LC3PLUS_fl( LC3PLUS_Dec *decoder, uint8_t *input, LC3_INT32 nu } else { - decoder->be_bp_right = decoder->be_bp_right - ( 8 * np_zero ); - decoder->be_bp_left = MAX( decoder->be_bp_left - ( 8 * np_zero ), 0 ); + decoder->be_bp_right = decoder->be_bp_right - (8 * np_zero); + decoder->be_bp_left = MAX(decoder->be_bp_left - (8 * np_zero), 0); } } lc3_num_bytes = lc3_num_bytes - padding_len; } #endif - if ( channel_bfi != 1 && lc3_num_bytes != decoder->channel_setup[ch]->last_size ) + if (channel_bfi != 1 && lc3_num_bytes != decoder->channel_setup[ch]->last_size) { - err = update_dec_bitrate( decoder, ch, lc3_num_bytes ); - if ( err ) + err = update_dec_bitrate(decoder, ch, lc3_num_bytes); + if (err) { channel_bfi = 1; decoder->last_error = err; @@ -310,7 +306,7 @@ LC3PLUS_Error Dec_LC3PLUS_fl( LC3PLUS_Dec *decoder, uint8_t *input, LC3_INT32 nu } } - channel_bfi = Dec_LC3PLUS_Channel_fl( decoder, ch, input, output[ch], bps, channel_bfi ); + channel_bfi = Dec_LC3PLUS_Channel_fl(decoder, ch, input, output[ch], bps, channel_bfi); out_bfi |= channel_bfi; input += fec_num_bytes; @@ -321,34 +317,34 @@ LC3PLUS_Error Dec_LC3PLUS_fl( LC3PLUS_Dec *decoder, uint8_t *input, LC3_INT32 nu } else { - for ( ch = 0; ch < decoder->channels; ch++ ) + for (ch = 0; ch < decoder->channels; ch++) { - lc3_num_bytes = num_bytes / decoder->channels + ( ch < ( num_bytes % decoder->channels ) ); + lc3_num_bytes = num_bytes / decoder->channels + (ch < (num_bytes % decoder->channels)); #ifdef ENABLE_PADDING - if ( bfi != 1 ) + if (bfi != 1) { LC3_INT32 padding_len = 0, np_zero = 0; - if ( paddingDec_fl( input, ( lc3_num_bytes << 3 ), decoder->yLen, decoder->BW_cutoff_bits, decoder->ep_enabled, &padding_len, &np_zero ) ) + if (paddingDec_fl(input, (lc3_num_bytes << 3), decoder->yLen, decoder->BW_cutoff_bits, decoder->ep_enabled, &padding_len, &np_zero)) { bfi = 1; decoder->last_error = LC3PLUS_PADDING_ERROR; } - + lc3_num_bytes = lc3_num_bytes - padding_len; - if ( lc3_num_bytes < 20 || lc3_num_bytes > LC3PLUS_MAX_BYTES ) + if (lc3_num_bytes < 20 || lc3_num_bytes > LC3PLUS_MAX_BYTES) { - bfi = 1; /* mark frame as broken if frame size is below the minimum of 20 bytes or above the maximum of LC3PLUS_MAX_BYTES */ + bfi = 1; /* mark frame as broken if frame size is below the minimum of 20 bytes or above the maximum of LC3PLUS_MAX_BYTES */ decoder->last_error = FRAMESIZE_ERROR; } } -#endif - - if ( bfi != 1 && lc3_num_bytes != decoder->channel_setup[ch]->last_size ) +#endif + + if (bfi != 1 && lc3_num_bytes != decoder->channel_setup[ch]->last_size) { - err = update_dec_bitrate( decoder, ch, lc3_num_bytes ); - if ( err ) + err = update_dec_bitrate(decoder, ch, lc3_num_bytes); + if (err) { bfi = 1; decoder->last_error = err; @@ -359,12 +355,11 @@ LC3PLUS_Error Dec_LC3PLUS_fl( LC3PLUS_Dec *decoder, uint8_t *input, LC3_INT32 nu } } - bfi = Dec_LC3PLUS_Channel_fl( decoder, ch, input, output[ch], bps, bfi ); + bfi = Dec_LC3PLUS_Channel_fl(decoder, ch, input, output[ch], bps, bfi); input += decoder->channel_setup[ch]->targetBytes; } } - if ( decoder->last_error == LC3PLUS_OK && bfi ) - decoder->last_error = LC3PLUS_DECODE_ERROR; + if (decoder->last_error == LC3PLUS_OK && bfi) decoder->last_error = LC3PLUS_DECODE_ERROR; return bfi == 1 ? LC3PLUS_DECODE_ERROR : LC3PLUS_OK; } diff --git a/lib_lc3plus/defines.h b/lib_lc3plus/defines.h index 3a41dec5ea..d978fa4e15 100644 --- a/lib_lc3plus/defines.h +++ b/lib_lc3plus/defines.h @@ -1,12 +1,12 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #ifndef DEFINES_H #define DEFINES_H @@ -14,13 +14,13 @@ #include "stdint.h" -typedef float LC3_FLOAT; -typedef int32_t LC3_INT; -typedef int16_t LC3_INT16; +typedef float LC3_FLOAT; +typedef int32_t LC3_INT; +typedef int16_t LC3_INT16; typedef uint16_t LC3_UINT16; -typedef short LC3_SHORT; -typedef uint8_t LC3_UINT8; -typedef int8_t LC3_INT8; +typedef short LC3_SHORT; +typedef uint8_t LC3_UINT8; +typedef int8_t LC3_INT8; typedef uint32_t LC3_UINT32; /* Release defines */ @@ -47,159 +47,159 @@ typedef uint32_t LC3_UINT32; #endif /* NO_POST_REL_CHANGES */ /* Precision Defines */ -#define LC3_FABS( x ) ( fabsf( x ) ) -#define LC3_POW( x, y ) ( powf( x, y ) ) -#define LC3_LOGTEN( x ) ( log10f( x ) ) -#define LC3_LOGTWO( x ) ( log2f( x ) ) -#define LC3_COS( x ) ( cos( x ) ) -#define LC3_SIN( x ) ( sin( x ) ) -#define LC3_SQRT( x ) ( sqrtf( x ) ) -#define LC3_EXP( x ) ( expf( x ) ) - -#define MAX_BR 320000 /* 400 * 800 */ -#define MIN_BR_100DMS 16000 /* 20 * 800 * 100/100 */ -#define MIN_BR_025DMS 64000 /* 20 * 800 * 100/ 25 */ -#define MIN_BR_050DMS 32000 /* 20 * 800 * 100/ 50 */ -#define MAX_BR_050DMS_NB 260800 /* 163 * 800 * 100/ 50 */ -#define MAX_BR_100DMS_NB 114400 /* for 100ms at 8kHz */ - -#define MAX_BR_100DMS_WB 221600 /* for 100ms at 16kHz */ -#define MAX_BR_100DMS_SSWB 314400 /* for 100ms at 24kHz */ - -typedef int32_t LC3_INT32; - -#if defined( __xtensa__ ) -#define ALIGNMENT_BALLOC 4 -#define ALIGNMENT_BALLOC_RED 3 -#else -#define ALIGNMENT_BALLOC 8 -#define ALIGNMENT_BALLOC_RED 7 -#endif - -#define PLC2_FADEOUT_IN_MS 30 -#define PHECU_FRES 62.5 -#define PHECU_C_JACOB 1.1429 -#define MAX_LGW 9 /* LGW48K + 1 !! */ -#define QUOT_LPR_LTR 4 -#define MAX_PLC_LPROT ( ( 512 * 48 ) / 32 ) -#define MAX_PLC_NPLOCS ( ( MAX_PLC_LPROT / 4 ) + 1 ) -#define MAX_PLC_LMSPEC ( ( MAX_PLC_LPROT / 2 ) + 1 ) -#define MAX_PLC_LMEM ( 400 ) /* "only" up to 20kHz (400 MDCT bins at 10 ms) at 48 kHz supported by PhEcu */ - -#define POS_ONE_Q15 ( 32767.0 / 32768.0 ) -#define PHECU_LTOT_MIN_MAN 1 /* lowest possible mantissa energy value */ -#define PHECU_LTOT_MIN_EXP -61 /* L_tot = PHECU_LTOT_MIN_MAN*2^(PHECU_LTOT_MIN_EXP-31) */ -#define PHECU_LTOT_MIN -#define PHECU_GRP_SHAPE_INIT 0 /* BASOP Q15 */ -#define PHECU_ENV_STAB_LOCAL POS_ONE_Q15 -#define PHECU_DELTA_CORR 5 -#define PHECU_PFIND_SENS 0.93 -#define PHECU_LA 0 - -#define LC3_ROUND( x ) ( roundf( x ) ) -#define LC3_FLOOR( x ) ( floorf( x ) ) - -#define LC3_CONST_POW_2_16 65536 -#define LC3_CONST_POW_2_M16 1.525878906250000e-05 -#define LC3_CONST_POW_2_100 1.267650600228229e+30 - -#define MAX_LEN_PCM_PLC ( MAX_PITCH + MAX_LEN ) -#define MAX_PITCH CEILING( ( MAX_PITCH_12K8 * MAX_LEN * 100 ), 12800 ) -#define TDC_L_FIR_HP 11 -#define PLC3_HPBLENDTHROTTLE 30 /* higher numbers increase throttled blending from hp filtered to unfiltered uv excitation (0 is no throttle) */ - -#define PLC_FADEOUT_IN_MS 60 /* fade-out to zero in ms for TD-PLC and NS, minimum value is 20 */ -#define PLC4_TRANSIT_START_IN_MS 20 /* begin of transition time for noise substitution for voiced signals */ -#define PLC4_TRANSIT_END_IN_MS PLC_FADEOUT_IN_MS /* end of transition time for noise substitution */ -#define PLC34_ATTEN_FAC_100 0.5000 /* attenuation factor for NS and TDC @ 10 ms*/ -#define PLC34_ATTEN_FAC_050 0.7071 /* attenuation factor for NS and TDC @ 5.0 ms*/ -#define PLC34_ATTEN_FAC_025 0.8409 /* attenuation factor for NS and TDC @ 2.5 ms*/ - -#define FEC_SLOT_BYTES_MIN 40 -#define FEC_SLOT_BYTES_MAX 400 - - -#define LC3_CONST_POW_2_M15 3.051757812500000e-05 -#define LC3_CONST_POW_2_23 8388608 -#define LC3_CONST_POW_2_23_NEG -8388608 -#define LC3_CONST_POW_2_23_RED 8388607 - -#define LC3_CONST_POW_2_100 1.267650600228229e+30 +#define LC3_FABS(x) (fabsf(x)) +#define LC3_POW(x, y) (powf(x, y)) +#define LC3_LOGTEN(x) (log10f(x)) +#define LC3_LOGTWO(x) (log2f(x)) +# define LC3_COS(x) (cos(x)) +# define LC3_SIN(x) (sin(x)) +#define LC3_SQRT(x) (sqrtf(x)) +#define LC3_EXP(x) (expf(x)) + +# define MAX_BR 320000 /* 400 * 800 */ +# define MIN_BR_100DMS 16000 /* 20 * 800 * 100/100 */ +# define MIN_BR_025DMS 64000 /* 20 * 800 * 100/ 25 */ +# define MIN_BR_050DMS 32000 /* 20 * 800 * 100/ 50 */ +# define MAX_BR_050DMS_NB 260800 /* 163 * 800 * 100/ 50 */ +# define MAX_BR_100DMS_NB 114400 /* for 100ms at 8kHz */ + +# define MAX_BR_100DMS_WB 221600 /* for 100ms at 16kHz */ +# define MAX_BR_100DMS_SSWB 314400 /* for 100ms at 24kHz */ + +typedef int32_t LC3_INT32; + +# if defined(__xtensa__) +# define ALIGNMENT_BALLOC 4 +# define ALIGNMENT_BALLOC_RED 3 +# else +# define ALIGNMENT_BALLOC 8 +# define ALIGNMENT_BALLOC_RED 7 +# endif + +# define PLC2_FADEOUT_IN_MS 30 +# define PHECU_FRES 62.5 +# define PHECU_C_JACOB 1.1429 +# define MAX_LGW 9 /* LGW48K + 1 !! */ +# define QUOT_LPR_LTR 4 +# define MAX_PLC_LPROT ((512 * 48) / 32) +# define MAX_PLC_NPLOCS ((MAX_PLC_LPROT / 4) + 1) +# define MAX_PLC_LMSPEC ((MAX_PLC_LPROT / 2) + 1) +# define MAX_PLC_LMEM (400) /* "only" up to 20kHz (400 MDCT bins at 10 ms) at 48 kHz supported by PhEcu */ + +# define POS_ONE_Q15 (32767.0 / 32768.0) +# define PHECU_LTOT_MIN_MAN 1 /* lowest possible mantissa energy value */ +# define PHECU_LTOT_MIN_EXP -61 /* L_tot = PHECU_LTOT_MIN_MAN*2^(PHECU_LTOT_MIN_EXP-31) */ +# define PHECU_LTOT_MIN +# define PHECU_GRP_SHAPE_INIT 0 /* BASOP Q15 */ +# define PHECU_ENV_STAB_LOCAL POS_ONE_Q15 +# define PHECU_DELTA_CORR 5 +# define PHECU_PFIND_SENS 0.93 +# define PHECU_LA 0 + +# define LC3_ROUND(x) (roundf(x)) +# define LC3_FLOOR(x) (floorf(x)) + +# define LC3_CONST_POW_2_16 65536 +# define LC3_CONST_POW_2_M16 1.525878906250000e-05 +# define LC3_CONST_POW_2_100 1.267650600228229e+30 + +# define MAX_LEN_PCM_PLC (MAX_PITCH + MAX_LEN) +# define MAX_PITCH CEILING((MAX_PITCH_12K8 * MAX_LEN * 100), 12800) +# define TDC_L_FIR_HP 11 +# define PLC3_HPBLENDTHROTTLE 30 /* higher numbers increase throttled blending from hp filtered to unfiltered uv excitation (0 is no throttle) */ + +# define PLC_FADEOUT_IN_MS 60 /* fade-out to zero in ms for TD-PLC and NS, minimum value is 20 */ +# define PLC4_TRANSIT_START_IN_MS 20 /* begin of transition time for noise substitution for voiced signals */ +# define PLC4_TRANSIT_END_IN_MS PLC_FADEOUT_IN_MS /* end of transition time for noise substitution */ +# define PLC34_ATTEN_FAC_100 0.5000 /* attenuation factor for NS and TDC @ 10 ms*/ +# define PLC34_ATTEN_FAC_050 0.7071 /* attenuation factor for NS and TDC @ 5.0 ms*/ +# define PLC34_ATTEN_FAC_025 0.8409 /* attenuation factor for NS and TDC @ 2.5 ms*/ + +# define FEC_SLOT_BYTES_MIN 40 +# define FEC_SLOT_BYTES_MAX 400 + + +# define LC3_CONST_POW_2_M15 3.051757812500000e-05 +# define LC3_CONST_POW_2_23 8388608 +# define LC3_CONST_POW_2_23_NEG -8388608 +# define LC3_CONST_POW_2_23_RED 8388607 + +# define LC3_CONST_POW_2_100 1.267650600228229e+30 /* G192 bitstream writing/reading */ #define G192_REDUNDANCY_FRAME 0x6B22 -#define G192_GOOD_FRAME 0x6B21 -#define G192_BAD_FRAME 0x6B20 -#define G192_ZERO 0x007F -#define G192_ONE 0x0081 -#define READ_G192FER /* Allow C executable to also read G192 formatted FER files */ +#define G192_GOOD_FRAME 0x6B21 +#define G192_BAD_FRAME 0x6B20 +#define G192_ZERO 0x007F +#define G192_ONE 0x0081 +#define READ_G192FER /* Allow C executable to also read G192 formatted FER files */ -#define LC3_EPS ( 1.1e-7f ) +# define LC3_EPS (1.1e-7f) #define M_PI 3.14159265358979323846 /* FUNCTION MACROS */ -#define CEILING( x, y ) ( ( ( x ) + (y) -1 ) / ( y ) ) -#define FRAME2FS_IDX( x ) ( x / 100 ) /* 80 -> 0, 160 -> 1, 240 -> 2, 320 -> 3, 480 -> 4*/ -#define FS2FS_IDX( x ) \ - ( x / 10000 ) /* 8000 -> 0, 16000 -> 1, 24000 -> 2, 32000 -> 3, 48000 -> 4 \ - */ -#define UNUSED( x ) (void) ( x ) /* silence unused parameter warning */ -#define MAX( a, b ) ( ( a ) > ( b ) ? ( a ) : ( b ) ) -#define MIN( a, b ) ( ( a ) < ( b ) ? ( a ) : ( b ) ) -#define STATIC_ASSERTS( cond, s ) typedef char assert_##s[( cond ) ? 1 : -1] -#define STATIC_ASSERTI( cond, i ) STATIC_ASSERTS( cond, i ) -#define STATIC_ASSERT( cond ) STATIC_ASSERTI( cond, __LINE__ ) +#define CEILING(x, y) (((x) + (y)-1) / (y)) +#define FRAME2FS_IDX(x) (x / 100) /* 80 -> 0, 160 -> 1, 240 -> 2, 320 -> 3, 480 -> 4*/ +#define FS2FS_IDX(x) \ + (x / 10000) /* 8000 -> 0, 16000 -> 1, 24000 -> 2, 32000 -> 3, 48000 -> 4 \ + */ +#define UNUSED(x) (void)(x) /* silence unused parameter warning */ +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#define STATIC_ASSERTS(cond, s) typedef char assert_##s[(cond) ? 1 : -1] +#define STATIC_ASSERTI(cond, i) STATIC_ASSERTS(cond, i) +#define STATIC_ASSERT(cond) STATIC_ASSERTI(cond, __LINE__) /* For dynamic memory calculations */ -#define CODEC_FS( fs ) ( ( fs ) == 44100 ? 48000 : ( fs ) ) -#define DYN_MAX_LEN( fs ) MAX( CODEC_FS( fs ) / 100, 160 ) -#define DYN_MAX_LEN_EXT( fs ) MAX( CODEC_FS( fs ) / 100, 160 ) /* extension to length 160 for NB(fs=8000) */ -#define DYN_MAX_MDCT_LEN( fs ) ( DYN_MAX_LEN( fs ) - ( 180 * DYN_MAX_LEN( fs ) / 480 ) ) +#define CODEC_FS(fs) ((fs) == 44100 ? 48000 : (fs)) +#define DYN_MAX_LEN(fs) MAX(CODEC_FS(fs) / 100, 160) +# define DYN_MAX_LEN_EXT(fs) MAX(CODEC_FS(fs) / 100, 160) /* extension to length 160 for NB(fs=8000) */ +#define DYN_MAX_MDCT_LEN(fs) (DYN_MAX_LEN(fs) - (180 * DYN_MAX_LEN(fs) / 480)) /* OPTIONS */ -#define MAX_SR 96000 -#define EXT_RES_ITER_MAX 20 +#define MAX_SR 96000 +#define EXT_RES_ITER_MAX 20 #define MAX_BW_BANDS_NUMBER 6 -#define MAX_LEN MAX_SR / 100 /* = 10ms at 96kHz */ -#define MAX_RESBITS 5000 -#define MAX_RESBITS_LEN ( ( MAX_RESBITS + 7 ) / 8 ) +#define MAX_LEN MAX_SR/100 /* = 10ms at 96kHz */ +#define MAX_RESBITS 5000 +#define MAX_RESBITS_LEN ((MAX_RESBITS + 7)/8) #define MAX_CHANNELS 2 -#define MIN_NBYTES 20 /* 100dms: 16 kbps at !=44.1kHz, 14.7kbps at 44.1kHz \ - 50dms: 32 kbps at !=44.1kHz, 29.4kbps at 44.1kHz \ - 25dms: 64 kbps at !=44.1kHz, 58.8kbps at 44.1kHz */ -#define MAX_NBYTES_025 100 /* any dms: 320 kbps at !=44.1kHz, 294 kbps at 44.1kHz */ -#define MAX_NBYTES_050 200 /* any dms: 320 kbps at !=44.1kHz, 294 kbps at 44.1kHz */ -#define MAX_NBYTES_100 400 /* any dms: 320 kbps at !=44.1kHz, 294 kbps at 44.1kHz */ +#define MIN_NBYTES 20 /* 100dms: 16 kbps at !=44.1kHz, 14.7kbps at 44.1kHz + 50dms: 32 kbps at !=44.1kHz, 29.4kbps at 44.1kHz + 25dms: 64 kbps at !=44.1kHz, 58.8kbps at 44.1kHz */ +#define MAX_NBYTES_025 100 /* any dms: 320 kbps at !=44.1kHz, 294 kbps at 44.1kHz */ +#define MAX_NBYTES_050 200 /* any dms: 320 kbps at !=44.1kHz, 294 kbps at 44.1kHz */ +#define MAX_NBYTES_100 400 /* any dms: 320 kbps at !=44.1kHz, 294 kbps at 44.1kHz */ #ifdef ENABLE_HR_MODE_FL -#define MIN_BR_25MS_48KHZ_HR ( (int) 172800 / 3200 / 2 ) * 3200 -#define MIN_BR_25MS_96KHZ_HR ( (int) 198400 / 3200 / 2 ) * 3200 -#define MIN_BR_50MS_48KHZ_HR ( (int) 148800 / 1600 / 2 ) * 1600 -#define MIN_BR_50MS_96KHZ_HR ( (int) 174400 / 1600 / 2 ) * 1600 -#define MIN_BR_100MS_48KHZ_HR ( (int) 124800 / 800 / 2 ) * 800 -#define MIN_BR_100MS_96KHZ_HR ( (int) 149600 / 800 / 2 ) * 800 +# define MIN_BR_25MS_48KHZ_HR ((int)172800/3200/2)*3200 +# define MIN_BR_25MS_96KHZ_HR ((int)198400/3200/2)*3200 +# define MIN_BR_50MS_48KHZ_HR ((int)148800/1600/2)*1600 +# define MIN_BR_50MS_96KHZ_HR ((int)174400/1600/2)*1600 +# define MIN_BR_100MS_48KHZ_HR ((int)124800/800/2)*800 +# define MIN_BR_100MS_96KHZ_HR ((int)149600/800/2)*800 #endif /* ENABLE_HR_MODE */ -#define MAX_NBYTES2 625 -#define BYTESBUFSIZE ( MAX_NBYTES2 * MAX_CHANNELS ) -#define MAX_BW_BIN 400 +#define MAX_NBYTES2 625 +#define BYTESBUFSIZE (MAX_NBYTES2 * MAX_CHANNELS) +#define MAX_BW_BIN 400 #if MAX_BW_BIN > MAX_LEN -#define MAX_BW MAX_LEN +# define MAX_BW MAX_LEN #else -#define MAX_BW MAX_BW_BIN +# define MAX_BW MAX_BW_BIN #endif -#ifdef ENABLE_HR_MODE_FL -#define MAX_BW_HR 960 -#endif +# ifdef ENABLE_HR_MODE_FL +# define MAX_BW_HR 960 +# endif /* SCF */ -#define M 16 -#define MAX_BANDS_NUMBER 64 +#define M 16 +#define MAX_BANDS_NUMBER 64 #define MAX_BANDS_NUMBER_PLC 80 -#define PVQ_MAX_VEC_SIZE M +#define PVQ_MAX_VEC_SIZE M /* PVQ VQ setup */ #define SCF_MAX_PARAM \ @@ -210,27 +210,28 @@ typedef int32_t LC3_INT32; #define NPRM_RESQ 5 * MAX_LEN /* MDCT */ -#define MDCT_MEM_LEN_MAX ( MAX_LEN - ( ( 180 * MAX_LEN ) / 480 ) ) +#define MDCT_MEM_LEN_MAX (MAX_LEN - ((180 * MAX_LEN) / 480)) /* TNS */ #define TNS_NUMFILTERS_MAX 2 -#define MAXLAG 8 +#define MAXLAG 8 /* OLPA/LTPF */ -#define LEN_12K8 128 -#define LEN_6K4 64 -#define MIN_PITCH_6K4 17 -#define MAX_PITCH_6K4 114 +#define LEN_12K8 128 +#define LEN_6K4 64 +#define MIN_PITCH_6K4 17 +#define MAX_PITCH_6K4 114 #define RANGE_PITCH_6K4 98 -#define MIN_PITCH_12K8 32 -#define MAX_PITCH_12K8 228 +#define MIN_PITCH_12K8 32 +#define MAX_PITCH_12K8 228 #define RES2_PITCH_12K8 157 #define RES4_PITCH_12K8 127 -#define LTPF_MEMIN_LEN ( MAX_PITCH_12K8 + 4 ) +#define LTPF_MEMIN_LEN (MAX_PITCH_12K8 + 4) /* Advanced PLC */ + /* some configurations leave empty translation units. */ extern int fix_empty_translation_unit_warning; diff --git a/lib_lc3plus/detect_cutoff_warped.c b/lib_lc3plus/detect_cutoff_warped.c index 0f4f18675d..9392867208 100644 --- a/lib_lc3plus/detect_cutoff_warped.c +++ b/lib_lc3plus/detect_cutoff_warped.c @@ -1,89 +1,83 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -void processDetectCutoffWarped_fl( LC3_FLOAT *d2, LC3_INT fs_idx, LC3_INT frame_dms, LC3_INT *bw_idx ) +void processDetectCutoffWarped_fl(LC3_FLOAT* d2, LC3_INT fs_idx, LC3_INT frame_dms, LC3_INT* bw_idx) { const LC3_INT *warp_idx_start = NULL, *warp_idx_stop = NULL; - LC3_INT counter = 0, brickwall = 0, i = 0, stop = 0, dist = 0; - LC3_FLOAT d2_mean = 0, d2_sum = 0, e_diff = 0, thr = 0; + LC3_INT counter = 0, brickwall = 0, i = 0, stop = 0, dist = 0; + LC3_FLOAT d2_mean = 0, d2_sum = 0, e_diff = 0, thr = 0; const LC3_INT *bw_dist = NULL; warp_idx_start = BW_warp_idx_start_all[fs_idx - 1]; - warp_idx_stop = BW_warp_idx_stop_all[fs_idx - 1]; + warp_idx_stop = BW_warp_idx_stop_all[fs_idx - 1]; - switch ( frame_dms ) + switch (frame_dms) { case 25: warp_idx_start = BW_warp_idx_start_all_2_5ms[fs_idx - 1]; - warp_idx_stop = BW_warp_idx_stop_all_2_5ms[fs_idx - 1]; - bw_dist = brickwall_dist; + warp_idx_stop = BW_warp_idx_stop_all_2_5ms[fs_idx - 1]; + bw_dist = brickwall_dist; break; case 50: warp_idx_start = BW_warp_idx_start_all_5ms[fs_idx - 1]; - warp_idx_stop = BW_warp_idx_stop_all_5ms[fs_idx - 1]; - bw_dist = brickwall_dist; + warp_idx_stop = BW_warp_idx_stop_all_5ms[fs_idx - 1]; + bw_dist = brickwall_dist; break; case 100: warp_idx_start = BW_warp_idx_start_all[fs_idx - 1]; - warp_idx_stop = BW_warp_idx_stop_all[fs_idx - 1]; - bw_dist = brickwall_dist; + warp_idx_stop = BW_warp_idx_stop_all[fs_idx - 1]; + bw_dist = brickwall_dist; break; } - + counter = fs_idx; + + d2_sum = sum_vec(&d2[warp_idx_start[counter - 1]], warp_idx_stop[counter - 1] - warp_idx_start[counter - 1] + 1); - d2_sum = sum_vec( &d2[warp_idx_start[counter - 1]], warp_idx_stop[counter - 1] - warp_idx_start[counter - 1] + 1 ); - - d2_mean = d2_sum / ( warp_idx_stop[counter - 1] - warp_idx_start[counter - 1] + 1 ); + d2_mean = d2_sum / (warp_idx_stop[counter - 1] - warp_idx_start[counter - 1] + 1); - while ( d2_mean < threshold_quiet[counter - 1] ) - { + while (d2_mean < threshold_quiet[counter - 1]) { d2_sum = 0; counter--; - if ( counter == 0 ) - { + if (counter == 0) { break; } /* calculate mean energy per band */ d2_sum = - sum_vec( &d2[warp_idx_start[counter - 1]], warp_idx_stop[counter - 1] - warp_idx_start[counter - 1] + 1 ); + sum_vec(&d2[warp_idx_start[counter - 1]], warp_idx_stop[counter - 1] - warp_idx_start[counter - 1] + 1); - d2_mean = d2_sum / ( warp_idx_stop[counter - 1] - warp_idx_start[counter - 1] + 1 ); + d2_mean = d2_sum / (warp_idx_stop[counter - 1] - warp_idx_start[counter - 1] + 1); } *bw_idx = counter; /* check if energy difference between bands is present */ - if ( *bw_idx < fs_idx ) - { - thr = (LC3_FLOAT) threshold_brickwall[counter]; + if (*bw_idx < fs_idx) { + thr = (LC3_FLOAT)threshold_brickwall[counter]; stop = warp_idx_start[counter]; dist = bw_dist[counter]; - for ( i = stop; i >= stop - dist; i-- ) - { - e_diff = 10.0 * LC3_LOGTEN( d2[i - dist + 1] + FLT_EPSILON ) - 10.0 * LC3_LOGTEN( d2[i + 1] + FLT_EPSILON ); + for (i = stop; i >= stop - dist; i--) { + e_diff = 10.0 * LC3_LOGTEN(d2[i - dist + 1] + FLT_EPSILON) - 10.0 * LC3_LOGTEN(d2[i + 1] + FLT_EPSILON); - if ( e_diff > thr ) - { + if (e_diff > thr) { brickwall = 1; break; } } - if ( brickwall == 0 ) - { + if (brickwall == 0) { *bw_idx = fs_idx; } } diff --git a/lib_lc3plus/enc_entropy.c b/lib_lc3plus/enc_entropy.c index ae9cbbc44e..a7ff8cd700 100644 --- a/lib_lc3plus/enc_entropy.c +++ b/lib_lc3plus/enc_entropy.c @@ -1,140 +1,126 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -void processEncoderEntropy_fl( LC3_UINT8 *bytes, LC3_INT *bp_side, LC3_INT *mask_side, LC3_INT numbytes, LC3_INT bw_cutoff_bits, LC3_INT bw_cutoff_idx, LC3_INT lastnz, LC3_INT N, LC3_INT lsbMode, LC3_INT gg_idx, LC3_INT num_tns_filters, LC3_INT *tns_order, LC3_INT *ltpf_idx, LC3_INT *scf_idx, LC3_INT fac_ns_idx, LC3_INT bfi_ext, LC3_INT fs_idx ) +void processEncoderEntropy_fl(LC3_UINT8* bytes, LC3_INT* bp_side, LC3_INT* mask_side, LC3_INT numbytes, LC3_INT bw_cutoff_bits, + LC3_INT bw_cutoff_idx, LC3_INT lastnz, LC3_INT N, LC3_INT lsbMode, LC3_INT gg_idx, LC3_INT num_tns_filters, + LC3_INT* tns_order, LC3_INT* ltpf_idx, LC3_INT* scf_idx, LC3_INT fac_ns_idx + , LC3_INT bfi_ext, LC3_INT fs_idx + ) { - LC3_UINT8 *ptr; - LC3_INT i = 0, submodeMSB = 0, submodeLSB = 0, tmp = 0, gainMSB = 0, gainLSB = 0; - LC3_INT gainMSBbits[4] = { 1, 1, 2, 2 }, gainLSBbits[4] = { 0, 1, 0, 1 }; - - LC3_INT16 lastnzTrigger[5] = { 63, 127, 127, 255, 255 }; + LC3_UINT8* ptr; + LC3_INT i = 0, submodeMSB = 0, submodeLSB = 0, tmp = 0, gainMSB = 0, gainLSB = 0; + LC3_INT gainMSBbits[4] = {1, 1, 2, 2}, gainLSBbits[4] = {0, 1, 0, 1}; + + LC3_INT16 lastnzTrigger[5] = {63, 127, 127, 255, 255}; - *bp_side = numbytes - 1; + *bp_side = numbytes - 1; *mask_side = 1; - ptr = bytes; + ptr = bytes; /* Bandwidth */ - if ( bw_cutoff_bits > 0 ) - { - write_uint_backward_fl( ptr, bp_side, mask_side, bw_cutoff_idx, bw_cutoff_bits ); + if (bw_cutoff_bits > 0) { + write_uint_backward_fl(ptr, bp_side, mask_side, bw_cutoff_idx, bw_cutoff_bits); } /* Last non zero touple */ - if ( bfi_ext == 1 ) - { - write_uint_backward_fl( ptr, bp_side, mask_side, lastnzTrigger[fs_idx], ceil( LC3_LOGTWO( N >> 1 ) ) ); + if (bfi_ext == 1) { + write_uint_backward_fl(ptr, bp_side, mask_side, lastnzTrigger[fs_idx], ceil(LC3_LOGTWO(N >> 1))); } else { - write_uint_backward_fl( ptr, bp_side, mask_side, lastnz / 2 - 1, ceil( LC3_LOGTWO( N / 2 ) ) ); + write_uint_backward_fl(ptr, bp_side, mask_side, lastnz / 2 - 1, ceil(LC3_LOGTWO(N / 2))); } /* LSB mode bit */ - write_bit_backward_fl( ptr, bp_side, mask_side, lsbMode ); + write_bit_backward_fl(ptr, bp_side, mask_side, lsbMode); /* Global gain */ - write_uint_backward_fl( ptr, bp_side, mask_side, gg_idx, 8 ); + write_uint_backward_fl(ptr, bp_side, mask_side, gg_idx, 8); /* TNS activation flag */ - for ( i = 0; i < num_tns_filters; i++ ) - { - write_bit_backward_fl( ptr, bp_side, mask_side, MIN( 1, tns_order[i] ) ); + for (i = 0; i < num_tns_filters; i++) { + write_bit_backward_fl(ptr, bp_side, mask_side, MIN(1, tns_order[i])); } /* LTPF activation flag */ - write_bit_backward_fl( ptr, bp_side, mask_side, ltpf_idx[0] ); + write_bit_backward_fl(ptr, bp_side, mask_side, ltpf_idx[0]); /* SNS-VQ 1st stage */ - write_uint_backward_fl( ptr, bp_side, mask_side, scf_idx[0], 5 ); - write_uint_backward_fl( ptr, bp_side, mask_side, scf_idx[1], 5 ); + write_uint_backward_fl(ptr, bp_side, mask_side, scf_idx[0], 5); + write_uint_backward_fl(ptr, bp_side, mask_side, scf_idx[1], 5); /* SNS-VQ 2nd stage side-info (3-4 bits) */ submodeMSB = scf_idx[2] / 2; submodeLSB = scf_idx[2] & 1; - write_bit_backward_fl( ptr, bp_side, mask_side, submodeMSB ); - gainMSB = scf_idx[3] >> ( gainLSBbits[scf_idx[2]] ); + write_bit_backward_fl(ptr, bp_side, mask_side, submodeMSB); + gainMSB = scf_idx[3] >> (gainLSBbits[scf_idx[2]]); gainLSB = scf_idx[3] & 1; - write_uint_backward_fl( ptr, bp_side, mask_side, gainMSB, gainMSBbits[scf_idx[2]] ); - write_bit_backward_fl( ptr, bp_side, mask_side, scf_idx[4] ); + write_uint_backward_fl(ptr, bp_side, mask_side, gainMSB, gainMSBbits[scf_idx[2]]); + write_bit_backward_fl(ptr, bp_side, mask_side, scf_idx[4]); /* SNS-VQ 2nd stage MPVQ data (24-25 bits) */ - if ( submodeMSB == 0 ) - { - if ( submodeLSB == 0 ) - { + if (submodeMSB == 0) { + if (submodeLSB == 0) { tmp = scf_idx[6] + 2; - } - else - { + } else { tmp = gainLSB; } tmp = tmp * 2390004 + scf_idx[5]; - write_uint_backward_fl( ptr, bp_side, mask_side, tmp, 25 ); - } - else - { + write_uint_backward_fl(ptr, bp_side, mask_side, tmp, 25); + } else { tmp = scf_idx[5]; - if ( submodeLSB != 0 ) - { + if (submodeLSB != 0) { tmp = 2 * tmp + gainLSB + 15158272; } - write_uint_backward_fl( ptr, bp_side, mask_side, tmp, 24 ); + write_uint_backward_fl(ptr, bp_side, mask_side, tmp, 24); } /* LTPF data */ - if ( ltpf_idx[0] == 1 ) - { - write_uint_backward_fl( ptr, bp_side, mask_side, ltpf_idx[1], 1 ); - write_uint_backward_fl( ptr, bp_side, mask_side, ltpf_idx[2], 9 ); + if (ltpf_idx[0] == 1) { + write_uint_backward_fl(ptr, bp_side, mask_side, ltpf_idx[1], 1); + write_uint_backward_fl(ptr, bp_side, mask_side, ltpf_idx[2], 9); } /* Noise factor */ - write_uint_backward_fl( ptr, bp_side, mask_side, fac_ns_idx, 3 ); + write_uint_backward_fl(ptr, bp_side, mask_side, fac_ns_idx, 3); } -void write_uint_backward_fl( LC3_UINT8 *ptr, LC3_INT *bp_side, LC3_INT *mask_side, LC3_INT val, LC3_INT numbits ) +void write_uint_backward_fl(LC3_UINT8* ptr, LC3_INT* bp_side, LC3_INT* mask_side, LC3_INT val, LC3_INT numbits) { LC3_INT k = 0, bit = 0; - for ( k = 0; k < numbits; k++ ) - { + for (k = 0; k < numbits; k++) { bit = val & 1; - write_bit_backward_fl( ptr, bp_side, mask_side, bit ); + write_bit_backward_fl(ptr, bp_side, mask_side, bit); val = val / 2; } } -void write_bit_backward_fl( LC3_UINT8 *ptr, LC3_INT *bp_side, LC3_INT *mask_side, LC3_INT bit ) +void write_bit_backward_fl(LC3_UINT8* ptr, LC3_INT* bp_side, LC3_INT* mask_side, LC3_INT bit) { - if ( bit == 0 ) - { - ptr[*bp_side] = ptr[*bp_side] & ( 255 - *mask_side ); - } - else - { + if (bit == 0) { + ptr[*bp_side] = ptr[*bp_side] & (255 - *mask_side); + } else { ptr[*bp_side] = ptr[*bp_side] | *mask_side; } - if ( *mask_side == 128 ) - { + if (*mask_side == 128) { *mask_side = 1; - *bp_side = *bp_side - 1; - } - else - { + *bp_side = *bp_side - 1; + } else { *mask_side = *mask_side * 2; } } diff --git a/lib_lc3plus/enc_lc3_fl.c b/lib_lc3plus/enc_lc3_fl.c index f5375ed742..c89f7244ca 100644 --- a/lib_lc3plus/enc_lc3_fl.c +++ b/lib_lc3plus/enc_lc3_fl.c @@ -1,139 +1,131 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -static void Enc_LC3PLUS_Channel_fl( LC3PLUS_Enc *encoder, int channel, int32_t *s_in, uint8_t *bytes, int bps, LC3_INT32 bfi_ext ) +static void Enc_LC3PLUS_Channel_fl(LC3PLUS_Enc* encoder, int channel, int32_t* s_in, uint8_t* bytes, int bps +, LC3_INT32 bfi_ext +) { - EncSetup *h_EncSetup; + EncSetup* h_EncSetup; LC3_INT s_12k8_len = 0, T0_out = 0, ltpfBits = 0, BW_cutoff_idx = 0, tns_numfilters = 0, quantizedGain = 0, - quantizedGainMin = 0, nbits = 0, nbits2 = 0, lastnz = 0, lsbMode = 0, gainChange = 0, bp_side = 0, - mask_side = 0, fac_ns_idx = 0, numResBits = 0, tns_order[2] = { 0 }, i = 0; + quantizedGainMin = 0, nbits = 0, nbits2 = 0, lastnz = 0, lsbMode = 0, gainChange = 0, bp_side = 0, + mask_side = 0, fac_ns_idx = 0, numResBits = 0, tns_order[2] = {0}, i = 0; LC3_FLOAT normcorr = 0, gain = 0; + - - LC3_FLOAT d_fl[MAX_LEN] = { 0 }; - LC3_INT q_d[MAX_LEN] = { 0 }; - LC3_INT indexes[TNS_NUMFILTERS_MAX * MAXLAG] = { 0 }; + LC3_FLOAT d_fl[MAX_LEN] = {0}; + LC3_INT q_d[MAX_LEN] = {0}; + LC3_INT indexes[TNS_NUMFILTERS_MAX * MAXLAG] = {0}; h_EncSetup = encoder->channel_setup[channel]; - memset( bytes, 0, sizeof( uint8_t ) * h_EncSetup->targetBytes ); + memset(bytes, 0, sizeof(uint8_t) * h_EncSetup->targetBytes); - if ( bps == 24 ) - { - for ( i = 0; i < encoder->frame_length; i++ ) - { - int32_t tmp = ( (int32_t *) s_in )[i]; + if (bps == 24) { + for (i = 0; i < encoder->frame_length; i++) { + int32_t tmp = ((int32_t*)s_in)[i]; - if ( tmp >= 0 ) + if (tmp >= 0) { tmp = tmp & 0x007fffff; } else { - tmp = tmp | (int32_t) 0xff800000; + tmp = tmp | (int32_t)0xff800000; } - h_EncSetup->s_in_scaled[i] = ( (LC3_FLOAT) tmp / (float) LC3_POW( 2, 8 ) ); + h_EncSetup->s_in_scaled[i] = ((LC3_FLOAT) tmp / (float) LC3_POW(2, 8)); } - } - else if ( bps == 16 ) - { - for ( i = 0; i < encoder->frame_length; i++ ) - { - h_EncSetup->s_in_scaled[i] = (LC3_FLOAT) ( (int16_t *) s_in )[i]; + } else if (bps == 16) { + for (i = 0; i < encoder->frame_length; i++) { + h_EncSetup->s_in_scaled[i] = (LC3_FLOAT)((int16_t*)s_in)[i]; } } /* MDCT */ - processMdct_fl( h_EncSetup->s_in_scaled, d_fl, &h_EncSetup->mdctStruct ); + processMdct_fl(h_EncSetup->s_in_scaled, d_fl, &h_EncSetup->mdctStruct); /* 12.8 kHz resampler */ - process_resamp12k8_fl( h_EncSetup->s_in_scaled, encoder->frame_length, h_EncSetup->r12k8_mem_in, - encoder->r12k8_mem_in_len, h_EncSetup->r12k8_mem_50, h_EncSetup->r12k8_mem_out, - encoder->r12k8_mem_out_len, h_EncSetup->s_12k8, &s_12k8_len, encoder->fs_idx, - encoder->frame_dms, encoder->fs ); + process_resamp12k8_fl(h_EncSetup->s_in_scaled, encoder->frame_length, h_EncSetup->r12k8_mem_in, + encoder->r12k8_mem_in_len, h_EncSetup->r12k8_mem_50, h_EncSetup->r12k8_mem_out, + encoder->r12k8_mem_out_len, h_EncSetup->s_12k8, &s_12k8_len, encoder->fs_idx, + encoder->frame_dms, encoder->fs); /* Pitch estimation */ - processOlpa_fl( h_EncSetup->s_12k8, h_EncSetup->olpa_mem_s12k8, h_EncSetup->olpa_mem_s6k4, - &h_EncSetup->olpa_mem_pitch, &T0_out, &normcorr, s_12k8_len, encoder->frame_dms ); + processOlpa_fl(h_EncSetup->s_12k8, h_EncSetup->olpa_mem_s12k8, h_EncSetup->olpa_mem_s6k4, + &h_EncSetup->olpa_mem_pitch, &T0_out, &normcorr, s_12k8_len, encoder->frame_dms); /* LTPF encoder */ - process_ltpf_coder_fl( h_EncSetup->s_12k8, s_12k8_len + 1, h_EncSetup->ltpf_enable, T0_out, normcorr, - encoder->frame_dms, h_EncSetup->ltpf_mem_in, encoder->ltpf_mem_in_len, - &h_EncSetup->ltpf_mem_normcorr, &h_EncSetup->ltpf_mem_ltpf_on, - &h_EncSetup->ltpf_mem_pitch, h_EncSetup->ltpf_param, &h_EncSetup->ltpf_mem_mem_normcorr, - <pfBits ); + process_ltpf_coder_fl(h_EncSetup->s_12k8, s_12k8_len + 1, h_EncSetup->ltpf_enable, T0_out, normcorr, + encoder->frame_dms, h_EncSetup->ltpf_mem_in, encoder->ltpf_mem_in_len, + &h_EncSetup->ltpf_mem_normcorr, &h_EncSetup->ltpf_mem_ltpf_on, + &h_EncSetup->ltpf_mem_pitch, h_EncSetup->ltpf_param, &h_EncSetup->ltpf_mem_mem_normcorr, + <pfBits); /* Attack detector */ - attack_detector_fl( h_EncSetup->s_in_scaled, encoder->frame_length, encoder->fs, &h_EncSetup->attdec_position, - &h_EncSetup->attdec_acc_energy, &h_EncSetup->attdec_detected, h_EncSetup->attdec_filter_mem, - h_EncSetup->attack_handling, encoder->attdec_nblocks, encoder->attdec_hangover_thresh ); + attack_detector_fl(h_EncSetup->s_in_scaled, encoder->frame_length, encoder->fs, &h_EncSetup->attdec_position, + &h_EncSetup->attdec_acc_energy, &h_EncSetup->attdec_detected, h_EncSetup->attdec_filter_mem, + h_EncSetup->attack_handling, encoder->attdec_nblocks, encoder->attdec_hangover_thresh); /* Per-band energy */ - processPerBandEnergy_fl( encoder->bands_number, encoder->bands_offset, encoder->hrmode, encoder->frame_dms, h_EncSetup->ener, d_fl ); + processPerBandEnergy_fl(encoder->bands_number, encoder->bands_offset, encoder->hrmode, encoder->frame_dms, h_EncSetup->ener, d_fl); /* Near Nyquist detector */ - processNearNyquistdetector_fl( &encoder->near_nyquist_flag, encoder->fs_idx, encoder->near_nyquist_index, encoder->bands_number, h_EncSetup->ener ); + processNearNyquistdetector_fl(&encoder->near_nyquist_flag, encoder->fs_idx, encoder->near_nyquist_index, encoder->bands_number, h_EncSetup->ener); /* Disable LTPF if nyquist detector triggers or -lfe mode is active*/ - if ( encoder->near_nyquist_flag != 0 || h_EncSetup->lfe == 1 ) + if (encoder->near_nyquist_flag != 0 || h_EncSetup->lfe == 1) { h_EncSetup->ltpf_mem_ltpf_on = 0; h_EncSetup->ltpf_param[1] = 0; } /* Bandwidth cut-off detection */ - if ( h_EncSetup->lfe == 0 ) - { - /* No BW Cutoff for 8 kHz and 96 kHz. No detection if bandwidth controller is active */ - if ( encoder->fs_idx > 0 && encoder->hrmode == 0 && encoder->bw_ctrl_active == 0 ) - { - processDetectCutoffWarped_fl( h_EncSetup->ener, encoder->fs_idx, encoder->frame_dms, &BW_cutoff_idx ); - } - else - { - BW_cutoff_idx = encoder->fs_idx; - } + if (h_EncSetup->lfe == 0) { + /* No BW Cutoff for 8 kHz and 96 kHz. No detection if bandwidth controller is active */ + if (encoder->fs_idx > 0 && encoder->hrmode == 0 && encoder->bw_ctrl_active == 0) { + processDetectCutoffWarped_fl(h_EncSetup->ener, encoder->fs_idx, encoder->frame_dms, &BW_cutoff_idx); + } else { + BW_cutoff_idx = encoder->fs_idx; } - else - { + } else { BW_cutoff_idx = 0; } - processSnsComputeScf_fl( h_EncSetup->ener, encoder->tilt, encoder->bands_number, h_EncSetup->scf, - h_EncSetup->attdec_detected, encoder->sns_damping, encoder->attdec_damping ); + processSnsComputeScf_fl(h_EncSetup->ener, encoder->tilt, encoder->bands_number, h_EncSetup->scf, + h_EncSetup->attdec_detected, encoder->sns_damping, encoder->attdec_damping); /* SNS Quantizer */ - process_snsQuantizesScf_Enc( h_EncSetup->scf, h_EncSetup->L_scf_idx, h_EncSetup->scf_q, h_EncSetup->dct2StructSNS ); + process_snsQuantizesScf_Enc(h_EncSetup->scf, h_EncSetup->L_scf_idx, h_EncSetup->scf_q, h_EncSetup->dct2StructSNS); /* SNS Interpolation */ - processSnsInterpolateScf_fl( h_EncSetup->scf_q, 1, encoder->bands_number, h_EncSetup->int_scf ); + processSnsInterpolateScf_fl(h_EncSetup->scf_q, 1, encoder->bands_number, h_EncSetup->int_scf); /* MDCT shaping */ - processMdctShaping_fl( d_fl, h_EncSetup->int_scf, encoder->bands_offset, encoder->bands_number ); - + processMdctShaping_fl(d_fl, h_EncSetup->int_scf, encoder->bands_offset, encoder->bands_number); + /* Bandwidth controller */ - if ( encoder->bandwidth < encoder->fs / 2 ) - { - process_cutoff_bandwidth( d_fl, encoder->yLen, encoder->bw_ctrl_cutoff_bin ); - BW_cutoff_idx = MIN( BW_cutoff_idx, encoder->bw_index ); + if (encoder->bandwidth < encoder->fs / 2) { + process_cutoff_bandwidth(d_fl, encoder->yLen, encoder->bw_ctrl_cutoff_bin); + BW_cutoff_idx = MIN(BW_cutoff_idx, encoder->bw_index); } - + /* TNS encoder */ - if ( h_EncSetup->lfe == 0 ) + if (h_EncSetup->lfe == 0) { - processTnsCoder_fl( d_fl, BW_cutoff_idx, encoder->cutoffBins[BW_cutoff_idx], encoder->fs, encoder->frame_length, - encoder->frame_dms, h_EncSetup->total_bits, tns_order, indexes, &tns_numfilters, - &( h_EncSetup->tns_bits ), encoder->near_nyquist_flag ); + processTnsCoder_fl(d_fl, BW_cutoff_idx, encoder->cutoffBins[BW_cutoff_idx], encoder->fs, encoder->frame_length, + encoder->frame_dms, h_EncSetup->total_bits, tns_order, indexes, &tns_numfilters, + &(h_EncSetup->tns_bits) + , encoder->near_nyquist_flag + ); } else { @@ -142,109 +134,119 @@ static void Enc_LC3PLUS_Channel_fl( LC3PLUS_Enc *encoder, int channel, int32_t * h_EncSetup->tns_bits = tns_numfilters; } /* Global Gain Estimation */ - h_EncSetup->targetBitsQuant = h_EncSetup->targetBitsInit - ( h_EncSetup->tns_bits + ltpfBits ); + h_EncSetup->targetBitsQuant = h_EncSetup->targetBitsInit - (h_EncSetup->tns_bits + ltpfBits); - if ( h_EncSetup->targetBitsQuant < 0 && ltpfBits > 1 ) + if (h_EncSetup->targetBitsQuant < 0 && ltpfBits > 1) { /* Disable LTPF */ h_EncSetup->ltpf_mem_ltpf_on = 0; - h_EncSetup->ltpf_param[1] = 0; - ltpfBits = 1; - h_EncSetup->targetBitsQuant = h_EncSetup->targetBitsInit - ( h_EncSetup->tns_bits + ltpfBits ); + h_EncSetup->ltpf_param[1] = 0; + ltpfBits = 1; + h_EncSetup->targetBitsQuant = h_EncSetup->targetBitsInit - (h_EncSetup->tns_bits + ltpfBits); } - processEstimateGlobalGain_fl( d_fl, encoder->yLen, h_EncSetup->targetBitsQuant, &gain, &quantizedGain, - &quantizedGainMin, h_EncSetup->quantizedGainOff, &h_EncSetup->targetBitsOff, - &h_EncSetup->mem_targetBits, h_EncSetup->mem_specBits, encoder->hrmode, h_EncSetup->regBits, encoder->frame_ms + processEstimateGlobalGain_fl(d_fl, encoder->yLen, h_EncSetup->targetBitsQuant, &gain, &quantizedGain, + &quantizedGainMin, h_EncSetup->quantizedGainOff, &h_EncSetup->targetBitsOff, + &h_EncSetup->mem_targetBits, h_EncSetup->mem_specBits + , encoder->hrmode, h_EncSetup->regBits, encoder->frame_ms ); /* 1. Quantization */ - processQuantizeSpec_fl( d_fl, gain, q_d, encoder->yLen, h_EncSetup->total_bits, &nbits, &nbits2, encoder->fs, - &lastnz, h_EncSetup->codingdata, &lsbMode, -1, h_EncSetup->targetBitsQuant, encoder->hrmode ); + processQuantizeSpec_fl(d_fl, gain, q_d, encoder->yLen, h_EncSetup->total_bits, &nbits, &nbits2, encoder->fs, + &lastnz, h_EncSetup->codingdata, &lsbMode, -1, h_EncSetup->targetBitsQuant, encoder->hrmode + ); h_EncSetup->mem_specBits = nbits; /* Global Gain Adjustment */ - processAdjustGlobalGain_fl( &quantizedGain, quantizedGainMin, h_EncSetup->quantizedGainOff, &gain, - h_EncSetup->targetBitsQuant, h_EncSetup->mem_specBits, &gainChange, encoder->fs_idx, encoder->hrmode, encoder->frame_dms ); + processAdjustGlobalGain_fl(&quantizedGain, quantizedGainMin, h_EncSetup->quantizedGainOff, &gain, + h_EncSetup->targetBitsQuant, h_EncSetup->mem_specBits, &gainChange, encoder->fs_idx + , encoder->hrmode, encoder->frame_dms + ); /* 2. Quantization */ - if ( gainChange ) - { - processQuantizeSpec_fl( d_fl, gain, q_d, encoder->yLen, h_EncSetup->total_bits, &nbits, &nbits2, encoder->fs, - &lastnz, - h_EncSetup->codingdata, - &lsbMode, 0, h_EncSetup->targetBitsQuant, encoder->hrmode ); + if (gainChange) { + processQuantizeSpec_fl(d_fl, gain, q_d, encoder->yLen, h_EncSetup->total_bits, &nbits, &nbits2, encoder->fs, + &lastnz, + h_EncSetup->codingdata, + &lsbMode, 0, h_EncSetup->targetBitsQuant + , encoder->hrmode + ); } /* Noise factor */ - if ( h_EncSetup->lfe == 0 ) - { - processNoiseFactor_fl( &fac_ns_idx, d_fl, q_d, gain, encoder->cutoffBins[BW_cutoff_idx], encoder->frame_dms, - h_EncSetup->targetBytes ); + if (h_EncSetup->lfe == 0) + { + processNoiseFactor_fl(&fac_ns_idx, d_fl, q_d, gain, encoder->cutoffBins[BW_cutoff_idx], encoder->frame_dms, + h_EncSetup->targetBytes + ); } else { fac_ns_idx = 7; } /* Residual Coding */ - if ( lsbMode == 0 ) - { - processResidualCoding_fl( d_fl, q_d, gain, encoder->yLen, h_EncSetup->targetBitsQuant, nbits2, - h_EncSetup->resBits, &numResBits, encoder->hrmode ); - } - else - { + if (lsbMode == 0) { + processResidualCoding_fl(d_fl, q_d, gain, encoder->yLen, h_EncSetup->targetBitsQuant, nbits2, + h_EncSetup->resBits, &numResBits + , encoder->hrmode + ); + } else { numResBits = 0; } /* Entropy encoding */ - processEncoderEntropy_fl( bytes, &bp_side, &mask_side, h_EncSetup->targetBytes, encoder->BW_cutoff_bits, - BW_cutoff_idx, lastnz, encoder->yLen, lsbMode, quantizedGain, tns_numfilters, tns_order, - h_EncSetup->ltpf_param, h_EncSetup->L_scf_idx, fac_ns_idx, bfi_ext, encoder->fs_idx ); + processEncoderEntropy_fl(bytes, &bp_side, &mask_side, h_EncSetup->targetBytes, encoder->BW_cutoff_bits, + BW_cutoff_idx, lastnz, encoder->yLen, lsbMode, quantizedGain, tns_numfilters, tns_order, + h_EncSetup->ltpf_param, h_EncSetup->L_scf_idx, fac_ns_idx + , bfi_ext, encoder->fs_idx + ); /* Artithmetic encoding */ - processAriEncoder_fl( bytes, bp_side, mask_side, q_d, tns_order, tns_numfilters, indexes, lastnz, - h_EncSetup->codingdata, - h_EncSetup->resBits, numResBits, lsbMode, h_EncSetup->targetBitsAri, - h_EncSetup->enable_lpc_weighting ); - - if ( encoder->combined_channel_coding == 0 && h_EncSetup->n_pc > 0 ) + processAriEncoder_fl(bytes, bp_side, mask_side, q_d, tns_order, tns_numfilters, indexes, lastnz, + h_EncSetup->codingdata, + h_EncSetup->resBits, numResBits, lsbMode, h_EncSetup->targetBitsAri, + h_EncSetup->enable_lpc_weighting); + + if (encoder->combined_channel_coding == 0 && h_EncSetup->n_pc > 0) { - LC3_INT32 xbuf[MAX_LEN] = { 0 }, nf_seed, tns_idx[M], zero_frame, nbits_residual, residualPresent, b_left, spec_inv_idx; - - memset( h_EncSetup->resBits, 0, sizeof( *( h_EncSetup->resBits ) ) * MAX_RESBITS_LEN ); - - processAriDecoder_fl( bytes, bp_side, mask_side, encoder->yLen, encoder->fs_idx, h_EncSetup->enable_lpc_weighting, - tns_numfilters, lsbMode, lastnz, &bfi_ext, tns_order, fac_ns_idx, quantizedGain, - h_EncSetup->resBits, xbuf, &nf_seed, tns_idx, &zero_frame, h_EncSetup->targetBytes, &nbits_residual, - &residualPresent, encoder->frame_dms, h_EncSetup->n_pc, 0, h_EncSetup->total_bits >> 3, 1, &b_left, - &spec_inv_idx, encoder->hrmode ); - - processReorderBitstream_fl( bytes, h_EncSetup->n_pccw, h_EncSetup->n_pc, b_left, h_EncSetup->targetBytes ); + LC3_INT32 xbuf[MAX_LEN] = {0}, nf_seed, tns_idx[M], zero_frame, nbits_residual, residualPresent, b_left, spec_inv_idx; + + memset(h_EncSetup->resBits, 0, sizeof(*(h_EncSetup->resBits)) * MAX_RESBITS_LEN); + + processAriDecoder_fl(bytes, bp_side, mask_side, encoder->yLen, encoder->fs_idx, h_EncSetup->enable_lpc_weighting, + tns_numfilters, lsbMode, lastnz, &bfi_ext, tns_order, fac_ns_idx, quantizedGain, + h_EncSetup->resBits, xbuf, &nf_seed, tns_idx, &zero_frame, h_EncSetup->targetBytes, &nbits_residual, + &residualPresent, encoder->frame_dms, h_EncSetup->n_pc, 0, h_EncSetup->total_bits >> 3, 1, &b_left, + &spec_inv_idx, encoder->hrmode); + + processReorderBitstream_fl(bytes, h_EncSetup->n_pccw, h_EncSetup->n_pc, b_left, h_EncSetup->targetBytes); } + } -int Enc_LC3PLUS_fl( LC3PLUS_Enc *encoder, void **input, uint8_t *output, int bps, LC3_INT32 bfi_ext ) +int Enc_LC3PLUS_fl(LC3PLUS_Enc* encoder, void** input, uint8_t* output, int bps +, LC3_INT32 bfi_ext +) { - int ch = 0, output_size = 0; - uint8_t *lc3buf = output; + int ch = 0, output_size = 0; + uint8_t* lc3buf = output; LC3_INT32 totalBytes; LC3_INT32 output_size2, input_size; + + totalBytes = encoder->bitrate * encoder->frame_length / (8 * encoder->fs_in); - totalBytes = encoder->bitrate * encoder->frame_length / ( 8 * encoder->fs_in ); - - for ( ch = 0; ch < encoder->channels; ch++ ) + for (ch = 0; ch < encoder->channels; ch++) { - Enc_LC3PLUS_Channel_fl( encoder, ch, input[ch], lc3buf, bps, bfi_ext ); - if ( encoder->epmode && encoder->combined_channel_coding == 0 ) + Enc_LC3PLUS_Channel_fl(encoder, ch, input[ch], lc3buf, bps, bfi_ext); + if (encoder->epmode && encoder->combined_channel_coding == 0) { - output_size2 = totalBytes / encoder->channels + ( ch < ( totalBytes % encoder->channels ) ); + output_size2 = totalBytes / encoder->channels + (ch < (totalBytes % encoder->channels)); - fec_encoder( encoder->epmode, encoder->epmr, lc3buf, encoder->channel_setup[ch]->targetBytes, output_size2, - encoder->channel_setup[ch]->n_pccw ); + fec_encoder(encoder->epmode, encoder->epmr, lc3buf, encoder->channel_setup[ch]->targetBytes, output_size2, + encoder->channel_setup[ch]->n_pccw); lc3buf += output_size2; output_size += output_size2; @@ -256,13 +258,13 @@ int Enc_LC3PLUS_fl( LC3PLUS_Enc *encoder, void **input, uint8_t *output, int bps } } - if ( encoder->epmode > 0 && encoder->combined_channel_coding ) + if (encoder->epmode > 0 && encoder->combined_channel_coding) { - input_size = output_size; - output_size = encoder->bitrate * encoder->frame_length / ( 8 * encoder->fs_in ); + input_size = output_size; + output_size = encoder->bitrate * encoder->frame_length / (8 * encoder->fs_in); - fec_encoder( encoder->epmode, encoder->epmr, output, input_size, output_size, encoder->channel_setup[0]->n_pccw ); + fec_encoder(encoder->epmode, encoder->epmr, output, input_size, output_size, encoder->channel_setup[0]->n_pccw); } - + return output_size; } diff --git a/lib_lc3plus/estimate_global_gain.c b/lib_lc3plus/estimate_global_gain.c index 6d637f82ea..df9b1f5f23 100644 --- a/lib_lc3plus/estimate_global_gain.c +++ b/lib_lc3plus/estimate_global_gain.c @@ -1,121 +1,107 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -void processEstimateGlobalGain_fl( LC3_FLOAT x[], LC3_INT lg, LC3_INT nbitsSQ, LC3_FLOAT *gain, LC3_INT *quantizedGain, LC3_INT *quantizedGainMin, LC3_INT quantizedGainOff, LC3_FLOAT *targetBitsOff, LC3_INT *old_targetBits, LC3_INT old_specBits, LC3_INT hrmode, LC3_INT regBits, LC3_FLOAT frame_ms ) +void processEstimateGlobalGain_fl(LC3_FLOAT x[], LC3_INT lg, LC3_INT nbitsSQ, LC3_FLOAT* gain, LC3_INT* quantizedGain, + LC3_INT* quantizedGainMin, LC3_INT quantizedGainOff, LC3_FLOAT* targetBitsOff, + LC3_INT* old_targetBits, LC3_INT old_specBits + , LC3_INT hrmode , LC3_INT regBits, LC3_FLOAT frame_ms +) { - LC3_INT i = 0, N = 0, offset = 0, j = 0, iszero = 0; + LC3_INT i = 0, N = 0, offset = 0, j = 0, iszero = 0; LC3_FLOAT g_min = 0, x_max = 0, tmp = 0, ind = 0, ind_min = 0, target = 0, fac = 0, ener = 0; - LC3_FLOAT en[MAX_LEN / 4] = { 0 }; + LC3_FLOAT en[MAX_LEN / 4] = {0}; LC3_FLOAT reg_val = 4.656612873077393e-10; - if ( *old_targetBits < 0 ) - { + if (*old_targetBits < 0) { *targetBitsOff = 0; - } - else - { - tmp = MIN( 40, MAX( -40, *targetBitsOff + *old_targetBits - old_specBits ) ); + } else { + tmp = MIN(40, MAX(-40, *targetBitsOff + *old_targetBits - old_specBits)); *targetBitsOff = 0.8 * *targetBitsOff + 0.2 * tmp; } *old_targetBits = nbitsSQ; - nbitsSQ = nbitsSQ + round( *targetBitsOff ); + nbitsSQ = nbitsSQ + round(*targetBitsOff); - x_max = array_max_abs( x, lg ); + x_max = array_max_abs(x, lg); - if ( hrmode && regBits > 0 ) + if (hrmode && regBits > 0) { LC3_FLOAT M0 = 1e-5, M1 = 1e-5, rB_offset; - LC3_FLOAT thresh = 2 * frame_ms; - for ( i = 0; i < lg; i++ ) + LC3_FLOAT thresh = 2*frame_ms; + for (i = 0; i < lg; i++) { - M0 += fabs( x[i] ); - M1 += i * fabs( x[i] ); + M0 += fabs(x[i]); + M1 += i*fabs(x[i]); } - rB_offset = 8 * ( 1 - MIN( M1 / M0, thresh ) / thresh ); - reg_val = x_max * LC3_POW( 2, -regBits - rB_offset ); + rB_offset = 8 * (1 - MIN(M1/M0, thresh) / thresh); + reg_val = x_max * LC3_POW(2,-regBits - rB_offset); } - if ( x_max < LC3_EPS ) + if (x_max < LC3_EPS) { - ind_min = quantizedGainOff; - ind = 0; + ind_min = quantizedGainOff; + ind = 0; *old_targetBits = -1; - } - else - { - if ( hrmode == 1 ) - { - g_min = x_max / ( 32768 * 256 - 2 ); - } - else - { - g_min = x_max / ( 32767 - 0.375 ); + } else { + if (hrmode == 1) { + g_min = x_max / (32768 * 256 - 2); + } else { + g_min = x_max / (32767 - 0.375); } /* Prevent positive rounding errors from LC3_LOGTEN function */ - ind_min = 28.0 * LC3_LOGTEN( g_min ); - - ind_min = ceil( ind_min + LC3_FABS( ind_min ) * LC3_EPS ); + ind_min = 28.0 * LC3_LOGTEN(g_min); - assert( LC3_POW( 10, ind_min / 28.0 ) >= g_min ); - assert( ind_min <= ( 255 + quantizedGainOff ) ); + ind_min = ceil(ind_min + LC3_FABS(ind_min) * LC3_EPS); + + assert(LC3_POW(10, ind_min / 28.0) >= g_min); + assert(ind_min <= (255 + quantizedGainOff)); N = lg; j = 0; - for ( i = 0; i < N; i = i + 4 ) - { + for (i = 0; i < N; i = i + 4) { tmp = x[i] * x[i]; tmp += x[i + 1] * x[i + 1]; tmp += x[i + 2] * x[i + 2]; tmp += x[i + 3] * x[i + 3]; - en[j] = ( 28.0 / 20.0 ) * ( 7 + 10.0 * LC3_LOGTEN( tmp + reg_val ) ); + en[j] = (28.0 / 20.0) * (7 + 10.0 * LC3_LOGTEN(tmp + reg_val)); j++; } - target = ( 28.0 / 20.0 ) * ( 1.4 ) * nbitsSQ; - fac = 256; + target = (28.0 / 20.0) * (1.4) * nbitsSQ; + fac = 256; offset = 255 + quantizedGainOff; - for ( i = 0; i < 8; i++ ) - { - fac = fac * 0.5; + for (i = 0; i < 8; i++) { + fac = fac * 0.5; offset = offset - fac; - ener = 0; + ener = 0; iszero = 1; - for ( j = N / 4 - 1; j >= 0; j-- ) - { + for (j = N / 4 - 1; j >= 0; j--) { tmp = en[j] - offset; - if ( tmp < ( 7.0 ) * ( 28.0 / 20.0 ) ) - { - if ( iszero == 0 ) - { - ener = ener + ( 2.7 ) * ( 28.0 / 20.0 ); + if (tmp < (7.0) * (28.0 / 20.0)) { + if (iszero == 0) { + ener = ener + (2.7) * (28.0 / 20.0); } - } - else - { - if ( tmp > ( 50.0 ) * ( 28.0 / 20.0 ) ) - { - ener = ener + 2.0 * tmp - ( 50.0 ) * ( 28.0 / 20.0 ); - } - else - { + } else { + if (tmp > (50.0) * (28.0 / 20.0)) { + ener = ener + 2.0 * tmp - (50.0) * (28.0 / 20.0); + } else { ener = ener + tmp; } @@ -123,22 +109,20 @@ void processEstimateGlobalGain_fl( LC3_FLOAT x[], LC3_INT lg, LC3_INT nbitsSQ, L } } - if ( ener > target && iszero == 0 ) - { + if (ener > target && iszero == 0) { offset = offset + fac; } } - if ( offset < ind_min ) - { + if (offset < ind_min) { *old_targetBits = -1; } - ind = MAX( ind_min, offset ) - quantizedGainOff; + ind = MAX(ind_min, offset) - quantizedGainOff; } *quantizedGainMin = ind_min; - *quantizedGain = ind; + *quantizedGain = ind; - *gain = LC3_POW( 10.0, ( ( ind + quantizedGainOff ) / 28.0 ) ); + *gain = LC3_POW(10.0, ((ind + quantizedGainOff) / 28.0)); } diff --git a/lib_lc3plus/functions.h b/lib_lc3plus/functions.h index 543fc9b7fd..7a529a25d7 100644 --- a/lib_lc3plus/functions.h +++ b/lib_lc3plus/functions.h @@ -1,12 +1,12 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #ifndef FUNCTIONS_H #define FUNCTIONS_H @@ -24,234 +24,281 @@ #include "fft/iisfft.h" /* fft.c */ -void real_fft_init( Fft *fft, LC3_INT32 length, HANDLE_IIS_FFT *handle ); -void real_ifft_init( Fft *fft, LC3_INT32 length, HANDLE_IIS_FFT *handle ); -void real_fft_apply( Fft *fft, const LC3_FLOAT *in, LC3_FLOAT *out ); +void real_fft_init(Fft* fft, LC3_INT32 length, HANDLE_IIS_FFT *handle); +void real_ifft_init(Fft* fft, LC3_INT32 length, HANDLE_IIS_FFT *handle); +void real_fft_apply(Fft* fft, const LC3_FLOAT* in, LC3_FLOAT* out); -void fft_init( Fft *fft, LC3_INT length ); -void fft_free( Fft *fft ); -void real_fft_free( Fft *fft ); -void fft_apply( Fft *fft, const Complex *input, Complex *output ); +void fft_init(Fft* fft, LC3_INT length); +void fft_free(Fft* fft); +void real_fft_free(Fft* fft); +void fft_apply(Fft* fft, const Complex* input, Complex* output); /* dct.c */ -void dct2_init( Dct2 *dct, LC3_INT length ); -void dct2_free( Dct2 *dct ); -void dct2_apply( Dct2 *dct, const LC3_FLOAT *input, LC3_FLOAT *output ); +void dct2_init(Dct2* dct, LC3_INT length); +void dct2_free(Dct2* dct); +void dct2_apply(Dct2* dct, const LC3_FLOAT* input, LC3_FLOAT* output); -void dct3_init( Dct3 *dct, LC3_INT length ); -void dct3_free( Dct3 *dct ); -void dct3_apply( Dct3 *dct, const LC3_FLOAT *input, LC3_FLOAT *output ); +void dct3_init(Dct3* dct, LC3_INT length); +void dct3_free(Dct3* dct); +void dct3_apply(Dct3* dct, const LC3_FLOAT* input, LC3_FLOAT* output); -void dct4_init( Dct4 *dct, LC3_INT length ); -void dct4_free( Dct4 *dct ); -void dct4_apply( Dct4 *dct, const LC3_FLOAT *input, LC3_FLOAT *output ); +void dct4_init(Dct4* dct, LC3_INT length); +void dct4_free(Dct4* dct); +void dct4_apply(Dct4* dct, const LC3_FLOAT* input, LC3_FLOAT* output); /* mdct.c */ -void mdct_init( Mdct *mdct, LC3_INT length, LC3_INT frame_dms, LC3_INT fs_idx, LC3_INT hrmode ); -void mdct_free( Mdct *mdct ); -void mdct_apply( const LC3_FLOAT *input, LC3_FLOAT *output, Mdct *mdct ); +void mdct_init(Mdct* mdct, LC3_INT length, LC3_INT frame_dms, LC3_INT fs_idx, LC3_INT hrmode); +void mdct_free(Mdct* mdct); +void mdct_apply(const LC3_FLOAT* input, LC3_FLOAT* output, Mdct* mdct); #ifdef ENABLE_PADDING -LC3_INT paddingDec_fl( LC3_UINT8 *bytes, LC3_INT nbbits, LC3_INT L_spec, LC3_INT bw_cutoff_bits, LC3_INT ep_enabled, LC3_INT *total_padding, LC3_INT *np_zero ); +LC3_INT paddingDec_fl(LC3_UINT8* bytes, LC3_INT nbbits, LC3_INT L_spec, LC3_INT bw_cutoff_bits, LC3_INT ep_enabled, LC3_INT* total_padding, LC3_INT *np_zero); #endif -void processEncoderEntropy_fl( LC3_UINT8 *bytes, LC3_INT *bp_side, LC3_INT *mask_side, LC3_INT numbytes, LC3_INT bw_cutoff_bits, LC3_INT bw_cutoff_idx, LC3_INT lastnz, LC3_INT N, LC3_INT lsbMode, LC3_INT gg_idx, LC3_INT num_tns_filters, LC3_INT *tns_order, LC3_INT *ltpf_idx, LC3_INT *scf_idx, LC3_INT fac_ns_idx, LC3_INT bfi_ext, LC3_INT fs_idx ); -void processDecoderEntropy_fl( LC3_UINT8 *bytes, LC3_INT numbytes, LC3_INT *mask_side, LC3_INT *bp_side, LC3_INT N, LC3_INT fs_idx, LC3_INT bw_cutoff_bits, LC3_INT *bfi, LC3_INT *gg_idx, LC3_INT *scf_idx, LC3_INT *fac_ns_idx, LC3_INT *tns_numfilters, LC3_INT *tns_order, LC3_INT *ltpf_idx, LC3_INT *bw_cutoff_idx, LC3_INT *lastnz, LC3_INT *lsbMode, LC3_INT frame_dms ); -void processQuantizeSpec_fl( LC3_FLOAT x[], LC3_FLOAT gain, LC3_INT xq[], LC3_INT nt, LC3_INT totalBits, LC3_INT *nbits, LC3_INT *nbits2, LC3_INT fs, LC3_INT *lastnzout, LC3_INT *codingdata, LC3_INT *lsbMode, LC3_INT mode, LC3_INT target, LC3_INT hrmode ); - -void processEstimateGlobalGain_fl( LC3_FLOAT x[], LC3_INT lg, LC3_INT nbitsSQ, LC3_FLOAT *gain, LC3_INT *quantizedGain, LC3_INT *quantizedGainMin, LC3_INT quantizedGainOff, LC3_FLOAT *targetBitsOff, LC3_INT *old_targetBits, LC3_INT old_specBits, LC3_INT bq_mode, LC3_INT regBits, LC3_FLOAT frame_ms ); +void processEncoderEntropy_fl(LC3_UINT8* bytes, LC3_INT* bp_side, LC3_INT* mask_side, LC3_INT numbytes, LC3_INT bw_cutoff_bits, + LC3_INT bw_cutoff_idx, LC3_INT lastnz, LC3_INT N, LC3_INT lsbMode, LC3_INT gg_idx, LC3_INT num_tns_filters, + LC3_INT* tns_order, LC3_INT* ltpf_idx, LC3_INT* scf_idx, LC3_INT fac_ns_idx + , LC3_INT bfi_ext, LC3_INT fs_idx + ); +void processDecoderEntropy_fl(LC3_UINT8* bytes, LC3_INT numbytes, LC3_INT* mask_side, LC3_INT* bp_side, LC3_INT N, LC3_INT fs_idx, + LC3_INT bw_cutoff_bits, LC3_INT* bfi, LC3_INT* gg_idx, LC3_INT* scf_idx, LC3_INT* fac_ns_idx, + LC3_INT* tns_numfilters, LC3_INT* tns_order, LC3_INT* ltpf_idx, LC3_INT* bw_cutoff_idx, LC3_INT* lastnz, + LC3_INT* lsbMode, LC3_INT frame_dms + ); +void processQuantizeSpec_fl(LC3_FLOAT x[], LC3_FLOAT gain, LC3_INT xq[], LC3_INT nt, LC3_INT totalBits, LC3_INT* nbits, LC3_INT* nbits2, LC3_INT fs, + LC3_INT* lastnzout, LC3_INT* codingdata, LC3_INT* lsbMode, LC3_INT mode, LC3_INT target, LC3_INT hrmode); + +void processEstimateGlobalGain_fl(LC3_FLOAT x[], LC3_INT lg, LC3_INT nbitsSQ, LC3_FLOAT* gain, LC3_INT* quantizedGain, + LC3_INT* quantizedGainMin, LC3_INT quantizedGainOff, LC3_FLOAT* targetBitsOff, + LC3_INT* old_targetBits, LC3_INT old_specBits, LC3_INT bq_mode + , LC3_INT regBits, LC3_FLOAT frame_ms +); -void processAriDecoder_fl( LC3_UINT8 *bytes, LC3_INT bp_side, LC3_INT mask_side, LC3_INT L_spec, LC3_INT fs_idx, LC3_INT enable_lpc_weighting, LC3_INT tns_numfilters, LC3_INT lsbMode, LC3_INT lastnz, LC3_INT *bfi, LC3_INT *tns_order, LC3_INT fac_ns_idx, LC3_INT gg_idx, uint8_t *resBits, LC3_INT *x, LC3_INT *nf_seed, LC3_INT *tns_idx, LC3_INT *zero_frame, LC3_INT numbytes, LC3_INT *nbits_residual, LC3_INT *residualPresent, LC3_INT frame_dms, LC3_INT32 n_pc, LC3_INT32 be_bp_left, LC3_INT32 be_bp_right, LC3_INT32 enc, LC3_INT32 *b_left, LC3_INT32 *spec_inv_idx, LC3_INT hrmode ); +void processAriDecoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side, LC3_INT L_spec, LC3_INT fs_idx, LC3_INT enable_lpc_weighting, + LC3_INT tns_numfilters, LC3_INT lsbMode, LC3_INT lastnz, LC3_INT* bfi, LC3_INT* tns_order, LC3_INT fac_ns_idx, + LC3_INT gg_idx, uint8_t* resBits, LC3_INT* x, LC3_INT* nf_seed, LC3_INT* tns_idx, LC3_INT* zero_frame, LC3_INT numbytes, + LC3_INT* nbits_residual, LC3_INT* residualPresent, LC3_INT frame_dms, + LC3_INT32 n_pc, LC3_INT32 be_bp_left, LC3_INT32 be_bp_right, LC3_INT32 enc, LC3_INT32 *b_left, LC3_INT32 *spec_inv_idx, + LC3_INT hrmode + ); -void processMdctShaping_fl( LC3_FLOAT x[], LC3_FLOAT gains[], const LC3_INT bands_offset[], LC3_INT fdns_npts ); +void processMdctShaping_fl(LC3_FLOAT x[], LC3_FLOAT gains[], const LC3_INT bands_offset[], LC3_INT fdns_npts); -void processResidualCoding_fl( LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gain, LC3_INT L_spec, LC3_INT targetBits, LC3_INT nBits, uint8_t *resBits, LC3_INT *numResBits, LC3_INT hrmode ); +void processResidualCoding_fl(LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gain, LC3_INT L_spec, LC3_INT targetBits, LC3_INT nBits, uint8_t * resBits, + LC3_INT* numResBits + , LC3_INT hrmode +); -void processResidualDecoding_fl( LC3_INT *bitsRead, LC3_FLOAT x[], LC3_INT L_spec, uint8_t prm[], LC3_INT resQBits, LC3_INT hrmode ); +void processResidualDecoding_fl(LC3_INT* bitsRead, LC3_FLOAT x[], LC3_INT L_spec, uint8_t prm[], LC3_INT resQBits + , LC3_INT hrmode +); -void processAdjustGlobalGain_fl( LC3_INT *gg_idx, LC3_INT gg_idx_min, LC3_INT gg_idx_off, LC3_FLOAT *gain, LC3_INT target, LC3_INT nBits, LC3_INT *gainChange, LC3_INT fs_idx, LC3_INT16 hrmode, LC3_INT16 frame_dms ); +void processAdjustGlobalGain_fl(LC3_INT* gg_idx, LC3_INT gg_idx_min, LC3_INT gg_idx_off, LC3_FLOAT* gain, LC3_INT target, LC3_INT nBits, + LC3_INT* gainChange, LC3_INT fs_idx + , LC3_INT16 hrmode, LC3_INT16 frame_dms + ); -void processApplyGlobalGain_fl( LC3_FLOAT x[], LC3_INT xLen, LC3_INT global_gain_idx, LC3_INT global_gain_off ); +void processApplyGlobalGain_fl(LC3_FLOAT x[], LC3_INT xLen, LC3_INT global_gain_idx, LC3_INT global_gain_off); -void processNoiseFactor_fl( LC3_INT *fac_ns_idx, LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gg, LC3_INT BW_cutoff_idx, LC3_INT frame_dms, LC3_INT target_bytes ); +void processNoiseFactor_fl(LC3_INT* fac_ns_idx, LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gg, LC3_INT BW_cutoff_idx, LC3_INT frame_dms, + LC3_INT target_bytes + ); -void processNoiseFilling_fl( LC3_FLOAT xq[], LC3_INT nfseed, LC3_INT fac_ns_idx, LC3_INT bw_stopband, LC3_INT frame_dms, LC3_FLOAT fac_ns_pc, LC3_INT spec_inv_idx ); +void processNoiseFilling_fl(LC3_FLOAT xq[], LC3_INT nfseed, LC3_INT fac_ns_idx, LC3_INT bw_stopband, LC3_INT frame_dms, LC3_FLOAT fac_ns_pc, LC3_INT spec_inv_idx); -void processOlpa_fl( LC3_FLOAT *s_12k8, LC3_FLOAT *mem_s12k8, LC3_FLOAT *mem_s6k4, LC3_INT *mem_old_T0, LC3_INT *T0_out, LC3_FLOAT *normcorr_out, LC3_INT len, LC3_INT frame_dms ); +void processOlpa_fl(LC3_FLOAT* s_12k8, LC3_FLOAT* mem_s12k8, LC3_FLOAT* mem_s6k4, LC3_INT* mem_old_T0, LC3_INT* T0_out, + LC3_FLOAT* normcorr_out, LC3_INT len, LC3_INT frame_dms); -void processTnsCoder_fl( LC3_FLOAT *x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, LC3_INT fs, LC3_INT N, LC3_INT frame_dms, LC3_INT nBits, LC3_INT *order_out, LC3_INT *rc_idx, LC3_INT *tns_numfilters, LC3_INT *bits_out, LC3_INT16 near_nyquist_flag ); -void levinsonDurbin( LC3_FLOAT *r, LC3_FLOAT *out_lev, LC3_FLOAT *rc_unq, LC3_FLOAT *error, LC3_INT len ); +void processTnsCoder_fl(LC3_FLOAT* x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, LC3_INT fs, LC3_INT N, LC3_INT frame_dms, LC3_INT nBits, + LC3_INT* order_out, LC3_INT* rc_idx, LC3_INT* tns_numfilters, LC3_INT* bits_out + , LC3_INT16 near_nyquist_flag + ); +void levinsonDurbin(LC3_FLOAT* r, LC3_FLOAT* out_lev, LC3_FLOAT* rc_unq, LC3_FLOAT* error, LC3_INT len); -void processTnsDecoder_fl( LC3_FLOAT *x, LC3_INT *rc_idx, LC3_INT *order, LC3_INT numfilters, LC3_INT bw_fcbin, LC3_INT N, LC3_INT fs ); +void processTnsDecoder_fl(LC3_FLOAT* x, LC3_INT* rc_idx, LC3_INT* order, LC3_INT numfilters, LC3_INT bw_fcbin, LC3_INT N, LC3_INT fs); -void processSnsComputeScf_fl( LC3_FLOAT *x, LC3_INT tilt, LC3_INT xLen, LC3_FLOAT *gains, LC3_INT smooth, LC3_FLOAT sns_damping, LC3_FLOAT attdec_damping_factor ); +void processSnsComputeScf_fl(LC3_FLOAT* x, LC3_INT tilt, LC3_INT xLen, LC3_FLOAT* gains, LC3_INT smooth, LC3_FLOAT sns_damping, LC3_FLOAT attdec_damping_factor); -void processSnsInterpolateScf_fl( LC3_FLOAT *gains, LC3_INT encoder_side, LC3_INT bands_number, LC3_FLOAT *gains_LC3_INT ); +void processSnsInterpolateScf_fl(LC3_FLOAT* gains, LC3_INT encoder_side, LC3_INT bands_number, LC3_FLOAT* gains_LC3_INT); -void processDetectCutoffWarped_fl( LC3_FLOAT *d2, LC3_INT fs_idx, LC3_INT frame_dms, LC3_INT *bw_idx ); -void processNearNyquistdetector_fl( LC3_INT16 *near_nyquist_flag, const LC3_INT fs_idx, const LC3_INT near_nyquist_index, const LC3_INT bands_number, const LC3_FLOAT *ener ); +void processDetectCutoffWarped_fl(LC3_FLOAT* d2, LC3_INT fs_idx, LC3_INT frame_dms, LC3_INT* bw_idx); +void processNearNyquistdetector_fl(LC3_INT16* near_nyquist_flag, const LC3_INT fs_idx, const LC3_INT near_nyquist_index, + const LC3_INT bands_number, const LC3_FLOAT* ener); -void processPerBandEnergy_fl( LC3_INT bands_number, const LC3_INT *acc_coeff_per_band, LC3_INT16 hrmode, LC3_INT16 frame_dms, LC3_FLOAT *d2, LC3_FLOAT *d ); +void processPerBandEnergy_fl(LC3_INT bands_number, const LC3_INT* acc_coeff_per_band, LC3_INT16 hrmode, LC3_INT16 frame_dms, LC3_FLOAT* d2, LC3_FLOAT* d); -void ProcessingIMDCT_fl( LC3_FLOAT *y, LC3_INT yLen, const LC3_FLOAT *win, LC3_INT winLen, LC3_INT last_zeros, LC3_FLOAT *mem, LC3_FLOAT *x, Dct4 *dct ); +void ProcessingIMDCT_fl(LC3_FLOAT* y, LC3_INT yLen, const LC3_FLOAT* win, LC3_INT winLen, LC3_INT last_zeros, LC3_FLOAT* mem, LC3_FLOAT* x, + Dct4* dct); -void ProcessingITDA_WIN_OLA_fl( LC3_FLOAT *x_tda, LC3_INT32 yLen, const LC3_FLOAT *win, LC3_INT32 winLen, LC3_INT32 last_zeros, LC3_FLOAT *mem, LC3_FLOAT *x ); +void ProcessingITDA_WIN_OLA_fl(LC3_FLOAT* x_tda, LC3_INT32 yLen, const LC3_FLOAT* win, LC3_INT32 winLen, LC3_INT32 last_zeros, LC3_FLOAT* mem, LC3_FLOAT* x); -void process_ltpf_coder_fl( LC3_FLOAT *xin, LC3_INT xLen, LC3_INT ltpf_enable, LC3_INT pitch_ol, LC3_FLOAT pitch_ol_norm_corr, LC3_INT frame_dms, LC3_FLOAT *mem_old_x, LC3_INT memLen, LC3_FLOAT *mem_norm_corr_past, LC3_INT *mem_on, LC3_FLOAT *mem_pitch, LC3_INT *param, LC3_FLOAT *mem_norm_corr_past_past, LC3_INT *bits ); +void process_ltpf_coder_fl(LC3_FLOAT* xin, LC3_INT xLen, LC3_INT ltpf_enable, LC3_INT pitch_ol, LC3_FLOAT pitch_ol_norm_corr, LC3_INT frame_dms, + LC3_FLOAT* mem_old_x, LC3_INT memLen, LC3_FLOAT* mem_norm_corr_past, LC3_INT* mem_on, LC3_FLOAT* mem_pitch, + LC3_INT* param, LC3_FLOAT* mem_norm_corr_past_past, LC3_INT* bits); -void process_ltpf_decoder_fl( LC3_FLOAT *x, LC3_INT xLen, LC3_FLOAT *y, LC3_INT fs, LC3_FLOAT *mem_old_x, LC3_FLOAT *mem_old_y, LC3_INT *mem_pitch_LC3_INT, LC3_INT *mem_pitch_fr, LC3_FLOAT *mem_gain, LC3_INT *mem_beta_idx, LC3_INT bfi, LC3_INT *param, LC3_INT *mem_param, LC3_INT conf_beta_idx, LC3_FLOAT conf_beta, LC3_INT concealMethod, LC3_FLOAT damping, LC3_INT *mem_ltpf_active ); +void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT fs, LC3_FLOAT* mem_old_x, LC3_FLOAT* mem_old_y, + LC3_INT* mem_pitch_LC3_INT, LC3_INT* mem_pitch_fr, LC3_FLOAT* mem_gain, LC3_INT* mem_beta_idx, LC3_INT bfi, + LC3_INT* param, LC3_INT* mem_param, LC3_INT conf_beta_idx, LC3_FLOAT conf_beta, LC3_INT concealMethod, LC3_FLOAT damping + , LC3_INT *mem_ltpf_active +); -void process_resamp12k8_fl( LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC3_INT mem_in_len, LC3_FLOAT mem_50[], LC3_FLOAT mem_out[], LC3_INT mem_out_len, LC3_FLOAT y[], LC3_INT *y_len, LC3_INT fs_idx, LC3_INT frame_dms, LC3_INT fs ); +void process_resamp12k8_fl(LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC3_INT mem_in_len, LC3_FLOAT mem_50[], LC3_FLOAT mem_out[], + LC3_INT mem_out_len, LC3_FLOAT y[], LC3_INT* y_len, LC3_INT fs_idx, LC3_INT frame_dms, LC3_INT fs); -void write_bit_backward_fl( LC3_UINT8 *ptr, LC3_INT *bp_side, LC3_INT *mask_side, LC3_INT bit ); -void write_uint_backward_fl( LC3_UINT8 *ptr, LC3_INT *bp_side, LC3_INT *mask_side, LC3_INT val, LC3_INT numbits ); +void write_bit_backward_fl(LC3_UINT8* ptr, LC3_INT* bp_side, LC3_INT* mask_side, LC3_INT bit); +void write_uint_backward_fl(LC3_UINT8* ptr, LC3_INT* bp_side, LC3_INT* mask_side, LC3_INT val, LC3_INT numbits); -void processAriEncoder_fl( LC3_UINT8 *bytes, LC3_INT bp_side, LC3_INT mask_side, LC3_INT *x, LC3_INT *tns_order, LC3_INT tns_numfilters, LC3_INT *tns_idx, LC3_INT lastnz, LC3_INT *codingdata, uint8_t *res_bits, LC3_INT resBitsLen, LC3_INT lsbMode, LC3_INT nbbits, LC3_INT enable_lpc_weighting ); +void processAriEncoder_fl(LC3_UINT8* bytes, LC3_INT bp_side, LC3_INT mask_side, LC3_INT* x, LC3_INT* tns_order, LC3_INT tns_numfilters, + LC3_INT* tns_idx, LC3_INT lastnz, + LC3_INT* codingdata, uint8_t* res_bits, LC3_INT resBitsLen, LC3_INT lsbMode, + LC3_INT nbbits, LC3_INT enable_lpc_weighting); -void attack_detector_fl( LC3_FLOAT *in, LC3_INT frame_size, LC3_INT fs, LC3_INT *lastAttackPosition, LC3_FLOAT *accNrg, LC3_INT *attackFlag, LC3_FLOAT *attdec_filter_mem, LC3_INT attackHandlingOn, LC3_INT attdec_nblocks, LC3_INT attdec_hangover_threshold ); +void attack_detector_fl(LC3_FLOAT* in, LC3_INT frame_size, LC3_INT fs, LC3_INT* lastAttackPosition, LC3_FLOAT* accNrg, LC3_INT* attackFlag, + LC3_FLOAT* attdec_filter_mem, LC3_INT attackHandlingOn, LC3_INT attdec_nblocks, LC3_INT attdec_hangover_threshold); -void process_snsQuantizesScf_Enc( LC3_FLOAT *env, LC3_INT *index, LC3_FLOAT *envq, Dct2 dct2structSNS ); +void process_snsQuantizesScf_Enc(LC3_FLOAT* env, LC3_INT* index, LC3_FLOAT* envq, Dct2 dct2structSNS); -void process_snsQuantizesScf_Dec( LC3_INT *scf_idx, LC3_FLOAT *scf_q ); +void process_snsQuantizesScf_Dec(LC3_INT* scf_idx, LC3_FLOAT* scf_q); -void processMdct_fl( LC3_FLOAT *in, LC3_FLOAT *out, Mdct *mdctStruct ); +void processMdct_fl(LC3_FLOAT* in, LC3_FLOAT* out, Mdct* mdctStruct); -int alloc_encoder( LC3PLUS_Enc *encoder, int channels ); -void set_enc_frame_params( LC3PLUS_Enc *encoder ); -LC3PLUS_Error update_enc_bitrate( LC3PLUS_Enc *encoder, int bitrate ); +int alloc_encoder(LC3PLUS_Enc* encoder, int channels); +void set_enc_frame_params(LC3PLUS_Enc* encoder); +LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate); -LC3PLUS_Error FillEncSetup( LC3PLUS_Enc *encoder, int samplerate, int channels, int hrmode, int32_t lfe_channel_array[] ); +LC3PLUS_Error FillEncSetup(LC3PLUS_Enc* encoder, int samplerate, int channels, int hrmode, int32_t lfe_channel_array[]); /* Setup Functions */ -int alloc_decoder( LC3PLUS_Dec *decoder, int samplerate, int channels ); -void set_dec_frame_params( LC3PLUS_Dec *decoder ); -LC3PLUS_Error update_dec_bitrate( LC3PLUS_Dec *decoder, int ch, int nBytes ); +int alloc_decoder(LC3PLUS_Dec* decoder, int samplerate, int channels); +void set_dec_frame_params(LC3PLUS_Dec* decoder); +LC3PLUS_Error update_dec_bitrate(LC3PLUS_Dec* decoder, int ch, int nBytes); -LC3PLUS_Error FillDecSetup( LC3PLUS_Dec *decoder, int samplerate, int channels, LC3PLUS_PlcMode plc_mode, int hrmode ); +LC3PLUS_Error FillDecSetup(LC3PLUS_Dec* decoder, int samplerate, int channels, LC3PLUS_PlcMode plc_mode, int hrmode); -int Enc_LC3PLUS_fl( LC3PLUS_Enc *encoder, void **input, LC3_UINT8 *output, int bps, LC3_INT32 bfi_ext ); -LC3PLUS_Error Dec_LC3PLUS_fl( LC3PLUS_Dec *decoder, LC3_UINT8 *input, int input_bytes, void **output, int bps, int bfi_ext ); +int Enc_LC3PLUS_fl(LC3PLUS_Enc* encoder, void** input, LC3_UINT8* output, int bps +, LC3_INT32 bfi_ext +); +LC3PLUS_Error Dec_LC3PLUS_fl(LC3PLUS_Dec* decoder, LC3_UINT8* input, int input_bytes, void** output, int bps, int bfi_ext); -void *balloc( void *base, size_t *base_size, size_t size ); +void* balloc(void* base, size_t* base_size, size_t size); -void processPlcMain_fl( LC3_FLOAT *q_d_fl_c, LC3_FLOAT *syntM_fl_c, LC3PLUS_Dec *decoder, DecSetup *h_DecSetup, LC3_INT bfi, PlcAdvSetup *PlcAdvSetup, PlcSetup *PlcSetup, LC3_INT plcMeth, LC3_INT ltpf_pitch_int, LC3_INT ltpf_pitch_fr, LC3_INT tilt, const LC3_INT *bands_offset, LC3_INT bands_number, const LC3_INT *bands_offsetPLC, LC3_INT n_bandsPLC, LC3_INT16 hrmode, pcState *statePC ); +void processPlcMain_fl(LC3_FLOAT *q_d_fl_c, LC3_FLOAT *syntM_fl_c, LC3PLUS_Dec* decoder, DecSetup* h_DecSetup, LC3_INT bfi, + PlcAdvSetup *PlcAdvSetup, PlcSetup *PlcSetup, LC3_INT plcMeth, LC3_INT ltpf_pitch_int, LC3_INT ltpf_pitch_fr, + LC3_INT tilt, const LC3_INT *bands_offset, LC3_INT bands_number, const LC3_INT *bands_offsetPLC, + LC3_INT n_bandsPLC, LC3_INT16 hrmode, pcState *statePC); -void processPlcUpdate_fl( PlcAdvSetup *PlcAdvSetup, LC3_INT32 frame_length, LC3_FLOAT *syntM, LC3_FLOAT *scf_q, LC3_INT32 *nbLostCmpt, LC3_FLOAT *cum_alpha, LC3_INT32 bfi, LC3_INT32 *prevBfi, LC3_INT32 *prevprevBfi ); +void processPlcUpdate_fl(PlcAdvSetup *PlcAdvSetup, LC3_INT32 frame_length, LC3_FLOAT *syntM, LC3_FLOAT *scf_q, + LC3_INT32 *nbLostCmpt, LC3_FLOAT *cum_alpha, LC3_INT32 bfi, LC3_INT32 *prevBfi, LC3_INT32 *prevprevBfi); -void processPlcUpdateSpec_fl( LC3_FLOAT *q_d_prev, LC3_FLOAT *q_d_fl_c, LC3_INT yLen ); +void processPlcUpdateSpec_fl(LC3_FLOAT *q_d_prev, LC3_FLOAT *q_d_fl_c, LC3_INT yLen); -void processNoiseSubstitution_fl( LC3_FLOAT *spec, LC3_FLOAT *spec_prev, LC3_INT32 yLen ); +void processNoiseSubstitution_fl(LC3_FLOAT* spec, LC3_FLOAT* spec_prev, LC3_INT32 yLen); -void process_cutoff_bandwidth( LC3_FLOAT *d_fl, LC3_INT len, LC3_INT bw_bin ); -void update_enc_bandwidth( LC3PLUS_Enc *encoder, LC3_INT bandwidth ); +void process_cutoff_bandwidth(LC3_FLOAT* d_fl, LC3_INT len, LC3_INT bw_bin); +void update_enc_bandwidth(LC3PLUS_Enc* encoder, LC3_INT bandwidth); /* al_fec.c */ -LC3_INT16 fec_get_n_pccw( LC3_INT16 slot_bytes, LC3_INT16 fec_mode, LC3_INT16 ccc_flag ); -LC3_INT16 fec_get_data_size( LC3_INT16 fec_mode, LC3_INT16 ccc_flag, LC3_INT16 slot_bytes ); -LC3_INT16 fec_get_n_pc( LC3_INT16 fec_mode, LC3_INT16 n_pccw, LC3_INT16 slot_bytes ); -void processReorderBitstream_fl( LC3_UINT8 *bytes, LC3_INT32 n_pccw, LC3_INT32 n_pc, LC3_INT32 b_left, LC3_INT32 len ); -void fec_encoder( LC3_INT16 mode, LC3_INT16 epmr, LC3_UINT8 *iobuf, LC3_INT16 data_bytes, LC3_INT16 slot_bytes, LC3_INT16 n_pccw ); -LC3_INT32 fec_decoder( LC3_UINT8 *iobuf, LC3_INT16 slot_bytes, LC3_INT32 *data_bytes, LC3PLUS_EpModeRequest *epmr, LC3_INT16 ccc_flag, LC3_INT16 *n_pccw, LC3_INT32 *bfi, LC3_INT16 *be_bp_left, LC3_INT16 *be_bp_right, LC3_INT16 *n_pc, LC3_INT16 *m_fec ); - -LC3_FLOAT array_max_abs( LC3_FLOAT *in, LC3_INT32 len ); - -void processPcClassify_fl( LC3_INT32 pitch_present, LC3_INT32 frame_dms, LC3_FLOAT *q_d_prev, LC3_FLOAT *q_old_res, LC3_INT32 yLen, LC3_INT32 spec_inv_idx, LC3_FLOAT stab_fac, LC3_INT32 *bfi ); -void processPcMain_fl( LC3_INT32 *bfi, LC3PLUS_Dec *decoder, LC3_FLOAT *sqQdec, DecSetup *h_DecSetup, LC3_INT32 pitch_present, LC3_FLOAT stab_fac, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_INT32 fac_ns_idx, pcState *statePC, LC3_INT32 spec_inv_idx, LC3_INT32 yLen ); -void processPcUpdate_fl( LC3_INT32 bfi, LC3_FLOAT *q_res, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_INT32 rframe, LC3_INT32 *BW_cutoff_idx_nf, LC3_INT32 *prev_BW_cutoff_idx_nf, LC3_INT32 fac_ns_idx, LC3_FLOAT *prev_fac_ns, LC3_FLOAT *fac, LC3_FLOAT *q_old_res, LC3_FLOAT *prev_gg, LC3_INT32 spec_inv_idx, LC3_INT32 yLen ); -void processPcApply_fl( LC3_FLOAT *q_res, LC3_FLOAT *q_old_res, LC3_FLOAT *q_d_prev, LC3_INT32 spec_inv_idx, LC3_INT32 yLen, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_FLOAT *prev_gg, LC3_FLOAT *fac, LC3_INT32 *pc_nbLostCmpt ); - -void processPlcClassify_fl( LC3_INT plcMeth, LC3_INT *concealMethod, LC3_INT32 *nbLostCmpt, LC3_INT32 bfi, LC3_FLOAT *xcorr, LC3_INT32 framelength, LC3_INT32 frame_dms, LC3_INT32 pitch_int, LC3_INT32 fs, const LC3_INT *band_offsets, LC3_INT32 bands_number, LC3_INT32 tilt, PlcAdvSetup *plcAd, LC3_INT32 hrmode ); -void processPlcComputeStabFacMain_fl( LC3_FLOAT *scf_q, LC3_FLOAT *old_scf_q, LC3_FLOAT *old_old_scf_q, LC3_INT32 bfi, LC3_INT32 prev_bfi, LC3_INT32 prev_prev_bfi, LC3_FLOAT *stab_fac ); - -void processPlcDampingScramblingMain_fl( LC3_INT32 *ns_seed, - LC3_INT32 *pc_seed, - LC3_INT32 ns_nbLostCmpt_pc, - LC3_INT32 ns_nbLostCmpt, - LC3_FLOAT *stabFac, - LC3_FLOAT *cum_fading_slow, - LC3_FLOAT *cum_fading_fast, - LC3_FLOAT *spec_prev, - LC3_FLOAT *spec, - LC3_INT32 spec_inv_idx, - LC3_INT32 yLen, - LC3_INT32 bfi, - LC3_INT32 frame_dms, - LC3_INT32 concealMethod, - LC3_INT32 pitch_present_bfi1, - LC3_INT32 pitch_present_bfi2, - LC3_FLOAT *cum_fflcAtten ); -void processPlcDampingScrambling_fl( LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 nbLostCmpt, LC3_FLOAT *stabFac, LC3_INT32 processDampScramb, LC3_FLOAT *cum_fflcAtten, LC3_INT32 pitch_present, LC3_INT32 frame_dms, LC3_FLOAT *cum_fading_slow, LC3_FLOAT *cum_fading_fast, LC3_INT32 *seed, LC3_INT32 spec_inv_idx ); - -void plc_phEcu_F0_refine_first( LC3_INT32 *plocs, LC3_INT32 n_plocs, LC3_FLOAT *f0est, const LC3_INT32 Xabs_len, LC3_FLOAT *f0binPtr, LC3_FLOAT *f0gainPtr, const LC3_INT32 nSubm ); -void processTdcLpcEstimation_fl( LC3_FLOAT *r, LC3_INT32 fs_idx, LC3_INT32 len, LC3_FLOAT *A, LC3_INT32 frame_dms ); - -LC3_FLOAT plc_phEcuSetF0Hz( LC3_INT32 fs, LC3_FLOAT *old_pitchPtr ); - -void plc_phEcu_processPLCspec2shape( LC3_INT16 prev_bfi, LC3_INT16 bfi, LC3_FLOAT q_d[], LC3_INT32 yLen, LC3_FLOAT *stPhECU_oold_grp_shape, LC3_FLOAT *stPhECU_old_grp_shape ); -void plc_phEcu_LF_peak_analysis( LC3_INT32 *plocs, LC3_INT32 *n_plocs, LC3_FLOAT *f0est, const LC3_FLOAT *Xabs, LC3_FLOAT *f0binPtr, LC3_FLOAT *f0gainPtr, const LC3_INT32 nSubm ); - -void plc_phEcu_F0_refine_first( LC3_INT32 *plocs, LC3_INT32 n_plocs, LC3_FLOAT *f0est, const LC3_INT32 Xabs_len, LC3_FLOAT *f0binPtr, LC3_FLOAT *f0gainPtr, const LC3_INT32 nSubm ); - -LC3_FLOAT plc_phEcu_imax2_jacobsen_mag( const Complex *y, LC3_FLOAT *c_jacobPtr ); -LC3_FLOAT plc_phEcu_interp_max( const LC3_FLOAT *y, LC3_INT32 y_len ); -void plc_phEcu_fft_spec2_sqrt_approx( const Complex *x, LC3_INT32 x_len, LC3_FLOAT *x_abs ); -LC3_INT32 plc_phEcu_pitch_in_plocs( LC3_INT32 *plocs, LC3_INT32 n_plocs ); -void plc_phEcu_spec_ana( LC3_FLOAT *xfp, LC3_INT32 xfp_len, const LC3_FLOAT *whr, LC3_FLOAT *pfind_sensPtr, LC3_INT32 *plocs, LC3_INT32 *n_plocs, LC3_FLOAT *f0est, Complex *x, LC3_INT32 *x_len, LC3_FLOAT *f0hzLtpBinPtr, LC3_FLOAT *f0gainLtpPtr, LC3_INT32 bw_idx, Fft *PhEcu_Fft ); -void plc_phEcu_subst_spec( LC3_INT32 *plocs, LC3_INT32 n_plocs, LC3_FLOAT *f0est, LC3_INT32 time_offs, Complex *X, LC3_INT32 X_len, LC3_FLOAT *mag_chg_gr, LC3_INT32 *seed, LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *Xavg, LC3_INT32 t_adv_in, LC3_INT32 Lprot, LC3_INT32 delta_corr, LC3_FLOAT *corr_phase_dbg, LC3_FLOAT *X_i_new_re_dbg, LC3_FLOAT *X_i_new_im_dbg ); -void plc_phEcu_rec_frame( Complex *X_in, LC3_INT32 xfp_len, LC3_INT32 Lecu, const LC3_FLOAT *whr, const LC3_FLOAT *winMDCT, LC3_INT32 Lprot, LC3_FLOAT *xfp, LC3_INT32 time_offs, LC3_FLOAT *x_out, Complex *full_spec_dbg, LC3_FLOAT *ifft_out_dbg, LC3_FLOAT *xsubst_dbg, LC3_INT32 LA_ZEROS, LC3_INT32 LA, Fft *PhEcu_Ifft - +LC3_INT16 fec_get_n_pccw(LC3_INT16 slot_bytes, LC3_INT16 fec_mode, LC3_INT16 ccc_flag); +LC3_INT16 fec_get_data_size(LC3_INT16 fec_mode, LC3_INT16 ccc_flag, LC3_INT16 slot_bytes); +LC3_INT16 fec_get_n_pc(LC3_INT16 fec_mode, LC3_INT16 n_pccw, LC3_INT16 slot_bytes); +void processReorderBitstream_fl(LC3_UINT8* bytes, LC3_INT32 n_pccw, LC3_INT32 n_pc, LC3_INT32 b_left, LC3_INT32 len); +void fec_encoder(LC3_INT16 mode, LC3_INT16 epmr, LC3_UINT8 *iobuf, LC3_INT16 data_bytes, LC3_INT16 slot_bytes, LC3_INT16 n_pccw); +LC3_INT32 fec_decoder(LC3_UINT8 *iobuf, LC3_INT16 slot_bytes, LC3_INT32 *data_bytes, LC3PLUS_EpModeRequest *epmr, LC3_INT16 ccc_flag, LC3_INT16 *n_pccw, LC3_INT32 *bfi, + LC3_INT16 *be_bp_left, LC3_INT16 *be_bp_right, LC3_INT16 *n_pc, LC3_INT16 *m_fec); + +LC3_FLOAT array_max_abs(LC3_FLOAT *in, LC3_INT32 len); + +void processPcClassify_fl(LC3_INT32 pitch_present, LC3_INT32 frame_dms, LC3_FLOAT *q_d_prev, LC3_FLOAT *q_old_res, LC3_INT32 yLen, LC3_INT32 spec_inv_idx, LC3_FLOAT stab_fac, LC3_INT32 *bfi); +void processPcMain_fl(LC3_INT32 *bfi, LC3PLUS_Dec* decoder, LC3_FLOAT *sqQdec, DecSetup* h_DecSetup, LC3_INT32 pitch_present, LC3_FLOAT stab_fac, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_INT32 fac_ns_idx, pcState *statePC, LC3_INT32 spec_inv_idx, LC3_INT32 yLen); +void processPcUpdate_fl(LC3_INT32 bfi, LC3_FLOAT *q_res, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_INT32 rframe, LC3_INT32 *BW_cutoff_idx_nf, LC3_INT32 *prev_BW_cutoff_idx_nf, LC3_INT32 fac_ns_idx, LC3_FLOAT *prev_fac_ns, LC3_FLOAT *fac, LC3_FLOAT *q_old_res, LC3_FLOAT *prev_gg, LC3_INT32 spec_inv_idx, LC3_INT32 yLen); +void processPcApply_fl(LC3_FLOAT *q_res, LC3_FLOAT *q_old_res, LC3_FLOAT *q_d_prev, LC3_INT32 spec_inv_idx, LC3_INT32 yLen, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_FLOAT *prev_gg, LC3_FLOAT *fac, LC3_INT32 *pc_nbLostCmpt); + +void processPlcClassify_fl(LC3_INT plcMeth, LC3_INT *concealMethod, LC3_INT32 *nbLostCmpt, LC3_INT32 bfi, + LC3_FLOAT *xcorr, LC3_INT32 framelength, LC3_INT32 frame_dms, LC3_INT32 pitch_int, + LC3_INT32 fs, const LC3_INT *band_offsets, LC3_INT32 bands_number, LC3_INT32 tilt, PlcAdvSetup *plcAd + , LC3_INT32 hrmode ); -void plc_phEcu_tba_spect_Xavg( LC3_INT32 fs_idx, LC3_INT32 n_grp, LC3_FLOAT *oold_spec_shape, LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_spec_shape, LC3_FLOAT *old_EwPtr, LC3_FLOAT *gr_pow_left, LC3_FLOAT *gr_pow_right, LC3_FLOAT *Xavg ); -void plc_phEcu_tba_per_band_gain( LC3_INT32 n_grp, LC3_FLOAT *gr_pow_left, LC3_FLOAT *gr_pow_right, LC3_FLOAT *trans, LC3_FLOAT *grp_pow_change ); -void plc_phEcu_tba_trans_dect_gains( LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FLOAT *grp_pow_change, LC3_FLOAT *stPhECU_beta_mute, LC3_FLOAT *stPhECU_mag_chg_1st, LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *mag_chg, LC3_FLOAT *ph_dith, LC3_INT32 *tr_dec, LC3_FLOAT *att_val, LC3_INT32 *attDegreeFrames, LC3_FLOAT *thresh_dbg ); -void plc_phEcu_trans_burst_ana_sub( LC3_INT32 fs_idx, LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FLOAT *oold_spect_shape, LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_spect_shape, LC3_FLOAT *old_EwPtr, LC3_FLOAT *stPhECU_beta_mute, LC3_FLOAT *stPhECU_mag_chg_1st, LC3_FLOAT *stPhECU_Xavg, LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *mag_chg, LC3_INT32 *tr_dec_dbg, LC3_FLOAT *gpc_dbg ); +void processPlcComputeStabFacMain_fl(LC3_FLOAT *scf_q, LC3_FLOAT *old_scf_q, LC3_FLOAT *old_old_scf_q, LC3_INT32 bfi, LC3_INT32 prev_bfi, LC3_INT32 prev_prev_bfi, LC3_FLOAT *stab_fac); + +void processPlcDampingScramblingMain_fl(LC3_INT32 *ns_seed, + LC3_INT32 *pc_seed, LC3_INT32 ns_nbLostCmpt_pc, + LC3_INT32 ns_nbLostCmpt, LC3_FLOAT *stabFac, LC3_FLOAT *cum_fading_slow, LC3_FLOAT *cum_fading_fast, + LC3_FLOAT *spec_prev, LC3_FLOAT *spec, LC3_INT32 spec_inv_idx, LC3_INT32 yLen, LC3_INT32 bfi, + LC3_INT32 frame_dms, LC3_INT32 concealMethod, LC3_INT32 pitch_present_bfi1, LC3_INT32 pitch_present_bfi2, + LC3_FLOAT *cum_fflcAtten); +void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 nbLostCmpt, LC3_FLOAT *stabFac, LC3_INT32 processDampScramb, + LC3_FLOAT *cum_fflcAtten, LC3_INT32 pitch_present, LC3_INT32 frame_dms, LC3_FLOAT *cum_fading_slow, + LC3_FLOAT *cum_fading_fast, LC3_INT32 *seed, LC3_INT32 spec_inv_idx); + +void plc_phEcu_F0_refine_first(LC3_INT32 *plocs, LC3_INT32 n_plocs, LC3_FLOAT *f0est, const LC3_INT32 Xabs_len, + LC3_FLOAT *f0binPtr, LC3_FLOAT *f0gainPtr, const LC3_INT32 nSubm); +void processTdcLpcEstimation_fl(LC3_FLOAT *r, LC3_INT32 fs_idx, LC3_INT32 len, LC3_FLOAT *A, LC3_INT32 frame_dms); + +LC3_FLOAT plc_phEcuSetF0Hz(LC3_INT32 fs, LC3_FLOAT *old_pitchPtr); + +void plc_phEcu_processPLCspec2shape(LC3_INT16 prev_bfi, LC3_INT16 bfi, LC3_FLOAT q_d[], LC3_INT32 yLen, LC3_FLOAT *stPhECU_oold_grp_shape, LC3_FLOAT *stPhECU_old_grp_shape); +void plc_phEcu_LF_peak_analysis(LC3_INT32 *plocs, LC3_INT32 *n_plocs, LC3_FLOAT *f0est, const LC3_FLOAT *Xabs, + LC3_FLOAT *f0binPtr, LC3_FLOAT *f0gainPtr, const LC3_INT32 nSubm); + +void plc_phEcu_F0_refine_first(LC3_INT32 *plocs, LC3_INT32 n_plocs, LC3_FLOAT *f0est, const LC3_INT32 Xabs_len, + LC3_FLOAT *f0binPtr, LC3_FLOAT *f0gainPtr, const LC3_INT32 nSubm); + +LC3_FLOAT plc_phEcu_imax2_jacobsen_mag(const Complex *y, LC3_FLOAT *c_jacobPtr); +LC3_FLOAT plc_phEcu_interp_max(const LC3_FLOAT *y, LC3_INT32 y_len); +void plc_phEcu_fft_spec2_sqrt_approx(const Complex* x, LC3_INT32 x_len, LC3_FLOAT* x_abs); +LC3_INT32 plc_phEcu_pitch_in_plocs(LC3_INT32* plocs, LC3_INT32 n_plocs); +void plc_phEcu_spec_ana(LC3_FLOAT* xfp, LC3_INT32 xfp_len, const LC3_FLOAT* whr, + LC3_FLOAT* pfind_sensPtr, LC3_INT32* plocs, + LC3_INT32* n_plocs, LC3_FLOAT* f0est, Complex* x, LC3_INT32* x_len, + LC3_FLOAT* f0hzLtpBinPtr, LC3_FLOAT* f0gainLtpPtr, LC3_INT32 bw_idx, Fft* PhEcu_Fft); +void plc_phEcu_subst_spec(LC3_INT32* plocs, LC3_INT32 n_plocs, LC3_FLOAT* f0est, LC3_INT32 time_offs, Complex* X, LC3_INT32 X_len, + LC3_FLOAT* mag_chg_gr, LC3_INT32 *seed, LC3_FLOAT* alpha, LC3_FLOAT* beta, LC3_FLOAT* Xavg, + LC3_INT32 t_adv_in, LC3_INT32 Lprot, LC3_INT32 delta_corr, LC3_FLOAT *corr_phase_dbg, + LC3_FLOAT *X_i_new_re_dbg, LC3_FLOAT *X_i_new_im_dbg); +void plc_phEcu_rec_frame(Complex *X_in, LC3_INT32 xfp_len, LC3_INT32 Lecu, const LC3_FLOAT *whr, const LC3_FLOAT *winMDCT, LC3_INT32 Lprot, + LC3_FLOAT *xfp, LC3_INT32 time_offs, LC3_FLOAT *x_out, + Complex *full_spec_dbg, LC3_FLOAT* ifft_out_dbg, LC3_FLOAT* xsubst_dbg, + LC3_INT32 LA_ZEROS, LC3_INT32 LA, Fft* PhEcu_Ifft + + ); +void plc_phEcu_tba_spect_Xavg(LC3_INT32 fs_idx, LC3_INT32 n_grp, LC3_FLOAT *oold_spec_shape, + LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_spec_shape, LC3_FLOAT *old_EwPtr, + LC3_FLOAT *gr_pow_left, LC3_FLOAT *gr_pow_right, LC3_FLOAT *Xavg); +void plc_phEcu_tba_per_band_gain(LC3_INT32 n_grp, LC3_FLOAT *gr_pow_left, LC3_FLOAT *gr_pow_right, LC3_FLOAT *trans, LC3_FLOAT *grp_pow_change); +void plc_phEcu_tba_trans_dect_gains(LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FLOAT *grp_pow_change, + LC3_FLOAT *stPhECU_beta_mute, LC3_FLOAT *stPhECU_mag_chg_1st, + LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *mag_chg, LC3_FLOAT *ph_dith, LC3_INT32 *tr_dec, + LC3_FLOAT *att_val, LC3_INT32 *attDegreeFrames, LC3_FLOAT *thresh_dbg); +void plc_phEcu_trans_burst_ana_sub(LC3_INT32 fs_idx, LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FLOAT *oold_spect_shape, + LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_spect_shape, + LC3_FLOAT *old_EwPtr, LC3_FLOAT *stPhECU_beta_mute, + LC3_FLOAT *stPhECU_mag_chg_1st, LC3_FLOAT *stPhECU_Xavg, LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *mag_chg, + LC3_INT32 *tr_dec_dbg, LC3_FLOAT *gpc_dbg); void plc_phEcu_hq_ecu( - LC3_FLOAT *f0binPtr, - LC3_FLOAT *f0ltpGainPtr, - LC3_FLOAT *xfp, - LC3_INT16 prev_bfi, - LC3_INT32 *short_flag_prev, - LC3_INT32 fs, - LC3_INT32 *time_offs, - Complex *X_sav_m, - LC3_INT32 *n_plocs, - LC3_INT32 *plocs, - LC3_FLOAT *f0est, - const LC3_FLOAT *mdctWin, - LC3_FLOAT *env_stabPtr, - LC3_INT32 delta_corr, + LC3_FLOAT *f0binPtr, LC3_FLOAT *f0ltpGainPtr, + LC3_FLOAT *xfp, LC3_INT16 prev_bfi, LC3_INT32 *short_flag_prev, + LC3_INT32 fs, LC3_INT32 * time_offs, + Complex *X_sav_m, LC3_INT32 *n_plocs, LC3_INT32 *plocs, LC3_FLOAT *f0est, const LC3_FLOAT *mdctWin, + LC3_FLOAT *env_stabPtr, LC3_INT32 delta_corr, LC3_FLOAT *pfind_sensPtr, - LC3_INT32 PhECU_LA, - LC3_INT32 t_adv, - const LC3_FLOAT *winWhr, - LC3_FLOAT *oold_grp_shape, - LC3_FLOAT *oold_EwPtr, - LC3_FLOAT *old_grp_shape, + LC3_INT32 PhECU_LA, LC3_INT32 t_adv, const LC3_FLOAT *winWhr, LC3_FLOAT *oold_grp_shape, + LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_grp_shape, LC3_FLOAT *old_EwPtr, - LC3_FLOAT *st_beta_mute, - LC3_FLOAT *st_mag_chg_1st, - LC3_FLOAT *st_Xavg, - LC3_INT32 LA_ZEROS, - LC3_FLOAT *x_tda, - LC3_FLOAT *xsubst_dbg, - Complex *X_out_m_dbg, - LC3_INT32 *seed_dbg, - LC3_FLOAT *mag_chg_dbg, - LC3_INT32 *tr_dec_dbg, - LC3_FLOAT *gpc_dbg, - LC3_FLOAT *X_i_new_re_dbg, - LC3_FLOAT *X_i_new_im_dbg, - LC3_FLOAT *corr_phase_dbg, - Fft *PhEcu_Fft, - Fft *PhEcu_Ifft ); - -void processTdcPreemphasis_fl( LC3_FLOAT *in, LC3_FLOAT *pre_emph_factor, LC3_INT32 n_bands ); - -void processTdcTdac_fl( const LC3_FLOAT *synth_inp, const LC3_FLOAT *win, LC3_INT32 frame_length, LC3_INT32 la_zeroes, LC3_FLOAT *ola_mem ); -void processTdcInverseOdft_fl( LC3_FLOAT *in, LC3_INT32 n_bands, LC3_FLOAT *out, LC3_INT32 lpc_order ); - -void processTdcApply_fl( const LC3_INT32 pitch_LC3_INT, const LC3_FLOAT *preemphFac, const LC3_FLOAT *A, const LC3_INT32 lpc_order, const LC3_FLOAT *pcmbufHist, const LC3_INT32 max_len_pcm_plc, const LC3_INT32 N, const LC3_INT32 frame_dms, const LC3_INT32 SampRate, const LC3_INT32 nbLostCmpt, const LC3_INT32 overlap, const LC3_FLOAT *stabFac, LC3_FLOAT harmonicBuf[MAX_PITCH], LC3_FLOAT synthHist[M], LC3_INT32 *fract, LC3_INT16 *seed, LC3_FLOAT *gain_c, LC3_FLOAT *alpha, LC3_FLOAT *synth ); -void *balloc( void *base, size_t *base_size, size_t size ); + LC3_FLOAT *st_beta_mute, LC3_FLOAT *st_mag_chg_1st, LC3_FLOAT *st_Xavg, LC3_INT32 LA_ZEROS, LC3_FLOAT *x_tda, LC3_FLOAT *xsubst_dbg, Complex *X_out_m_dbg, + LC3_INT32 *seed_dbg, LC3_FLOAT *mag_chg_dbg, LC3_INT32 *tr_dec_dbg, LC3_FLOAT *gpc_dbg, LC3_FLOAT *X_i_new_re_dbg, LC3_FLOAT *X_i_new_im_dbg, LC3_FLOAT *corr_phase_dbg + ,Fft* PhEcu_Fft,Fft* PhEcu_Ifft +); + +void processTdcPreemphasis_fl(LC3_FLOAT *in, LC3_FLOAT *pre_emph_factor, LC3_INT32 n_bands); + +void processTdcTdac_fl(const LC3_FLOAT *synth_inp, const LC3_FLOAT *win, LC3_INT32 frame_length, LC3_INT32 la_zeroes, LC3_FLOAT *ola_mem); +void processTdcInverseOdft_fl(LC3_FLOAT *in, LC3_INT32 n_bands, LC3_FLOAT *out, LC3_INT32 lpc_order); + +void processTdcApply_fl(const LC3_INT32 pitch_LC3_INT, const LC3_FLOAT *preemphFac, const LC3_FLOAT* A, const LC3_INT32 lpc_order, const LC3_FLOAT* pcmbufHist, const LC3_INT32 max_len_pcm_plc, const LC3_INT32 N, const LC3_INT32 frame_dms, + const LC3_INT32 SampRate, const LC3_INT32 nbLostCmpt, const LC3_INT32 overlap, const LC3_FLOAT *stabFac, LC3_FLOAT harmonicBuf[MAX_PITCH], LC3_FLOAT synthHist[M], + LC3_INT32* fract, LC3_INT16* seed, LC3_FLOAT* gain_c, LC3_FLOAT* alpha, LC3_FLOAT* synth); +void* balloc(void* base, size_t* base_size, size_t size); + #endif diff --git a/lib_lc3plus/imdct.c b/lib_lc3plus/imdct.c index 7e1d9ca6d0..5d38aa6cc7 100644 --- a/lib_lc3plus/imdct.c +++ b/lib_lc3plus/imdct.c @@ -1,112 +1,102 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" /* Function expects already flipped window */ -void ProcessingIMDCT_fl( LC3_FLOAT *y, LC3_INT yLen, const LC3_FLOAT *win, LC3_INT winLen, LC3_INT last_zeros, LC3_FLOAT *mem, LC3_FLOAT *x, Dct4 *dct ) +void ProcessingIMDCT_fl(LC3_FLOAT* y, LC3_INT yLen, const LC3_FLOAT* win, LC3_INT winLen, LC3_INT last_zeros, LC3_FLOAT* mem, LC3_FLOAT* x, Dct4* dct) { - LC3_FLOAT x_tda[MAX_LEN] = { 0 }, x_ov[2 * MAX_LEN] = { 0 }; - LC3_INT i = 0, j = 0; + LC3_FLOAT x_tda[MAX_LEN] = {0}, x_ov[2 * MAX_LEN] = {0}; + LC3_INT i = 0, j = 0; /* Flip imdct window up to down */ i = winLen - 1; j = 0; - dct4_apply( dct, y, x_tda ); + dct4_apply(dct, y, x_tda); - move_float( x_ov, &x_tda[yLen / 2], yLen / 2 ); + move_float(x_ov, &x_tda[yLen / 2], yLen / 2); j = yLen / 2; - for ( i = 0; i < yLen / 2; i++ ) - { + for (i = 0; i < yLen / 2; i++) { x_ov[j] = -x_tda[yLen - 1 - i]; j++; } j = yLen; - for ( i = 0; i < yLen / 2; i++ ) - { + for (i = 0; i < yLen / 2; i++) { x_ov[j] = -x_tda[yLen / 2 - 1 - i]; j++; } j = yLen + yLen / 2; - for ( i = 0; i < yLen / 2; i++ ) - { + for (i = 0; i < yLen / 2; i++) { x_ov[j] = -x_tda[i]; j++; } - for ( i = 0; i < winLen; i++ ) - { + for (i = 0; i < winLen; i++) { x_ov[i] = x_ov[i] * win[winLen - 1 - i]; } /* Buffer update */ j = 0; - for ( i = last_zeros; i < yLen; i++ ) - { + for (i = last_zeros; i < yLen; i++) { x_ov[i] = x_ov[i] + mem[j]; j++; } - move_float( &x[0], &x_ov[last_zeros], yLen ); + move_float(&x[0], &x_ov[last_zeros], yLen); - move_float( &mem[0], &x_ov[yLen + last_zeros], ( winLen - ( yLen + last_zeros ) ) ); + move_float(&mem[0], &x_ov[yLen + last_zeros], (winLen - (yLen + last_zeros))); } -void ProcessingITDA_WIN_OLA_fl( LC3_FLOAT *x_tda, LC3_INT32 yLen, const LC3_FLOAT *win, LC3_INT32 winLen, LC3_INT32 last_zeros, LC3_FLOAT *mem, LC3_FLOAT *x ) +void ProcessingITDA_WIN_OLA_fl(LC3_FLOAT* x_tda, LC3_INT32 yLen, const LC3_FLOAT* win, LC3_INT32 winLen, LC3_INT32 last_zeros, LC3_FLOAT* mem, LC3_FLOAT* x) { - LC3_FLOAT x_ov[2 * MAX_LEN] = { 0 }; + LC3_FLOAT x_ov[2 * MAX_LEN] = {0}; LC3_INT32 i, j; - move_float( x_ov, &x_tda[yLen / 2], yLen / 2 ); + move_float(x_ov, &x_tda[yLen / 2], yLen / 2); j = yLen / 2; - for ( i = 0; i < yLen / 2; i++ ) - { + for (i = 0; i < yLen / 2; i++) { x_ov[j] = -x_tda[yLen - 1 - i]; j++; } j = yLen; - for ( i = 0; i < yLen / 2; i++ ) - { + for (i = 0; i < yLen / 2; i++) { x_ov[j] = -x_tda[yLen / 2 - 1 - i]; j++; } j = yLen + yLen / 2; - for ( i = 0; i < yLen / 2; i++ ) - { + for (i = 0; i < yLen / 2; i++) { x_ov[j] = -x_tda[i]; j++; } - for ( i = 0; i < winLen; i++ ) - { + for (i = 0; i < winLen; i++) { x_ov[i] = x_ov[i] * win[winLen - 1 - i]; } /* Buffer update */ j = 0; - for ( i = last_zeros; i < yLen; i++ ) - { + for (i = last_zeros; i < yLen; i++) { x[j] = x_ov[i] + mem[j]; j++; } - move_float( &x[j], &x_ov[last_zeros + j], yLen - j ); + move_float(&x[j], &x_ov[last_zeros+j], yLen-j); - move_float( &mem[0], &x_ov[yLen + last_zeros], ( winLen - ( yLen + last_zeros ) ) ); + move_float(&mem[0], &x_ov[yLen + last_zeros], (winLen - (yLen + last_zeros))); } diff --git a/lib_lc3plus/lc3.c b/lib_lc3plus/lc3.c index 0bffb1877e..17d2ccb712 100644 --- a/lib_lc3plus/lc3.c +++ b/lib_lc3plus/lc3.c @@ -1,12 +1,12 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "lc3.h" @@ -17,416 +17,409 @@ #include "setup_dec_lc3.h" #include "setup_enc_lc3.h" -#define RETURN_IF( cond, error ) \ - if ( cond ) \ - return ( error ) +#define RETURN_IF(cond, error) \ + if (cond) \ + return (error) /* ensure api header constants are up to date */ -STATIC_ASSERT( LC3PLUS_MAX_SAMPLES >= MAX_LEN ); -STATIC_ASSERT( LC3PLUS_MAX_CHANNELS >= MAX_CHANNELS ); -STATIC_ASSERT( LC3PLUS_MAX_BYTES >= BYTESBUFSIZE ); +STATIC_ASSERT(LC3PLUS_MAX_SAMPLES >= MAX_LEN); +STATIC_ASSERT(LC3PLUS_MAX_CHANNELS >= MAX_CHANNELS); +STATIC_ASSERT(LC3PLUS_MAX_BYTES >= BYTESBUFSIZE); /* misc functions ************************************************************/ -int lc3plus_version( void ) +int lc3plus_version(void) { return LC3PLUS_VERSION; } -int lc3plus_channels_supported( int channels ) +int lc3plus_channels_supported(int channels) { return channels >= 1 && channels <= MAX_CHANNELS; } -int lc3plus_samplerate_supported( int samplerate ) +int lc3plus_samplerate_supported(int samplerate) { - switch ( samplerate ) + switch (samplerate) { - case 8000: - return 1; - case 16000: - return 1; - case 24000: - return 1; - case 32000: - return 1; - case 44100: - return 1; - case 48000: - return 1; - case 96000: - return 1; - default: - break; + case 8000: return 1; + case 16000: return 1; + case 24000: return 1; + case 32000: return 1; + case 44100: return 1; + case 48000: return 1; + case 96000: return 1; + default: break; } return 0; } -static int lc3plus_plc_mode_supported( LC3PLUS_PlcMode plc_mode ) +static int lc3plus_plc_mode_supported(LC3PLUS_PlcMode plc_mode) { - switch ( (int) plc_mode ) + switch ((int)plc_mode) { - case LC3PLUS_PLC_ADVANCED: /* fallthru */ - return 1; - default: - break; + case LC3PLUS_PLC_ADVANCED: /* fallthru */ + return 1; + default: break; } return 0; } -static int lc3plus_frame_size_supported( float frame_ms ) +static int lc3plus_frame_size_supported(float frame_ms) { - switch ( (int) ( ceil( frame_ms * 10 ) ) ) + switch ((int)(ceil(frame_ms * 10))) { - case 25: /* fallthru */ - case 50: /* fallthru */ - case 100: - return 1; - default: - break; + case 25: /* fallthru */ + case 50: /* fallthru */ + case 100: return 1; + default: break; } return 0; } -static int null_in_list( void **list, int n ) +static int null_in_list(void **list, int n) { - while ( --n >= 0 ) - RETURN_IF( list[n] == NULL, 1 ); + while (--n >= 0) + RETURN_IF(list[n] == NULL, 1); return 0; } /* return pointer to aligned base + base_size, *base_size += size + 4 bytes align */ -void *balloc( void *base, size_t *base_size, size_t size ) +void *balloc(void *base, size_t *base_size, size_t size) { - uintptr_t ptr = ( (uintptr_t) base + *base_size + 3 ) & ~3; - assert( (uintptr_t) base % 4 == 0 ); /* base must be 4-byte aligned */ - *base_size = ( *base_size + size + 3 ) & ~3; - return (void *) ptr; + uintptr_t ptr = ((uintptr_t)base + *base_size + 3) & ~3; + assert((uintptr_t)base % 4 == 0); /* base must be 4-byte aligned */ + *base_size = (*base_size + size + 3) & ~3; + return (void *)ptr; } -int32_t lc3_enc_supported_lfe( void ) +int32_t lc3_enc_supported_lfe(void) { return 1; } /* encoder functions *********************************************************/ -LC3PLUS_Error lc3plus_enc_init( LC3PLUS_Enc *encoder, int samplerate, int channels, int hrmode, int32_t lfe_channel_array[] ) +LC3PLUS_Error lc3plus_enc_init(LC3PLUS_Enc *encoder, int samplerate, int channels, int hrmode, int32_t lfe_channel_array[]) { int ch = 0; - RETURN_IF( encoder == NULL, LC3PLUS_NULL_ERROR ); - RETURN_IF( (uintptr_t) encoder % 4 != 0, LC3PLUS_ALIGN_ERROR ); - RETURN_IF( !lc3plus_samplerate_supported( samplerate ), LC3PLUS_SAMPLERATE_ERROR ); - RETURN_IF( !lc3plus_channels_supported( channels ), LC3PLUS_CHANNELS_ERROR ); - RETURN_IF( samplerate == 96000 && hrmode == 0, LC3PLUS_HRMODE_ERROR ); + RETURN_IF(encoder == NULL, LC3PLUS_NULL_ERROR); + RETURN_IF((uintptr_t)encoder % 4 != 0, LC3PLUS_ALIGN_ERROR); + RETURN_IF(!lc3plus_samplerate_supported(samplerate), LC3PLUS_SAMPLERATE_ERROR); + RETURN_IF(!lc3plus_channels_supported(channels), LC3PLUS_CHANNELS_ERROR); + RETURN_IF(samplerate==96000 && hrmode == 0, LC3PLUS_HRMODE_ERROR); - for ( ch = 0; ch < channels; ch++ ) + for (ch = 0; ch < channels; ch++) { - RETURN_IF( !lc3_enc_supported_lfe() && lfe_channel_array[ch], LC3PLUS_LFE_MODE_NOT_SUPPORTED ); + RETURN_IF(!lc3_enc_supported_lfe() && lfe_channel_array[ch], LC3PLUS_LFE_MODE_NOT_SUPPORTED); } - return FillEncSetup( encoder, samplerate, channels, hrmode, lfe_channel_array ); /* real bitrate check happens here */ + return FillEncSetup(encoder, samplerate, channels, hrmode, lfe_channel_array); /* real bitrate check happens here */ } -int lc3plus_enc_get_size( int samplerate, int channels ) +int lc3plus_enc_get_size(int samplerate, int channels) { - RETURN_IF( !lc3plus_samplerate_supported( samplerate ), 0 ); - RETURN_IF( !lc3plus_channels_supported( channels ), 0 ); - return alloc_encoder( NULL, channels ); + RETURN_IF(!lc3plus_samplerate_supported(samplerate), 0); + RETURN_IF(!lc3plus_channels_supported(channels), 0); + return alloc_encoder(NULL, channels); } /* Dummy function for API alignment */ -int lc3plus_enc_get_scratch_size( const LC3PLUS_Enc *encoder ) +int lc3plus_enc_get_scratch_size(const LC3PLUS_Enc *encoder) { - UNUSED( encoder ); + UNUSED(encoder); return 0; } -int lc3plus_enc_get_input_samples( const LC3PLUS_Enc *encoder ) +int lc3plus_enc_get_input_samples(const LC3PLUS_Enc *encoder) { - RETURN_IF( encoder == NULL, 0 ); + RETURN_IF(encoder == NULL, 0); return encoder->frame_length; } -int lc3plus_enc_get_num_bytes( const LC3PLUS_Enc *encoder ) +int lc3plus_enc_get_num_bytes(const LC3PLUS_Enc *encoder) { - RETURN_IF( encoder == NULL, 0 ); - - return encoder->bitrate * encoder->frame_length / ( 8 * encoder->fs_in ); + RETURN_IF(encoder == NULL, 0); + + return encoder->bitrate * encoder->frame_length / (8 * encoder->fs_in); } -int lc3plus_enc_get_real_bitrate( const LC3PLUS_Enc *encoder ) +int lc3plus_enc_get_real_bitrate(const LC3PLUS_Enc *encoder) { int ch = 0, totalBytes = 0; int bitrate; - RETURN_IF( encoder == NULL, 0 ); - RETURN_IF( !encoder->lc3_br_set, LC3PLUS_BITRATE_UNSET_ERROR ); - - for ( ch = 0; ch < encoder->channels; ch++ ) + RETURN_IF(encoder == NULL, 0); + RETURN_IF(!encoder->lc3_br_set, LC3PLUS_BITRATE_UNSET_ERROR); + + for (ch = 0; ch < encoder->channels; ch++) { totalBytes += encoder->channel_setup[ch]->targetBytes; } - - bitrate = ( totalBytes * 80000.0 + encoder->frame_dms - 1 ) / encoder->frame_dms; - - if ( encoder->fs_in == 44100 ) + + bitrate = (totalBytes * 80000.0 + encoder->frame_dms - 1) / encoder->frame_dms; + + if (encoder->fs_in == 44100) { int rem = bitrate % 480; - bitrate = ( ( bitrate - rem ) / 480 ) * 441 + ( rem * 441 ) / 480; + bitrate = ((bitrate - rem) / 480) * 441 + (rem * 441) / 480; } - + return bitrate; } -LC3PLUS_Error lc3plus_enc_set_bitrate( LC3PLUS_Enc *encoder, int bitrate ) +LC3PLUS_Error lc3plus_enc_set_bitrate(LC3PLUS_Enc *encoder, int bitrate) { - RETURN_IF( encoder == NULL, LC3PLUS_NULL_ERROR ); - RETURN_IF( bitrate <= 0, LC3PLUS_BITRATE_ERROR ); + RETURN_IF(encoder == NULL, LC3PLUS_NULL_ERROR); + RETURN_IF(bitrate <= 0, LC3PLUS_BITRATE_ERROR); #ifndef STRIP_HR_MODE_API - RETURN_IF( encoder->fs_idx == 5 && encoder->hrmode == 0, LC3PLUS_HRMODE_ERROR ); + RETURN_IF(encoder->fs_idx == 5 && encoder->hrmode == 0, LC3PLUS_HRMODE_ERROR); #endif - return update_enc_bitrate( encoder, bitrate ); + return update_enc_bitrate(encoder, bitrate); } -int lc3plus_enc_get_delay( const LC3PLUS_Enc *encoder ) +int lc3plus_enc_get_delay(const LC3PLUS_Enc *encoder) { - RETURN_IF( encoder == NULL, 0 ); + RETURN_IF(encoder == NULL, 0); return encoder->frame_length - 2 * encoder->la_zeroes; } -LC3PLUS_Error lc3plus_enc_set_frame_dms( LC3PLUS_Enc *encoder, int frame_dms ) +LC3PLUS_Error lc3plus_enc_set_frame_dms(LC3PLUS_Enc *encoder, int frame_dms) { - RETURN_IF( encoder == NULL, LC3PLUS_NULL_ERROR ); - RETURN_IF( !lc3plus_frame_size_supported( frame_dms / 10.0 ), LC3PLUS_FRAMEMS_ERROR ); - RETURN_IF( encoder->lc3_br_set, LC3PLUS_BITRATE_SET_ERROR ); + RETURN_IF(encoder == NULL, LC3PLUS_NULL_ERROR); + RETURN_IF(!lc3plus_frame_size_supported(frame_dms / 10.0), LC3PLUS_FRAMEMS_ERROR); + RETURN_IF(encoder->lc3_br_set, LC3PLUS_BITRATE_SET_ERROR); encoder->frame_dms = frame_dms; encoder->frame_ms = frame_dms / 10.0; - set_enc_frame_params( encoder ); + set_enc_frame_params(encoder); return LC3PLUS_OK; } -LC3PLUS_Error lc3plus_enc_set_bandwidth( LC3PLUS_Enc *encoder, int bandwidth ) +LC3PLUS_Error lc3plus_enc_set_bandwidth(LC3PLUS_Enc *encoder, int bandwidth) { LC3_INT effective_fs; - RETURN_IF( encoder == NULL, LC3PLUS_NULL_ERROR ); + RETURN_IF(encoder == NULL, LC3PLUS_NULL_ERROR); #ifdef ENABLE_HR_MODE_FL_FLAG - RETURN_IF( encoder->hrmode == 1, LC3PLUS_HRMODE_BW_ERROR ); + RETURN_IF(encoder->hrmode == 1, LC3PLUS_HRMODE_BW_ERROR); #endif effective_fs = encoder->fs_in; - if ( encoder->bandwidth != bandwidth ) - { - if ( encoder->fs_in > 40000 ) - { + if (encoder->bandwidth != bandwidth) { + if (encoder->fs_in > 40000) { effective_fs = 40000; } - if ( ( bandwidth * 2 ) > effective_fs ) - { + if ((bandwidth * 2) > effective_fs) { return LC3PLUS_BW_WARNING; } - else - { + else { encoder->bandwidth = bandwidth; encoder->bandwidth_preset = bandwidth; - encoder->bw_ctrl_active = 1; - update_enc_bitrate( encoder, encoder->bitrate ); + encoder->bw_ctrl_active = 1; + update_enc_bitrate(encoder, encoder->bitrate); } } return LC3PLUS_OK; } -LC3PLUS_Error lc3plus_enc16( LC3PLUS_Enc *encoder, int16_t **input_samples, void *output_bytes, int *num_bytes, void *scratch ) +LC3PLUS_Error lc3plus_enc16(LC3PLUS_Enc* encoder, int16_t** input_samples, void* output_bytes, int* num_bytes +, void *scratch +) { - UNUSED( scratch ); - return lc3plus_enc_fl( encoder, (void **) input_samples, 16, output_bytes, num_bytes ); + UNUSED(scratch); + return lc3plus_enc_fl(encoder, (void**)input_samples, 16, output_bytes, num_bytes); } -LC3PLUS_Error lc3plus_enc24( LC3PLUS_Enc *encoder, int32_t **input_samples, void *output_bytes, int *num_bytes, void *scratch ) +LC3PLUS_Error lc3plus_enc24(LC3PLUS_Enc* encoder, int32_t** input_samples, void* output_bytes, int* num_bytes +, void *scratch +) { - UNUSED( scratch ); - return lc3plus_enc_fl( encoder, (void **) input_samples, 24, output_bytes, num_bytes ); + UNUSED(scratch); + return lc3plus_enc_fl(encoder, (void**)input_samples, 24, output_bytes, num_bytes); } -LC3PLUS_Error lc3plus_enc_fl( LC3PLUS_Enc *encoder, void **input_samples, int bitdepth, void *output_bytes, int *num_bytes ) +LC3PLUS_Error lc3plus_enc_fl(LC3PLUS_Enc* encoder, void** input_samples, int bitdepth, void* output_bytes, int* num_bytes) { - RETURN_IF( !encoder || !input_samples || !output_bytes || !num_bytes, LC3PLUS_NULL_ERROR ); - RETURN_IF( null_in_list( input_samples, encoder->channels ), LC3PLUS_NULL_ERROR ); - RETURN_IF( bitdepth != 16 && bitdepth != 24, LC3PLUS_ERROR ); - *num_bytes = Enc_LC3PLUS_fl( encoder, input_samples, output_bytes, bitdepth, *num_bytes == -1 ); - assert( *num_bytes == lc3plus_enc_get_num_bytes( encoder ) ); + RETURN_IF(!encoder || !input_samples || !output_bytes || !num_bytes, LC3PLUS_NULL_ERROR); + RETURN_IF(null_in_list(input_samples, encoder->channels), LC3PLUS_NULL_ERROR); + RETURN_IF(bitdepth != 16 && bitdepth != 24, LC3PLUS_ERROR); + *num_bytes = Enc_LC3PLUS_fl(encoder, input_samples, output_bytes, bitdepth + , *num_bytes == -1 + ); + assert(*num_bytes == lc3plus_enc_get_num_bytes(encoder)); return LC3PLUS_OK; } /* decoder functions *********************************************************/ -LC3PLUS_Error lc3plus_dec_init( LC3PLUS_Dec *decoder, int samplerate, int channels, LC3PLUS_PlcMode plc_mode, int hrmode ) +LC3PLUS_Error lc3plus_dec_init(LC3PLUS_Dec* decoder, int samplerate, int channels, LC3PLUS_PlcMode plc_mode, int hrmode) { - RETURN_IF( decoder == NULL, LC3PLUS_NULL_ERROR ); - RETURN_IF( !lc3plus_samplerate_supported( samplerate ), LC3PLUS_SAMPLERATE_ERROR ); - RETURN_IF( !lc3plus_channels_supported( channels ), LC3PLUS_CHANNELS_ERROR ); - RETURN_IF( !lc3plus_plc_mode_supported( plc_mode ), LC3PLUS_PLCMODE_ERROR ); - RETURN_IF( samplerate == 96000 && hrmode == 0, LC3PLUS_HRMODE_ERROR ); - return FillDecSetup( decoder, samplerate, channels, plc_mode, hrmode ); + RETURN_IF(decoder == NULL, LC3PLUS_NULL_ERROR); + RETURN_IF(!lc3plus_samplerate_supported(samplerate), LC3PLUS_SAMPLERATE_ERROR); + RETURN_IF(!lc3plus_channels_supported(channels), LC3PLUS_CHANNELS_ERROR); + RETURN_IF(!lc3plus_plc_mode_supported(plc_mode), LC3PLUS_PLCMODE_ERROR); + RETURN_IF(samplerate==96000 && hrmode == 0, LC3PLUS_HRMODE_ERROR); + return FillDecSetup(decoder, samplerate, channels, plc_mode, hrmode); } -int lc3plus_dec_get_size( int samplerate, int channels ) +int lc3plus_dec_get_size(int samplerate, int channels) { - RETURN_IF( !lc3plus_samplerate_supported( samplerate ), 0 ); - RETURN_IF( !lc3plus_channels_supported( channels ), 0 ); - return alloc_decoder( NULL, samplerate, channels ); + RETURN_IF(!lc3plus_samplerate_supported(samplerate), 0); + RETURN_IF(!lc3plus_channels_supported(channels), 0); + return alloc_decoder(NULL, samplerate, channels); } /* Dummy function for API alignment */ -int lc3plus_dec_get_scratch_size( const LC3PLUS_Dec *decoder ) +int lc3plus_dec_get_scratch_size(const LC3PLUS_Dec *decoder) { - UNUSED( decoder ); + UNUSED(decoder); return 0; } -LC3PLUS_Error lc3plus_dec_set_frame_dms( LC3PLUS_Dec *decoder, int frame_dms ) +LC3PLUS_Error lc3plus_dec_set_frame_dms(LC3PLUS_Dec *decoder, int frame_dms) { - RETURN_IF( decoder == NULL, LC3PLUS_NULL_ERROR ); - RETURN_IF( !lc3plus_frame_size_supported( frame_dms / 10.0 ), LC3PLUS_FRAMEMS_ERROR ); - RETURN_IF( decoder->plcMeth == 2 && frame_dms != 100, LC3PLUS_FRAMEMS_ERROR ); + RETURN_IF(decoder == NULL, LC3PLUS_NULL_ERROR); + RETURN_IF(!lc3plus_frame_size_supported(frame_dms / 10.0), LC3PLUS_FRAMEMS_ERROR); + RETURN_IF(decoder->plcMeth == 2 && frame_dms != 100, LC3PLUS_FRAMEMS_ERROR); decoder->frame_dms = frame_dms; decoder->frame_ms = frame_dms / 10.0; - set_dec_frame_params( decoder ); + set_dec_frame_params(decoder); return LC3PLUS_OK; } -int lc3plus_dec_get_output_samples( const LC3PLUS_Dec *decoder ) +int lc3plus_dec_get_output_samples(const LC3PLUS_Dec* decoder) { - RETURN_IF( decoder == NULL, 0 ); + RETURN_IF(decoder == NULL, 0); return decoder->frame_length; } -int lc3plus_dec_get_delay( const LC3PLUS_Dec *decoder ) +int lc3plus_dec_get_delay(const LC3PLUS_Dec* decoder) { - RETURN_IF( decoder == NULL, 0 ); + RETURN_IF(decoder == NULL, 0); return decoder->frame_length - 2 * decoder->la_zeroes; } -LC3PLUS_Error lc3plus_dec_fl( LC3PLUS_Dec *decoder, void *input_bytes, int num_bytes, void **output_samples, int bps, int bfi_ext ) +LC3PLUS_Error lc3plus_dec_fl(LC3PLUS_Dec* decoder, void* input_bytes, int num_bytes, void** output_samples, int bps, int bfi_ext) { - RETURN_IF( !decoder || !input_bytes || !output_samples, LC3PLUS_NULL_ERROR ); - RETURN_IF( null_in_list( (void **) output_samples, decoder->channels ), LC3PLUS_NULL_ERROR ); - return Dec_LC3PLUS_fl( decoder, input_bytes, num_bytes, output_samples, bps, bfi_ext ); + RETURN_IF(!decoder || !input_bytes || !output_samples, LC3PLUS_NULL_ERROR); + RETURN_IF(null_in_list((void**)output_samples, decoder->channels), LC3PLUS_NULL_ERROR); + return Dec_LC3PLUS_fl(decoder, input_bytes, num_bytes, output_samples, bps, bfi_ext); } -LC3PLUS_Error lc3plus_dec16( LC3PLUS_Dec *decoder, void *input_bytes, int num_bytes, int16_t **output_samples, void *scratch, int bfi_ext ) +LC3PLUS_Error lc3plus_dec16(LC3PLUS_Dec* decoder, void* input_bytes, int num_bytes, int16_t** output_samples, + void* scratch, + int bfi_ext) { - UNUSED( scratch ); - return lc3plus_dec_fl( decoder, input_bytes, num_bytes, (void **) output_samples, 16, bfi_ext ); + UNUSED(scratch); + return lc3plus_dec_fl(decoder, input_bytes, num_bytes, (void**)output_samples, 16, bfi_ext); } -LC3PLUS_Error lc3plus_dec24( LC3PLUS_Dec *decoder, void *input_bytes, int num_bytes, int32_t **output_samples, void *scratch, int bfi_ext ) +LC3PLUS_Error lc3plus_dec24(LC3PLUS_Dec* decoder, void* input_bytes, int num_bytes, int32_t** output_samples, + void* scratch, + int bfi_ext) { - UNUSED( scratch ); - return lc3plus_dec_fl( decoder, input_bytes, num_bytes, (void **) output_samples, 24, bfi_ext ); + UNUSED(scratch); + return lc3plus_dec_fl(decoder, input_bytes, num_bytes, (void**)output_samples, 24, bfi_ext); } /* memory functions *********************************************************/ -LC3PLUS_Error lc3plus_enc_free_memory( LC3PLUS_Enc *encoder ) +LC3PLUS_Error lc3plus_enc_free_memory(LC3PLUS_Enc* encoder) { - RETURN_IF( !encoder, LC3PLUS_NULL_ERROR ); + RETURN_IF(!encoder, LC3PLUS_NULL_ERROR); - lc3plus_free_encoder_structs( encoder ); + lc3plus_free_encoder_structs(encoder); return LC3PLUS_OK; } -LC3PLUS_Error lc3plus_dec_free_memory( LC3PLUS_Dec *decoder ) +LC3PLUS_Error lc3plus_dec_free_memory(LC3PLUS_Dec* decoder) { - RETURN_IF( !decoder, LC3PLUS_NULL_ERROR ); + RETURN_IF(!decoder, LC3PLUS_NULL_ERROR); - lc3plus_free_decoder_structs( decoder ); + lc3plus_free_decoder_structs(decoder); return LC3PLUS_OK; } -LC3PLUS_Error lc3plus_free_encoder_structs( LC3PLUS_Enc *encoder ) +LC3PLUS_Error lc3plus_free_encoder_structs(LC3PLUS_Enc* encoder) { int ch = 0; - RETURN_IF( !encoder, LC3PLUS_NULL_ERROR ); + RETURN_IF(!encoder, LC3PLUS_NULL_ERROR); - for ( ch = 0; ch < encoder->channels; ch++ ) - { - mdct_free( &encoder->channel_setup[ch]->mdctStruct ); - dct2_free( &encoder->channel_setup[ch]->dct2StructSNS ); + for (ch = 0; ch < encoder->channels; ch++) { + mdct_free(&encoder->channel_setup[ch]->mdctStruct); + dct2_free(&encoder->channel_setup[ch]->dct2StructSNS); } return LC3PLUS_OK; } -LC3PLUS_Error lc3plus_free_decoder_structs( LC3PLUS_Dec *decoder ) +LC3PLUS_Error lc3plus_free_decoder_structs(LC3PLUS_Dec* decoder) { int ch = 0; - RETURN_IF( !decoder, LC3PLUS_NULL_ERROR ); + RETURN_IF(!decoder, LC3PLUS_NULL_ERROR); - for ( ch = 0; ch < decoder->channels; ch++ ) - { - dct4_free( &decoder->channel_setup[ch]->dct4structImdct ); - real_fft_free( &decoder->channel_setup[ch]->PlcAdvSetup->PlcPhEcuSetup.PhEcu_Fft ); - real_fft_free( &decoder->channel_setup[ch]->PlcAdvSetup->PlcPhEcuSetup.PhEcu_Ifft ); + for (ch = 0; ch < decoder->channels; ch++) { + dct4_free(&decoder->channel_setup[ch]->dct4structImdct); + real_fft_free(&decoder->channel_setup[ch]->PlcAdvSetup->PlcPhEcuSetup.PhEcu_Fft); + real_fft_free(&decoder->channel_setup[ch]->PlcAdvSetup->PlcPhEcuSetup.PhEcu_Ifft); } return LC3PLUS_OK; } -LC3PLUS_EpModeRequest lc3plus_dec_get_ep_mode_request( const LC3PLUS_Dec *decoder ) +LC3PLUS_EpModeRequest lc3plus_dec_get_ep_mode_request(const LC3PLUS_Dec *decoder) { - RETURN_IF( decoder == NULL, LC3PLUS_EPMR_ZERO ); - return (LC3PLUS_EpModeRequest) decoder->epmr; + RETURN_IF(decoder == NULL, LC3PLUS_EPMR_ZERO); + return (LC3PLUS_EpModeRequest)decoder->epmr; } -int lc3plus_dec_get_error_report( const LC3PLUS_Dec *decoder ) +int lc3plus_dec_get_error_report(const LC3PLUS_Dec *decoder) { - RETURN_IF( decoder == NULL, 0 ); + RETURN_IF(decoder == NULL, 0); return decoder->error_report == 2047 ? -1 : decoder->error_report & 0x07FF; } -LC3PLUS_Error lc3plus_enc_set_ep_mode( LC3PLUS_Enc *encoder, LC3PLUS_EpMode epmode ) +LC3PLUS_Error lc3plus_enc_set_ep_mode(LC3PLUS_Enc *encoder, LC3PLUS_EpMode epmode) { LC3PLUS_EpMode oldEpmode; LC3PLUS_Error error; - RETURN_IF( encoder == NULL, LC3PLUS_NULL_ERROR ); - RETURN_IF( (unsigned) epmode > LC3PLUS_EP_HIGH, LC3PLUS_EPMODE_ERROR ); + RETURN_IF(encoder == NULL, LC3PLUS_NULL_ERROR); + RETURN_IF((unsigned)epmode > LC3PLUS_EP_HIGH, LC3PLUS_EPMODE_ERROR); oldEpmode = encoder->epmode; encoder->epmode = epmode; - error = encoder->lc3_br_set ? update_enc_bitrate( encoder, encoder->bitrate ) : LC3PLUS_OK; - if ( error != LC3PLUS_OK ) + error = encoder->lc3_br_set ? update_enc_bitrate(encoder, encoder->bitrate) : LC3PLUS_OK; + if (error != LC3PLUS_OK) { - encoder->epmode = oldEpmode; // preserve old epmode in case of failure + encoder->epmode = oldEpmode; // preserve old epmode in case of failure } return error; } -LC3PLUS_Error lc3plus_enc_set_ep_mode_request( LC3PLUS_Enc *encoder, LC3PLUS_EpModeRequest epmr ) +LC3PLUS_Error lc3plus_enc_set_ep_mode_request(LC3PLUS_Enc *encoder, LC3PLUS_EpModeRequest epmr) { - RETURN_IF( encoder == NULL, LC3PLUS_NULL_ERROR ); - RETURN_IF( (unsigned) epmr > LC3PLUS_EPMR_HIGH, LC3PLUS_EPMODE_ERROR ); + RETURN_IF(encoder == NULL, LC3PLUS_NULL_ERROR); + RETURN_IF((unsigned)epmr > LC3PLUS_EPMR_HIGH, LC3PLUS_EPMODE_ERROR); encoder->epmr = epmr; return LC3PLUS_OK; } -LC3PLUS_Error lc3plus_dec_set_ep_enabled( LC3PLUS_Dec *decoder, int32_t ep_enabled ) +LC3PLUS_Error lc3plus_dec_set_ep_enabled(LC3PLUS_Dec *decoder, int32_t ep_enabled) { - RETURN_IF( decoder == NULL, LC3PLUS_NULL_ERROR ); + RETURN_IF(decoder == NULL, LC3PLUS_NULL_ERROR); decoder->ep_enabled = ep_enabled != 0; - decoder->epmr = LC3PLUS_EPMR_ZERO; + decoder->epmr = LC3PLUS_EPMR_ZERO; return LC3PLUS_OK; } -int lc3plus_dec_get_epok_flags( const LC3PLUS_Dec *decoder ) +int lc3plus_dec_get_epok_flags(const LC3PLUS_Dec *decoder) { - RETURN_IF( decoder == NULL, 0 ); + RETURN_IF(decoder == NULL, 0); return decoder->error_report >> 11; } @@ -435,3 +428,4 @@ int lc3plus_dec_get_epok_flags( const LC3PLUS_Dec *decoder ) #ifndef STRIP_ERROR_PROTECTION_API_FL #endif /* STRIP_ERROR_PROTECTION_API_FL */ + diff --git a/lib_lc3plus/lc3.h b/lib_lc3plus/lc3.h index bb835554bb..3e45438fed 100644 --- a/lib_lc3plus/lc3.h +++ b/lib_lc3plus/lc3.h @@ -1,18 +1,18 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + /*! \file lc3.h * This header provides the API for LC3plus. * * This library is targeting devices with extreme memory limitations, so memory management - * must be handeled by the user. This includes allocating memory for the structs. The structs are persistent + * must be handeled by the user. This includes allocating memory for the structs. The structs are persistent * between function calls. * * The amount of memory needed for various configurations can be obtained from the lc3plus_*_get_size @@ -28,15 +28,15 @@ #include #else typedef unsigned char uint8_t; -typedef __int16 int16_t; -typedef __int32 int32_t; +typedef __int16 int16_t; +typedef __int32 int32_t; #endif /*! Construct version number from major/minor/micro values. */ -#define LC3PLUS_VERSION_INT( major, minor, micro ) ( ( ( major ) << 16 ) | ( ( minor ) << 8 ) | ( micro ) ) +#define LC3PLUS_VERSION_INT(major, minor, micro) (((major) << 16) | ((minor) << 8) | (micro)) /*! Version number to ensure header and binary are matching. */ -#define LC3PLUS_VERSION LC3PLUS_VERSION_INT( 1, 6, 9 ) +#define LC3PLUS_VERSION LC3PLUS_VERSION_INT(1, 6, 9) /*! Maximum number of supported channels. The actual binary might support * less, use lc3plus_channels_supported() to check. */ @@ -58,64 +58,64 @@ typedef __int32 int32_t; /*! Error codes returned by functions. */ typedef enum { - LC3PLUS_PLC_ADVANCED = 1 /*!< Enhanced concealment method */ + LC3PLUS_PLC_ADVANCED = 1 /*!< Enhanced concealment method */ } LC3PLUS_PlcMode; /*! Error protection mode. LC3PLUS_EP_ZERO differs to LC3PLUS_EP_OFF in that * errors can be detected but not corrected. */ typedef enum { - LC3PLUS_EP_OFF = 0, /*!< Error protection is disabled */ - LC3PLUS_EP_ZERO = 1, /*!< Error protection with 0 bit correction */ - LC3PLUS_EP_LOW = 2, /*!< Error protection correcting one symbol per codeword */ + LC3PLUS_EP_OFF = 0, /*!< Error protection is disabled */ + LC3PLUS_EP_ZERO = 1, /*!< Error protection with 0 bit correction */ + LC3PLUS_EP_LOW = 2, /*!< Error protection correcting one symbol per codeword */ LC3PLUS_EP_MEDIUM = 3, /*!< Error protection correcting two symbols per codeword */ - LC3PLUS_EP_HIGH = 4 /*!< Error protection correcting three symbols per codeword */ + LC3PLUS_EP_HIGH = 4 /*!< Error protection correcting three symbols per codeword */ } LC3PLUS_EpMode; /*! Error protection mode request. On the encoder sidem, LC3PLUS_EPMR_ZERO to LC3PLUS_EPMR_HIGH * can be set. The decoder returns mode requests with different confidences. */ typedef enum { - LC3PLUS_EPMR_ZERO = 0, /*!< Request no error correction. High confidence if returned by decoder. */ - LC3PLUS_EPMR_LOW = 1, /*!< Request low error correction. High confidence if returned by decoder. */ - LC3PLUS_EPMR_MEDIUM = 2, /*!< Request medium error correction. High confidence if returned by decoder. */ - LC3PLUS_EPMR_HIGH = 3, /*!< Request high error correction. High confidence if returned by decoder. */ - LC3PLUS_EPMR_ZERO_MC = 4, /*!< No error correction requested, medium confidence. */ - LC3PLUS_EPMR_LOW_MC = 5, /*!< Low error correction requested, medium confidence. */ + LC3PLUS_EPMR_ZERO = 0, /*!< Request no error correction. High confidence if returned by decoder. */ + LC3PLUS_EPMR_LOW = 1, /*!< Request low error correction. High confidence if returned by decoder. */ + LC3PLUS_EPMR_MEDIUM = 2, /*!< Request medium error correction. High confidence if returned by decoder. */ + LC3PLUS_EPMR_HIGH = 3, /*!< Request high error correction. High confidence if returned by decoder. */ + LC3PLUS_EPMR_ZERO_MC = 4, /*!< No error correction requested, medium confidence. */ + LC3PLUS_EPMR_LOW_MC = 5, /*!< Low error correction requested, medium confidence. */ LC3PLUS_EPMR_MEDIUM_MC = 6, /*!< Medium error correction requested, medium confidence. */ - LC3PLUS_EPMR_HIGH_MC = 7, /*!< High error correction requested, medium confidence. */ - LC3PLUS_EPMR_ZERO_NC = 8, /*!< No error correction requested, unvalidated. */ - LC3PLUS_EPMR_LOW_NC = 9, /*!< Low error correction requested, unvalidated. */ + LC3PLUS_EPMR_HIGH_MC = 7, /*!< High error correction requested, medium confidence. */ + LC3PLUS_EPMR_ZERO_NC = 8, /*!< No error correction requested, unvalidated. */ + LC3PLUS_EPMR_LOW_NC = 9, /*!< Low error correction requested, unvalidated. */ LC3PLUS_EPMR_MEDIUM_NC = 10, /*!< Medium error correction requested, unvalidated. */ - LC3PLUS_EPMR_HIGH_NC = 11 /*!< High error correction requested, unvalidated. */ + LC3PLUS_EPMR_HIGH_NC = 11 /*!< High error correction requested, unvalidated. */ } LC3PLUS_EpModeRequest; /*! Error codes returned by functions. */ typedef enum { - LC3PLUS_OK = 0, /*!< No error occurred */ - LC3PLUS_ERROR = 1, /*!< Function call failed */ - LC3PLUS_DECODE_ERROR = 2, /*!< Frame failed to decode and was concealed */ - LC3PLUS_NULL_ERROR = 3, /*!< Pointer argument is null */ - LC3PLUS_SAMPLERATE_ERROR = 4, /*!< Invalid samplerate value */ - LC3PLUS_CHANNELS_ERROR = 5, /*!< Invalid channels value */ - LC3PLUS_BITRATE_ERROR = 6, /*!< Invalid bitrate value */ - LC3PLUS_NUMBYTES_ERROR = 7, /*!< Invalid num_bytes value */ - LC3PLUS_EPMODE_ERROR = 8, /*!< Invalid plc_method value */ - LC3PLUS_FRAMEMS_ERROR = 9, /*!< Invalid epmode value */ - LC3PLUS_ALIGN_ERROR = 10, /*!< Invalid frame_ms value */ - LC3PLUS_HRMODE_ERROR = 11, /*!< Unaligned pointer */ - LC3PLUS_BITRATE_UNSET_ERROR = 12, /*!< Invalid epmr value */ - LC3PLUS_BITRATE_SET_ERROR = 13, /*!< Invalid usage of hrmode, sampling rate and frame size */ - LC3PLUS_HRMODE_BW_ERROR = 14, /*!< Function called before bitrate has been set */ - LC3PLUS_PLCMODE_ERROR = 15, /*!< Function called after bitrate has been set */ - LC3PLUS_EPMR_ERROR = 16, /*!< Invalid external bad frame index */ - LC3PLUS_PADDING_ERROR = 17, /*!< Incorrect padding value */ - FRAMESIZE_ERROR = 18, /*!< Incorrect frame size during decoding */ + LC3PLUS_OK = 0, /*!< No error occurred */ + LC3PLUS_ERROR = 1, /*!< Function call failed */ + LC3PLUS_DECODE_ERROR = 2, /*!< Frame failed to decode and was concealed */ + LC3PLUS_NULL_ERROR = 3, /*!< Pointer argument is null */ + LC3PLUS_SAMPLERATE_ERROR = 4, /*!< Invalid samplerate value */ + LC3PLUS_CHANNELS_ERROR = 5, /*!< Invalid channels value */ + LC3PLUS_BITRATE_ERROR = 6, /*!< Invalid bitrate value */ + LC3PLUS_NUMBYTES_ERROR = 7, /*!< Invalid num_bytes value */ + LC3PLUS_EPMODE_ERROR = 8, /*!< Invalid plc_method value */ + LC3PLUS_FRAMEMS_ERROR = 9, /*!< Invalid epmode value */ + LC3PLUS_ALIGN_ERROR = 10, /*!< Invalid frame_ms value */ + LC3PLUS_HRMODE_ERROR = 11, /*!< Unaligned pointer */ + LC3PLUS_BITRATE_UNSET_ERROR = 12, /*!< Invalid epmr value */ + LC3PLUS_BITRATE_SET_ERROR = 13, /*!< Invalid usage of hrmode, sampling rate and frame size */ + LC3PLUS_HRMODE_BW_ERROR = 14, /*!< Function called before bitrate has been set */ + LC3PLUS_PLCMODE_ERROR = 15, /*!< Function called after bitrate has been set */ + LC3PLUS_EPMR_ERROR = 16, /*!< Invalid external bad frame index */ + LC3PLUS_PADDING_ERROR = 17, /*!< Incorrect padding value */ + FRAMESIZE_ERROR = 18, /*!< Incorrect frame size during decoding */ LC3PLUS_LFE_MODE_NOT_SUPPORTED = 19, /*!< LFE support not available */ /* START WARNING */ - LC3PLUS_WARNING = 20, + LC3PLUS_WARNING = 20, LC3PLUS_BW_WARNING = 21 /*!< Invalid bandwidth cutoff frequency */ } LC3PLUS_Error; @@ -127,29 +127,29 @@ typedef struct LC3PLUS_Dec LC3PLUS_Dec; /*!< Opaque decoder struct. */ * \{ */ /*! Test LFE mode support. - * + * * Tests the support of the LFE mode. * * \return 1 for true, 0 for false. */ -int32_t lc3_enc_supported_lfe( void ); +int32_t lc3_enc_supported_lfe(void); /*! Return library version number. It should match LC3PLUS_VERSION. */ -int lc3plus_version( void ); +int lc3plus_version(void); /*! Tests if the library supports number of channels. * * \param[in] channels Number of channels. * \return 1 for true, 0 for false. */ -int lc3plus_channels_supported( int channels ); +int lc3plus_channels_supported(int channels); /*! Tests if the library supports a sampling rate. * * \param[in] samplerate Sampling rate * \return 1 for true, 0 for false */ -int lc3plus_samplerate_supported( int samplerate ); +int lc3plus_samplerate_supported(int samplerate); /*! \} * \addtogroup Encoder @@ -171,7 +171,7 @@ int lc3plus_samplerate_supported( int samplerate ); * \param[in] hrmode High resolution mode. * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_enc_init( LC3PLUS_Enc *encoder, int samplerate, int channels, int hrmode, int32_t lfe_channel_array[] ); +LC3PLUS_Error lc3plus_enc_init(LC3PLUS_Enc* encoder, int samplerate, int channels, int hrmode, int32_t lfe_channel_array[]); /*! * Encode LC3plus frame with 16 bit input. @@ -190,20 +190,24 @@ LC3PLUS_Error lc3plus_enc_init( LC3PLUS_Enc *encoder, int samplerate, int channe * \param scratch See comment above. * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_enc16( LC3PLUS_Enc *encoder, int16_t **input_samples, void *output_bytes, int *num_bytes, void *scratch ); +LC3PLUS_Error lc3plus_enc16(LC3PLUS_Enc* encoder, int16_t** input_samples, void* output_bytes, int* num_bytes +, void *scratch +); /*! Encode LC3plus frame with 24 bit input. * * The input samples are expected to be 24-bit values, sign-extended to 32-bit. * See lc3plus_enc16() for parameter documentation. */ -LC3PLUS_Error lc3plus_enc24( LC3PLUS_Enc *encoder, int32_t **input_samples, void *output_bytes, int *num_bytes, void *scratch ); +LC3PLUS_Error lc3plus_enc24(LC3PLUS_Enc* encoder, int32_t** input_samples, void* output_bytes, int* num_bytes +, void *scratch +); /*! * Internal function. Use lc3plus_enc16() or lc3plus_enc24() for encoding. */ -LC3PLUS_Error lc3plus_enc_fl( LC3PLUS_Enc *encoder, void **input_samples, int bitdepth, void *output_bytes, int *num_bytes ); +LC3PLUS_Error lc3plus_enc_fl(LC3PLUS_Enc* encoder, void** input_samples, int bitdepth, void* output_bytes, int* num_bytes); /*! Get the size of the LC3plus encoder struct for a samplerate / channel * configuration. If memory is not restricted LC3PLUS_ENC_MAX_SIZE can be used for @@ -213,21 +217,21 @@ LC3PLUS_Error lc3plus_enc_fl( LC3PLUS_Enc *encoder, void **input_samples, int bi * \param[in] channels Number of channels. * \return Size in bytes or 0 on error. */ -int lc3plus_enc_get_size( int samplerate, int channels ); +int lc3plus_enc_get_size(int samplerate, int channels); /*! Dummy function as no scratch management available in floating-point code. Returns always zero. Used to align fixed-point and floating-point APIs. * * \param[in] encoder Encoder handle. * \return Size in bytes or 0 on error. */ -int lc3plus_enc_get_scratch_size( const LC3PLUS_Enc *encoder ); +int lc3plus_enc_get_scratch_size(const LC3PLUS_Enc *encoder); /*! Get number of samples per channel expected by lc3plus_enc16() or lc3plus_enc24(). * * \param[in] encoder Encoder handle. * \return Number of samples or 0 on error. */ -int lc3plus_enc_get_input_samples( const LC3PLUS_Enc *encoder ); +int lc3plus_enc_get_input_samples(const LC3PLUS_Enc* encoder); /*! Get real internal bitrate of the encoder. It might differ from the requested * bitrate due to 44.1 kHz input. @@ -235,7 +239,7 @@ int lc3plus_enc_get_input_samples( const LC3PLUS_Enc *encoder ); * \param[in] encoder Encoder handle. * \return Bitrate in bits per second or 0 on error. */ -int lc3plus_enc_get_real_bitrate( const LC3PLUS_Enc *encoder ); +int lc3plus_enc_get_real_bitrate(const LC3PLUS_Enc* encoder); /*! Get the maximum number of bytes produced by lc3plus_enc16() or lc3plus_enc24() for the current * bitrate. It should be equal to the num_bytes output of lc3plus_enc16/24(). @@ -243,7 +247,7 @@ int lc3plus_enc_get_real_bitrate( const LC3PLUS_Enc *encoder ); * \param[in] encoder Encoder handle. * \return Size in bytes or 0 on error. */ -int lc3plus_enc_get_num_bytes( const LC3PLUS_Enc *encoder ); +int lc3plus_enc_get_num_bytes(const LC3PLUS_Enc *encoder); /*! Set encoder bitrate for all channels. * This function must be called at least once before encoding the first frame, but @@ -257,20 +261,20 @@ int lc3plus_enc_get_num_bytes( const LC3PLUS_Enc *encoder ); * 24 | 48 * 32 | 64 * 44.1/48 | 80(voice) 128(music) - * 96 | 128 + * 96 | 128 * * \param[in] encoder Encoder handle. * \param[in] bitrate Bitrate in bits per second. * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_enc_set_bitrate( LC3PLUS_Enc *encoder, int bitrate ); +LC3PLUS_Error lc3plus_enc_set_bitrate(LC3PLUS_Enc* encoder, int bitrate); /*! Get the encoder delay in number of samples. * * \param[in] encoder Encoder handle. * \return Encoder in samples or 0 on error. */ -int lc3plus_enc_get_delay( const LC3PLUS_Enc *encoder ); +int lc3plus_enc_get_delay(const LC3PLUS_Enc *encoder); /*! Set the frame length for LC3plus decoder in deci milliseconds. * Not all lengths may be enabled, in that case LC3PLUS_FRAMEMS_ERROR is returned. @@ -280,7 +284,7 @@ int lc3plus_enc_get_delay( const LC3PLUS_Enc *encoder ); * \param[in] frame_ms Frame length in ms. * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_enc_set_frame_dms( LC3PLUS_Enc *encoder, int frame_ms ); +LC3PLUS_Error lc3plus_enc_set_frame_dms(LC3PLUS_Enc *encoder, int frame_ms); /*! Set encoder Low-frequency effect moded. deactivates LTPF, TNS, NF @@ -289,14 +293,14 @@ LC3PLUS_Error lc3plus_enc_set_frame_dms( LC3PLUS_Enc *encoder, int frame_ms ); * \param[in] lfe LFE mode flag * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_enc_set_lfe( LC3PLUS_Enc *encoder, int lfe ); +LC3PLUS_Error lc3plus_enc_set_lfe(LC3PLUS_Enc* encoder, int lfe); /*! Free memory allocated within LC3plus encoder struct. * * \param[in] encoder Encoder handle. * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_enc_free_memory( LC3PLUS_Enc *encoder ); +LC3PLUS_Error lc3plus_enc_free_memory(LC3PLUS_Enc* encoder); /*! Set encoder bandwidth to a different value. All frequency bins above the cutoff * frequency are cut off. Allowed frequencies are: 4 kHz, 8 kHz, 12 kHz, 16 kHz and 24 kHz. @@ -305,14 +309,14 @@ LC3PLUS_Error lc3plus_enc_free_memory( LC3PLUS_Enc *encoder ); * \param[in] bandwidth Cutoff Frequency in Hz * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_enc_set_bandwidth( LC3PLUS_Enc *encoder, int bandwidth ); +LC3PLUS_Error lc3plus_enc_set_bandwidth(LC3PLUS_Enc *encoder, int bandwidth); /*! Internal function called by lc3plus_enc_free_memory. * * \param[in] encoder Encoder handle. * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_free_encoder_structs( LC3PLUS_Enc *encoder ); +LC3PLUS_Error lc3plus_free_encoder_structs(LC3PLUS_Enc* encoder); /*! Sets error protection mode request transmitted in each channel encoded frame. * The channel coder includes an error protection mode request (EPMR) in every frame. @@ -324,7 +328,7 @@ LC3PLUS_Error lc3plus_free_encoder_structs( LC3PLUS_Enc *encoder ); * \param[in] epmr Error Protection Mode Request * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_enc_set_ep_mode_request( LC3PLUS_Enc *encoder, LC3PLUS_EpModeRequest epmr ); +LC3PLUS_Error lc3plus_enc_set_ep_mode_request(LC3PLUS_Enc *encoder, LC3PLUS_EpModeRequest epmr); /*! Set error protection mode. The default is LC3PLUS_EP_OFF. It is possible to switch between * different modees during encoding. Dynamic switching is only allowed between LC3PLUS_EP_ZERO, @@ -335,7 +339,7 @@ LC3PLUS_Error lc3plus_enc_set_ep_mode_request( LC3PLUS_Enc *encoder, LC3PLUS_EpM * \param[in] epmode Error protection mode. * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_enc_set_ep_mode( LC3PLUS_Enc *encoder, LC3PLUS_EpMode epmode ); +LC3PLUS_Error lc3plus_enc_set_ep_mode(LC3PLUS_Enc *encoder, LC3PLUS_EpMode epmode); /*! \} * \addtogroup Decoder @@ -358,7 +362,8 @@ LC3PLUS_Error lc3plus_enc_set_ep_mode( LC3PLUS_Enc *encoder, LC3PLUS_EpMode epmo * * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_dec_init( LC3PLUS_Dec *decoder, int samplerate, int channels, LC3PLUS_PlcMode plc_mode, int hrmode ); +LC3PLUS_Error lc3plus_dec_init(LC3PLUS_Dec* decoder, int samplerate, int channels, LC3PLUS_PlcMode plc_mode, int hrmode); + /*! @@ -384,17 +389,21 @@ LC3PLUS_Error lc3plus_dec_init( LC3PLUS_Dec *decoder, int samplerate, int channe * \return Returns LC3PLUS_OK on success or appropriate error code. Note there is * a special case for LC3PLUS_DECODE_ERROR where the output is still valid. */ -LC3PLUS_Error lc3plus_dec16( LC3PLUS_Dec *decoder, void *input_bytes, int num_bytes, int16_t **output_samples, void *scratch, int bfi_ext ); +LC3PLUS_Error lc3plus_dec16(LC3PLUS_Dec* decoder, void* input_bytes, int num_bytes, int16_t** output_samples, + void* scratch, + int bfi_ext); /*! Decode compressed LC3plus frame to 24 bit PCM output. * * The output samples are 24-bit values, sign-extended to 32-bit. * See lc3plus_dec16() for parameter documentation. */ -LC3PLUS_Error lc3plus_dec24( LC3PLUS_Dec *decoder, void *input_bytes, int num_bytes, int32_t **output_samples, void *scratch, int bfi_ext ); +LC3PLUS_Error lc3plus_dec24(LC3PLUS_Dec* decoder, void* input_bytes, int num_bytes, int32_t** output_samples, + void* scratch, + int bfi_ext); /* Internal function */ -LC3PLUS_Error lc3plus_dec_fl( LC3PLUS_Dec *decoder, void *input_bytes, int num_bytes, void **output_samples, int bps, int bfi_ext ); + LC3PLUS_Error lc3plus_dec_fl(LC3PLUS_Dec* decoder, void* input_bytes, int num_bytes, void** output_samples, int bps, int bfi_ext); /*! Get the size of the LC3plus decoder struct for a samplerate / channel * configuration. If memory is not restricted LC3PLUS_DEC_MAX_SIZE can be used for @@ -404,28 +413,28 @@ LC3PLUS_Error lc3plus_dec_fl( LC3PLUS_Dec *decoder, void *input_bytes, int num_b * \param[in] samplerate Sampling rate. * \return Size in bytes or 0 on error. */ -int lc3plus_dec_get_size( int samplerate, int channels ); +int lc3plus_dec_get_size(int samplerate, int channels); /*! Dummy function as no scratch management available in floating-point code. Returns always zero. Used to align fixed-point and floating-point APIs. * * \param[in] decoder Decoder handle. * \return Size in bytes or 0 on error. */ -int lc3plus_dec_get_scratch_size( const LC3PLUS_Dec *decoder ); +int lc3plus_dec_get_scratch_size(const LC3PLUS_Dec *decoder); /*! Get the number of samples per channel produced by lc3plus_dec16() or lc3plus_dec24. * * \param[in] decoder Decoder handle. * \return Number of samples or 0 on error. */ -int lc3plus_dec_get_output_samples( const LC3PLUS_Dec *decoder ); +int lc3plus_dec_get_output_samples(const LC3PLUS_Dec* decoder); /*! Get the decoder delay in number of samples. * * \param[in] decoder Decoder handle. * \return Delay in samples or 0 on error. */ -int lc3plus_dec_get_delay( const LC3PLUS_Dec *decoder ); +int lc3plus_dec_get_delay(const LC3PLUS_Dec* decoder); /*! Set the frame length for LC3plus encoder in deci milliseconds. * Not all lengths may be enabled, in that case LC3PLUS_FRAMEMS_ERROR is returned. @@ -436,7 +445,7 @@ int lc3plus_dec_get_delay( const LC3PLUS_Dec *decoder ); * \param[in] frame_ms Frame length in ms. * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_dec_set_frame_dms( LC3PLUS_Dec *decoder, int frame_ms ); +LC3PLUS_Error lc3plus_dec_set_frame_dms(LC3PLUS_Dec *decoder, int frame_ms); /*! Free memory allocated within LC3plus decoder struct. @@ -444,14 +453,14 @@ LC3PLUS_Error lc3plus_dec_set_frame_dms( LC3PLUS_Dec *decoder, int frame_ms ); * \param[in] decoder Decoder handle. * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_dec_free_memory( LC3PLUS_Dec *decoder ); +LC3PLUS_Error lc3plus_dec_free_memory(LC3PLUS_Dec* decoder); /*! Internal function called by lc3plus_dec_free_memory. * * \param[in] decoder Decoder handle. * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_free_decoder_structs( LC3PLUS_Dec *decoder ); +LC3PLUS_Error lc3plus_free_decoder_structs(LC3PLUS_Dec* decoder); /*! Enable or disable error protection. Default value is 0 (disabled). If error protection is * enabled, the decoder expects that the frames were encoded with error protection mode @@ -461,7 +470,7 @@ LC3PLUS_Error lc3plus_free_decoder_structs( LC3PLUS_Dec *decoder ); * \param[in] ep_enabled 1 (or any nonzero) for true, 0 for false. * \return LC3PLUS_OK on success or appropriate error code. */ -LC3PLUS_Error lc3plus_dec_set_ep_enabled( LC3PLUS_Dec *decoder, int ep_enabled ); +LC3PLUS_Error lc3plus_dec_set_ep_enabled(LC3PLUS_Dec *decoder, int ep_enabled); /*! Retrieves the error protection mode reqeust from channel decoder. * @@ -483,7 +492,7 @@ LC3PLUS_Error lc3plus_dec_set_ep_enabled( LC3PLUS_Dec *decoder, int ep_enabled ) * \param[in] decoder Decoder handle. * \return Error protection mode reqeust. */ -LC3PLUS_EpModeRequest lc3plus_dec_get_ep_mode_request( const LC3PLUS_Dec *decoder ); +LC3PLUS_EpModeRequest lc3plus_dec_get_ep_mode_request(const LC3PLUS_Dec *decoder); /*! Get the number of corrected bit errors in the last decoded frame. This only works if * error protection is active. If the number of errors is greater than the current error @@ -493,7 +502,7 @@ LC3PLUS_EpModeRequest lc3plus_dec_get_ep_mode_request( const LC3PLUS_Dec *decode * \param[in] decoder Decoder handle. * \return Number of corrected bits or -1. See description for details. */ -int lc3plus_dec_get_error_report( const LC3PLUS_Dec *decoder ); +int lc3plus_dec_get_error_report(const LC3PLUS_Dec *decoder); /*! This function returns an set of flags indicating whether the last frame * would have been channel decodable in epmode m, m ranging from 1 to 4. Note that * this information is not available in case the last frame was not channel @@ -502,7 +511,7 @@ int lc3plus_dec_get_error_report( const LC3PLUS_Dec *decoder ); * Otherwise, if the frame would not have been decodable or if this information * cannot be retrieved, the m-1th bit of the return value will be 0. */ -int lc3plus_dec_get_epok_flags( const LC3PLUS_Dec *decoder ); +int lc3plus_dec_get_epok_flags(const LC3PLUS_Dec *decoder); /*! \} */ #endif /* LC3plus */ diff --git a/lib_lc3plus/lc3plus_fft.c b/lib_lc3plus/lc3plus_fft.c index 01e09ff8ab..14f443f860 100644 --- a/lib_lc3plus/lc3plus_fft.c +++ b/lib_lc3plus/lc3plus_fft.c @@ -1,11 +1,11 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ #include "options.h" @@ -14,88 +14,86 @@ #include "fft/iisfft.c" #include "fft/cfft.c" -void fft_init( Fft *fft, int length ) +void fft_init(Fft* fft, int length) { HANDLE_IIS_FFT handle = NULL; IIS_FFT_ERROR error = 0; - assert( length % 2 == 0 ); + assert(length % 2 == 0); fft->length = length; - error = LC3_IIS_CFFT_Create( &handle, length, IIS_FFT_FWD ); + error = LC3_IIS_CFFT_Create(&handle, length, IIS_FFT_FWD); - assert( error == IIS_FFT_NO_ERROR ); + assert(error == IIS_FFT_NO_ERROR); fft->handle = handle; } -void fft_free( Fft *fft ) +void fft_free(Fft* fft) { IIS_FFT_ERROR error = 0; - if ( fft ) - { - error = LC3_IIS_CFFT_Destroy( (HANDLE_IIS_FFT *) &fft->handle ); + if (fft) { + error = LC3_IIS_CFFT_Destroy((HANDLE_IIS_FFT *) &fft->handle); - assert( error == IIS_FFT_NO_ERROR ); - memset( fft, 0, sizeof( *fft ) ); + assert(error == IIS_FFT_NO_ERROR); + memset(fft, 0, sizeof(*fft)); } } -void real_fft_free( Fft *fft ) +void real_fft_free(Fft* fft) { IIS_FFT_ERROR error = 0; - if ( fft ) - { - error = LC3_IIS_RFFT_Destroy( (HANDLE_IIS_FFT *) &fft->handle ); + if (fft) { + error = LC3_IIS_RFFT_Destroy((HANDLE_IIS_FFT *) &fft->handle); - assert( error == IIS_FFT_NO_ERROR ); - memset( fft, 0, sizeof( *fft ) ); + assert(error == IIS_FFT_NO_ERROR); + memset(fft, 0, sizeof(*fft)); } } -void real_fft_init( Fft *fft, LC3_INT32 length, HANDLE_IIS_FFT *handle ) +void real_fft_init(Fft* fft, LC3_INT32 length, HANDLE_IIS_FFT *handle) { IIS_FFT_ERROR error = IIS_FFT_NO_ERROR; - assert( length % 4 == 0 ); /* due to current limitation of core complex FFTs*/ + assert(length % 4 == 0); /* due to current limitation of core complex FFTs*/ fft->length = length; - error = LC3_IIS_RFFT_Create( handle, length, IIS_FFT_FWD ); - assert( error == IIS_FFT_NO_ERROR ); + error = LC3_IIS_RFFT_Create(handle, length, IIS_FFT_FWD); + assert(error == IIS_FFT_NO_ERROR); fft->handle = *handle; } -void real_ifft_init( Fft *fft, LC3_INT32 length, HANDLE_IIS_FFT *handle ) +void real_ifft_init(Fft* fft, LC3_INT32 length, HANDLE_IIS_FFT *handle) { IIS_FFT_ERROR error = IIS_FFT_NO_ERROR; - assert( length % 4 == 0 ); /* due to current limitation of core complex FFTs*/ + assert(length % 4 == 0); /* due to current limitation of core complex FFTs*/ fft->length = length; - error = LC3_IIS_RFFT_Create( handle, length, IIS_FFT_BWD ); + error = LC3_IIS_RFFT_Create(handle, length, IIS_FFT_BWD); - assert( error == IIS_FFT_NO_ERROR ); + assert(error == IIS_FFT_NO_ERROR); fft->handle = *handle; } -void fft_apply( Fft *fft, const Complex *input, Complex *output ) +void fft_apply(Fft* fft, const Complex* input, Complex* output) { IIS_FFT_ERROR error = 0; - error = LC3_IIS_FFT_Apply_CFFT( fft->handle, input, output ); + error = LC3_IIS_FFT_Apply_CFFT(fft->handle, input, output); - assert( error == IIS_FFT_NO_ERROR ); + assert(error == IIS_FFT_NO_ERROR); } -void real_fft_apply( Fft *fft, const LC3_FLOAT *input, LC3_FLOAT *output ) +void real_fft_apply(Fft* fft, const LC3_FLOAT* input, LC3_FLOAT* output) { IIS_FFT_ERROR error = IIS_FFT_NO_ERROR; - UNUSED( error ); + UNUSED(error); - error = LC3_IIS_FFT_Apply_RFFT( fft->handle, input, output ); + error = LC3_IIS_FFT_Apply_RFFT(fft->handle, input, output); - assert( error == IIS_FFT_NO_ERROR ); + assert(error == IIS_FFT_NO_ERROR); } diff --git a/lib_lc3plus/license.h b/lib_lc3plus/license.h index 513b89d7c7..d9d6c89675 100644 --- a/lib_lc3plus/license.h +++ b/lib_lc3plus/license.h @@ -1,12 +1,12 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "defines.h" diff --git a/lib_lc3plus/ltpf_coder.c b/lib_lc3plus/ltpf_coder.c index 14262cbba6..fac8c481c0 100644 --- a/lib_lc3plus/ltpf_coder.c +++ b/lib_lc3plus/ltpf_coder.c @@ -1,33 +1,30 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -static LC3_INT searchMaxIndice( LC3_FLOAT *in, LC3_INT len ); +static LC3_INT searchMaxIndice(LC3_FLOAT* in, LC3_INT len); -LC3_INT searchMaxIndice( LC3_FLOAT *in, LC3_INT len ) +LC3_INT searchMaxIndice(LC3_FLOAT* in, LC3_INT len) { - LC3_INT max_i = 0, i = 0; + LC3_INT max_i = 0, i = 0; LC3_FLOAT max = 0; - if ( len <= 0 ) - { + if (len <= 0) { return -128; } - for ( i = 0; i < len; i++ ) - { - if ( in[i] > max ) - { - max = in[i]; + for (i = 0; i < len; i++) { + if (in[i] > max) { + max = in[i]; max_i = i; } } @@ -35,41 +32,42 @@ LC3_INT searchMaxIndice( LC3_FLOAT *in, LC3_INT len ) return max_i; } -void process_ltpf_coder_fl( LC3_FLOAT *xin, LC3_INT xLen, LC3_INT ltpf_enable, LC3_INT pitch_ol, LC3_FLOAT pitch_ol_norm_corr, LC3_INT frame_dms, LC3_FLOAT *mem_old_x, LC3_INT memLen, LC3_FLOAT *mem_norm_corr_past, LC3_INT *mem_on, LC3_FLOAT *mem_pitch, LC3_INT *param, LC3_FLOAT *mem_norm_corr_past_past, LC3_INT *bits ) +void process_ltpf_coder_fl(LC3_FLOAT* xin, LC3_INT xLen, LC3_INT ltpf_enable, LC3_INT pitch_ol, LC3_FLOAT pitch_ol_norm_corr, LC3_INT frame_dms, + LC3_FLOAT* mem_old_x, LC3_INT memLen, LC3_FLOAT* mem_norm_corr_past, LC3_INT* mem_on, LC3_FLOAT* mem_pitch, + LC3_INT* param, LC3_FLOAT* mem_norm_corr_past_past, LC3_INT* bits) { - LC3_FLOAT buffer[LTPF_MEMIN_LEN + LEN_12K8 + 1 + ( LEN_12K8 >> 2 )] = { 0 }, sum = 0, buf_tmp[MAX_LEN] = { 0 }, cor_up[MAX_LEN] = { 0 }, *x; - LC3_INT i = 0, j = 0, k = 0, n = 0, step = 0, N = 0, ltpf_active = 0, pitch_search_delta = 0, - pitch_search_upsamp = 0, pitch_search_L_interpol1 = 0, - t0_min = 0, t0_max = 0, t_min = 0, t_max = 0, temp2 = 0, t1 = 0, pitch_int = 0, pitch_fr = 0, midpoint = 0, - delta_up = 0, delta_down = 0, pitch_index = 0, gain = 0, acflen = 0; - LC3_FLOAT norm_corr = 0, cor[MAX_LEN] = { 0 }, cor_int[MAX_LEN] = { 0 }, currFrame[MAX_LEN] = { 0 }, predFrame[MAX_LEN] = { 0 }, sum1 = 0, sum2 = 0, sum3 = 0; + LC3_FLOAT buffer[LTPF_MEMIN_LEN + LEN_12K8 + 1 + (LEN_12K8 >> 2)] = {0}, sum = 0, buf_tmp[MAX_LEN] = {0}, cor_up[MAX_LEN] = {0}, *x; + LC3_INT i = 0, j = 0, k = 0, n = 0, step = 0, N = 0, ltpf_active = 0, pitch_search_delta = 0, + pitch_search_upsamp = 0, pitch_search_L_interpol1 = 0, + t0_min = 0, t0_max = 0, t_min = 0, t_max = 0, temp2 = 0, t1 = 0, pitch_int = 0, pitch_fr = 0, midpoint = 0, + delta_up = 0, delta_down = 0, pitch_index = 0, gain = 0, acflen = 0; + LC3_FLOAT norm_corr = 0, cor[MAX_LEN] = {0}, cor_int[MAX_LEN] = {0}, currFrame[MAX_LEN] = {0}, predFrame[MAX_LEN] = {0}, sum1 = 0, sum2 = 0, sum3 = 0; LC3_FLOAT pitch = 0; /* Signal Buffer */ N = xLen - 1; x = &buffer[memLen]; - move_float( buffer, mem_old_x, memLen ); - move_float( x, xin, xLen ); - move_float( mem_old_x, &buffer[N], xLen + memLen - N ); + move_float(buffer, mem_old_x, memLen); + move_float(x, xin, xLen); + move_float(mem_old_x, &buffer[N], xLen + memLen - N); ltpf_active = 0; - norm_corr = 0; + norm_corr = 0; - pitch_search_delta = 4; - pitch_search_upsamp = 4; + pitch_search_delta = 4; + pitch_search_upsamp = 4; pitch_search_L_interpol1 = 4; - if ( pitch_ol_norm_corr > 0.6 ) - { + if (pitch_ol_norm_corr > 0.6) { /* Search Bounds */ t0_min = pitch_ol - pitch_search_delta; t0_max = pitch_ol + pitch_search_delta; - t0_min = MAX( t0_min, MIN_PITCH_12K8 ); - t0_max = MIN( t0_max, MAX_PITCH_12K8 ); + t0_min = MAX(t0_min, MIN_PITCH_12K8); + t0_max = MIN(t0_max, MAX_PITCH_12K8); acflen = N; - - if ( frame_dms == 25 ) + + if (frame_dms == 25) { acflen = 2 * N; x = x - N; @@ -81,68 +79,59 @@ void process_ltpf_coder_fl( LC3_FLOAT *xin, LC3_INT xLen, LC3_INT ltpf_enable, L /* Compute norm */ sum1 = sum2 = 0; - for ( j = 0; j < acflen; j++ ) - { + for (j = 0; j < acflen; j++) { sum1 += x[j] * x[j]; sum2 += x[j - t_min] * x[j - t_min]; } /* Compute Cross-Correlation */ - for ( i = t_min; i <= t_max; i++ ) - { + for (i = t_min; i <= t_max; i++) { sum = 0; - for ( j = 0; j < acflen; j++ ) - { + for (j = 0; j < acflen; j++) { sum += x[j] * x[j - i]; } - if ( i > t_min ) - { - sum2 = sum2 + x[-i] * x[-i] - x[acflen - 1 - ( i - 1 )] * x[acflen - 1 - ( i - 1 )]; + if (i > t_min) { + sum2 = sum2 + x[-i]*x[-i] + - x[acflen - 1 - ( i - 1 )]*x[acflen - 1 - ( i - 1 )]; } - sum3 = LC3_SQRT( sum1 * sum2 ) + LC3_POW( 10, -5 ); + sum3 = LC3_SQRT(sum1 * sum2) + LC3_POW(10, -5); norm_corr = sum / sum3; - - norm_corr = MAX( 0, norm_corr ); + + norm_corr = MAX(0, norm_corr); cor[i - t_min] = norm_corr; + } /* Find Integer Pitch-Lag */ j = 0; - for ( i = pitch_search_L_interpol1; i <= t_max - t_min - pitch_search_L_interpol1; i++ ) - { + for (i = pitch_search_L_interpol1; i <= t_max - t_min - pitch_search_L_interpol1; i++) { buf_tmp[j] = cor[i]; j++; } - temp2 = searchMaxIndice( buf_tmp, j ); + temp2 = searchMaxIndice(buf_tmp, j); t1 = temp2 + t0_min; - assert( t1 >= t0_min && t1 <= t0_max ); + assert(t1 >= t0_min && t1 <= t0_max); /* Find Fractional Pitch-Lag */ - if ( t1 >= RES2_PITCH_12K8 ) - { + if (t1 >= RES2_PITCH_12K8) { pitch_int = t1; - pitch_fr = 0; - } - else - { + pitch_fr = 0; + } else { j = 0; - - for ( i = 0; i < pitch_search_upsamp * ( t_max - t_min ) + 1; i = i + pitch_search_upsamp ) - { + + for (i = 0; i < pitch_search_upsamp * (t_max - t_min) + 1; i = i + pitch_search_upsamp) { cor_up[i] = cor[j]; j++; } - for ( i = 0; i < pitch_search_upsamp * ( t0_max - t0_min + 1 ); i++ ) - { + for (i = 0; i < pitch_search_upsamp * (t0_max - t0_min + 1); i++) { sum = 0; k = 0; - for ( j = i; j < i + 32; j++ ) - { + for (j = i; j < i + 32; j++) { sum += cor_up[j] * inter4_1[k]; k++; } @@ -150,78 +139,63 @@ void process_ltpf_coder_fl( LC3_FLOAT *xin, LC3_INT xLen, LC3_INT ltpf_enable, L cor_int[i] = sum; } - if ( t1 >= RES4_PITCH_12K8 ) - { + if (t1 >= RES4_PITCH_12K8) { step = 2; - } - else - { + } else { step = 1; } - midpoint = pitch_search_upsamp * ( t1 - t0_min ) + 1; + midpoint = pitch_search_upsamp * (t1 - t0_min) + 1; delta_up = pitch_search_upsamp - step; - if ( t1 == t0_min ) - { + if (t1 == t0_min) { delta_down = 0; - } - else - { + } else { delta_down = pitch_search_upsamp - step; } j = 0; - for ( i = midpoint - delta_down - 1; i <= midpoint + delta_up; i = i + step ) - { + for (i = midpoint - delta_down - 1; i <= midpoint + delta_up; i = i + step) { buf_tmp[j] = cor_int[i]; j++; } - temp2 = searchMaxIndice( buf_tmp, ( ( midpoint + delta_up ) - ( midpoint - delta_down ) ) / step + 1 ); + temp2 = searchMaxIndice(buf_tmp, ((midpoint + delta_up) - (midpoint - delta_down)) / step + 1); pitch_fr = temp2 * step - delta_down; - if ( pitch_fr >= 0 ) - { + if (pitch_fr >= 0) { pitch_int = t1; - } - else - { + } else { pitch_int = t1 - 1; - pitch_fr = pitch_search_upsamp + pitch_fr; + pitch_fr = pitch_search_upsamp + pitch_fr; } } - assert( ( pitch_int <= MAX_PITCH_12K8 && pitch_int >= RES2_PITCH_12K8 && pitch_fr == 0 ) || - ( pitch_int < RES2_PITCH_12K8 && pitch_int >= RES4_PITCH_12K8 && ( pitch_fr == 0 || pitch_fr == 2 ) ) || - ( pitch_int < RES4_PITCH_12K8 && pitch_int >= MIN_PITCH_12K8 && - ( pitch_fr == 0 || pitch_fr == 1 || pitch_fr == 2 || pitch_fr == 3 ) ) ); - - if ( pitch_int < RES4_PITCH_12K8 ) - { - pitch_index = pitch_int * 4 + pitch_fr - ( MIN_PITCH_12K8 * 4 ); - } - else if ( pitch_int < RES2_PITCH_12K8 ) - { - pitch_index = pitch_int * 2 + floor( pitch_fr / 2 ) - ( RES4_PITCH_12K8 * 2 ) + ( ( RES4_PITCH_12K8 - MIN_PITCH_12K8 ) * 4 ); - } - else - { - pitch_index = pitch_int - RES2_PITCH_12K8 + ( ( RES4_PITCH_12K8 - MIN_PITCH_12K8 ) * 4 ) + ( ( RES2_PITCH_12K8 - RES4_PITCH_12K8 ) * 2 ); + assert((pitch_int <= MAX_PITCH_12K8 && pitch_int >= RES2_PITCH_12K8 && pitch_fr == 0) || + (pitch_int < RES2_PITCH_12K8 && pitch_int >= RES4_PITCH_12K8 && (pitch_fr == 0 || pitch_fr == 2)) || + (pitch_int < RES4_PITCH_12K8 && pitch_int >= MIN_PITCH_12K8 && + (pitch_fr == 0 || pitch_fr == 1 || pitch_fr == 2 || pitch_fr == 3))); + + if (pitch_int < RES4_PITCH_12K8) { + pitch_index = pitch_int * 4 + pitch_fr - (MIN_PITCH_12K8 * 4); + } else if (pitch_int < RES2_PITCH_12K8) { + pitch_index = pitch_int * 2 + floor(pitch_fr / 2) - (RES4_PITCH_12K8 * 2) + ((RES4_PITCH_12K8 - MIN_PITCH_12K8) * 4); + } else { + pitch_index = pitch_int - RES2_PITCH_12K8 + ((RES4_PITCH_12K8 - MIN_PITCH_12K8) * 4) + ((RES2_PITCH_12K8 - RES4_PITCH_12K8) * 2); } - assert( pitch_index >= 0 && pitch_index < 512 ); + assert(pitch_index >= 0 && pitch_index < 512); pitch = (LC3_FLOAT) pitch_int + (LC3_FLOAT) pitch_fr / 4.0; + - - for ( n = 0; n < acflen; n++ ) + for (n = 0; n < acflen; n++) { currFrame[n] = x[n + 1] * enc_inter_filter[0][0] + - x[n] * enc_inter_filter[0][1] + + x[n] * enc_inter_filter[0][1] + x[n - 1] * enc_inter_filter[0][2]; predFrame[n] = x[n - pitch_int + 1] * enc_inter_filter[pitch_fr][0] + - x[n - pitch_int] * enc_inter_filter[pitch_fr][1] + + x[n - pitch_int] * enc_inter_filter[pitch_fr][1] + x[n - pitch_int - 1] * enc_inter_filter[pitch_fr][2] + x[n - pitch_int - 2] * enc_inter_filter[pitch_fr][3]; } @@ -229,73 +203,62 @@ void process_ltpf_coder_fl( LC3_FLOAT *xin, LC3_INT xLen, LC3_INT ltpf_enable, L /* Normalized Correlation */ sum1 = sum2 = sum3 = 0; - for ( i = 0; i < acflen; i++ ) - { + for (i = 0; i < acflen; i++) { sum1 += currFrame[i] * predFrame[i]; } - for ( i = 0; i < acflen; i++ ) - { + for (i = 0; i < acflen; i++) { sum2 += currFrame[i] * currFrame[i]; } - for ( i = 0; i < acflen; i++ ) - { + for (i = 0; i < acflen; i++) { sum3 += predFrame[i] * predFrame[i]; } - sum2 = LC3_SQRT( sum2 * sum3 ) + LC3_POW( 10, -5 ); + sum2 = LC3_SQRT(sum2 * sum3) + LC3_POW(10, -5); norm_corr = sum1 / sum2; - assert( norm_corr >= -1.00001 && norm_corr <= 1.00001 ); - norm_corr = MIN( 1, MAX( -1, norm_corr ) ); - if ( norm_corr < 0 ) - { + assert(norm_corr >= -1.00001 && norm_corr <= 1.00001); + norm_corr = MIN(1, MAX(-1, norm_corr)); + if (norm_corr < 0) { norm_corr = 0; } - if ( ltpf_enable == 1 ) - { + if (ltpf_enable == 1) { /* Decision if ltpf active */ - if ( ( *mem_on == 0 && ( frame_dms == 100 || *mem_norm_corr_past_past > 0.94 ) && *mem_norm_corr_past > 0.94 && - norm_corr > 0.94 ) || - ( *mem_on == 1 && norm_corr > 0.9 ) || - ( *mem_on == 1 && LC3_FABS( pitch - *mem_pitch ) < 2 && ( norm_corr - *mem_norm_corr_past ) > -0.1 && - norm_corr > 0.84 ) ) - { + if ((*mem_on == 0 && (frame_dms == 100 || *mem_norm_corr_past_past > 0.94) && *mem_norm_corr_past > 0.94 && + norm_corr > 0.94) || + (*mem_on == 1 && norm_corr > 0.9) || + (*mem_on == 1 && LC3_FABS(pitch - *mem_pitch) < 2 && (norm_corr - *mem_norm_corr_past) > -0.1 && + norm_corr > 0.84)) { ltpf_active = 1; } } gain = 4; - } - else - { - gain = 0; + + } else { + gain = 0; norm_corr = pitch_ol_norm_corr; - pitch = 0; + pitch = 0; } - if ( gain > 0 ) - { + if (gain > 0) { param[0] = 1; param[1] = ltpf_active; param[2] = pitch_index; - *bits = 11; - } - else - { - zero_int( param, 3 ); + *bits = 11; + } else { + zero_int(param, 3); *bits = 1; } - if ( frame_dms < 100 ) - { + if (frame_dms < 100) { *mem_norm_corr_past_past = *mem_norm_corr_past; } *mem_norm_corr_past = norm_corr; - *mem_on = ltpf_active; - *mem_pitch = pitch; + *mem_on = ltpf_active; + *mem_pitch = pitch; } diff --git a/lib_lc3plus/ltpf_decoder.c b/lib_lc3plus/ltpf_decoder.c index 6ce7797193..a40c85213a 100644 --- a/lib_lc3plus/ltpf_decoder.c +++ b/lib_lc3plus/ltpf_decoder.c @@ -1,239 +1,211 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -void process_ltpf_decoder_fl( LC3_FLOAT *x, LC3_INT xLen, LC3_FLOAT *y, LC3_INT fs, LC3_FLOAT *mem_old_x, LC3_FLOAT *mem_old_y, LC3_INT *mem_pitch_int, LC3_INT *mem_pitch_fr, LC3_FLOAT *mem_gain, LC3_INT *mem_beta_idx, LC3_INT bfi, LC3_INT *param, LC3_INT *mem_param, LC3_INT conf_beta_idx, LC3_FLOAT conf_beta, LC3_INT concealMethod, LC3_FLOAT damping, LC3_INT *mem_ltpf_active ) +void process_ltpf_decoder_fl(LC3_FLOAT* x, LC3_INT xLen, LC3_FLOAT* y, LC3_INT fs, LC3_FLOAT* mem_old_x, LC3_FLOAT* mem_old_y, + LC3_INT* mem_pitch_int, LC3_INT* mem_pitch_fr, LC3_FLOAT* mem_gain, LC3_INT* mem_beta_idx, LC3_INT bfi, + LC3_INT* param, LC3_INT* mem_param, LC3_INT conf_beta_idx, LC3_FLOAT conf_beta, LC3_INT concealMethod, + LC3_FLOAT damping + , LC3_INT *mem_ltpf_active +) { LC3_INT i = 0, j = 0, n = 0, N = 0, L_past_x = 0, N4 = 0, N34 = 0, - pitch_int = 0, pitch_fr = 0, p1 = 0, p2 = 0, L_past_y = 0, inter_len = 0, tilt_len = 0, - tilt_len_r = 0, inter_len_r = 0, old_x_len = 0, old_y_len = 0; + pitch_int = 0, pitch_fr = 0, p1 = 0, p2 = 0, L_past_y = 0, inter_len = 0, tilt_len = 0, + tilt_len_r = 0, inter_len_r = 0, old_x_len = 0, old_y_len = 0; - LC3_FLOAT conf_alpha = 0, gain = 0, a1[MAX_LEN] = { 0 }, a2[MAX_LEN] = { 0 }, b1[MAX_LEN] = { 0 }, b2[MAX_LEN] = { 0 }, - buf_x[4 * MAX_LEN] = { 0 }, buf_y[4 * MAX_LEN] = { 0 }, buf_z[4 * MAX_LEN] = { 0 }, pitch = 0, sum1 = 0, sum2 = 0; + LC3_FLOAT conf_alpha = 0, gain = 0, a1[MAX_LEN] = {0}, a2[MAX_LEN] = {0}, b1[MAX_LEN] = {0}, b2[MAX_LEN] = {0}, + buf_x[4 * MAX_LEN] = {0}, buf_y[4 * MAX_LEN] = {0}, buf_z[4 * MAX_LEN] = {0}, pitch = 0, sum1 = 0, sum2 = 0; const LC3_FLOAT *inter_filter[4], *tilt_filter[4]; conf_alpha = 0.85; - if ( bfi != 1 ) - { + if (bfi != 1) { /* Decode pitch */ - if ( param[0] == 1 ) - { - if ( param[2] < ( RES4_PITCH_12K8 - MIN_PITCH_12K8 ) * 4 ) - { - pitch_int = MIN_PITCH_12K8 + floor( param[2] / 4 ); - pitch_fr = param[2] - ( ( pitch_int - MIN_PITCH_12K8 ) * 4 ); - } - else if ( param[2] < ( ( RES4_PITCH_12K8 - MIN_PITCH_12K8 ) * 4 ) + ( ( RES2_PITCH_12K8 - RES4_PITCH_12K8 ) * 2 ) ) - { - param[2] = param[2] - ( ( RES4_PITCH_12K8 - MIN_PITCH_12K8 ) * 4 ); - pitch_int = RES4_PITCH_12K8 + floor( param[2] / 2 ); - pitch_fr = param[2] - ( ( pitch_int - RES4_PITCH_12K8 ) * 2 ); - pitch_fr = pitch_fr * 2; - } - else - { + if (param[0] == 1) { + if (param[2] < (RES4_PITCH_12K8 - MIN_PITCH_12K8) * 4) { + pitch_int = MIN_PITCH_12K8 + floor(param[2] / 4); + pitch_fr = param[2] - ((pitch_int - MIN_PITCH_12K8) * 4); + } else if (param[2] < ((RES4_PITCH_12K8 - MIN_PITCH_12K8) * 4) + ((RES2_PITCH_12K8 - RES4_PITCH_12K8) * 2)) { + param[2] = param[2] - ((RES4_PITCH_12K8 - MIN_PITCH_12K8) * 4); + pitch_int = RES4_PITCH_12K8 + floor(param[2] / 2); + pitch_fr = param[2] - ((pitch_int - RES4_PITCH_12K8) * 2); + pitch_fr = pitch_fr * 2; + } else { pitch_int = - param[2] + ( RES2_PITCH_12K8 - ( ( RES4_PITCH_12K8 - MIN_PITCH_12K8 ) * 4 ) - ( ( RES2_PITCH_12K8 - RES4_PITCH_12K8 ) * 2 ) ); + param[2] + (RES2_PITCH_12K8 - ((RES4_PITCH_12K8 - MIN_PITCH_12K8) * 4) - ((RES2_PITCH_12K8 - RES4_PITCH_12K8) * 2)); pitch_fr = 0; } - pitch = ( (LC3_FLOAT) pitch_int + (LC3_FLOAT) pitch_fr / 4.0 ) * (LC3_FLOAT) fs / 12800.0; - pitch = round( pitch * 4.0 ) / 4.0; - pitch_int = floor( pitch ); - pitch_fr = (LC3_INT) ( ( pitch - (LC3_FLOAT) pitch_int ) * 4.0 ); - } - else - { + pitch = ((LC3_FLOAT)pitch_int + (LC3_FLOAT)pitch_fr / 4.0) * (LC3_FLOAT)fs / 12800.0; + pitch = round(pitch * 4.0) / 4.0; + pitch_int = floor(pitch); + pitch_fr = (LC3_INT)((pitch - (LC3_FLOAT)pitch_int) * 4.0); + } else { pitch_int = 0; - pitch_fr = 0; + pitch_fr = 0; } /* Decode gain */ - if ( conf_beta_idx < 0 ) - { + if (conf_beta_idx < 0) { param[1] = 0; } - if ( param[1] == 1 ) - { + if (param[1] == 1) { gain = conf_beta; - } - else - { + } else { gain = 0; } } - else if ( concealMethod > 0 ) - { - if ( conf_beta_idx < 0 ) - { - if ( mem_param[1] && *mem_beta_idx >= 0 ) + else if (concealMethod > 0) { + if (conf_beta_idx < 0) { + if (mem_param[1] && *mem_beta_idx >= 0) { conf_beta_idx = *mem_beta_idx; } } - memmove( param, mem_param, sizeof( LC3_INT32 ) * 3 ); - if ( concealMethod == 2 ) + memmove(param, mem_param, sizeof(LC3_INT32) * 3); + if (concealMethod == 2) { /* cause the ltpf to "fade_out" and only filter during initial 2.5 ms and then its buffer during 7.5 ms */ - assert( bfi == 1 ); + assert(bfi == 1); param[1] = 0; /* ltpf_active = 0 */ } pitch_int = *mem_pitch_int; - pitch_fr = *mem_pitch_fr; - gain = (LC3_FLOAT) *mem_gain * damping; + pitch_fr = *mem_pitch_fr; + gain = (LC3_FLOAT) *mem_gain * damping; } - if ( ( conf_beta <= 0 ) && ( *mem_ltpf_active == 0 ) ) - { - if ( fs == 8000 || fs == 16000 ) - { - tilt_len = 4 - 2; - } - else if ( fs == 24000 ) + if ((conf_beta <= 0) && (*mem_ltpf_active == 0)) { - tilt_len = 6 - 2; - } - else if ( fs == 32000 ) - { - tilt_len = 8 - 2; - } - else if ( fs == 44100 || fs == 48000 ) - { - tilt_len = 12 - 2; - } + if (fs == 8000 || fs == 16000) { + tilt_len = 4 - 2; + } + else if (fs == 24000) { + tilt_len = 6 - 2; + } + else if (fs == 32000) { + tilt_len = 8 - 2; + } + else if (fs == 44100 || fs == 48000) { + tilt_len = 12 - 2; + } - N = xLen; - old_x_len = tilt_len; - inter_len = MAX( fs, 16000 ) / 8000; - old_y_len = ceilf( (LC3_FLOAT) 228.0 * fs / 12800.0 ) + inter_len; /* 228.0 needed to make use of ceil */ + N = xLen; + old_x_len = tilt_len; + inter_len = MAX(fs, 16000) / 8000; + old_y_len = ceilf((LC3_FLOAT)228.0 * fs / 12800.0) + inter_len; /* 228.0 needed to make use of ceil */ - move_float( mem_old_y, &mem_old_y[N], ( old_y_len - N ) ); - move_float( &mem_old_y[old_y_len - N], x, N ); - move_float( mem_old_x, &x[N - old_x_len], old_x_len ); + move_float(mem_old_y, &mem_old_y[N], (old_y_len - N)); + move_float(&mem_old_y[old_y_len - N], x, N); + move_float(mem_old_x, &x[N - old_x_len], old_x_len); - *mem_ltpf_active = 0; - } - else - { - inter_len_r = 0; - tilt_len_r = 0; - if ( fs == 8000 || fs == 16000 ) + *mem_ltpf_active = 0; + } + else { + inter_len_r = 0; tilt_len_r = 0; + if (fs == 8000 || fs == 16000) { inter_filter[0] = conf_inter_filter_16[0]; inter_filter[1] = conf_inter_filter_16[1]; inter_filter[2] = conf_inter_filter_16[2]; inter_filter[3] = conf_inter_filter_16[3]; - inter_len_r = 4; + inter_len_r = 4; tilt_filter[0] = conf_tilt_filter_16[0]; tilt_filter[1] = conf_tilt_filter_16[1]; tilt_filter[2] = conf_tilt_filter_16[2]; tilt_filter[3] = conf_tilt_filter_16[3]; - tilt_len = 4 - 2; - tilt_len_r = 3; - } - else if ( fs == 24000 ) - { + tilt_len = 4 - 2; + tilt_len_r = 3; + } else if (fs == 24000) { inter_filter[0] = conf_inter_filter_24[0]; inter_filter[1] = conf_inter_filter_24[1]; inter_filter[2] = conf_inter_filter_24[2]; inter_filter[3] = conf_inter_filter_24[3]; - inter_len_r = 6; + inter_len_r = 6; tilt_filter[0] = conf_tilt_filter_24[0]; tilt_filter[1] = conf_tilt_filter_24[1]; tilt_filter[2] = conf_tilt_filter_24[2]; tilt_filter[3] = conf_tilt_filter_24[3]; - tilt_len = 6 - 2; - tilt_len_r = 5; - } - else if ( fs == 32000 ) - { + tilt_len = 6 - 2; + tilt_len_r = 5; + } else if (fs == 32000) { inter_filter[0] = conf_inter_filter_32[0]; inter_filter[1] = conf_inter_filter_32[1]; inter_filter[2] = conf_inter_filter_32[2]; inter_filter[3] = conf_inter_filter_32[3]; - inter_len_r = 8; + inter_len_r = 8; tilt_filter[0] = conf_tilt_filter_32[0]; tilt_filter[1] = conf_tilt_filter_32[1]; tilt_filter[2] = conf_tilt_filter_32[2]; tilt_filter[3] = conf_tilt_filter_32[3]; - tilt_len = 8 - 2; - tilt_len_r = 7; - } - else if ( fs == 44100 || fs == 48000 ) - { + tilt_len = 8 - 2; + tilt_len_r = 7; + } else if (fs == 44100 || fs == 48000) { inter_filter[0] = conf_inter_filter_48[0]; inter_filter[1] = conf_inter_filter_48[1]; inter_filter[2] = conf_inter_filter_48[2]; inter_filter[3] = conf_inter_filter_48[3]; - inter_len_r = 12; + inter_len_r = 12; tilt_filter[0] = conf_tilt_filter_48[0]; tilt_filter[1] = conf_tilt_filter_48[1]; tilt_filter[2] = conf_tilt_filter_48[2]; tilt_filter[3] = conf_tilt_filter_48[3]; - tilt_len = 12 - 2; - tilt_len_r = 11; + tilt_len = 12 - 2; + tilt_len_r = 11; } - inter_len = MAX( fs, 16000 ) / 8000; + inter_len = MAX(fs, 16000) / 8000; /* Init buffers */ - N = xLen; + N = xLen; old_x_len = tilt_len; - old_y_len = ceilf( 228.0 * fs / 12800.0 ) + inter_len; + old_y_len = ceilf(228.0 * fs / 12800.0) + inter_len; L_past_x = old_x_len; - move_float( buf_x, mem_old_x, old_x_len ); - move_float( &buf_x[old_x_len], x, xLen ); + move_float(buf_x, mem_old_x, old_x_len); + move_float(&buf_x[old_x_len], x, xLen); L_past_y = old_y_len; - move_float( buf_y, mem_old_y, old_y_len ); - zero_float( &buf_y[old_y_len], xLen ); + move_float(buf_y, mem_old_y, old_y_len); + zero_float(&buf_y[old_y_len], xLen); - N4 = fs * 0.0025; + N4 = fs * 0.0025; N34 = N - N4; /* Init filter parameters */ - if ( mem_param[1] == 1 ) - { - for ( i = 0; i < inter_len_r; i++ ) - { + if (mem_param[1] == 1) { + for (i = 0; i < inter_len_r; i++) { a1[i] = *mem_gain * inter_filter[*mem_pitch_fr][i]; } - for ( i = 0; i < tilt_len_r; i++ ) - { - b1[i] = conf_alpha * ( *mem_gain ) * tilt_filter[*mem_beta_idx][i]; + for (i = 0; i < tilt_len_r; i++) { + b1[i] = conf_alpha * (*mem_gain) * tilt_filter[*mem_beta_idx][i]; } p1 = *mem_pitch_int; } - if ( param[1] == 1 ) - { - for ( i = 0; i < tilt_len_r; i++ ) - { + if (param[1] == 1) { + for (i = 0; i < tilt_len_r; i++) { b2[i] = conf_alpha * gain * tilt_filter[conf_beta_idx][i]; } - for ( i = 0; i < inter_len_r; i++ ) - { + for (i = 0; i < inter_len_r; i++) { a2[i] = gain * inter_filter[pitch_fr][i]; } @@ -241,150 +213,122 @@ void process_ltpf_decoder_fl( LC3_FLOAT *x, LC3_INT xLen, LC3_FLOAT *y, LC3_INT } /* First quarter of the current frame: cross-fading */ - if ( mem_param[1] == 0 && param[1] == 0 ) - { - memmove( &buf_y[L_past_y], &buf_x[L_past_x], sizeof( LC3_FLOAT ) * N4 ); - } - else if ( mem_param[1] == 1 && param[1] == 0 ) - { - for ( n = 0; n < N4; n++ ) - { + if (mem_param[1] == 0 && param[1] == 0) { + memmove(&buf_y[L_past_y], &buf_x[L_past_x], sizeof(LC3_FLOAT) * N4); + + } else if (mem_param[1] == 1 && param[1] == 0) { + for (n = 0; n < N4; n++) { sum1 = 0; sum2 = 0; - j = 0; - for ( i = L_past_x + n; i >= L_past_x + n - tilt_len; i-- ) - { + j = 0; + for (i = L_past_x + n; i >= L_past_x + n - tilt_len; i--) { sum1 += b1[j] * buf_x[i]; j++; } j = 0; - for ( i = L_past_y + n - p1 + inter_len - 1; i >= L_past_y + n - p1 - inter_len; i-- ) - { + for (i = L_past_y + n - p1 + inter_len - 1; i >= L_past_y + n - p1 - inter_len; i--) { sum2 += a1[j] * buf_y[i]; j++; } - buf_y[L_past_y + n] = buf_x[L_past_x + n] - ( ( (LC3_FLOAT) N4 - (LC3_FLOAT) n ) / (LC3_FLOAT) N4 ) * sum1 + - ( ( (LC3_FLOAT) N4 - (LC3_FLOAT) n ) / (LC3_FLOAT) N4 ) * sum2; + buf_y[L_past_y + n] = buf_x[L_past_x + n] - (((LC3_FLOAT)N4 - (LC3_FLOAT)n) / (LC3_FLOAT)N4) * sum1 + + (((LC3_FLOAT)N4 - (LC3_FLOAT)n) / (LC3_FLOAT)N4) * sum2; } - } - else if ( mem_param[1] == 0 && param[1] == 1 ) - { - for ( n = 0; n < N4; n++ ) - { + + } else if (mem_param[1] == 0 && param[1] == 1) { + for (n = 0; n < N4; n++) { sum1 = 0; sum2 = 0; - j = 0; - for ( i = L_past_x + n; i >= L_past_x + n - tilt_len; i-- ) - { + j = 0; + for (i = L_past_x + n; i >= L_past_x + n - tilt_len; i--) { sum1 += b2[j] * buf_x[i]; j++; } j = 0; - for ( i = L_past_y + n - p2 + inter_len - 1; i >= L_past_y + n - p2 - inter_len; i-- ) - { + for (i = L_past_y + n - p2 + inter_len - 1; i >= L_past_y + n - p2 - inter_len; i--) { sum2 += a2[j] * buf_y[i]; j++; } - buf_y[L_past_y + n] = buf_x[L_past_x + n] - ( (LC3_FLOAT) n / (LC3_FLOAT) N4 ) * sum1 + ( (LC3_FLOAT) n / (LC3_FLOAT) N4 ) * sum2; + buf_y[L_past_y + n] = buf_x[L_past_x + n] - ((LC3_FLOAT)n / (LC3_FLOAT)N4) * sum1 + ((LC3_FLOAT)n / (LC3_FLOAT)N4) * sum2; } - } - else if ( *mem_pitch_int == pitch_int && *mem_pitch_fr == pitch_fr ) - { - for ( n = 0; n < N4; n++ ) - { + } else if (*mem_pitch_int == pitch_int && *mem_pitch_fr == pitch_fr) { + for (n = 0; n < N4; n++) { sum1 = 0; sum2 = 0; - j = 0; - for ( i = L_past_x + n; i >= L_past_x + n - tilt_len; i-- ) - { + j = 0; + for (i = L_past_x + n; i >= L_past_x + n - tilt_len; i--) { sum1 += b2[j] * buf_x[i]; j++; } j = 0; - for ( i = L_past_y + n - p2 + inter_len - 1; i >= L_past_y + n - p2 - inter_len; i-- ) - { + for (i = L_past_y + n - p2 + inter_len - 1; i >= L_past_y + n - p2 - inter_len; i--) { sum2 += a2[j] * buf_y[i]; j++; } buf_y[L_past_y + n] = buf_x[L_past_x + n] - sum1 + sum2; } - } - else - { - for ( n = 0; n < N4; n++ ) - { + } else { + for (n = 0; n < N4; n++) { sum1 = 0; sum2 = 0; - j = 0; - for ( i = L_past_x + n; i >= L_past_x + n - tilt_len; i-- ) - { + j = 0; + for (i = L_past_x + n; i >= L_past_x + n - tilt_len; i--) { sum1 += b1[j] * buf_x[i]; j++; } j = 0; - for ( i = L_past_y + n - p1 + inter_len - 1; i >= L_past_y + n - p1 - inter_len; i-- ) - { + for (i = L_past_y + n - p1 + inter_len - 1; i >= L_past_y + n - p1 - inter_len; i--) { sum2 += a1[j] * buf_y[i]; j++; } - buf_y[L_past_y + n] = buf_x[L_past_x + n] - ( ( (LC3_FLOAT) N4 - (LC3_FLOAT) n ) / (LC3_FLOAT) N4 ) * sum1 + - ( ( (LC3_FLOAT) N4 - (LC3_FLOAT) n ) / (LC3_FLOAT) N4 ) * sum2; + buf_y[L_past_y + n] = buf_x[L_past_x + n] - (((LC3_FLOAT)N4 - (LC3_FLOAT)n) / (LC3_FLOAT)N4) * sum1 + + (((LC3_FLOAT)N4 - (LC3_FLOAT)n) / (LC3_FLOAT)N4) * sum2; } - memmove( buf_z, buf_y, sizeof( LC3_FLOAT ) * 4 * MAX_LEN ); + memmove(buf_z, buf_y, sizeof(LC3_FLOAT) * 4 * MAX_LEN); - for ( n = 0; n < N4; n++ ) - { + for (n = 0; n < N4; n++) { sum1 = 0; sum2 = 0; - j = 0; - for ( i = L_past_y + n; i >= L_past_y + n - tilt_len; i-- ) - { + j = 0; + for (i = L_past_y + n; i >= L_past_y + n - tilt_len; i--) { sum1 += b2[j] * buf_z[i]; j++; } j = 0; - for ( i = L_past_y + n - p2 + inter_len - 1; i >= L_past_y + n - p2 - inter_len; i-- ) - { + for (i = L_past_y + n - p2 + inter_len - 1; i >= L_past_y + n - p2 - inter_len; i--) { sum2 += a2[j] * buf_y[i]; j++; } - buf_y[L_past_y + n] = buf_z[L_past_y + n] - ( (LC3_FLOAT) n / (LC3_FLOAT) N4 ) * sum1 + ( (LC3_FLOAT) n / (LC3_FLOAT) N4 ) * sum2; + buf_y[L_past_y + n] = buf_z[L_past_y + n] - ((LC3_FLOAT)n / (LC3_FLOAT)N4) * sum1 + ((LC3_FLOAT)n / (LC3_FLOAT)N4) * sum2; } } /* Second quarter of the current frame */ - if ( param[1] == 0 ) - { - memmove( &buf_y[L_past_y + N4], &buf_x[L_past_x + N4], - sizeof( LC3_FLOAT ) * ( ( L_past_x + N4 + N34 ) - ( L_past_x + N4 ) ) ); - } - else - { - for ( n = 0; n < N34; n++ ) - { + if (param[1] == 0) { + memmove(&buf_y[L_past_y + N4], &buf_x[L_past_x + N4], + sizeof(LC3_FLOAT) * ((L_past_x + N4 + N34) - (L_past_x + N4))); + } else { + for (n = 0; n < N34; n++) { sum1 = 0; sum2 = 0; - j = 0; - for ( i = L_past_x + N4 + n; i >= L_past_x + n + N4 - tilt_len; i-- ) - { + j = 0; + for (i = L_past_x + N4 + n; i >= L_past_x + n + N4 - tilt_len; i--) { sum1 += b2[j] * buf_x[i]; j++; } j = 0; - for ( i = L_past_y + N4 + n - p2 + inter_len - 1; i >= L_past_y + N4 + n - p2 - inter_len; i-- ) - { + for (i = L_past_y + N4 + n - p2 + inter_len - 1; i >= L_past_y + N4 + n - p2 - inter_len; i--) { sum2 += a2[j] * buf_y[i]; j++; } @@ -394,19 +338,19 @@ void process_ltpf_decoder_fl( LC3_FLOAT *x, LC3_INT xLen, LC3_FLOAT *y, LC3_INT } /* Output */ - move_float( y, &buf_y[L_past_y], N ); + move_float(y, &buf_y[L_past_y], N); /* Update memory */ - move_float( mem_old_x, &buf_x[N], old_x_len ); - move_float( mem_old_y, &buf_y[N], old_y_len ); + move_float(mem_old_x, &buf_x[N], old_x_len); + move_float(mem_old_y, &buf_y[N], old_y_len); - *mem_ltpf_active = ( conf_beta > 0 ); + *mem_ltpf_active = (conf_beta > 0); } /* Update ltpf param memory */ - move_int( mem_param, param, 3 ); + move_int(mem_param, param, 3); *mem_pitch_int = pitch_int; - *mem_pitch_fr = pitch_fr; - *mem_gain = gain; - *mem_beta_idx = conf_beta_idx; + *mem_pitch_fr = pitch_fr; + *mem_gain = gain; + *mem_beta_idx = conf_beta_idx; } diff --git a/lib_lc3plus/mdct.c b/lib_lc3plus/mdct.c index 39efa26cee..11618b9465 100644 --- a/lib_lc3plus/mdct.c +++ b/lib_lc3plus/mdct.c @@ -1,140 +1,128 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -static const LC3_FLOAT *mdct_window( LC3_INT length, LC3_INT frame_dms, LC3_INT hrmode ) +static const LC3_FLOAT* mdct_window(LC3_INT length, LC3_INT frame_dms, LC3_INT hrmode) { - if ( frame_dms == 100 ) - { - switch ( length ) - { - case 80: - return MDCT_WINS_10ms[hrmode][0]; - case 160: - return MDCT_WINS_10ms[hrmode][1]; - case 240: - return MDCT_WINS_10ms[hrmode][2]; - case 320: - return MDCT_WINS_10ms[hrmode][3]; - case 480: - return MDCT_WINS_10ms[hrmode][4]; - case 960: - return MDCT_WINS_10ms[hrmode][5]; - default: - return NULL; + if (frame_dms == 100) { + switch (length) { + case 80: + return MDCT_WINS_10ms[hrmode][0]; + case 160: + return MDCT_WINS_10ms[hrmode][1]; + case 240: + return MDCT_WINS_10ms[hrmode][2]; + case 320: + return MDCT_WINS_10ms[hrmode][3]; + case 480: + return MDCT_WINS_10ms[hrmode][4]; + case 960: + return MDCT_WINS_10ms[hrmode][5]; + default: + return NULL; } } - else if ( frame_dms == 50 ) - { - switch ( length ) - { - case 40: - return MDCT_WINS_5ms[hrmode][0]; - case 80: - return MDCT_WINS_5ms[hrmode][1]; - case 120: - return MDCT_WINS_5ms[hrmode][2]; - case 160: - return MDCT_WINS_5ms[hrmode][3]; - case 240: - return MDCT_WINS_5ms[hrmode][4]; - case 480: - return MDCT_WINS_5ms[hrmode][5]; - default: - return NULL; + else if (frame_dms == 50) { + switch (length) { + case 40: + return MDCT_WINS_5ms[hrmode][0]; + case 80: + return MDCT_WINS_5ms[hrmode][1]; + case 120: + return MDCT_WINS_5ms[hrmode][2]; + case 160: + return MDCT_WINS_5ms[hrmode][3]; + case 240: + return MDCT_WINS_5ms[hrmode][4]; + case 480: + return MDCT_WINS_5ms[hrmode][5]; + default: + return NULL; } } - else if ( frame_dms == 25 ) - { - switch ( length ) - { - case 20: - return MDCT_WINS_2_5ms[hrmode][0]; - case 40: - return MDCT_WINS_2_5ms[hrmode][1]; - case 60: - return MDCT_WINS_2_5ms[hrmode][2]; - case 80: - return MDCT_WINS_2_5ms[hrmode][3]; - case 120: - return MDCT_WINS_2_5ms[hrmode][4]; - case 240: - return MDCT_WINS_2_5ms[hrmode][5]; - default: - return NULL; + else if (frame_dms == 25) { + switch (length) { + case 20: + return MDCT_WINS_2_5ms[hrmode][0]; + case 40: + return MDCT_WINS_2_5ms[hrmode][1]; + case 60: + return MDCT_WINS_2_5ms[hrmode][2]; + case 80: + return MDCT_WINS_2_5ms[hrmode][3]; + case 120: + return MDCT_WINS_2_5ms[hrmode][4]; + case 240: + return MDCT_WINS_2_5ms[hrmode][5]; + default: + return NULL; } } return NULL; } -void mdct_init( Mdct *mdct, LC3_INT length, LC3_INT frame_dms, LC3_INT fs_idx, LC3_INT hrmode ) +void mdct_init(Mdct* mdct, LC3_INT length, LC3_INT frame_dms, LC3_INT fs_idx, LC3_INT hrmode) { - if ( frame_dms == 100 ) - { + if (frame_dms == 100) { mdct->leading_zeros = MDCT_la_zeroes[fs_idx]; - } - else if ( frame_dms == 50 ) - { + } + else if (frame_dms == 50) { mdct->leading_zeros = MDCT_la_zeroes_5ms[fs_idx]; - } - else if ( frame_dms == 25 ) - { + } + else if (frame_dms == 25) { mdct->leading_zeros = MDCT_la_zeroes_2_5ms[fs_idx]; } - else - { - assert( !"invalid frame_ms" ); + else { + assert(!"invalid frame_ms"); } - mdct->length = length; + mdct->length = length; mdct->mem_length = length - mdct->leading_zeros; - mdct->window = mdct_window( length, frame_dms, hrmode ); - mdct->mem = calloc( sizeof( *mdct->mem ), mdct->mem_length ); - dct4_init( &mdct->dct, length ); + mdct->window = mdct_window(length, frame_dms, hrmode); + mdct->mem = calloc(sizeof(*mdct->mem), mdct->mem_length); + dct4_init(&mdct->dct, length); } -void mdct_free( Mdct *mdct ) +void mdct_free(Mdct* mdct) { - if ( mdct ) - { - free( mdct->mem ); - dct4_free( &mdct->dct ); - memset( mdct, 0, sizeof( *mdct ) ); + if (mdct) { + free(mdct->mem); + dct4_free(&mdct->dct); + memset(mdct, 0, sizeof(*mdct)); } } -void mdct_apply( const LC3_FLOAT *input, LC3_FLOAT *output, Mdct *mdct ) +void mdct_apply(const LC3_FLOAT* input, LC3_FLOAT* output, Mdct* mdct) { - LC3_FLOAT tmp[MAX_LEN * 2] = { 0 }; - LC3_INT i = 0; + LC3_FLOAT tmp[MAX_LEN * 2] = {0}; + LC3_INT i = 0; LC3_INT hlen; - move_float( tmp, mdct->mem, mdct->mem_length ); - move_float( tmp + mdct->mem_length, input, mdct->length ); - zero_float( tmp + mdct->length * 2 - mdct->leading_zeros, mdct->leading_zeros ); - move_float( mdct->mem, tmp + mdct->length, mdct->mem_length ); + move_float(tmp, mdct->mem, mdct->mem_length); + move_float(tmp + mdct->mem_length, input, mdct->length); + zero_float(tmp + mdct->length * 2 - mdct->leading_zeros, mdct->leading_zeros); + move_float(mdct->mem, tmp + mdct->length, mdct->mem_length); - mult_vec( tmp, mdct->window, mdct->length * 2 ); + mult_vec(tmp, mdct->window, mdct->length * 2); hlen = mdct->length / 2; - for ( i = 0; i < hlen; i++ ) - { - output[i] = -tmp[hlen * 3 - i - 1] - tmp[hlen * 3 + i]; + for (i = 0; i < hlen; i++) { + output[i] = -tmp[hlen * 3 - i - 1] - tmp[hlen * 3 + i]; output[hlen + i] = tmp[i] - tmp[hlen * 2 - i - 1]; } - move_float( tmp, output, mdct->length ); + move_float(tmp, output, mdct->length); - dct4_apply( &mdct->dct, tmp, output ); + dct4_apply(&mdct->dct, tmp, output); } -void processMdct_fl( LC3_FLOAT *in, LC3_FLOAT *out, Mdct *mdctStruct ) { mdct_apply( in, out, mdctStruct ); } +void processMdct_fl(LC3_FLOAT* in, LC3_FLOAT* out, Mdct* mdctStruct) { mdct_apply(in, out, mdctStruct); } diff --git a/lib_lc3plus/mdct_shaping.c b/lib_lc3plus/mdct_shaping.c index bcbcd1fab1..1876192504 100644 --- a/lib_lc3plus/mdct_shaping.c +++ b/lib_lc3plus/mdct_shaping.c @@ -1,24 +1,22 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -void processMdctShaping_fl( LC3_FLOAT x[], LC3_FLOAT scf[], const LC3_INT bands_offset[], LC3_INT fdns_npts ) +void processMdctShaping_fl(LC3_FLOAT x[], LC3_FLOAT scf[], const LC3_INT bands_offset[], LC3_INT fdns_npts) { LC3_INT i = 0, j = 0; - for ( i = 0; i < fdns_npts; i++ ) - { - for ( ; j < bands_offset[i + 1]; j++ ) - { + for (i = 0; i < fdns_npts; i++) { + for (; j < bands_offset[i + 1]; j++) { x[j] = x[j] * scf[i]; } } diff --git a/lib_lc3plus/near_nyquist_detector.c b/lib_lc3plus/near_nyquist_detector.c index a6e74e6cca..ce94351302 100644 --- a/lib_lc3plus/near_nyquist_detector.c +++ b/lib_lc3plus/near_nyquist_detector.c @@ -1,37 +1,37 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ #include "functions.h" #include "options.h" -void processNearNyquistdetector_fl( LC3_INT16 *near_nyquist_flag, const LC3_INT fs_idx, const LC3_INT near_nyquist_index, const LC3_INT bands_number, const LC3_FLOAT *ener ) +void processNearNyquistdetector_fl(LC3_INT16* near_nyquist_flag, const LC3_INT fs_idx, const LC3_INT near_nyquist_index, + const LC3_INT bands_number, const LC3_FLOAT* ener) { *near_nyquist_flag = 0; - if ( fs_idx < 4 ) + if (fs_idx < 4) { - LC3_INT i = 0; + LC3_INT i = 0; LC3_FLOAT ener_low = FLT_EPSILON, ener_high = 0; - for ( i = 0; i < near_nyquist_index; i++ ) + for (i=0; i NN_thresh * ener_low ) - { + if (ener_high > NN_thresh * ener_low){ *near_nyquist_flag = 1; } } diff --git a/lib_lc3plus/noise_factor.c b/lib_lc3plus/noise_factor.c index 2f9e634b01..c5aa582e45 100644 --- a/lib_lc3plus/noise_factor.c +++ b/lib_lc3plus/noise_factor.c @@ -1,24 +1,26 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -void processNoiseFactor_fl( LC3_INT *fac_ns_idx, LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gg, LC3_INT BW_cutoff_idx, LC3_INT frame_dms, LC3_INT target_bytes ) +void processNoiseFactor_fl(LC3_INT* fac_ns_idx, LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gg, LC3_INT BW_cutoff_idx, LC3_INT frame_dms, + LC3_INT target_bytes +) { LC3_INT sumZeroLines = 0, kZeroLines = 0, startOffset = 0, nTransWidth = 0, end = 0, start = 0, i = 0, j = 0, k = 0, - allZeros = 0, m = 0; + allZeros = 0, m = 0; LC3_FLOAT fac_ns_unq = 0, mean = 0, idx = 0, nsf1 = 0, nsf2 = 0; - LC3_INT zeroLines[MAX_LEN] = { 0 }, zL1[MAX_LEN] = { 0 }, zL2[MAX_LEN] = { 0 }; + LC3_INT zeroLines[MAX_LEN] = {0}, zL1[MAX_LEN] = {0}, zL2[MAX_LEN] = {0}; - switch ( frame_dms ) + switch (frame_dms) { case 25: nTransWidth = 4; @@ -34,92 +36,77 @@ void processNoiseFactor_fl( LC3_INT *fac_ns_idx, LC3_FLOAT x[], LC3_INT xq[], LC break; } - for ( k = startOffset; k < BW_cutoff_idx; k++ ) - { + for (k = startOffset; k < BW_cutoff_idx; k++) { allZeros = 1; - start = k - ( nTransWidth - 2 ) / 2; - end = MIN( BW_cutoff_idx - 1, k + ( nTransWidth - 2 ) / 2 ); + start = k - (nTransWidth - 2) / 2; + end = MIN(BW_cutoff_idx - 1, k + (nTransWidth - 2) / 2); - for ( i = start; i <= end; i++ ) - { - if ( xq[i] != 0 ) - { + for (i = start; i <= end; i++) { + if (xq[i] != 0) { allZeros = 0; } } - if ( allZeros == 1 ) - { + if (allZeros == 1) { zeroLines[j] = k + 1; kZeroLines++; j++; } } - for ( i = 0; i < kZeroLines; i++ ) - { + for (i = 0; i < kZeroLines; i++) { sumZeroLines += zeroLines[i]; } - if ( sumZeroLines > 0 ) - { - for ( j = 0; j < kZeroLines; j++ ) - { - mean += LC3_FABS( x[zeroLines[j] - 1] ); + if (sumZeroLines > 0) { + for (j = 0; j < kZeroLines; j++) { + mean += LC3_FABS(x[zeroLines[j] - 1]); } - fac_ns_unq = mean / ( gg * kZeroLines ); - } - else - { + fac_ns_unq = mean / (gg * kZeroLines); + } else { fac_ns_unq = 0; } - if ( kZeroLines > 0 ) + if (kZeroLines > 0) { - if ( target_bytes <= 20 && frame_dms == 100 ) - { + if (target_bytes <= 20 && frame_dms == 100) { j = 0, k = 0; - m = floor( sumZeroLines / kZeroLines ); + m = floor(sumZeroLines / kZeroLines); - for ( i = 0; i < kZeroLines; i++ ) - { - if ( zeroLines[i] <= m ) - { + for (i = 0; i < kZeroLines; i++) { + if (zeroLines[i] <= m) { zL1[j] = zeroLines[i]; j++; } - if ( zeroLines[i] > m ) - { + if (zeroLines[i] > m) { zL2[k] = zeroLines[i]; k++; } } mean = 0; - for ( i = 0; i < j; i++ ) - { - mean += LC3_FABS( x[zL1[i] - 1] ) / gg; + for (i = 0; i < j; i++) { + mean += LC3_FABS(x[zL1[i] - 1]) / gg; } nsf1 = mean / j; mean = 0; - for ( i = 0; i < k; i++ ) - { - mean += LC3_FABS( x[zL2[i] - 1] ) / gg; + for (i = 0; i < k; i++) { + mean += LC3_FABS(x[zL2[i] - 1]) / gg; } nsf2 = mean / k; - fac_ns_unq = MIN( nsf1, nsf2 ); + fac_ns_unq = MIN(nsf1, nsf2); } } - idx = round( 8 - 16 * fac_ns_unq ); - idx = MIN( MAX( idx, 0 ), 7 ); + idx = round(8 - 16 * fac_ns_unq); + idx = MIN(MAX(idx, 0), 7); *fac_ns_idx = idx; } diff --git a/lib_lc3plus/noise_filling.c b/lib_lc3plus/noise_filling.c index 85361c8091..7fac5e0f72 100644 --- a/lib_lc3plus/noise_filling.c +++ b/lib_lc3plus/noise_filling.c @@ -1,23 +1,23 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -void processNoiseFilling_fl( LC3_FLOAT xq[], LC3_INT nfseed, LC3_INT fac_ns_idx, LC3_INT bw_stopband, LC3_INT frame_dms, LC3_FLOAT fac_ns_pc, LC3_INT spec_inv_idx ) +void processNoiseFilling_fl(LC3_FLOAT xq[], LC3_INT nfseed, LC3_INT fac_ns_idx, LC3_INT bw_stopband, LC3_INT frame_dms, LC3_FLOAT fac_ns_pc, LC3_INT spec_inv_idx) { - LC3_INT zeroLines[MAX_LEN] = { 0 }; - LC3_INT nTransWidth = 0, startOffset = 0, i = 0, j = 0, k = 0, start = 0, end = 0, allZeros = 0, kZeroLines = 0; + LC3_INT zeroLines[MAX_LEN] = {0}; + LC3_INT nTransWidth = 0, startOffset = 0, i = 0, j = 0, k = 0, start = 0, end = 0, allZeros = 0, kZeroLines = 0; LC3_FLOAT fac_ns = 0; - switch ( frame_dms ) + switch (frame_dms) { case 25: nTransWidth = 1; @@ -33,57 +33,45 @@ void processNoiseFilling_fl( LC3_FLOAT xq[], LC3_INT nfseed, LC3_INT fac_ns_idx, break; } - fac_ns = ( 8.0 - fac_ns_idx ) / 16.0; + fac_ns = (8.0 - fac_ns_idx) / 16.0; j = 0; - for ( k = startOffset; k < bw_stopband; k++ ) - { + for (k = startOffset; k < bw_stopband; k++) { allZeros = 1; start = k - nTransWidth; - end = MIN( bw_stopband - 1, k + nTransWidth ); + end = MIN(bw_stopband - 1, k + nTransWidth); - for ( i = start; i <= end; i++ ) - { - if ( xq[i] != 0 ) - { + for (i = start; i <= end; i++) { + if (xq[i] != 0) { allZeros = 0; } } - if ( allZeros == 1 ) - { + if (allZeros == 1) { zeroLines[j] = k; kZeroLines++; j++; } } - for ( k = 0; k < kZeroLines; k++ ) - { - nfseed = ( 13849 + ( nfseed + 32768 ) * 31821 ) & 65535; + for (k = 0; k < kZeroLines; k++) { + nfseed = (13849 + (nfseed + 32768) * 31821) & 65535; nfseed -= 32768; - if ( nfseed >= 0 ) - { - if ( zeroLines[k] < spec_inv_idx ) + if (nfseed >= 0) { + if (zeroLines[k] < spec_inv_idx) { xq[zeroLines[k]] = fac_ns; - } - else - { + } else { xq[zeroLines[k]] = fac_ns_pc; } - } - else - { - if ( zeroLines[k] < spec_inv_idx ) + } else { + if (zeroLines[k] < spec_inv_idx) { xq[zeroLines[k]] = -fac_ns; - } - else - { + } else { xq[zeroLines[k]] = -fac_ns_pc; } } diff --git a/lib_lc3plus/olpa.c b/lib_lc3plus/olpa.c index 13340ff6f9..6bec50952e 100644 --- a/lib_lc3plus/olpa.c +++ b/lib_lc3plus/olpa.c @@ -1,31 +1,29 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -static void filter_olpa( LC3_FLOAT *in, LC3_FLOAT *out, const LC3_FLOAT *buf, LC3_FLOAT len_buf, LC3_INT len_input ); -static LC3_INT searchMaxIndice( LC3_FLOAT *in, LC3_INT len ); +static void filter_olpa(LC3_FLOAT* in, LC3_FLOAT* out, const LC3_FLOAT* buf, LC3_FLOAT len_buf, LC3_INT len_input); +static LC3_INT searchMaxIndice(LC3_FLOAT* in, LC3_INT len); -void filter_olpa( LC3_FLOAT *in, LC3_FLOAT *out, const LC3_FLOAT *buf, LC3_FLOAT len_buf, LC3_INT len_input ) +void filter_olpa(LC3_FLOAT* in, LC3_FLOAT* out, const LC3_FLOAT* buf, LC3_FLOAT len_buf, LC3_INT len_input) { - LC3_INT i = 0, j = 0; + LC3_INT i = 0, j = 0; LC3_FLOAT sum = 0; /* a = 1, so denominator == 1, nothing to do here */ - for ( i = 0; i < len_input; i++ ) - { - j = 0; + for (i = 0; i < len_input; i++) { + j = 0; sum = 0; - for ( j = 0; ( j < len_buf ) && ( j <= i ); j++ ) - { + for (j = 0; (j < len_buf) && (j <= i); j++) { sum += buf[j] * in[i - j]; } @@ -33,21 +31,18 @@ void filter_olpa( LC3_FLOAT *in, LC3_FLOAT *out, const LC3_FLOAT *buf, LC3_FLOAT } } -LC3_INT searchMaxIndice( LC3_FLOAT *in, LC3_INT len ) +LC3_INT searchMaxIndice(LC3_FLOAT* in, LC3_INT len) { - LC3_INT max_i = 0, i = 0; + LC3_INT max_i = 0, i = 0; LC3_FLOAT max = in[0]; - if ( len <= 0 ) - { + if (len <= 0) { return -128; } - for ( i = 0; i < len; i++ ) - { - if ( in[i] > max ) - { - max = in[i]; + for (i = 0; i < len; i++) { + if (in[i] > max) { + max = in[i]; max_i = i; } } @@ -55,102 +50,95 @@ LC3_INT searchMaxIndice( LC3_FLOAT *in, LC3_INT len ) return max_i; } -void processOlpa_fl( LC3_FLOAT *s_12k8, LC3_FLOAT *mem_s12k8, LC3_FLOAT *mem_s6k4, LC3_INT *mem_old_T0, LC3_INT *T0_out, LC3_FLOAT *normcorr_out, LC3_INT len, LC3_INT frame_dms ) +void processOlpa_fl(LC3_FLOAT* s_12k8, LC3_FLOAT* mem_s12k8, LC3_FLOAT* mem_s6k4, LC3_INT* mem_old_T0, LC3_INT* T0_out, + LC3_FLOAT* normcorr_out, LC3_INT len, LC3_INT frame_dms) { LC3_FLOAT norm_corr = 0, sum = 0, sum0 = 0, sum1 = 0, sum2 = 0, norm_corr2 = 0, *s6k4; - LC3_FLOAT buf[LEN_6K4 + MAX_PITCH_6K4] = { 0 }, filt_out[LEN_12K8 + 3] = { 0 }, d_wsp[LEN_6K4] = { 0 }, R0[RANGE_PITCH_6K4] = { 0 }, R[RANGE_PITCH_6K4] = { 0 }; /* constant length */ - LC3_INT i = 0, j = 0, len2 = 0, T0 = 0, T02 = 0, min_pitch = 0, max_pitch = 0, L = 0, mem_in_len = 0, acflen = 0; - + LC3_FLOAT buf[LEN_6K4 + MAX_PITCH_6K4] = {0}, filt_out[LEN_12K8 + 3] = {0}, d_wsp[LEN_6K4] = {0}, R0[RANGE_PITCH_6K4] = {0}, R[RANGE_PITCH_6K4] = {0}; /* constant length */ + LC3_INT i = 0, j = 0, len2 = 0, T0 = 0, T02 = 0, min_pitch = 0, max_pitch = 0, L = 0, mem_in_len = 0, acflen = 0; + mem_in_len = MAX_PITCH_6K4; - len2 = len / 2; - acflen = len2; - if ( frame_dms == 25 ) + len2 = len / 2; + acflen = len2; + if (frame_dms == 25) { mem_in_len += 16; - acflen += 16; + acflen += 16; } /* Downsampling */ - move_float( buf, mem_s12k8, 3 ); - move_float( &buf[3], s_12k8, len ); - move_float( mem_s12k8, &buf[len], 3 ); - filter_olpa( buf, filt_out, olpa_down2, 5, len + 3 ); - for ( i = 4, j = 0; i < len + 3; i = i + 2 ) - { + move_float(buf, mem_s12k8, 3); + move_float(&buf[3], s_12k8, len); + move_float(mem_s12k8, &buf[len], 3); + filter_olpa(buf, filt_out, olpa_down2, 5, len + 3); + for (i = 4, j = 0; i < len + 3; i = i + 2) { d_wsp[j] = filt_out[i]; j++; } /* Compute autocorrelation */ s6k4 = &buf[mem_in_len]; - move_float( buf, mem_s6k4, mem_in_len ); - move_float( s6k4, d_wsp, len2 ); - move_float( mem_s6k4, &buf[len2], mem_in_len ); - if ( frame_dms == 25 ) + move_float(buf, mem_s6k4, mem_in_len); + move_float(s6k4, d_wsp, len2); + move_float(mem_s6k4, &buf[len2], mem_in_len); + if (frame_dms == 25) { s6k4 = s6k4 - 16; } - for ( i = MIN_PITCH_6K4; i <= MAX_PITCH_6K4; i++ ) - { + for (i = MIN_PITCH_6K4; i <= MAX_PITCH_6K4; i++) { sum = 0; - for ( j = 0; j < acflen; j++ ) - { + for (j = 0; j < acflen; j++) { sum += s6k4[j] * s6k4[j - i]; } R0[i - MIN_PITCH_6K4] = sum; } /* Weight autocorrelation and find maximum */ - move_float( R, R0, RANGE_PITCH_6K4 ); - for ( i = 0; i < RANGE_PITCH_6K4; i++ ) - { + move_float(R, R0, RANGE_PITCH_6K4); + for (i = 0; i < RANGE_PITCH_6K4; i++) { R0[i] = R0[i] * olpa_acw[i]; } - L = searchMaxIndice( R0, RANGE_PITCH_6K4 ); + L = searchMaxIndice(R0, RANGE_PITCH_6K4); T0 = L + MIN_PITCH_6K4; /* Compute normalized correlation */ sum0 = sum1 = sum2 = 0; - for ( i = 0; i < acflen; i++ ) - { + for (i = 0; i < acflen; i++) { sum0 += s6k4[i] * s6k4[i - T0]; sum1 += s6k4[i - T0] * s6k4[i - T0]; sum2 += s6k4[i] * s6k4[i]; } sum1 = sum1 * sum2; - sum1 = LC3_SQRT( sum1 ) + LC3_POW( 10.0, -5.0 ); + sum1 = LC3_SQRT(sum1) + LC3_POW(10.0, -5.0); norm_corr = sum0 / sum1; - norm_corr = MAX( 0, norm_corr ); + norm_corr = MAX(0, norm_corr); /* Second try in the neighborhood of the previous pitch */ - min_pitch = MAX( MIN_PITCH_6K4, *mem_old_T0 - 4 ); - max_pitch = MIN( MAX_PITCH_6K4, *mem_old_T0 + 4 ); - L = searchMaxIndice( &R[min_pitch - MIN_PITCH_6K4], max_pitch - min_pitch + 1 ); + min_pitch = MAX(MIN_PITCH_6K4, *mem_old_T0 - 4); + max_pitch = MIN(MAX_PITCH_6K4, *mem_old_T0 + 4); + L = searchMaxIndice(&R[min_pitch - MIN_PITCH_6K4], max_pitch - min_pitch + 1 ); T02 = L + min_pitch; - if ( T02 != T0 ) - { + if (T02 != T0) { sum0 = sum1 = sum2 = 0; - for ( i = 0; i < acflen; i++ ) - { + for (i = 0; i < acflen; i++) { sum0 += s6k4[i] * s6k4[i - T02]; sum1 += s6k4[i - T02] * s6k4[i - T02]; sum2 += s6k4[i] * s6k4[i]; } sum1 = sum1 * sum2; - sum1 = LC3_SQRT( sum1 ) + LC3_POW( 10.0, -5.0 ); + sum1 = LC3_SQRT(sum1) + LC3_POW(10.0, -5.0); norm_corr2 = sum0 / sum1; - norm_corr2 = MAX( 0, norm_corr2 ); + norm_corr2 = MAX(0, norm_corr2); - if ( norm_corr2 > ( norm_corr * 0.85 ) ) - { - T0 = T02; + if (norm_corr2 > (norm_corr * 0.85)) { + T0 = T02; norm_corr = norm_corr2; } } - *mem_old_T0 = T0; - *T0_out = T0 * 2.0; + *mem_old_T0 = T0; + *T0_out = T0 * 2.0; *normcorr_out = norm_corr; } diff --git a/lib_lc3plus/pc_apply.c b/lib_lc3plus/pc_apply.c index 3befa3a68c..1d1bc40005 100644 --- a/lib_lc3plus/pc_apply.c +++ b/lib_lc3plus/pc_apply.c @@ -1,75 +1,73 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -void processPcApply_fl( LC3_FLOAT *q_res, LC3_FLOAT *q_old_res, LC3_FLOAT *q_d_prev, LC3_INT32 spec_inv_idx, LC3_INT32 yLen, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_FLOAT *prev_gg, LC3_FLOAT *fac, LC3_INT32 *pc_nbLostCmpt ) +void processPcApply_fl(LC3_FLOAT *q_res, LC3_FLOAT *q_old_res, LC3_FLOAT *q_d_prev, LC3_INT32 spec_inv_idx, LC3_INT32 yLen, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_FLOAT *prev_gg, LC3_FLOAT *fac, LC3_INT32 *pc_nbLostCmpt) { - LC3_FLOAT gg, mean_nrg_low, mean_nrg_high, ener_prev, ener_curr, fac_local; - LC3_INT32 i; - - ener_prev = 0; - ener_curr = 0; - mean_nrg_low = 0; - mean_nrg_high = 0; - + LC3_FLOAT gg, mean_nrg_low, mean_nrg_high, ener_prev, ener_curr, fac_local; + LC3_INT32 i; + + ener_prev = 0; ener_curr = 0; mean_nrg_low = 0; mean_nrg_high = 0; + *pc_nbLostCmpt = *pc_nbLostCmpt + 1; + + assert(spec_inv_idx > 1); + + gg = LC3_POW(10, (((LC3_FLOAT) (gg_idx + gg_idx_off)) / 28.0)); - assert( spec_inv_idx > 1 ); - - gg = LC3_POW( 10, ( ( (LC3_FLOAT) ( gg_idx + gg_idx_off ) ) / 28.0 ) ); - - for ( i = 0; i < spec_inv_idx; i++ ) + for (i = 0; i < spec_inv_idx; i++) { - mean_nrg_low += LC3_POW( q_d_prev[i], 2 ); + mean_nrg_low += LC3_POW(q_d_prev[i], 2); } - + mean_nrg_low /= (LC3_FLOAT) spec_inv_idx; - - if ( spec_inv_idx < yLen ) + + if (spec_inv_idx < yLen) { - for ( i = spec_inv_idx; i < yLen; i++ ) + for (i = spec_inv_idx; i < yLen; i++) { - mean_nrg_high += LC3_POW( q_d_prev[i], 2 ); + mean_nrg_high += LC3_POW(q_d_prev[i], 2); } } + + mean_nrg_high /= (LC3_FLOAT) (yLen - spec_inv_idx); - mean_nrg_high /= (LC3_FLOAT) ( yLen - spec_inv_idx ); - - for ( i = 0; i < spec_inv_idx; i++ ) + for (i = 0; i < spec_inv_idx; i++) { - ener_prev += LC3_POW( q_old_res[i], 2 ); - ener_curr += LC3_POW( q_res[i], 2 ); + ener_prev += LC3_POW(q_old_res[i], 2); + ener_curr += LC3_POW(q_res[i], 2); } *fac = 1; - if ( ener_prev > 0 ) + if (ener_prev > 0) { - *fac = LC3_SQRT( ener_curr / ener_prev ); + *fac = LC3_SQRT(ener_curr / ener_prev); } - + fac_local = *fac; - if ( mean_nrg_low <= mean_nrg_high || ener_prev * LC3_POW( *prev_gg, 2 ) <= ener_curr * LC3_POW( gg, 2 ) ) + if (mean_nrg_low <= mean_nrg_high || ener_prev * LC3_POW(*prev_gg, 2) <= ener_curr * LC3_POW(gg, 2)) { fac_local = *prev_gg / gg; } - - for ( i = spec_inv_idx; i < yLen; i++ ) + + for (i = spec_inv_idx; i < yLen; i++) { q_res[i] = q_old_res[i] * fac_local; - - if ( LC3_FABS( q_res[i] ) < ( 1 - 0.375 ) ) + + if (LC3_FABS(q_res[i]) < (1 - 0.375)) { q_res[i] = 0; } } } + diff --git a/lib_lc3plus/pc_classify.c b/lib_lc3plus/pc_classify.c index 22b228c9a2..71196edb89 100644 --- a/lib_lc3plus/pc_classify.c +++ b/lib_lc3plus/pc_classify.c @@ -1,59 +1,55 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -LC3_FLOAT pc_peak_detector( LC3_FLOAT *q_d_prev, LC3_INT32 yLen ); +LC3_FLOAT pc_peak_detector(LC3_FLOAT *q_d_prev, LC3_INT32 yLen); -void processPcClassify_fl( LC3_INT32 pitch_present, LC3_INT32 frame_dms, LC3_FLOAT *q_d_prev, LC3_FLOAT *q_old_res, LC3_INT32 yLen, LC3_INT32 spec_inv_idx, LC3_FLOAT stab_fac, LC3_INT32 *bfi ) +void processPcClassify_fl(LC3_INT32 pitch_present, LC3_INT32 frame_dms, LC3_FLOAT *q_d_prev, LC3_FLOAT *q_old_res, LC3_INT32 yLen, LC3_INT32 spec_inv_idx, LC3_FLOAT stab_fac, LC3_INT32 *bfi) { - LC3_INT32 maxPitchBin, xover, i; - LC3_FLOAT part_nrg, full_nrg; - - part_nrg = 0; - full_nrg = 0; - - if ( spec_inv_idx < ( 4 * frame_dms / 10 ) ) + LC3_INT32 maxPitchBin, xover, i; + LC3_FLOAT part_nrg, full_nrg; + + part_nrg = 0; full_nrg = 0; + + if (spec_inv_idx < (4 * frame_dms / 10)) { - if ( stab_fac < 0.5 ) + if (stab_fac < 0.5) { *bfi = 1; - } - else if ( pitch_present == 1 ) + } else if (pitch_present == 1) { maxPitchBin = 8; - if ( frame_dms == 50 ) + if (frame_dms == 50) { maxPitchBin = 4; } - xover = pc_peak_detector( q_d_prev, yLen ); - if ( spec_inv_idx < xover || spec_inv_idx < maxPitchBin ) + xover = pc_peak_detector(q_d_prev, yLen); + if (spec_inv_idx < xover || spec_inv_idx < maxPitchBin) { *bfi = 1; } - } - else - { - for ( i = 0; i < spec_inv_idx; i++ ) + } else { + for (i = 0; i < spec_inv_idx; i++) { - part_nrg += LC3_POW( q_old_res[i], 2 ); + part_nrg += LC3_POW(q_old_res[i], 2); } - - for ( i = 0; i < yLen; i++ ) + + for (i = 0; i < yLen; i++) { - full_nrg += LC3_POW( q_old_res[i], 2 ); + full_nrg += LC3_POW(q_old_res[i], 2); } - if ( part_nrg < ( 0.3 * full_nrg ) ) + if (part_nrg < (0.3 * full_nrg)) { *bfi = 1; } @@ -61,74 +57,74 @@ void processPcClassify_fl( LC3_INT32 pitch_present, LC3_INT32 frame_dms, LC3_FLO } } -LC3_FLOAT pc_peak_detector( LC3_FLOAT *q_d_prev, LC3_INT32 yLen ) +LC3_FLOAT pc_peak_detector(LC3_FLOAT *q_d_prev, LC3_INT32 yLen) { - LC3_INT32 block_size, thresh1, i, peak, j, k; - LC3_FLOAT fac, mean_block_nrg, cur_max, block_cent, maxPeak, next_max, prev_max; - + LC3_INT32 block_size, thresh1, i, peak, j, k; + LC3_FLOAT fac, mean_block_nrg, cur_max, block_cent, maxPeak, next_max, prev_max; + mean_block_nrg = 0; - + block_size = 3; thresh1 = 8; fac = 0.3; - - for ( i = 0; i < yLen; i++ ) + + for (i = 0; i < yLen; i++) { - mean_block_nrg += LC3_POW( q_d_prev[i], 2 ); + mean_block_nrg += LC3_POW(q_d_prev[i], 2); } - + mean_block_nrg /= yLen; - + maxPeak = 0; peak = 0; - - if ( LC3_FABS( q_d_prev[0] ) > LC3_FABS( q_d_prev[1] ) ) + + if (LC3_FABS(q_d_prev[0]) > LC3_FABS(q_d_prev[1])) { - block_cent = LC3_POW( q_d_prev[0], 2 ) + LC3_POW( q_d_prev[1], 2 ); - - if ( ( block_cent / block_size ) > ( thresh1 * mean_block_nrg ) ) + block_cent = LC3_POW(q_d_prev[0], 2) + LC3_POW(q_d_prev[1], 2); + + if ((block_cent / block_size) > (thresh1 * mean_block_nrg)) { - cur_max = MAX( LC3_FABS( q_d_prev[0] ), LC3_FABS( q_d_prev[1] ) ); - next_max = array_max_abs( &q_d_prev[2], 3 ); - - if ( cur_max > next_max ) + cur_max = MAX(LC3_FABS(q_d_prev[0]), LC3_FABS(q_d_prev[1])); + next_max = array_max_abs(&q_d_prev[2], 3); + + if (cur_max > next_max) { maxPeak = block_cent; peak = 1; } } } - - for ( i = 0; i < block_size; i++ ) + + for (i = 0; i < block_size; i++) { - if ( ( LC3_FABS( q_d_prev[i + 1] ) >= LC3_FABS( q_d_prev[i] ) ) && LC3_FABS( q_d_prev[i + 1] ) >= LC3_FABS( q_d_prev[i + 2] ) ) + if ((LC3_FABS(q_d_prev[i + 1]) >= LC3_FABS(q_d_prev[i])) && LC3_FABS(q_d_prev[i + 1]) >= LC3_FABS(q_d_prev[i + 2])) { block_cent = 0; - for ( j = i; j < i + block_size; j++ ) + for (j = i; j < i + block_size; j++) { - block_cent += LC3_POW( q_d_prev[j], 2 ); + block_cent += LC3_POW(q_d_prev[j], 2); } - - if ( ( block_cent / block_size ) > ( thresh1 * mean_block_nrg ) ) + + if ((block_cent / block_size) > (thresh1 * mean_block_nrg)) { - cur_max = array_max_abs( &q_d_prev[i], block_size ); + cur_max = array_max_abs(&q_d_prev[i], block_size); prev_max = 0; - - for ( k = i - block_size; k < i; k++ ) + + for (k = i - block_size; k < i; k++) { - if ( k > 0 ) + if (k > 0) { - prev_max = MAX( LC3_FABS( q_d_prev[k] ), prev_max ); + prev_max = MAX(LC3_FABS(q_d_prev[k]), prev_max); } } - next_max = array_max_abs( &q_d_prev[i + block_size], block_size ); - - if ( ( cur_max >= prev_max ) && ( cur_max > next_max ) ) + next_max = array_max_abs(&q_d_prev[i + block_size], block_size); + + if ((cur_max >= prev_max) && (cur_max > next_max)) { - if ( block_cent > ( fac * maxPeak ) ) + if (block_cent > (fac * maxPeak)) { peak = i + block_size - 1; - if ( block_cent >= maxPeak ) + if (block_cent >= maxPeak) { maxPeak = block_cent; } @@ -137,29 +133,29 @@ LC3_FLOAT pc_peak_detector( LC3_FLOAT *q_d_prev, LC3_INT32 yLen ) } } } - - for ( i = block_size; i < yLen - ( 2 * block_size ); i++ ) + + for (i = block_size; i < yLen - (2 * block_size); i++) { - if ( ( LC3_FABS( q_d_prev[i + 1] ) >= LC3_FABS( q_d_prev[i] ) ) && LC3_FABS( q_d_prev[i + 1] ) >= LC3_FABS( q_d_prev[i + 2] ) ) + if ((LC3_FABS(q_d_prev[i + 1]) >= LC3_FABS(q_d_prev[i])) && LC3_FABS(q_d_prev[i + 1]) >= LC3_FABS(q_d_prev[i + 2])) { block_cent = 0; - for ( j = i; j < i + block_size; j++ ) + for (j = i; j < i + block_size; j++) { - block_cent += LC3_POW( q_d_prev[j], 2 ); + block_cent += LC3_POW(q_d_prev[j], 2); } - - if ( ( block_cent / block_size ) > ( thresh1 * mean_block_nrg ) ) + + if ((block_cent / block_size) > (thresh1 * mean_block_nrg)) { - cur_max = array_max_abs( &q_d_prev[i], block_size ); - prev_max = array_max_abs( &q_d_prev[i - block_size], block_size ); - next_max = array_max_abs( &q_d_prev[i + block_size], block_size ); - - if ( ( cur_max >= prev_max ) && ( cur_max > next_max ) ) + cur_max = array_max_abs(&q_d_prev[i], block_size); + prev_max = array_max_abs(&q_d_prev[i - block_size], block_size); + next_max = array_max_abs(&q_d_prev[i + block_size], block_size); + + if ((cur_max >= prev_max) && (cur_max > next_max)) { - if ( block_cent > ( fac * maxPeak ) ) + if (block_cent > (fac * maxPeak)) { peak = i + block_size - 1; - if ( block_cent >= maxPeak ) + if (block_cent >= maxPeak) { maxPeak = block_cent; } @@ -168,6 +164,7 @@ LC3_FLOAT pc_peak_detector( LC3_FLOAT *q_d_prev, LC3_INT32 yLen ) } } } - + return peak; } + diff --git a/lib_lc3plus/pc_main.c b/lib_lc3plus/pc_main.c index 891320e1af..268ee94d2a 100644 --- a/lib_lc3plus/pc_main.c +++ b/lib_lc3plus/pc_main.c @@ -1,42 +1,43 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -void processPcMain_fl( LC3_INT32 *bfi, LC3PLUS_Dec *decoder, LC3_FLOAT *sqQdec, DecSetup *h_DecSetup, LC3_INT32 pitch_present, LC3_FLOAT stab_fac, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_INT32 fac_ns_idx, pcState *statePC, LC3_INT32 spec_inv_idx, LC3_INT32 yLen ) +void processPcMain_fl(LC3_INT32 *bfi, LC3PLUS_Dec* decoder, LC3_FLOAT *sqQdec, DecSetup* h_DecSetup, LC3_INT32 pitch_present, LC3_FLOAT stab_fac, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_INT32 fac_ns_idx, pcState *statePC, LC3_INT32 spec_inv_idx, LC3_INT32 yLen) { - LC3_FLOAT fac; - + LC3_FLOAT fac; + /* PC Classifier */ - if ( *bfi == 2 ) + if (*bfi == 2) { - processPcClassify_fl( pitch_present, decoder->frame_dms, h_DecSetup->PlcSetup.q_d_prev, statePC->q_old_res, decoder->yLen, h_DecSetup->spec_inv_idx, stab_fac, bfi ); + processPcClassify_fl(pitch_present, decoder->frame_dms, h_DecSetup->PlcSetup.q_d_prev, statePC->q_old_res, decoder->yLen, h_DecSetup->spec_inv_idx, stab_fac, bfi); } /* PC Apply */ - if ( *bfi == 2 ) + if (*bfi == 2) { - processPcApply_fl( sqQdec, statePC->q_old_res, h_DecSetup->PlcSetup.q_d_prev, h_DecSetup->spec_inv_idx, decoder->yLen, gg_idx, gg_idx_off, &statePC->prev_gg, &fac, &statePC->ns_nbLostCmpt_pc ); + processPcApply_fl(sqQdec, statePC->q_old_res, h_DecSetup->PlcSetup.q_d_prev, h_DecSetup->spec_inv_idx, decoder->yLen, gg_idx, gg_idx_off, &statePC->prev_gg, &fac, &statePC->ns_nbLostCmpt_pc); } - + /* PC Update */ - if ( *bfi != 1 ) + if (*bfi != 1) { - processPcUpdate_fl( *bfi, sqQdec, gg_idx, gg_idx_off, decoder->rframe, &h_DecSetup->BW_cutoff_idx_nf, &h_DecSetup->prev_BW_cutoff_idx_nf, fac_ns_idx, &h_DecSetup->prev_fac_ns, &fac, statePC->q_old_res, &statePC->prev_gg, spec_inv_idx, yLen ); + processPcUpdate_fl(*bfi, sqQdec, gg_idx, gg_idx_off, decoder->rframe, &h_DecSetup->BW_cutoff_idx_nf, &h_DecSetup->prev_BW_cutoff_idx_nf, fac_ns_idx, &h_DecSetup->prev_fac_ns, &fac, statePC->q_old_res, &statePC->prev_gg, spec_inv_idx, yLen); } - + /* Reset counter */ - if ( *bfi == 0 ) + if (*bfi == 0) { statePC->ns_nbLostCmpt_pc = 0; } } + diff --git a/lib_lc3plus/pc_update.c b/lib_lc3plus/pc_update.c index 265f079d80..57539b5079 100644 --- a/lib_lc3plus/pc_update.c +++ b/lib_lc3plus/pc_update.c @@ -1,35 +1,37 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -void processPcUpdate_fl( LC3_INT32 bfi, LC3_FLOAT *q_res, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_INT32 rframe, LC3_INT32 *BW_cutoff_idx_nf, LC3_INT32 *prev_BW_cutoff_idx_nf, LC3_INT32 fac_ns_idx, LC3_FLOAT *prev_fac_ns, LC3_FLOAT *fac, LC3_FLOAT *q_old_res, LC3_FLOAT *prev_gg, LC3_INT32 spec_inv_idx, LC3_INT32 yLen ) +void processPcUpdate_fl(LC3_INT32 bfi, LC3_FLOAT *q_res, LC3_INT32 gg_idx, LC3_INT32 gg_idx_off, LC3_INT32 rframe, LC3_INT32 *BW_cutoff_idx_nf, LC3_INT32 *prev_BW_cutoff_idx_nf, + LC3_INT32 fac_ns_idx, LC3_FLOAT *prev_fac_ns, LC3_FLOAT *fac, LC3_FLOAT *q_old_res, LC3_FLOAT *prev_gg, LC3_INT32 spec_inv_idx, LC3_INT32 yLen) { - LC3_FLOAT gg; - - gg = LC3_POW( 10.0, ( (LC3_FLOAT) ( gg_idx + gg_idx_off ) ) / 28.0 ); + LC3_FLOAT gg; + + gg = LC3_POW(10.0, ((LC3_FLOAT) (gg_idx + gg_idx_off)) / 28.0); *prev_gg = gg; - move_float( q_old_res, q_res, yLen ); - - if ( rframe == 0 ) + move_float(q_old_res, q_res, yLen); + + if (rframe == 0) { *prev_BW_cutoff_idx_nf = *BW_cutoff_idx_nf; - *prev_fac_ns = ( 8.0 - (LC3_FLOAT) fac_ns_idx ) / 16.0; - } - else if ( ( bfi == 2 ) && ( *BW_cutoff_idx_nf != *prev_BW_cutoff_idx_nf ) && ( spec_inv_idx < yLen ) ) + *prev_fac_ns = (8.0 - (LC3_FLOAT) fac_ns_idx) / 16.0; + } else if ((bfi == 2) && (*BW_cutoff_idx_nf != *prev_BW_cutoff_idx_nf) && (spec_inv_idx < yLen)) { *BW_cutoff_idx_nf = *prev_BW_cutoff_idx_nf; - *prev_fac_ns = *prev_fac_ns * ( *fac ); - *prev_fac_ns = MAX( *prev_fac_ns, ( 8.0 - 7.0 ) / 16.0 ); - *prev_fac_ns = MIN( *prev_fac_ns, ( 8.0 - 0.0 ) / 16.0 ); + *prev_fac_ns = *prev_fac_ns * (*fac); + *prev_fac_ns = MAX(*prev_fac_ns, (8.0 - 7.0) / 16.0); + *prev_fac_ns = MIN(*prev_fac_ns, (8.0 - 0.0) / 16.0); } + } + diff --git a/lib_lc3plus/per_band_energy.c b/lib_lc3plus/per_band_energy.c index bc0f871d23..db1b5b2d0f 100644 --- a/lib_lc3plus/per_band_energy.c +++ b/lib_lc3plus/per_band_energy.c @@ -1,61 +1,58 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -void processPerBandEnergy_fl( LC3_INT bands_number, const LC3_INT *acc_coeff_per_band, LC3_INT16 hrmode, LC3_INT16 frame_dms, LC3_FLOAT *d2, LC3_FLOAT *d ) +void processPerBandEnergy_fl(LC3_INT bands_number, const LC3_INT* acc_coeff_per_band, LC3_INT16 hrmode, LC3_INT16 frame_dms, LC3_FLOAT* d2, LC3_FLOAT* d) { - LC3_INT i = 0, j = 0, start = 0, stop = 0, maxBwBin = 0; + LC3_INT i = 0, j = 0, start = 0, stop = 0, maxBwBin = 0; LC3_FLOAT sum = 0; -#ifdef ENABLE_HR_MODE_FL - if ( hrmode ) +# ifdef ENABLE_HR_MODE_FL + if (hrmode) { maxBwBin = MAX_BW_HR; } else -#else - UNUSED( hrmode ); -#endif +# else + UNUSED(hrmode); +# endif { maxBwBin = MAX_BW; } - switch ( frame_dms ) + switch (frame_dms) { -#ifdef ENABLE_2_5MS_MODE - case 25: - maxBwBin = maxBwBin >> 2; - break; -#endif -#ifdef ENABLE_5MS_MODE - case 50: - maxBwBin = maxBwBin >> 1; - break; -#endif +# ifdef ENABLE_2_5MS_MODE + case 25: + maxBwBin = maxBwBin >> 2; + break; +# endif +# ifdef ENABLE_5MS_MODE + case 50: + maxBwBin = maxBwBin >> 1; + break; +# endif } - for ( i = 0; i < bands_number; i++ ) - { - sum = 0; + for (i = 0; i < bands_number; i++) { + sum = 0; start = acc_coeff_per_band[i]; - stop = MIN( acc_coeff_per_band[i + 1], maxBwBin ); + stop = MIN(acc_coeff_per_band[i + 1], maxBwBin); - for ( j = start; j < stop; j++ ) - { + for (j = start; j < stop; j++) { sum += d[j] * d[j]; } - if ( stop - start > 0 ) - { - sum = sum / (LC3_FLOAT) ( stop - start ); + if (stop - start > 0) { + sum = sum / (LC3_FLOAT)(stop - start); } d2[i] = sum; } diff --git a/lib_lc3plus/plc_classify.c b/lib_lc3plus/plc_classify.c index 7a93419f02..619a1f7419 100644 --- a/lib_lc3plus/plc_classify.c +++ b/lib_lc3plus/plc_classify.c @@ -1,50 +1,54 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -static void plc_xcorr_lc( LC3_FLOAT *pcmbufHist, LC3_INT32 max_len_pcm_plc, LC3_INT32 pitch_int, LC3_INT32 framelength, LC3_INT32 frame_dms, LC3_INT32 fs, LC3_FLOAT *xcorr ); -static void spectral_centroid_lc( LC3_FLOAT *gains, LC3_INT32 tilt, const LC3_INT *bands_offset, LC3_INT32 bands_number, LC3_INT32 framelength, LC3_INT32 fs, LC3_FLOAT *sc ); +static void plc_xcorr_lc(LC3_FLOAT *pcmbufHist, LC3_INT32 max_len_pcm_plc, LC3_INT32 pitch_int, LC3_INT32 framelength, LC3_INT32 frame_dms, LC3_INT32 fs, LC3_FLOAT *xcorr); +static void spectral_centroid_lc(LC3_FLOAT *gains, LC3_INT32 tilt, const LC3_INT *bands_offset, LC3_INT32 bands_number, LC3_INT32 framelength, LC3_INT32 fs, LC3_FLOAT *sc); -void processPlcClassify_fl( LC3_INT plcMeth, LC3_INT *concealMethod, LC3_INT32 *nbLostCmpt, LC3_INT32 bfi, LC3_FLOAT *xcorr, LC3_INT32 framelength, LC3_INT32 frame_dms, LC3_INT32 pitch_int, LC3_INT32 fs, const LC3_INT *band_offsets, LC3_INT32 bands_number, LC3_INT32 tilt, PlcAdvSetup *plcAd, LC3_INT32 hrmode ) +void processPlcClassify_fl(LC3_INT plcMeth, LC3_INT *concealMethod, LC3_INT32 *nbLostCmpt, LC3_INT32 bfi, + LC3_FLOAT *xcorr, LC3_INT32 framelength, LC3_INT32 frame_dms, LC3_INT32 pitch_int, + LC3_INT32 fs, const LC3_INT *band_offsets, LC3_INT32 bands_number, LC3_INT32 tilt, PlcAdvSetup *plcAd + , LC3_INT32 hrmode +) { - LC3_FLOAT sc, class; - - if ( plcAd ) + LC3_FLOAT sc, class; + + if (plcAd) { *xcorr = 0; } - - if ( bfi == 1 ) + + if (bfi == 1) { *nbLostCmpt = *nbLostCmpt + 1; - + /* Use pitch correlation at ltpf integer lag if available */ - if ( *nbLostCmpt == 1 ) + if (*nbLostCmpt == 1) { *concealMethod = plcMeth; // this is a dangerous mapping! - + /* Advanced PLC */ - if ( pitch_int > 0 ) + if (pitch_int > 0) { *concealMethod = 3; /* Timedomain PLC assumed */ - plc_xcorr_lc( plcAd->pcmbufHist, plcAd->max_len_pcm_plc, pitch_int, framelength, frame_dms, fs, xcorr ); + plc_xcorr_lc(plcAd->pcmbufHist, plcAd->max_len_pcm_plc, pitch_int, framelength, frame_dms, fs, xcorr); - spectral_centroid_lc( plcAd->scf_q_old, tilt, band_offsets, bands_number, framelength, fs, &sc ); - class = *xcorr * 7640.0 / 32768.0 - sc - 5112.0 / 32768.0; + spectral_centroid_lc(plcAd->scf_q_old, tilt, band_offsets, bands_number, framelength, fs, &sc); + class = *xcorr * 7640.0/32768.0 - sc - 5112.0/32768.0; - if ( class <= 0 ) + if (class <= 0) { - if ( frame_dms == 100 && hrmode == 0 ) + if (frame_dms == 100 && hrmode == 0) { *concealMethod = 2; /* PhaseEcu selected */ } @@ -62,39 +66,39 @@ void processPlcClassify_fl( LC3_INT plcMeth, LC3_INT *concealMethod, LC3_INT32 * } } -static void spectral_centroid_lc( LC3_FLOAT *gains, LC3_INT32 tilt, const LC3_INT *band_offsets, LC3_INT32 bands_number, LC3_INT32 framelength, LC3_INT32 fs, LC3_FLOAT *sc ) +static void spectral_centroid_lc(LC3_FLOAT *gains, LC3_INT32 tilt, const LC3_INT *band_offsets, LC3_INT32 bands_number, LC3_INT32 framelength, LC3_INT32 fs, LC3_FLOAT *sc) { - LC3_FLOAT gains_lin[M], gains_dee[M], numerator, denumerator; - LC3_INT32 i, j, sum, len, start, stop; - LC3_INT band_offsets_local[MAX_BANDS_NUMBER + 1]; - + LC3_FLOAT gains_lin[M], gains_dee[M], numerator, denumerator; + LC3_INT32 i, j, sum, len, start, stop; + LC3_INT band_offsets_local[MAX_BANDS_NUMBER + 1]; + numerator = 0; - for ( i = 0; i < M; i++ ) + for (i = 0; i < M; i++) { - gains_lin[i] = LC3_POW( 2, gains[i] ); + gains_lin[i] = LC3_POW(2, gains[i]); } - - for ( i = 0; i < M; i++ ) + + for (i = 0; i < M; i++) { - gains_dee[i] = gains_lin[i] / LC3_POW( 10, i * (LC3_FLOAT) tilt / (LC3_FLOAT) ( M - 1 ) / 10.0 ); + gains_dee[i] = gains_lin[i] / LC3_POW(10, i * (LC3_FLOAT) tilt / (LC3_FLOAT) (M - 1) / 10.0); } - - if ( bands_number == 64 ) + + if (bands_number == 64) { - memmove( band_offsets_local, band_offsets, ( bands_number + 1 ) * sizeof( LC3_INT ) ); + memmove(band_offsets_local, band_offsets, (bands_number + 1) * sizeof(LC3_INT)); } - if ( bands_number < 32 ) + if (bands_number < 32) { band_offsets_local[0] = 0; j = 32 - bands_number; - for ( i = bands_number - 1; i >= j; i-- ) + for (i = bands_number - 1; i >= j; i--) { - band_offsets_local[( i + j ) * 2 + 1 + 1] = band_offsets[i + 1]; - band_offsets_local[( i + j ) * 2 + 0 + 1] = band_offsets[i + 1]; + band_offsets_local[(i + j) * 2 + 1 + 1] = band_offsets[i + 1]; + band_offsets_local[(i + j) * 2 + 0 + 1] = band_offsets[i + 1]; } - for ( i = j - 1; i >= 0; i-- ) + for (i = j - 1; i >= 0; i--) { band_offsets_local[i * 4 + 3 + 1] = band_offsets[i + 1]; band_offsets_local[i * 4 + 2 + 1] = band_offsets[i + 1]; @@ -102,15 +106,16 @@ static void spectral_centroid_lc( LC3_FLOAT *gains, LC3_INT32 tilt, const LC3_IN band_offsets_local[i * 4 + 0 + 1] = band_offsets[i + 1]; } } - else if ( bands_number < 64 ) + else + if (bands_number < 64) { band_offsets_local[0] = 0; j = 64 - bands_number; - for ( i = bands_number - 1; i >= j; i-- ) + for (i = bands_number - 1; i >= j; i--) { band_offsets_local[i + j + 1] = band_offsets[i + 1]; } - for ( i = j - 1; i >= 0; i-- ) + for (i = j - 1; i >= 0; i--) { band_offsets_local[i * 2 + 1 + 1] = band_offsets[i + 1]; band_offsets_local[i * 2 + 0 + 1] = band_offsets[i + 1]; @@ -118,48 +123,46 @@ static void spectral_centroid_lc( LC3_FLOAT *gains, LC3_INT32 tilt, const LC3_IN } denumerator = 0.001; - - for ( i = 0; i < M; i++ ) + + for (i = 0; i < M; i++) { - sum = 0; - len = 0; - start = band_offsets_local[i * 4] + 1; - stop = band_offsets_local[i * 4 + 4]; - - for ( j = stop; j >= start; j-- ) + sum = 0; len = 0; + start = band_offsets_local[i * 4] + 1; stop = band_offsets_local[i * 4 + 4]; + + for (j = stop; j >= start; j--) { sum += j; len++; } - - numerator += gains_dee[i] * ( (LC3_FLOAT) sum / (LC3_FLOAT) framelength ); + + numerator += gains_dee[i] * ((LC3_FLOAT) sum / (LC3_FLOAT) framelength); denumerator += gains_dee[i] * len; } - + *sc = numerator / denumerator; *sc = *sc * (LC3_FLOAT) fs / 48000.0; /* scaling, because training is for 48kHz */ } -static void plc_xcorr_lc( LC3_FLOAT *pcmbufHist, LC3_INT32 max_len_pcm_plc, LC3_INT32 pitch_int, LC3_INT32 framelength, LC3_INT32 frame_dms, LC3_INT32 fs, LC3_FLOAT *xcorr ) +static void plc_xcorr_lc(LC3_FLOAT *pcmbufHist, LC3_INT32 max_len_pcm_plc, LC3_INT32 pitch_int, LC3_INT32 framelength, + LC3_INT32 frame_dms, LC3_INT32 fs, LC3_FLOAT *xcorr) { - LC3_INT32 max_corr_len, pitch_min, corr_len, min_corr_len, pcm_max_corr_len, range1Start, range2Start, i; - LC3_FLOAT norm_w, norm_w_t; - - norm_w_t = 0; - norm_w = 0; - - assert( pitch_int >= 0 ); - assert( pitch_int <= MAX_LEN * 100 * MAX_PITCH_12K8 / 12800 ); - + LC3_INT32 max_corr_len, pitch_min, corr_len, min_corr_len, pcm_max_corr_len, range1Start, range2Start, i; + LC3_FLOAT norm_w, norm_w_t; + + norm_w_t = 0; norm_w = 0; + + assert(pitch_int >= 0); + assert(pitch_int <= MAX_LEN*100*MAX_PITCH_12K8/12800); + *xcorr = 0; - if ( pitch_int > 0 ) + if (pitch_int > 0) { - pitch_min = fs * MIN_PITCH_12K8 / 12800; + pitch_min = fs * MIN_PITCH_12K8/12800; pcm_max_corr_len = max_len_pcm_plc - pitch_int; - min_corr_len = 2 * pitch_min; /* at least 5 ms (=2*pitchmin*) corr length */ - max_corr_len = framelength * 100 / frame_dms; /* maximum 10 ms */ + min_corr_len = 2 * pitch_min; /* at least 5 ms (=2*pitchmin*) corr length */ + max_corr_len = framelength*100/frame_dms; /* maximum 10 ms */ max_corr_len = MIN( max_corr_len, pcm_max_corr_len ); corr_len = MIN( max_corr_len, pitch_int ); /* pitch_int is prefered, but maximum 10ms or left pcm buf size */ @@ -172,26 +175,25 @@ static void plc_xcorr_lc( LC3_FLOAT *pcmbufHist, LC3_INT32 max_len_pcm_plc, LC3_ assert( corr_len <= max_corr_len ); assert( range2Start >= 0 ); - for ( i = 0; i < corr_len; i++ ) + for (i = 0; i < corr_len; i++) { norm_w += pcmbufHist[range1Start + i] * pcmbufHist[range1Start + i]; } - for ( i = 0; i < corr_len; i++ ) + for (i = 0; i < corr_len; i++) { norm_w_t += pcmbufHist[range2Start + i] * pcmbufHist[range2Start + i]; } - for ( i = 0; i < corr_len; i++ ) + for (i = 0; i < corr_len; i++) { *xcorr = *xcorr + pcmbufHist[range1Start + i] * pcmbufHist[range2Start + i]; } - *xcorr = *xcorr / sqrt( norm_w * norm_w_t + 0.1 ); - *xcorr = MAX( 0, *xcorr ); - } - else - { + *xcorr = *xcorr / sqrt(norm_w * norm_w_t + 0.1); + *xcorr = MAX(0, *xcorr); + } else { *xcorr = 0; } } + diff --git a/lib_lc3plus/plc_compute_stab_fac.c b/lib_lc3plus/plc_compute_stab_fac.c index 04f2743684..4a1111a2c7 100644 --- a/lib_lc3plus/plc_compute_stab_fac.c +++ b/lib_lc3plus/plc_compute_stab_fac.c @@ -1,62 +1,64 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -static void processPlcComputeStabFac_fl( LC3_FLOAT *scf_q, LC3_FLOAT *old_scf_q, LC3_INT32 prev_bfi, LC3_FLOAT *stab_fac ); +static void processPlcComputeStabFac_fl(LC3_FLOAT *scf_q, LC3_FLOAT *old_scf_q, LC3_INT32 prev_bfi, LC3_FLOAT *stab_fac); -void processPlcComputeStabFacMain_fl( LC3_FLOAT *scf_q, LC3_FLOAT *old_scf_q, LC3_FLOAT *old_old_scf_q, LC3_INT32 bfi, LC3_INT32 prev_bfi, LC3_INT32 prev_prev_bfi, LC3_FLOAT *stab_fac ) +void processPlcComputeStabFacMain_fl(LC3_FLOAT *scf_q, LC3_FLOAT *old_scf_q, LC3_FLOAT *old_old_scf_q, LC3_INT32 bfi, LC3_INT32 prev_bfi, + LC3_INT32 prev_prev_bfi, LC3_FLOAT *stab_fac) { - if ( bfi == 1 ) + if (bfi == 1) { - if ( prev_bfi != 1 ) + if (prev_bfi != 1) { - processPlcComputeStabFac_fl( old_scf_q, old_old_scf_q, prev_prev_bfi, stab_fac ); + processPlcComputeStabFac_fl(old_scf_q, old_old_scf_q, prev_prev_bfi, stab_fac); } } - else if ( bfi == 2 ) + else if (bfi == 2) { - processPlcComputeStabFac_fl( scf_q, old_scf_q, prev_bfi, stab_fac ); + processPlcComputeStabFac_fl(scf_q, old_scf_q, prev_bfi, stab_fac); } } -static void processPlcComputeStabFac_fl( LC3_FLOAT *scf_q, LC3_FLOAT *old_scf_q, LC3_INT32 prev_bfi, LC3_FLOAT *stab_fac ) +static void processPlcComputeStabFac_fl(LC3_FLOAT *scf_q, LC3_FLOAT *old_scf_q, LC3_INT32 prev_bfi, LC3_FLOAT *stab_fac) { - LC3_FLOAT tmp; - LC3_INT32 i; - + LC3_FLOAT tmp; + LC3_INT32 i; + tmp = 0; - - if ( prev_bfi == 1 ) + + if (prev_bfi == 1) { *stab_fac = 0.8; } else { - for ( i = 0; i < M; i++ ) + for (i = 0; i < M; i++) { - tmp += ( scf_q[i] - old_scf_q[i] ) * ( scf_q[i] - old_scf_q[i] ); + tmp += (scf_q[i] - old_scf_q[i]) * (scf_q[i] - old_scf_q[i]); } *stab_fac = 1.25 - tmp / 25.0; - if ( *stab_fac > 1 ) + if (*stab_fac > 1) { *stab_fac = 1; } - if ( *stab_fac < 0 ) + if (*stab_fac < 0) { *stab_fac = 0; } } } + diff --git a/lib_lc3plus/plc_damping_scrambling.c b/lib_lc3plus/plc_damping_scrambling.c index 15fb5d7860..ecea32be5f 100644 --- a/lib_lc3plus/plc_damping_scrambling.c +++ b/lib_lc3plus/plc_damping_scrambling.c @@ -1,172 +1,152 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -void processPlcDampingScramblingMain_fl( LC3_INT32 *ns_seed, - LC3_INT32 *pc_seed, - LC3_INT32 ns_nbLostCmpt_pc, - LC3_INT32 ns_nbLostCmpt, - LC3_FLOAT *stabFac, - LC3_FLOAT *cum_fading_slow, - LC3_FLOAT *cum_fading_fast, - LC3_FLOAT *spec_prev, - LC3_FLOAT *spec, - LC3_INT32 spec_inv_idx, - LC3_INT32 yLen, - LC3_INT32 bfi, - LC3_INT32 frame_dms, - LC3_INT32 concealMethod, - LC3_INT32 pitch_present_bfi1, - LC3_INT32 pitch_present_bfi2, - LC3_FLOAT *cum_fflcAtten ) +void processPlcDampingScramblingMain_fl(LC3_INT32 *ns_seed, + LC3_INT32 *pc_seed, LC3_INT32 ns_nbLostCmpt_pc, + LC3_INT32 ns_nbLostCmpt, LC3_FLOAT *stabFac, LC3_FLOAT *cum_fading_slow, LC3_FLOAT *cum_fading_fast, + LC3_FLOAT *spec_prev, LC3_FLOAT *spec, LC3_INT32 spec_inv_idx, LC3_INT32 yLen, LC3_INT32 bfi, + LC3_INT32 frame_dms, LC3_INT32 concealMethod, LC3_INT32 pitch_present_bfi1, LC3_INT32 pitch_present_bfi2, + LC3_FLOAT *cum_fflcAtten) { - LC3_INT32 processDampScramb; + LC3_INT32 processDampScramb; processDampScramb = 0; - + if ( bfi != 0 ) { - if ( concealMethod == 4 || bfi == 2 ) + if (concealMethod == 4 || bfi == 2) { processDampScramb = 1; } if ( bfi == 1 ) { - processPlcDampingScrambling_fl( spec, yLen, ns_nbLostCmpt, stabFac, processDampScramb, cum_fflcAtten, - pitch_present_bfi1, frame_dms, cum_fading_slow, cum_fading_fast, ns_seed, 0 ); + processPlcDampingScrambling_fl(spec, yLen, ns_nbLostCmpt, stabFac, processDampScramb, cum_fflcAtten, + pitch_present_bfi1, frame_dms, cum_fading_slow, cum_fading_fast, ns_seed, 0); } else /* bfi == 2 */ { - processPlcDampingScrambling_fl( spec, yLen, ns_nbLostCmpt_pc, stabFac, processDampScramb, cum_fflcAtten, - pitch_present_bfi2, frame_dms, cum_fading_slow, cum_fading_fast, pc_seed, spec_inv_idx ); - processPlcUpdateSpec_fl( spec_prev, spec, yLen ); + processPlcDampingScrambling_fl(spec, yLen, ns_nbLostCmpt_pc, stabFac, processDampScramb, cum_fflcAtten, + pitch_present_bfi2, frame_dms, cum_fading_slow, cum_fading_fast, pc_seed, spec_inv_idx); + processPlcUpdateSpec_fl(spec_prev, spec, yLen); } } } -void processPlcDampingScrambling_fl( LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 nbLostCmpt, LC3_FLOAT *stabFac, LC3_INT32 processDampScramb, LC3_FLOAT *cum_fflcAtten, LC3_INT32 pitch_present, LC3_INT32 frame_dms, LC3_FLOAT *cum_fading_slow, LC3_FLOAT *cum_fading_fast, LC3_INT32 *seed, LC3_INT32 spec_inv_idx ) +void processPlcDampingScrambling_fl(LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 nbLostCmpt, LC3_FLOAT *stabFac, LC3_INT32 processDampScramb, + LC3_FLOAT *cum_fflcAtten, LC3_INT32 pitch_present, LC3_INT32 frame_dms, LC3_FLOAT *cum_fading_slow, + LC3_FLOAT *cum_fading_fast, LC3_INT32 *seed, LC3_INT32 spec_inv_idx) { LC3_INT32 plc_start_inFrames, plc_end_inFrames, plc_duration_inFrames, x, b, i, ad_ThreshFac_start; LC3_FLOAT slow, fast, linFuncStartStop, randThreshold, ad_ThreshFac_end, ad_threshFac, frame_energy, mean_energy, energThreshold, fac, m, n, fflcAtten, cum_fading_slow_local, cum_fading_fast_local; - + frame_energy = 0; /* Main process */ - if ( nbLostCmpt == 1 ) + if (nbLostCmpt == 1) { *cum_fading_slow = 1; *cum_fading_fast = 1; - *cum_fflcAtten = 1; + *cum_fflcAtten = 1; } - slow = 0.8 + 0.2 * ( *stabFac ); - fast = 0.3 + 0.2 * ( *stabFac ); + slow = 0.8 + 0.2 * (*stabFac); + fast = 0.3 + 0.2 * (*stabFac); - switch ( frame_dms ) + switch (frame_dms) { - case 25: - slow = LC3_SQRT( LC3_SQRT( slow ) ); - fast = LC3_SQRT( LC3_SQRT( fast ) ); - break; - case 50: - slow = LC3_SQRT( slow ); - fast = LC3_SQRT( fast ); - break; + case 25: + slow = LC3_SQRT(LC3_SQRT(slow)); + fast = LC3_SQRT(LC3_SQRT(fast)); + break; + case 50: + slow = LC3_SQRT(slow); + fast = LC3_SQRT(fast); + break; } *cum_fading_slow = *cum_fading_slow * slow; *cum_fading_fast = *cum_fading_fast * fast; - - if ( processDampScramb == 1 ) + + if (processDampScramb == 1) { fflcAtten = 1; cum_fading_slow_local = *cum_fading_slow; cum_fading_fast_local = *cum_fading_fast; - - if ( spec_inv_idx == 0 ) + + if (spec_inv_idx == 0) { - if ( nbLostCmpt * frame_dms > PLC_FADEOUT_IN_MS * 10 ) + if (nbLostCmpt * frame_dms > PLC_FADEOUT_IN_MS * 10) { fflcAtten = 0; *cum_fflcAtten = 0; } - else if ( nbLostCmpt * frame_dms > 200 ) + else if (nbLostCmpt * frame_dms > 200) { - switch ( frame_dms ) + switch(frame_dms) { - case 25: - fflcAtten = PLC34_ATTEN_FAC_025; - break; - case 50: - fflcAtten = PLC34_ATTEN_FAC_050; - break; - case 100: - fflcAtten = PLC34_ATTEN_FAC_100; - break; + case 25: fflcAtten = PLC34_ATTEN_FAC_025; break; + case 50: fflcAtten = PLC34_ATTEN_FAC_050; break; + case 100: fflcAtten = PLC34_ATTEN_FAC_100; break; } } - - - *cum_fflcAtten = *cum_fflcAtten * fflcAtten; + + + *cum_fflcAtten = *cum_fflcAtten * fflcAtten; cum_fading_slow_local = *cum_fading_slow * *cum_fflcAtten; cum_fading_fast_local = *cum_fading_fast * *cum_fflcAtten; } - if ( pitch_present == 0 ) + if (pitch_present == 0) { - plc_start_inFrames = 1; - } - else - { - plc_start_inFrames = floor( PLC4_TRANSIT_START_IN_MS / ( frame_dms / 10.0 ) ); + plc_start_inFrames = 1; + } else { + plc_start_inFrames = floor(PLC4_TRANSIT_START_IN_MS / (frame_dms / 10.0)); } - plc_end_inFrames = floor( PLC4_TRANSIT_END_IN_MS / ( frame_dms / 10.0 ) ); - plc_duration_inFrames = plc_end_inFrames - plc_start_inFrames; + plc_end_inFrames = floor(PLC4_TRANSIT_END_IN_MS / (frame_dms / 10.0)); + plc_duration_inFrames = plc_end_inFrames - plc_start_inFrames; - if ( nbLostCmpt <= plc_start_inFrames ) + if (nbLostCmpt <= plc_start_inFrames) { linFuncStartStop = 1; - } - else if ( nbLostCmpt >= plc_end_inFrames ) + } else if (nbLostCmpt >= plc_end_inFrames) { linFuncStartStop = 0; - } - else - { + } else { x = nbLostCmpt; m = -1.0 / plc_duration_inFrames; b = -plc_end_inFrames; - linFuncStartStop = m * ( x + b ); + linFuncStartStop = m * (x + b); } - + randThreshold = -32768 * linFuncStartStop; - - for ( i = spec_inv_idx; i < yLen; i++ ) + + for (i = spec_inv_idx; i < yLen; i++) { *seed = 16831 + *seed * 12821; - *seed = (LC3_INT16) ( *seed ); - if ( *seed == 32768 ) + *seed = (LC3_INT16)(*seed); + if (*seed == 32768) { *seed -= 32768; } - if ( *seed < 0 ) + if (*seed < 0) { - if ( pitch_present == 0 || *seed < randThreshold ) + if (pitch_present == 0 || *seed < randThreshold) { spec[i] = -spec[i]; } @@ -174,29 +154,29 @@ void processPlcDampingScrambling_fl( LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 } ad_ThreshFac_start = 10; - ad_ThreshFac_end = 1.2; - ad_threshFac = ( ad_ThreshFac_start - ad_ThreshFac_end ) * linFuncStartStop + ad_ThreshFac_end; + ad_ThreshFac_end = 1.2; + ad_threshFac = (ad_ThreshFac_start - ad_ThreshFac_end) * linFuncStartStop + ad_ThreshFac_end; - if ( spec_inv_idx < yLen ) + if (spec_inv_idx < yLen) { - for ( i = spec_inv_idx; i < yLen; i++ ) + for (i = spec_inv_idx; i < yLen; i++) { - frame_energy = frame_energy + ( spec[i] * spec[i] ); + frame_energy = frame_energy + (spec[i] * spec[i]); } - mean_energy = frame_energy * 1 / ( yLen - spec_inv_idx ); + mean_energy = frame_energy * 1 / (yLen - spec_inv_idx); } else { mean_energy = 0; } - energThreshold = LC3_SQRT( ad_threshFac * mean_energy ); - fac = ( cum_fading_slow_local - cum_fading_fast_local ) * energThreshold; + energThreshold = LC3_SQRT(ad_threshFac * mean_energy); + fac = (cum_fading_slow_local - cum_fading_fast_local) * energThreshold; - for ( i = spec_inv_idx; i < yLen; i++ ) + for (i = spec_inv_idx; i < yLen; i++) { - if ( LC3_FABS( spec[i] ) < energThreshold ) + if (LC3_FABS(spec[i]) < energThreshold) { m = cum_fading_slow_local; n = 0; @@ -205,11 +185,11 @@ void processPlcDampingScrambling_fl( LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 { m = cum_fading_fast_local; - if ( spec[i] > 0 ) + if (spec[i] > 0) { n = fac; } - else if ( spec[i] == 0 ) + else if (spec[i] == 0) { n = 0; } @@ -223,3 +203,4 @@ void processPlcDampingScrambling_fl( LC3_FLOAT *spec, LC3_INT32 yLen, LC3_INT32 } } } + diff --git a/lib_lc3plus/plc_main.c b/lib_lc3plus/plc_main.c index 27d3474ecc..df3fd184d9 100644 --- a/lib_lc3plus/plc_main.c +++ b/lib_lc3plus/plc_main.c @@ -1,34 +1,38 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -void processPlcMain_fl( LC3_FLOAT *q_d_fl_c, LC3_FLOAT *syntM_fl_c, LC3PLUS_Dec *decoder, DecSetup *h_DecSetup, LC3_INT bfi, PlcAdvSetup *PlcAdvSetup, PlcSetup *PlcSetup, LC3_INT plcMeth, LC3_INT ltpf_pitch_int, LC3_INT ltpf_pitch_fr, LC3_INT tilt, const LC3_INT *bands_offset, LC3_INT bands_number, const LC3_INT *bands_offsetPLC, LC3_INT n_bandsPLC, LC3_INT16 hrmode, pcState *statePC ) +void processPlcMain_fl(LC3_FLOAT *q_d_fl_c, LC3_FLOAT *syntM_fl_c, LC3PLUS_Dec* decoder, DecSetup* h_DecSetup, LC3_INT bfi, + PlcAdvSetup *PlcAdvSetup, PlcSetup *PlcSetup, LC3_INT plcMeth, LC3_INT ltpf_pitch_int, LC3_INT ltpf_pitch_fr, + LC3_INT tilt, const LC3_INT *bands_offset, LC3_INT bands_number, const LC3_INT *bands_offsetPLC, + LC3_INT n_bandsPLC, LC3_INT16 hrmode, pcState *statePC +) { LC3_FLOAT r[MAX_BANDS_NUMBER_PLC], A[M + 1], synth[MAX_LEN + MDCT_MEM_LEN_MAX], energies[MAX_BANDS_NUMBER_PLC]; LC3_INT32 pitch_classifier; LC3_FLOAT xcorr; LC3_INT32 yLen; LC3_INT16 prev_bfi_plc2; - LC3_FLOAT phEcu_env_stab_local[1]; - LC3_FLOAT phEcu_pfind_sens[1]; + LC3_FLOAT phEcu_env_stab_local[1]; + LC3_FLOAT phEcu_pfind_sens[1]; prev_bfi_plc2 = 1; - if ( PlcSetup->nbLostCmpt == 0 ) + if (PlcSetup->nbLostCmpt == 0) { prev_bfi_plc2 = 0; } - assert( ( h_DecSetup->PlcSetup.prevBfi == 1 ) == ( prev_bfi_plc2 == 1 ) ); + assert((h_DecSetup->PlcSetup.prevBfi == 1) == (prev_bfi_plc2 == 1)); - if ( bfi == 1 && PlcAdvSetup ) + if (bfi == 1 && PlcAdvSetup) { /* FFLC increases the PFLC counter */ statePC->ns_nbLostCmpt_pc = statePC->ns_nbLostCmpt_pc + 1; @@ -36,161 +40,170 @@ void processPlcMain_fl( LC3_FLOAT *q_d_fl_c, LC3_FLOAT *syntM_fl_c, LC3PLUS_Dec pitch_classifier = ltpf_pitch_int; #ifdef NONBE_PLC_CLASSIFER_LAG_FIX - if ( ltpf_pitch_fr > 2 ) + if (ltpf_pitch_fr > 2) { pitch_classifier++; } #endif - processPlcClassify_fl( plcMeth, &h_DecSetup->concealMethod, &PlcSetup->nbLostCmpt, bfi, &xcorr, - decoder->frame_length, decoder->frame_dms, pitch_classifier, decoder->fs, - bands_offset, bands_number, tilt, PlcAdvSetup, hrmode ); + processPlcClassify_fl(plcMeth, &h_DecSetup->concealMethod, &PlcSetup->nbLostCmpt, bfi, &xcorr, + decoder->frame_length, decoder->frame_dms, pitch_classifier, decoder->fs, + bands_offset, bands_number, tilt, PlcAdvSetup, hrmode + ); - if ( bfi == 1 ) + if (bfi == 1) { - switch ( h_DecSetup->concealMethod ) + switch (h_DecSetup->concealMethod) + { + case 2: { - case 2: + LC3_FLOAT pitch_fl_c; + + assert(decoder->fs_idx == floor(decoder->fs / 10000)); + // phaseECU supports only 10ms framing + assert(PlcSetup->nbLostCmpt != 0 || decoder->frame_dms == 100); + + if (decoder->frame_dms != 100) { - LC3_FLOAT pitch_fl_c; + // muting, if frame size changed during phaseECU concealment + memset(q_d_fl_c, 0, sizeof(LC3_FLOAT) * decoder->frame_length); + h_DecSetup->alpha = 0; + break; + } - assert( decoder->fs_idx == floor( decoder->fs / 10000 ) ); - // phaseECU supports only 10ms framing - assert( PlcSetup->nbLostCmpt != 0 || decoder->frame_dms == 100 ); + /* call phaseEcu */ + pitch_fl_c = (LC3_FLOAT)ltpf_pitch_int + (LC3_FLOAT)ltpf_pitch_fr / 4.0; /* use non-rounded pitch indeces */ - if ( decoder->frame_dms != 100 ) - { - // muting, if frame size changed during phaseECU concealment - memset( q_d_fl_c, 0, sizeof( LC3_FLOAT ) * decoder->frame_length ); - h_DecSetup->alpha = 0; - break; - } - /* call phaseEcu */ - pitch_fl_c = (LC3_FLOAT) ltpf_pitch_int + (LC3_FLOAT) ltpf_pitch_fr / 4.0; /* use non-rounded pitch indeces */ + if (prev_bfi_plc2 == 0) + { + /* convert fractional pitch lag info at current fs to a normalized fractional bin-frequency */ + PlcAdvSetup->PlcPhEcuSetup.PhECU_f0hzLtpBin = plc_phEcuSetF0Hz(decoder->fs, &pitch_fl_c); + /* several buffers used in Cflt , a copy pcmbufHist, right before calling PhEcu in bad frames */ + assert(bfi == 1); + move_float(PlcAdvSetup->PlcPhEcuSetup.PhECU_xfp, + &(PlcAdvSetup->pcmbufHist[PlcAdvSetup->max_len_pcm_plc - PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot]), + PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot); + + /* a first bfi frame:: calc windowed 16 ms energy twice in a 26 ms buffer separated by 10 ms*/ + { + const LC3_FLOAT *w, *prev_xfp; + LC3_INT32 i, oold_start; + oold_start = PlcAdvSetup->max_len_pcm_plc - (decoder->frame_length + PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot); + assert(oold_start > 0); + w = PhECU_whr16ms_wins[decoder->fs_idx]; /* hammrect table */ + prev_xfp = &(PlcAdvSetup->pcmbufHist[oold_start + 0]); - if ( prev_bfi_plc2 == 0 ) - { - /* convert fractional pitch lag info at current fs to a normalized fractional bin-frequency */ - PlcAdvSetup->PlcPhEcuSetup.PhECU_f0hzLtpBin = plc_phEcuSetF0Hz( decoder->fs, &pitch_fl_c ); - /* several buffers used in Cflt , a copy pcmbufHist, right before calling PhEcu in bad frames */ - assert( bfi == 1 ); - move_float( PlcAdvSetup->PlcPhEcuSetup.PhECU_xfp, - &( PlcAdvSetup->pcmbufHist[PlcAdvSetup->max_len_pcm_plc - PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot] ), - PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot ); - - /* a first bfi frame:: calc windowed 16 ms energy twice in a 26 ms buffer separated by 10 ms*/ + PlcAdvSetup->PlcPhEcuSetup.PhECU_L_oold_xfp_w_E = 0; + PlcAdvSetup->PlcPhEcuSetup.PhECU_L_old_xfp_w_E = 0; + for (i = 0; i < PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot; i++) { - const LC3_FLOAT *w, *prev_xfp; - LC3_INT32 i, oold_start; - - oold_start = PlcAdvSetup->max_len_pcm_plc - ( decoder->frame_length + PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot ); - assert( oold_start > 0 ); - w = PhECU_whr16ms_wins[decoder->fs_idx]; /* hammrect table */ - prev_xfp = &( PlcAdvSetup->pcmbufHist[oold_start + 0] ); - - PlcAdvSetup->PlcPhEcuSetup.PhECU_L_oold_xfp_w_E = 0; - PlcAdvSetup->PlcPhEcuSetup.PhECU_L_old_xfp_w_E = 0; - for ( i = 0; i < PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot; i++ ) - { - PlcAdvSetup->PlcPhEcuSetup.PhECU_L_oold_xfp_w_E += sqrf( prev_xfp[i] * w[i] ); - PlcAdvSetup->PlcPhEcuSetup.PhECU_L_old_xfp_w_E += sqrf( PlcAdvSetup->PlcPhEcuSetup.PhECU_xfp[i] * w[i] ); - } + PlcAdvSetup->PlcPhEcuSetup.PhECU_L_oold_xfp_w_E += sqrf(prev_xfp[i] * w[i]); + PlcAdvSetup->PlcPhEcuSetup.PhECU_L_old_xfp_w_E += sqrf(PlcAdvSetup->PlcPhEcuSetup.PhECU_xfp[i] * w[i]); } - } /* (prev_bfi_plc2 == 0)*/ - else - { - /* overwrite last 3.75 ms of xfp with most recent pcmbufHist tail , right before calling PhEcu in bursts of bad frames */ - LC3_INT32 lenCopyOla = decoder->la_zeroes; /*copy_part + ola_part = 3.75 ms for 10 ms frame*/ - - assert( bfi == 1 && prev_bfi_plc2 ); - move_float( &( PlcAdvSetup->PlcPhEcuSetup.PhECU_xfp[PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot - lenCopyOla] ), - &( PlcAdvSetup->pcmbufHist[PlcAdvSetup->max_len_pcm_plc - lenCopyOla] ), lenCopyOla ); } - { - LC3_FLOAT x_tda[MAX_LEN]; /* 960/2 */ - PlcAdvSetup->PlcPhEcuSetup.PhECU_norm_corr = xcorr; - phEcu_env_stab_local[0] = (LC3_FLOAT) PHECU_ENV_STAB_LOCAL; - phEcu_pfind_sens[0] = (LC3_FLOAT) PHECU_PFIND_SENS; - - plc_phEcu_hq_ecu( &( PlcAdvSetup->PlcPhEcuSetup.PhECU_f0hzLtpBin ), - &( PlcAdvSetup->PlcPhEcuSetup.PhECU_norm_corr ), - PlcAdvSetup->PlcPhEcuSetup.PhECU_xfp, - prev_bfi_plc2, - &( PlcAdvSetup->PlcPhEcuSetup.PhECU_short_flag_prev ), - decoder->fs, - &( PlcAdvSetup->PlcPhEcuSetup.PhECU_time_offs ), - PlcAdvSetup->PlcPhEcuSetup.PhECU_X_sav_m, /* Complex */ - &( PlcAdvSetup->PlcPhEcuSetup.PhECU_num_plocs ), - PlcAdvSetup->PlcPhEcuSetup.PhECU_plocs, - PlcAdvSetup->PlcPhEcuSetup.PhECU_f0est, - MDCT_WINS_10ms[hrmode][decoder->fs_idx], - - phEcu_env_stab_local, - PHECU_DELTA_CORR, - phEcu_pfind_sens, - PHECU_LA, - PlcAdvSetup->PlcPhEcuSetup.PhECU_t_adv, - PhECU_whr16ms_wins[decoder->fs_idx], - PlcAdvSetup->PlcPhEcuSetup.PhECU_oold_grp_shape, - &( PlcAdvSetup->PlcPhEcuSetup.PhECU_L_oold_xfp_w_E ), - PlcAdvSetup->PlcPhEcuSetup.PhECU_old_grp_shape, - &( PlcAdvSetup->PlcPhEcuSetup.PhECU_L_old_xfp_w_E ), - &( PlcAdvSetup->PlcPhEcuSetup.PhECU_beta_mute ), - PlcAdvSetup->PlcPhEcuSetup.PhECU_mag_chg_1st, - PlcAdvSetup->PlcPhEcuSetup.PhECU_Xavg, - decoder->la_zeroes, - x_tda, /* time domain aliased output */ - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - &( PlcAdvSetup->PlcPhEcuSetup.PhEcu_Fft ), - &( PlcAdvSetup->PlcPhEcuSetup.PhEcu_Ifft ) ); - - - ProcessingITDA_WIN_OLA_fl( x_tda, decoder->frame_length, decoder->imdct_win, decoder->imdct_winLen, decoder->imdct_laZeros, - h_DecSetup->imdct_mem, synth ); - move_float( syntM_fl_c, synth, decoder->frame_length ); - } + } /* (prev_bfi_plc2 == 0)*/ + else + { + /* overwrite last 3.75 ms of xfp with most recent pcmbufHist tail , right before calling PhEcu in bursts of bad frames */ + LC3_INT32 lenCopyOla = decoder->la_zeroes; /*copy_part + ola_part = 3.75 ms for 10 ms frame*/ + + assert(bfi == 1 && prev_bfi_plc2); + move_float(&(PlcAdvSetup->PlcPhEcuSetup.PhECU_xfp[PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot-lenCopyOla]), + &(PlcAdvSetup->pcmbufHist[PlcAdvSetup->max_len_pcm_plc - lenCopyOla]), lenCopyOla); + } - break; - case 3: - if ( PlcSetup->nbLostCmpt == 1 ) - { - PlcAdvSetup->PlcTdcSetup.fract = ltpf_pitch_fr; - } - processPerBandEnergy_fl( n_bandsPLC, bands_offsetPLC, hrmode, decoder->frame_dms, energies, PlcSetup->q_d_prev ); - processTdcPreemphasis_fl( energies, &PlcAdvSetup->PlcTdcSetup.preemphFac, n_bandsPLC ); - processTdcInverseOdft_fl( energies, n_bandsPLC, r, PlcAdvSetup->PlcTdcSetup.lpcorder ); - processTdcLpcEstimation_fl( r, decoder->fs_idx, PlcAdvSetup->PlcTdcSetup.lpcorder + 1, A, decoder->frame_dms ); - processTdcApply_fl( ltpf_pitch_int, &PlcAdvSetup->PlcTdcSetup.preemphFac, A, PlcAdvSetup->PlcTdcSetup.lpcorder, PlcAdvSetup->pcmbufHist, PlcAdvSetup->max_len_pcm_plc, decoder->frame_length, - decoder->frame_dms, decoder->fs, PlcSetup->nbLostCmpt, decoder->frame_length - decoder->la_zeroes, &PlcAdvSetup->stabFac, PlcAdvSetup->PlcTdcSetup.harmonicBuf, - PlcAdvSetup->PlcTdcSetup.synthHist, &PlcAdvSetup->PlcTdcSetup.fract, &PlcAdvSetup->PlcTdcSetup.seed, &PlcAdvSetup->PlcTdcSetup.gain_c, - &h_DecSetup->alpha, synth ); - - processTdcTdac_fl( synth, decoder->imdct_win, decoder->frame_length, decoder->la_zeroes, h_DecSetup->imdct_mem ); - memmove( syntM_fl_c, synth, sizeof( LC3_FLOAT ) * decoder->frame_length ); - break; - case 4: - processNoiseSubstitution_fl( q_d_fl_c, PlcSetup->q_d_prev, decoder->yLen ); - break; - default: - assert( "Invalid PLC method!" ); + { + LC3_FLOAT x_tda[MAX_LEN]; /* 960/2 */ + PlcAdvSetup->PlcPhEcuSetup.PhECU_norm_corr = xcorr; + phEcu_env_stab_local[0] = (LC3_FLOAT)PHECU_ENV_STAB_LOCAL; + phEcu_pfind_sens[0] = (LC3_FLOAT)PHECU_PFIND_SENS; + + plc_phEcu_hq_ecu(&(PlcAdvSetup->PlcPhEcuSetup.PhECU_f0hzLtpBin), + &(PlcAdvSetup->PlcPhEcuSetup.PhECU_norm_corr), + PlcAdvSetup->PlcPhEcuSetup.PhECU_xfp, + prev_bfi_plc2, + &(PlcAdvSetup->PlcPhEcuSetup.PhECU_short_flag_prev), + decoder->fs, + &(PlcAdvSetup->PlcPhEcuSetup.PhECU_time_offs), + PlcAdvSetup->PlcPhEcuSetup.PhECU_X_sav_m, /* Complex */ + &(PlcAdvSetup->PlcPhEcuSetup.PhECU_num_plocs), + PlcAdvSetup->PlcPhEcuSetup.PhECU_plocs, + PlcAdvSetup->PlcPhEcuSetup.PhECU_f0est, + MDCT_WINS_10ms[hrmode][decoder->fs_idx], + + phEcu_env_stab_local, + PHECU_DELTA_CORR, + phEcu_pfind_sens, + PHECU_LA, + PlcAdvSetup->PlcPhEcuSetup.PhECU_t_adv, + PhECU_whr16ms_wins[decoder->fs_idx], + PlcAdvSetup->PlcPhEcuSetup.PhECU_oold_grp_shape, + &(PlcAdvSetup->PlcPhEcuSetup.PhECU_L_oold_xfp_w_E), + PlcAdvSetup->PlcPhEcuSetup.PhECU_old_grp_shape, + &(PlcAdvSetup->PlcPhEcuSetup.PhECU_L_old_xfp_w_E), + &(PlcAdvSetup->PlcPhEcuSetup.PhECU_beta_mute), + PlcAdvSetup->PlcPhEcuSetup.PhECU_mag_chg_1st, + PlcAdvSetup->PlcPhEcuSetup.PhECU_Xavg, + decoder->la_zeroes, + x_tda, /* time domain aliased output */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL + , + &(PlcAdvSetup->PlcPhEcuSetup.PhEcu_Fft), + &(PlcAdvSetup->PlcPhEcuSetup.PhEcu_Ifft) + ); + + + ProcessingITDA_WIN_OLA_fl(x_tda, decoder->frame_length, decoder->imdct_win, decoder->imdct_winLen, decoder->imdct_laZeros, + h_DecSetup->imdct_mem, synth); + move_float(syntM_fl_c, synth, decoder->frame_length); + + + + } } - } + break; + case 3: + if (PlcSetup->nbLostCmpt == 1) + { + PlcAdvSetup->PlcTdcSetup.fract = ltpf_pitch_fr; + } - if ( bfi == 0 ) - { - processPlcUpdateSpec_fl( PlcSetup->q_d_prev, q_d_fl_c, decoder->yLen ); + processPerBandEnergy_fl(n_bandsPLC, bands_offsetPLC, hrmode, decoder->frame_dms, energies, PlcSetup->q_d_prev); + processTdcPreemphasis_fl(energies, &PlcAdvSetup->PlcTdcSetup.preemphFac, n_bandsPLC); + processTdcInverseOdft_fl(energies, n_bandsPLC, r, PlcAdvSetup->PlcTdcSetup.lpcorder); + processTdcLpcEstimation_fl(r, decoder->fs_idx, PlcAdvSetup->PlcTdcSetup.lpcorder + 1, A, decoder->frame_dms); + processTdcApply_fl(ltpf_pitch_int, &PlcAdvSetup->PlcTdcSetup.preemphFac, A, PlcAdvSetup->PlcTdcSetup.lpcorder, PlcAdvSetup->pcmbufHist, PlcAdvSetup->max_len_pcm_plc, decoder->frame_length, + decoder->frame_dms, decoder->fs, PlcSetup->nbLostCmpt, decoder->frame_length - decoder->la_zeroes, &PlcAdvSetup->stabFac, PlcAdvSetup->PlcTdcSetup.harmonicBuf, + PlcAdvSetup->PlcTdcSetup.synthHist, &PlcAdvSetup->PlcTdcSetup.fract, &PlcAdvSetup->PlcTdcSetup.seed, &PlcAdvSetup->PlcTdcSetup.gain_c, + &h_DecSetup->alpha, synth); + + processTdcTdac_fl(synth, decoder->imdct_win, decoder->frame_length, decoder->la_zeroes, h_DecSetup->imdct_mem); + memmove(syntM_fl_c, synth, sizeof(LC3_FLOAT) * decoder->frame_length); + break; + case 4: + processNoiseSubstitution_fl(q_d_fl_c, PlcSetup->q_d_prev, decoder->yLen); + break; + default: + assert("Invalid PLC method!"); + } } - yLen = MIN( decoder->frame_length, MAX_PLC_LMEM ); - if ( PlcAdvSetup != NULL && ( decoder->frame_dms == 100 ) && ( hrmode == 0 ) ) + if (bfi == 0) { - /* BASOP processPLCspec2shape_fx(prev_bfi, bfi, q_old_d_fx, yLen, plcAd->PhECU_oold_grp_shape_fx, plcAd->PhECU_old_grp_shape_fx);*/ - plc_phEcu_processPLCspec2shape( prev_bfi_plc2, bfi, q_d_fl_c, yLen, - PlcAdvSetup->PlcPhEcuSetup.PhECU_oold_grp_shape, PlcAdvSetup->PlcPhEcuSetup.PhECU_old_grp_shape ); + processPlcUpdateSpec_fl(PlcSetup->q_d_prev, q_d_fl_c, decoder->yLen); } + + yLen = MIN(decoder->frame_length, MAX_PLC_LMEM); + if (PlcAdvSetup != NULL && (decoder->frame_dms == 100) && (hrmode == 0)) + { + /* BASOP processPLCspec2shape_fx(prev_bfi, bfi, q_old_d_fx, yLen, plcAd->PhECU_oold_grp_shape_fx, plcAd->PhECU_old_grp_shape_fx);*/ + plc_phEcu_processPLCspec2shape(prev_bfi_plc2, bfi, q_d_fl_c, yLen, + PlcAdvSetup->PlcPhEcuSetup.PhECU_oold_grp_shape, PlcAdvSetup->PlcPhEcuSetup.PhECU_old_grp_shape); + } } + diff --git a/lib_lc3plus/plc_noise_substitution.c b/lib_lc3plus/plc_noise_substitution.c index ba63aaabe9..4913ee53e5 100644 --- a/lib_lc3plus/plc_noise_substitution.c +++ b/lib_lc3plus/plc_noise_substitution.c @@ -1,21 +1,22 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -void processNoiseSubstitution_fl( LC3_FLOAT *spec, LC3_FLOAT *spec_prev, LC3_INT32 yLen ) +void processNoiseSubstitution_fl(LC3_FLOAT* spec, LC3_FLOAT* spec_prev, LC3_INT32 yLen) { - memmove( spec, spec_prev, sizeof( LC3_FLOAT ) * yLen ); - + memmove(spec, spec_prev, sizeof(LC3_FLOAT) * yLen); + spec[0] *= 0.2; spec[1] *= 0.5; } + diff --git a/lib_lc3plus/plc_phecu_f0_refine_first.c b/lib_lc3plus/plc_phecu_f0_refine_first.c index 36cf39c23d..11ebf276b1 100644 --- a/lib_lc3plus/plc_phecu_f0_refine_first.c +++ b/lib_lc3plus/plc_phecu_f0_refine_first.c @@ -1,78 +1,68 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "defines.h" #include "functions.h" -void plc_phEcu_F0_refine_first( LC3_INT32 *plocs, /* i/o 0 ... Lprot/2 +1*/ +void plc_phEcu_F0_refine_first( LC3_INT32 *plocs, /* i/o 0 ... Lprot/2 +1*/ LC3_INT32 n_plocs, - LC3_FLOAT *f0est, /* i/o f0est */ + LC3_FLOAT *f0est, /* i/o f0est */ const LC3_INT32 Xabs_len, LC3_FLOAT *f0binPtr, /* i */ LC3_FLOAT *f0gainPtr, /* i */ - const LC3_INT32 nSubm ) + const LC3_INT32 nSubm + ) { - LC3_FLOAT sens; - LC3_INT32 i, j, high_idx, breakflag; - LC3_FLOAT f0est_lim[MAX_PLC_NPLOCS]; - LC3_FLOAT f0bin; - LC3_FLOAT f0gain; - - f0bin = *f0binPtr; - f0gain = *f0gainPtr; + LC3_FLOAT sens; + LC3_INT32 i, j, high_idx, breakflag; + LC3_FLOAT f0est_lim[MAX_PLC_NPLOCS]; + LC3_FLOAT f0bin; + LC3_FLOAT f0gain; - if ( n_plocs > 0 && f0gain > 0.25 ) - { + f0bin = *f0binPtr; + f0gain = *f0gainPtr; + if (n_plocs > 0 && f0gain > 0.25) { + sens = 0.5; - if ( f0gain < 0.75 ) - { + if (f0gain < 0.75) { sens = 0.25; } - + high_idx = -1; - for ( i = 0; i < n_plocs; i++ ) - { - if ( plocs[i] <= 25 ) - { /* 25 ~= 1550 Hz */ - high_idx = MAX( high_idx, i ); - } - else - { + for (i = 0; i < n_plocs; i++) { + if (plocs[i] <= 25) { /* 25 ~= 1550 Hz */ + high_idx = MAX(high_idx, i); + } else { /* Optimization, only works if plocs vector is sorted. Which it should be. */ break; } } - - if ( high_idx != -1 ) - { + + if (high_idx != -1) { high_idx++; - move_float( f0est_lim, f0est, high_idx ); - + move_float(f0est_lim, f0est, high_idx); + breakflag = 0; - for ( i = 0; i < nSubm; i++ ) - { - for ( j = 0; j < high_idx; j++ ) - { - if ( LC3_FABS( f0est_lim[j] - ( i + 1 ) * f0bin ) < sens ) - { - f0est[j] = ( i + 1 ) * f0bin; - plocs[j] = MIN( Xabs_len - 1, MAX( 1, (LC3_INT32) LC3_ROUND( f0est[j] ) ) ); + for (i = 0; i < nSubm; i++) { + for (j = 0; j < high_idx; j++) { + if (LC3_FABS(f0est_lim[j] - (i+1) * f0bin) < sens) { + f0est[j] = (i+1)*f0bin; + plocs[j] = MIN(Xabs_len-1, MAX(1,(LC3_INT32) LC3_ROUND(f0est[j]))); breakflag = 1; break; } } - if ( breakflag ) - { + if (breakflag) { break; } sens *= 0.875; @@ -80,5 +70,6 @@ void plc_phEcu_F0_refine_first( LC3_INT32 *plocs, /* i/o 0 ... Lprot/2 +1*/ } } - return; + return; } + diff --git a/lib_lc3plus/plc_phecu_fec_hq.c b/lib_lc3plus/plc_phecu_fec_hq.c index fd44ad604d..c25466c3e9 100644 --- a/lib_lc3plus/plc_phecu_fec_hq.c +++ b/lib_lc3plus/plc_phecu_fec_hq.c @@ -1,20 +1,19 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "defines.h" #include "functions.h" -LC3_FLOAT plc_phEcu_imax2_jacobsen_mag( const Complex *y, LC3_FLOAT *c_jacobPtr ) -{ +LC3_FLOAT plc_phEcu_imax2_jacobsen_mag(const Complex *y, LC3_FLOAT *c_jacobPtr) { LC3_FLOAT posi; const Complex *pY; @@ -24,12 +23,12 @@ LC3_FLOAT plc_phEcu_imax2_jacobsen_mag( const Complex *y, LC3_FLOAT *c_jacobPtr LC3_FLOAT numer, denom; /* Jacobsen estimates peak offset relative y_0 using - * X_m1 - X_p1 - * d = REAL ( ------------------- ) * c_jacob - * 2*X_0 - X_m1 -Xp1 - * - * Where c_jacob is a window dependent constant - */ + * X_m1 - X_p1 + * d = REAL ( ------------------- ) * c_jacob + * 2*X_0 - X_m1 -Xp1 + * + * Where c_jacob is a window dependent constant + */ /* Get the parameters into variables */ pY = y; @@ -38,28 +37,25 @@ LC3_FLOAT plc_phEcu_imax2_jacobsen_mag( const Complex *y, LC3_FLOAT *c_jacobPtr y_p1 = *pY++; /* prepare numerator real and imaginary parts*/ - N = csub( y_m1, y_p1 ); + N = csub(y_m1, y_p1); /* prepare denominator real and imaginary parts */ - D = cmul( cmplx( 2.0, 0.0 ), y_0 ); - D = csub( D, y_m1 ); - D = csub( D, y_p1 ); + D = cmul(cmplx(2.0, 0.0), y_0); + D = csub(D, y_m1); + D = csub(D, y_p1); /* REAL part of complex division */ - numer = N.r * D.r + N.i * D.i; - denom = D.r * D.r + D.i * D.i; + numer = N.r*D.r + N.i*D.i; + denom = D.r*D.r + D.i*D.i; - if ( numer != 0 && denom != 0 ) - { - posi = numer / denom * ( *c_jacobPtr ); - } - else - { + if (numer != 0 && denom != 0) { + posi = numer / denom * (*c_jacobPtr); + } else { posi = 0.0; /* flat top, division is not possible choose center freq */ } - posi = fclampf( -1.0, posi, 1.0 ); + posi = fclampf(-1.0, posi, 1.0); return posi; } @@ -69,59 +65,47 @@ LC3_FLOAT plc_phEcu_imax2_jacobsen_mag( const Complex *y, LC3_FLOAT *c_jacobPtr * Get interpolated maximum position *-------------------------------------------------------------------*/ -LC3_FLOAT plc_phEcu_interp_max( const LC3_FLOAT *y, LC3_INT32 y_len ) -{ +LC3_FLOAT plc_phEcu_interp_max(const LC3_FLOAT *y, LC3_INT32 y_len) { LC3_FLOAT posi, y1, y2, y3, y3_y1, y2i; LC3_FLOAT ftmp_den1, ftmp_den2; /* Seek the extrema of the parabola P(x) defined by 3 consecutive points so that P([-1 0 1]) = [y1 y2 y3] */ y1 = y[0]; y2 = y[1]; - + /* If interp between two values only */ - if ( y_len == 2 ) - { - if ( y1 < y2 ) - { + if (y_len == 2) { + if (y1 < y2) { return 1.0; - } - else - { + } else { return 0.0; } } - + y3 = y[2]; - y3_y1 = y3 - y1; - ftmp_den1 = ( y1 + y3 - 2 * y2 ); - ftmp_den2 = ( 4 * y2 - 2 * y1 - 2 * y3 ); - - if ( ftmp_den2 == 0.0 || ftmp_den1 == 0.0 ) - { - return 0.0; /* early exit with left-most value */ + y3_y1 = y3-y1; + ftmp_den1 = (y1+y3-2*y2); + ftmp_den2 = (4*y2 - 2*y1 - 2*y3); + + if(ftmp_den2 == 0.0 || ftmp_den1 == 0.0) { + return 0.0; /* early exit with left-most value */ } - - y2i = ( (LC3_FLOAT) -0.125 ) * sqrf( y3_y1 ) / ( ftmp_den1 ) + y2; + + y2i = ((LC3_FLOAT)-0.125) * sqrf(y3_y1) /(ftmp_den1) + y2; /* their corresponding normalized locations */ - posi = y3_y1 / ( ftmp_den2 ); + posi = y3_y1/(ftmp_den2); /* Interpolated maxima if locations are not within [-1,1], calculated extrema are ignored */ - if ( posi >= (LC3_FLOAT) 1.0 || posi <= (LC3_FLOAT) -1.0 ) - { - posi = y3 > y1 ? (LC3_FLOAT) 1.0 : (LC3_FLOAT) -1.0; - } - else - { - if ( y1 >= y2i ) - { - posi = ( y1 > y3 ) ? (LC3_FLOAT) -1.0 : (LC3_FLOAT) 1.0; - } - else if ( y3 >= y2i ) - { - posi = (LC3_FLOAT) 1.0; + if (posi >= (LC3_FLOAT)1.0 || posi <= (LC3_FLOAT)-1.0) { + posi = y3 > y1 ? (LC3_FLOAT)1.0 : (LC3_FLOAT)-1.0; + } else { + if (y1 >= y2i) { + posi = (y1 > y3) ? (LC3_FLOAT)-1.0 :(LC3_FLOAT) 1.0; + } else if (y3 >= y2i) { + posi = (LC3_FLOAT)1.0; } } - - return posi + (LC3_FLOAT) 1.0; + + return posi + (LC3_FLOAT)1.0; } /*----------------------------------------------------------------------------- @@ -134,49 +118,42 @@ LC3_FLOAT plc_phEcu_interp_max( const LC3_FLOAT *y, LC3_INT32 y_len ) * abs = 0.84 max_abs + 0.561*min_abs * end * - + *----------------------------------------------------------------------------*/ -void plc_phEcu_fft_spec2_sqrt_approx( const Complex *x, LC3_INT32 x_len, LC3_FLOAT *x_abs ) -{ +void plc_phEcu_fft_spec2_sqrt_approx(const Complex* x, LC3_INT32 x_len, LC3_FLOAT* x_abs) { LC3_INT32 i; LC3_FLOAT max_abs, min_abs, re, im; - - for ( i = 0; i < x_len; i++ ) - { - re = LC3_FABS( x[i].r ); - im = LC3_FABS( x[i].i ); - max_abs = MAX( re, im ); - min_abs = MIN( re, im ); - - if ( min_abs <= (LC3_FLOAT) 0.4142135 * max_abs ) - { - x_abs[i] = (LC3_FLOAT) 0.99 * max_abs + (LC3_FLOAT) 0.197 * min_abs; - } - else - { - x_abs[i] = (LC3_FLOAT) 0.84 * max_abs + (LC3_FLOAT) 0.561 * min_abs; + + for (i = 0; i < x_len; i++) { + re = LC3_FABS(x[i].r); + im = LC3_FABS(x[i].i); + max_abs = MAX(re, im); + min_abs = MIN(re, im); + + if (min_abs <= (LC3_FLOAT)0.4142135 * max_abs) { + x_abs[i] = (LC3_FLOAT)0.99*max_abs + (LC3_FLOAT)0.197*min_abs; + } else { + x_abs[i] = (LC3_FLOAT)0.84*max_abs + (LC3_FLOAT)0.561*min_abs; } } - return; + return; } -LC3_INT32 plc_phEcu_pitch_in_plocs( LC3_INT32 *plocs, LC3_INT32 n_plocs ) -{ - +LC3_INT32 plc_phEcu_pitch_in_plocs(LC3_INT32* plocs, LC3_INT32 n_plocs) { + LC3_INT32 i; LC3_INT32 p_in_plocs; p_in_plocs = 0; - - for ( i = 0; i < n_plocs; i++ ) - { - if ( plocs[i] > 0 && plocs[i] < 7 ) - { + + for (i = 0; i < n_plocs; i++) { + if (plocs[i] > 0 && plocs[i] < 7) { p_in_plocs++; } } return p_in_plocs; } + diff --git a/lib_lc3plus/plc_phecu_hq_ecu.c b/lib_lc3plus/plc_phecu_hq_ecu.c index 53e8545ef6..5b1978bcab 100644 --- a/lib_lc3plus/plc_phecu_hq_ecu.c +++ b/lib_lc3plus/plc_phecu_hq_ecu.c @@ -1,12 +1,12 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "defines.h" @@ -14,128 +14,103 @@ void plc_phEcu_hq_ecu( - LC3_FLOAT *f0binPtr, - LC3_FLOAT *f0ltpGainPtr, - LC3_FLOAT *xfp, - LC3_INT16 prev_bfi, - LC3_INT32 *short_flag_prev, - LC3_INT32 fs, - LC3_INT32 *time_offs, - Complex *X_sav_m, - LC3_INT32 *n_plocs, - LC3_INT32 *plocs, - LC3_FLOAT *f0est, - const LC3_FLOAT *mdctWin, - LC3_FLOAT *env_stabPtr, - LC3_INT32 delta_corr, - LC3_FLOAT *pfind_sensPtr, - LC3_INT32 PhECU_LA, - LC3_INT32 t_adv, - const LC3_FLOAT *winWhr, - LC3_FLOAT *oold_grp_shape, - LC3_FLOAT *oold_EwPtr, - LC3_FLOAT *old_grp_shape, - LC3_FLOAT *old_EwPtr, - LC3_FLOAT *st_beta_mute, - LC3_FLOAT *st_mag_chg_1st, - LC3_FLOAT *st_Xavg, - LC3_INT32 LA_ZEROS, - LC3_FLOAT *x_tda, - LC3_FLOAT *xsubst_dbg, - Complex *X_out_m_dbg, - LC3_INT32 *seed_dbg, - LC3_FLOAT *mag_chg_dbg, - LC3_INT32 *tr_dec_dbg, - LC3_FLOAT *gpc_dbg, - LC3_FLOAT *X_i_new_re_dbg, - LC3_FLOAT *X_i_new_im_dbg, + LC3_FLOAT *f0binPtr, LC3_FLOAT *f0ltpGainPtr, LC3_FLOAT *xfp, + LC3_INT16 prev_bfi, LC3_INT32 *short_flag_prev, LC3_INT32 fs, + LC3_INT32 *time_offs, Complex *X_sav_m, LC3_INT32 *n_plocs, LC3_INT32 *plocs, LC3_FLOAT *f0est, + const LC3_FLOAT *mdctWin, LC3_FLOAT *env_stabPtr, LC3_INT32 delta_corr, LC3_FLOAT *pfind_sensPtr, + LC3_INT32 PhECU_LA, LC3_INT32 t_adv, const LC3_FLOAT *winWhr, + LC3_FLOAT *oold_grp_shape, LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_grp_shape, LC3_FLOAT *old_EwPtr, + LC3_FLOAT *st_beta_mute, LC3_FLOAT *st_mag_chg_1st, LC3_FLOAT *st_Xavg, LC3_INT32 LA_ZEROS, LC3_FLOAT *x_tda, + LC3_FLOAT *xsubst_dbg, Complex *X_out_m_dbg, + LC3_INT32 *seed_dbg, LC3_FLOAT *mag_chg_dbg, LC3_INT32 *tr_dec_dbg, LC3_FLOAT *gpc_dbg, LC3_FLOAT *X_i_new_re_dbg, LC3_FLOAT *X_i_new_im_dbg, LC3_FLOAT *corr_phase_dbg, - Fft *PhEcu_Fft, - Fft *PhEcu_Ifft ) + Fft *PhEcu_Fft, Fft *PhEcu_Ifft) { - LC3_INT32 i; - LC3_INT32 fs_idx, L, Lprot, n_grp, Lecu, LXsav, Lxfp_inuse; - LC3_FLOAT alpha[8]; - LC3_FLOAT beta[8]; - LC3_FLOAT mag_chg[8]; - LC3_FLOAT xfp_local_rnd[2 * MAX_LEN]; - Complex X_out_m[2 * MAX_LEN]; - LC3_INT32 seed; - LC3_INT32 burst_len; - - - fs_idx = (LC3_INT32) floor( fs / 10000.0 ); - L = (LC3_INT32) floor( 0.01 * fs ); - Lprot = (LC3_INT32) ( 1.6 * L ); + LC3_INT32 i; + LC3_INT32 fs_idx, L, Lprot, n_grp, Lecu, LXsav, Lxfp_inuse; + LC3_FLOAT alpha[8]; + LC3_FLOAT beta[8]; + LC3_FLOAT mag_chg[8]; + LC3_FLOAT xfp_local_rnd[2*MAX_LEN]; + Complex X_out_m[2*MAX_LEN]; + LC3_INT32 seed; + LC3_INT32 burst_len; + + + fs_idx = (LC3_INT32)floor(fs / 10000.0); + L = (LC3_INT32)floor(0.01 * fs); + Lprot = (LC3_INT32)(1.6 * L); n_grp = xavg_N_grp[fs_idx]; Lecu = 2 * L; - LXsav = Lprot / 2 + 1; /* 48 kHz may be optimized , to save only up to 20 kHz as in BASOP */ - Lxfp_inuse = Lprot; - if ( prev_bfi == 1 ) - { - Lxfp_inuse = (LC3_INT32) ( L * ( 3.75 / 10.0 ) ); + LXsav = Lprot / 2 + 1; /* 48 kHz may be optimized , to save only up to 20 kHz as in BASOP */ + Lxfp_inuse = Lprot ; + if (prev_bfi == 1){ + Lxfp_inuse = (LC3_INT32)(L*(3.75/10.0)); } - UNUSED( env_stabPtr ); - UNUSED( xsubst_dbg ); - UNUSED( X_out_m_dbg ); - UNUSED( seed_dbg ); - UNUSED( mag_chg_dbg ); - UNUSED( tr_dec_dbg ); - UNUSED( gpc_dbg ); - UNUSED( X_i_new_re_dbg ); - UNUSED( X_i_new_im_dbg ); - UNUSED( corr_phase_dbg ); - - - if ( prev_bfi != 1 ) + UNUSED(env_stabPtr); + UNUSED(xsubst_dbg); + UNUSED(X_out_m_dbg); + UNUSED(seed_dbg); + UNUSED(mag_chg_dbg); + UNUSED(tr_dec_dbg); + UNUSED(gpc_dbg); + UNUSED(X_i_new_re_dbg); + UNUSED(X_i_new_im_dbg); + UNUSED(corr_phase_dbg); + + + if (prev_bfi != 1) { - for ( i = ( Lprot - Lxfp_inuse ); i < Lprot; i++ ) - { - xfp_local_rnd[i] = xfp[i]; - /* hysteresis of low level input aligns float fft analysis and peak picking to BASOP performance for low level noisy signals */ - if ( xfp[i] >= -0.5 && xfp[i] <= 0.5 ) - { - xfp_local_rnd[i] = 0.0; - } - } - + for (i = (Lprot-Lxfp_inuse); i < Lprot; i++) { + xfp_local_rnd[i] = xfp[i]; + /* hysteresis of low level input aligns float fft analysis and peak picking to BASOP performance for low level noisy signals */ + if (xfp[i] >= -0.5 && xfp[i] <= 0.5) { + xfp_local_rnd[i] = 0.0; + } + } + *time_offs = 0; - burst_len = ( *time_offs / L + 1 ); - plc_phEcu_trans_burst_ana_sub( fs_idx, burst_len, n_grp, oold_grp_shape, oold_EwPtr, old_grp_shape, old_EwPtr, st_beta_mute, - st_mag_chg_1st, st_Xavg, alpha, beta, mag_chg, NULL, NULL ); - - plc_phEcu_spec_ana( xfp_local_rnd, Lprot, winWhr, pfind_sensPtr, plocs, n_plocs, f0est, X_sav_m, &LXsav, f0binPtr, f0ltpGainPtr, fs_idx, PhEcu_Fft ); + burst_len = (*time_offs / L + 1); + plc_phEcu_trans_burst_ana_sub(fs_idx, burst_len, n_grp, oold_grp_shape, oold_EwPtr , old_grp_shape, old_EwPtr, st_beta_mute, + st_mag_chg_1st, st_Xavg, alpha, beta, mag_chg, NULL, NULL); + + plc_phEcu_spec_ana(xfp_local_rnd, Lprot, winWhr, pfind_sensPtr, plocs, n_plocs, f0est, X_sav_m, &LXsav, f0binPtr, f0ltpGainPtr, fs_idx, PhEcu_Fft); } else { *time_offs = *time_offs + L; - *time_offs = imin( 32767, *time_offs ); /* limit to Word16 range as in BASOP ~= 70 10ms frames@48kHz */ - burst_len = ( ( *time_offs / L ) + 1 ); + *time_offs = imin(32767 ,*time_offs); /* limit to Word16 range as in BASOP ~= 70 10ms frames@48kHz */ + burst_len = ((*time_offs / L) + 1); + + plc_phEcu_trans_burst_ana_sub(fs_idx, burst_len, n_grp, oold_grp_shape, oold_EwPtr, old_grp_shape, old_EwPtr, st_beta_mute, + st_mag_chg_1st, st_Xavg, alpha, beta, mag_chg, NULL, NULL); - plc_phEcu_trans_burst_ana_sub( fs_idx, burst_len, n_grp, oold_grp_shape, oold_EwPtr, old_grp_shape, old_EwPtr, st_beta_mute, - st_mag_chg_1st, st_Xavg, alpha, beta, mag_chg, NULL, NULL ); } seed = *time_offs; - - if ( *short_flag_prev != 0 ) + + if (*short_flag_prev != 0) { *n_plocs = 0; } - move_cmplx( X_out_m, X_sav_m, LXsav ); + move_cmplx( X_out_m, X_sav_m, LXsav); /* inplace X_out_m update */ - plc_phEcu_subst_spec( plocs, *n_plocs, f0est, *time_offs, X_out_m, LXsav, mag_chg, &seed, alpha, beta, st_Xavg, t_adv, Lprot, delta_corr, - NULL, NULL, NULL ); + plc_phEcu_subst_spec(plocs, *n_plocs, f0est, *time_offs, X_out_m, LXsav, mag_chg, &seed, alpha, beta, st_Xavg, t_adv, Lprot, delta_corr, + NULL, NULL, NULL); + - plc_phEcu_rec_frame( X_out_m, L, Lecu, winWhr, mdctWin, Lprot, - xfp, /* last 3.75ms of non-rounded xfp used here */ - *time_offs, - x_tda /* output */, - NULL, NULL, NULL, - LA_ZEROS, PhECU_LA, PhEcu_Ifft ); + + plc_phEcu_rec_frame(X_out_m, L, Lecu, winWhr, mdctWin, Lprot, + xfp, /* last 3.75ms of non-rounded xfp used here */ + *time_offs, + x_tda /* output */, + NULL, NULL, NULL, + LA_ZEROS, PhECU_LA, PhEcu_Ifft); + } + diff --git a/lib_lc3plus/plc_phecu_lf_peak_analysis.c b/lib_lc3plus/plc_phecu_lf_peak_analysis.c index 2eb3108924..0bcc98d7a4 100644 --- a/lib_lc3plus/plc_phecu_lf_peak_analysis.c +++ b/lib_lc3plus/plc_phecu_lf_peak_analysis.c @@ -1,25 +1,26 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "defines.h" #include "functions.h" -void plc_phEcu_LF_peak_analysis( LC3_INT32 *plocs, /* i/o 0 ... Lprot/2 +1*/ - LC3_INT32 *n_plocs, /* i/o 0.. MAX_PLOCS */ - LC3_FLOAT *f0est, /* i/o Q16*/ - const LC3_FLOAT *Xabs, - LC3_FLOAT *f0binPtr, - LC3_FLOAT *f0gainPtr, - const LC3_INT32 nSubm ) +void plc_phEcu_LF_peak_analysis(LC3_INT32 *plocs, /* i/o 0 ... Lprot/2 +1*/ + LC3_INT32 *n_plocs, /* i/o 0.. MAX_PLOCS */ + LC3_FLOAT *f0est, /* i/o Q16*/ + const LC3_FLOAT *Xabs, + LC3_FLOAT *f0binPtr, + LC3_FLOAT *f0gainPtr, + const LC3_INT32 nSubm +) { LC3_INT32 i, j, fin, f_ind, prel_low, prel_high, start; LC3_FLOAT f0est_prel[3]; @@ -28,97 +29,84 @@ void plc_phEcu_LF_peak_analysis( LC3_INT32 *plocs, /* i/o 0 ... Lprot/2 +1*/ LC3_FLOAT f0est_old[MAX_PLC_NPLOCS]; LC3_INT32 plocs_old[MAX_PLC_NPLOCS]; LC3_FLOAT peakLF_Xval, f; - LC3_FLOAT f0bin; - LC3_FLOAT f0gain; - - f0bin = *f0binPtr; + LC3_FLOAT f0bin ; + LC3_FLOAT f0gain ; + + f0bin = *f0binPtr; f0gain = *f0gainPtr; - if ( *n_plocs > 0 && f0gain > 0.25 && f0bin < 2.75 ) - { + if (*n_plocs > 0 && f0gain > 0.25 && f0bin < 2.75) { /* Assumes sorted plocs */ - if ( plocs[0] < 3 ) - { - fin = MIN( 3, *n_plocs ); + if (plocs[0] < 3) { + fin = MIN(3, *n_plocs); peakLF_Xval = Xabs[plocs[0]]; - for ( i = 1; i < fin; i++ ) - { - peakLF_Xval = MAX( peakLF_Xval, Xabs[plocs[i]] ); + for (i = 1; i < fin; i++) { + peakLF_Xval = MAX(peakLF_Xval, Xabs[plocs[i]]); } n_prel = 0; - for ( i = 0; i < nSubm; i++ ) - { - f = ( i + 1 ) * f0bin; - f_ind = (LC3_INT32) LC3_ROUND( f ); - if ( f * PHECU_FRES <= 400 && Xabs[f_ind] > peakLF_Xval * 0.375 ) - { + for (i = 0; i < nSubm; i++) { + f = (i+1)*f0bin; + f_ind = (LC3_INT32)LC3_ROUND(f); + if (f*PHECU_FRES <= 400 && Xabs[f_ind] > peakLF_Xval*0.375) { f0est_prel[n_prel] = f; plocs_prel[n_prel] = f_ind; n_prel++; } } - if ( n_prel > 0 ) - { + if (n_prel > 0) { prel_low = plocs_prel[0]; - prel_high = plocs_prel[n_prel - 1]; - - /* initial assumption:: all original peaks (1 or 2 of them) are positioned below prel_low */ - start = ( *n_plocs ); /* at this point 'start' is the location_c where to add any harmonics peaks */ - for ( i = ( *n_plocs ) - 1; i >= 0; i-- ) - { - if ( plocs[i] >= prel_low ) - { + prel_high = plocs_prel[n_prel-1]; + + /* initial assumption:: all original peaks (1 or 2 of them) are positioned below prel_low */ + start = (*n_plocs); /* at this point 'start' is the location_c where to add any harmonics peaks */ + for (i = (*n_plocs)-1; i >= 0; i--) { + if (plocs[i] >= prel_low) { start = i; } } /* found position_c where to start adding */ - start = ( start - 1 ); /* one step lower, now start is of original LF peaks to keep */ - start = MAX( start, -1 ); /* limit for loop */ + start = (start-1 ); /* one step lower, now start is of original LF peaks to keep */ + start = MAX(start, -1); /* limit for loop */ - if ( prel_high < plocs[0] ) - { + if (prel_high < plocs[0]) { fin = 0; - } - else - { - fin = ( *n_plocs ) + 1; - for ( i = 0; i < *n_plocs; i++ ) - { - if ( plocs[i] <= prel_high ) - { + } else { + fin = (*n_plocs)+1; + for (i = 0; i < *n_plocs; i++) { + if (plocs[i] <= prel_high) { fin = i; } } fin++; } - move_int( plocs_old, plocs, *n_plocs ); - move_float( f0est_old, f0est, *n_plocs ); + move_int(plocs_old, plocs, *n_plocs); + move_float(f0est_old, f0est, *n_plocs); - j = ( start + 1 ); /* [0..(j-1)] of original LF peaks will be kept */ - /* j now points to first location_c where to add peaks */ + j = (start+1); /* [0..(j-1)] of original LF peaks will be kept */ + /* j now points to first location_c where to add peaks */ - for ( i = 0; i < n_prel; i++ ) - { - plocs[j] = plocs_prel[i]; - f0est[j] = f0est_prel[i]; - j++; - } - for ( i = fin; i < *n_plocs; i++ ) - { - plocs[j] = plocs_old[i]; - f0est[j] = f0est_old[i]; - j++; - } + for (i = 0; i < n_prel; i++) { + plocs[j] = plocs_prel[i]; + f0est[j] = f0est_prel[i]; + j++; + } + for (i = fin; i < *n_plocs; i++) { + plocs[j] = plocs_old[i]; + f0est[j] = f0est_old[i]; + j++; + } *n_plocs = j; + } } } return; } + diff --git a/lib_lc3plus/plc_phecu_rec_frame.c b/lib_lc3plus/plc_phecu_rec_frame.c index db472f3405..0e6570743a 100644 --- a/lib_lc3plus/plc_phecu_rec_frame.c +++ b/lib_lc3plus/plc_phecu_rec_frame.c @@ -1,148 +1,147 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "defines.h" #include "functions.h" -void plc_phEcu_rec_frame( Complex *X_in, - LC3_INT32 L, - LC3_INT32 Lecu, - const LC3_FLOAT *whr, - const LC3_FLOAT *winMDCT, - LC3_INT32 Lprot, - LC3_FLOAT *xfp, - LC3_INT32 time_offs, - LC3_FLOAT *x_out, - Complex *full_spec_dbg, - LC3_FLOAT *ifft_out_dbg, - LC3_FLOAT *xsubst_dbg, - LC3_INT32 LA_ZEROS, - LC3_INT32 LA, - Fft *PhEcu_ifft ) +void plc_phEcu_rec_frame(Complex *X_in, + LC3_INT32 L, + LC3_INT32 Lecu, + const LC3_FLOAT *whr, + const LC3_FLOAT *winMDCT, + LC3_INT32 Lprot, + LC3_FLOAT *xfp, + LC3_INT32 time_offs, + LC3_FLOAT *x_out, + Complex *full_spec_dbg, + LC3_FLOAT* ifft_out_dbg, + LC3_FLOAT* xsubst_dbg, + LC3_INT32 LA_ZEROS, + LC3_INT32 LA, + Fft* PhEcu_ifft +) { - LC3_INT32 i; + LC3_INT32 i; + + LC3_FLOAT xrec[2*MAX_LEN]; + LC3_FLOAT xsubst[2*MAX_LEN]; + LC3_FLOAT xsubst_LL[2*MAX_LEN]; + LC3_FLOAT *pXsubst_LL; + + LC3_INT32 fs_idx; + + LC3_FLOAT *pXfp, *pOlaXsubst, *pXOut; + LC3_INT32 work_part, copy_part, ola_part; - LC3_FLOAT xrec[2 * MAX_LEN]; - LC3_FLOAT xsubst[2 * MAX_LEN]; - LC3_FLOAT xsubst_LL[2 * MAX_LEN]; - LC3_FLOAT *pXsubst_LL; + const LC3_FLOAT *hannOla; + const LC3_FLOAT *pHannOla; - LC3_INT32 fs_idx; + UNUSED(time_offs); + UNUSED(full_spec_dbg); + UNUSED(ifft_out_dbg); + UNUSED(xsubst_dbg); + UNUSED(xsubst_LL); + fs_idx = FRAME2FS_IDX(L); + hannOla = hannOla_wins[fs_idx]; - LC3_FLOAT *pXfp, *pOlaXsubst, *pXOut; - LC3_INT32 work_part, copy_part, ola_part; + X_in[0].i = X_in[Lprot / 2].r; /* move fs/2 real to imag part of X_in[0]*/ - const LC3_FLOAT *hannOla; - const LC3_FLOAT *pHannOla; + real_fft_apply(PhEcu_ifft, (LC3_FLOAT*)X_in, xrec); - UNUSED( time_offs ); - UNUSED( full_spec_dbg ); - UNUSED( ifft_out_dbg ); - UNUSED( xsubst_dbg ); - UNUSED( xsubst_LL ); - fs_idx = FRAME2FS_IDX( L ); - hannOla = hannOla_wins[fs_idx]; + move_float(xsubst, xrec, Lprot); - X_in[0].i = X_in[Lprot / 2].r; /* move fs/2 real to imag part of X_in[0]*/ - real_fft_apply( PhEcu_ifft, (LC3_FLOAT *) X_in, xrec ); - move_float( xsubst, xrec, Lprot ); + { + for (i = 0; i < Lprot; i++) { - { - for ( i = 0; i < Lprot; i++ ) - { + if (whr[i] != 0) { + xsubst[i] = xsubst[i] / whr[i]; /* inverse stored in BASOP */ + } - if ( whr[i] != 0 ) - { - xsubst[i] = xsubst[i] / whr[i]; /* inverse stored in BASOP */ - } - } + } - assert( xsubst_LL != NULL ); - zero_float( xsubst_LL, ( Lecu - Lprot ) / 2 ); /* initial 2ms */ - zero_float( &( xsubst_LL[Lecu - ( Lecu - Lprot ) / 2] ), ( Lecu - Lprot ) / 2 ); /* tail 2ms */ - { - /* position reconstruction properly */ - /* pXsubst_LL = &xsubst_LL[Lecu - Lprot - (Lecu - Lprot) / 2]; */ - pXsubst_LL = &xsubst_LL[( Lecu - Lprot ) / 2]; - for ( i = 0; i < Lprot; i++ ) - { - *pXsubst_LL++ = xsubst[i]; /* copy required 14.25 ms into center */ - } - } - } + assert(xsubst_LL != NULL); + zero_float(xsubst_LL, (Lecu-Lprot)/2); /* initial 2ms */ + zero_float(&(xsubst_LL[ Lecu- (Lecu-Lprot)/2]), (Lecu-Lprot)/2); /* tail 2ms */ + { + /* position reconstruction properly */ + /* pXsubst_LL = &xsubst_LL[Lecu - Lprot - (Lecu - Lprot) / 2]; */ + pXsubst_LL = &xsubst_LL[(Lecu - Lprot) / 2]; + for (i = 0; i < Lprot ; i++) { + *pXsubst_LL++ = xsubst[i]; /* copy required 14.25 ms into center */ + } + } + } - work_part = LA_ZEROS + LA; - copy_part = ( Lecu - Lprot ) / 2; - ola_part = work_part - copy_part; - pXfp = &xfp[Lprot - work_part]; - for ( i = 0; i < copy_part; i++ ) - { - xsubst_LL[i] = *pXfp++; - } - assert( xsubst_LL != NULL ); - pOlaXsubst = &( xsubst_LL[copy_part] ); - pHannOla = hannOla; - for ( i = 0; i < ola_part; i++ ) - { - *pOlaXsubst = *pOlaXsubst * *pHannOla++; - pOlaXsubst++; - } + work_part = LA_ZEROS + LA; + copy_part = (Lecu - Lprot) / 2; + ola_part = work_part - copy_part; - pOlaXsubst = &( xsubst_LL[copy_part] ); - for ( i = 0; i < ola_part; i++ ) - { - *pOlaXsubst = *pOlaXsubst + *pXfp++ * *pHannOla--; - pOlaXsubst++; - } + pXfp = &xfp[Lprot - work_part]; + for (i = 0; i < copy_part; i++) { + xsubst_LL[i] = *pXfp++; + } + assert(xsubst_LL != NULL); + pOlaXsubst = &(xsubst_LL[copy_part]); + pHannOla = hannOla; + for (i = 0; i < ola_part; i++) { + *pOlaXsubst = *pOlaXsubst * *pHannOla++; + pOlaXsubst++; + } - /* clear x_out to start with */ - assert( x_out != NULL ); - zero_float( x_out, L ); + pOlaXsubst = &(xsubst_LL[copy_part]); + for (i = 0; i < ola_part; i++) { + *pOlaXsubst = *pOlaXsubst + *pXfp++ * *pHannOla--; + pOlaXsubst++; + } - for ( i = 0; i < ( Lecu - LA_ZEROS ); i++ ) - { + /* clear x_out to start with */ + assert(x_out != NULL); + zero_float(x_out, L); - xsubst_LL[i] = xsubst_LL[i] * winMDCT[i]; /* xsubstLL windowing up to 16.25 ms i.e not last 3.75 ms */ - } - zero_float( &( xsubst_LL[Lecu - LA_ZEROS] ), LA_ZEROS ); /* tail 3.75ms always zero */ - /* perform tda */ + for (i = 0; i < (Lecu - LA_ZEROS); i++) { + + xsubst_LL[i] = xsubst_LL[i] * winMDCT[i]; /* xsubstLL windowing up to 16.25 ms i.e not last 3.75 ms */ + + } + zero_float(&(xsubst_LL[Lecu - LA_ZEROS]), LA_ZEROS); /* tail 3.75ms always zero */ + + /* perform tda */ /* first half */ - pXsubst_LL = &xsubst_LL[3 * Lecu / 4]; - pXfp = &xsubst_LL[( 3 * Lecu / 4 ) - 1]; - - pXOut = x_out; - for ( i = 0; i < Lecu / 4; i++ ) - { - *pXOut++ = -*pXsubst_LL++ - *pXfp--; /* 3.75 ms mults with 0 . may be skipped, see BASOP */ - } - - /* second half */ - /* */ - - pXsubst_LL = &( xsubst_LL[0] ); - pXfp = &xsubst_LL[( Lecu / 2 ) - 1]; - for ( i = 0; i < Lecu / 4; i++ ) - { - *pXOut++ = *pXsubst_LL++ - *pXfp--; - } + pXsubst_LL = &xsubst_LL[3 * Lecu / 4]; + pXfp = &xsubst_LL[(3 * Lecu / 4) - 1]; + + pXOut = x_out; + for (i = 0; i < Lecu / 4; i++) { + *pXOut++ = -*pXsubst_LL++ - *pXfp--; /* 3.75 ms mults with 0 . may be skipped, see BASOP */ + } + + /* second half */ + /* */ + + pXsubst_LL = &(xsubst_LL[0]); + pXfp = &xsubst_LL[(Lecu / 2) - 1]; + for (i = 0; i < Lecu / 4; i++) { + *pXOut++ = *pXsubst_LL++ - *pXfp--; + } } + diff --git a/lib_lc3plus/plc_phecu_setf0hz.c b/lib_lc3plus/plc_phecu_setf0hz.c index 716d0bd3fc..b14327e2b2 100644 --- a/lib_lc3plus/plc_phecu_setf0hz.c +++ b/lib_lc3plus/plc_phecu_setf0hz.c @@ -1,27 +1,28 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "defines.h" #include "functions.h" -LC3_FLOAT plc_phEcuSetF0Hz( LC3_INT32 fs, LC3_FLOAT *old_pitchPtr ) +LC3_FLOAT plc_phEcuSetF0Hz(LC3_INT32 fs, LC3_FLOAT * old_pitchPtr) { LC3_FLOAT result; result = 0; - if ( *old_pitchPtr != 0 ) + if (*old_pitchPtr != 0) { - result = LC3_ROUND( fs / ( *old_pitchPtr ) / PHECU_FRES * 128.0 ) / 128.0; + result = LC3_ROUND(fs/(*old_pitchPtr)/PHECU_FRES * 128.0) / 128.0; } return result; } + diff --git a/lib_lc3plus/plc_phecu_spec_ana.c b/lib_lc3plus/plc_phecu_spec_ana.c index bec60147db..b496900305 100644 --- a/lib_lc3plus/plc_phecu_spec_ana.c +++ b/lib_lc3plus/plc_phecu_spec_ana.c @@ -1,64 +1,65 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "defines.h" #include "functions.h" -#define PEAK_LOCATOR_RES_FX 1 /* fixed point resolution minimum value */ +#define PEAK_LOCATOR_RES_FX 1 /* fixed point resolution minimum value */ -static LC3_INT16 plc_phEcu_find_ind_fx( /* o : output maximum indx 0.. len-1 */ - const LC3_INT16 *inp, /* i : vector */ - const LC3_INT16 len, /* i : length */ - const LC3_INT16 val /* i : value to find */ +static LC3_INT16 plc_phEcu_find_ind_fx( /* o : output maximum indx 0.. len-1 */ + const LC3_INT16 *inp, /* i : vector */ + const LC3_INT16 len, /* i : length */ + const LC3_INT16 val /* i : value to find */ ); -static void plc_phEcu_peak_locator_fxlike( const LC3_INT16 *inp, /* i: vector with values >=0 ,Qx */ - const LC3_INT16 inp_len, /* i: length of inp */ - LC3_INT16 *int_plocs, /* o: array of filtered integer plocs Q0 */ - LC3_INT16 *n_fsc, /* o: total_ number of filtered located highs Q0 */ - const LC3_INT16 sens, /* i sensitivity, Qx */ - const LC3_INT16 inp_high, /* i global high , Qx */ - const LC3_INT16 inp_low /* i: global low, Qx */ +static void plc_phEcu_peak_locator_fxlike(const LC3_INT16 *inp, /* i: vector with values >=0 ,Qx */ + const LC3_INT16 inp_len, /* i: length of inp */ + LC3_INT16 * int_plocs, /* o: array of filtered integer plocs Q0 */ + LC3_INT16 * n_fsc, /* o: total_ number of filtered located highs Q0 */ + const LC3_INT16 sens, /* i sensitivity, Qx */ + const LC3_INT16 inp_high, /* i global high , Qx */ + const LC3_INT16 inp_low /* i: global low, Qx */ ); -void plc_phEcu_spec_ana( LC3_FLOAT *xfp, - LC3_INT32 xfp_len, - const LC3_FLOAT *whr, - LC3_FLOAT *pfind_sensPtr, - LC3_INT32 *plocs, - LC3_INT32 *n_plocs, - LC3_FLOAT *f0est, - Complex *x, - LC3_INT32 *x_len, - LC3_FLOAT *f0hzLtpBinPtr, - LC3_FLOAT *f0gainLtpPtr, - LC3_INT32 bw_idx, - Fft *PhEcu_fft ) +void plc_phEcu_spec_ana(LC3_FLOAT* xfp, + LC3_INT32 xfp_len, + const LC3_FLOAT* whr, + LC3_FLOAT *pfind_sensPtr, + LC3_INT32* plocs, + LC3_INT32* n_plocs, + LC3_FLOAT* f0est, + Complex* x, + LC3_INT32* x_len, + LC3_FLOAT * f0hzLtpBinPtr, + LC3_FLOAT * f0gainLtpPtr, + LC3_INT32 bw_idx, + Fft* PhEcu_fft +) { - LC3_INT32 i, peak_range_1, curr; - LC3_FLOAT xfp_w[MAX_PLC_LPROT]; - - LC3_FLOAT Xabs[MAX_LEN] = { 0 }; - LC3_FLOAT inp_high, inp_low, sens; - LC3_FLOAT interPos; - Complex Xana_p[3]; - LC3_INT32 P_in_plocs; - LC3_INT32 nSubs; - LC3_INT32 n_plocs_in; - LC3_FLOAT phEcu_c_jacob[1]; + LC3_INT32 i, peak_range_1, curr; + LC3_FLOAT xfp_w[MAX_PLC_LPROT]; + + LC3_FLOAT Xabs[MAX_LEN] = {0}; + LC3_FLOAT inp_high, inp_low, sens; + LC3_FLOAT interPos; + Complex Xana_p[3]; + LC3_INT32 P_in_plocs; + LC3_INT32 nSubs; + LC3_INT32 n_plocs_in; + LC3_FLOAT phEcu_c_jacob[1]; LC3_FLOAT fx_fft_scale; LC3_FLOAT fft_fs_scale; @@ -67,495 +68,472 @@ void plc_phEcu_spec_ana( LC3_FLOAT *xfp, LC3_FLOAT PLC2_Q_flt; LC3_FLOAT Q_scale_flt; - LC3_INT16 Xabs_fx[MAX_LEN]; - LC3_INT16 plocs_fx[MAX_LEN]; - - LC3_INT16 sens_fx; - LC3_INT16 inp_high_fx; - LC3_INT16 inp_low_fx; - LC3_INT16 n_plocs_fx; + LC3_INT16 Xabs_fx[MAX_LEN]; + LC3_INT16 plocs_fx[MAX_LEN]; - LC3_FLOAT pfind_sens; - LC3_FLOAT f0hzLtpBin; - LC3_FLOAT f0gainLtp; + LC3_INT16 sens_fx; + LC3_INT16 inp_high_fx; + LC3_INT16 inp_low_fx; + LC3_INT16 n_plocs_fx; - pfind_sens = *pfind_sensPtr; - f0hzLtpBin = *f0hzLtpBinPtr; - f0gainLtp = *f0gainLtpPtr; + LC3_FLOAT pfind_sens ; + LC3_FLOAT f0hzLtpBin ; + LC3_FLOAT f0gainLtp ; + + pfind_sens = *pfind_sensPtr; + f0hzLtpBin = *f0hzLtpBinPtr; + f0gainLtp = *f0gainLtpPtr; - for ( i = 0; i < xfp_len; i++ ) + for (i = 0; i < xfp_len; i++) { - xfp_w[i] = xfp[i] * whr[i]; /* whr windowing may be split into three segments , two loops, and possibly inplace */ + xfp_w[i] = xfp[i] * whr[i]; /* whr windowing may be split into three segments , two loops, and possibly inplace */ } - real_fft_apply( PhEcu_fft, xfp_w, (LC3_FLOAT *) x ); - - x[xfp_len / 2].r = x[0].i; /* move the real Fs/2 value to end */ - x[xfp_len / 2].i = 0; /* safety clear imaginary Fs/2 value at end */ - x[0].i = 0.0; /* safety, make DC value only real */ - - - *x_len = xfp_len / 2 + 1; - - i = (LC3_INT32) LC3_FLOOR( 20000.0 / PHECU_FRES ) + 1; - zero_cmplx( &( x[i] ), *x_len - i ); - - peak_range_1 = (LC3_INT32) MIN( *x_len, ( 40000.0 / 100 * 1.6 ) / 2 + 1 ); - - plc_phEcu_fft_spec2_sqrt_approx( x, peak_range_1, Xabs ); - - zero_float( &( Xabs[peak_range_1] ), *x_len - peak_range_1 ); - + real_fft_apply(PhEcu_fft, xfp_w, (LC3_FLOAT *)x); + + x[xfp_len/2].r = x[0].i; /* move the real Fs/2 value to end */ + x[xfp_len/2].i = 0; /* safety clear imaginary Fs/2 value at end */ + x[0].i = 0.0; /* safety, make DC value only real */ + + + *x_len = xfp_len/2 + 1; + + i =(LC3_INT32) LC3_FLOOR(20000.0/PHECU_FRES)+1; + zero_cmplx( &(x[i]), *x_len - i); + + peak_range_1 = (LC3_INT32) MIN(*x_len, (40000.0 / 100 * 1.6) / 2 + 1); + + plc_phEcu_fft_spec2_sqrt_approx(x, peak_range_1, Xabs); + + zero_float(&(Xabs[peak_range_1]), *x_len - peak_range_1); + inp_high = Xabs[0]; inp_low = Xabs[0]; - - for ( i = 1; i < peak_range_1; i++ ) - { - inp_high = MAX( inp_high, Xabs[i] ); - inp_low = MIN( inp_low, Xabs[i] ); + + for (i = 1; i < peak_range_1; i++) { + inp_high = MAX(inp_high, Xabs[i]); + inp_low = MIN(inp_low, Xabs[i]); } - - sens = ( inp_high - inp_low ) * ( 1 - pfind_sens ); - - if ( inp_high > ( (LC3_FLOAT) PEAK_LOCATOR_RES_FX ) / 2.0 ) - { - { - /* from ROM constants.c */ - LC3_FLOAT fx_fft_scales[5] = { 6, 7, 7, 8, 8 }; /*NB,WB, sSWB, SWB, FB*/ - fx_fft_scale = LC3_POW( 2.0, fx_fft_scales[bw_idx] ); /*% scaling due to up / dn pre shifts in fx FFT */ - } - { /* from ROM constants.c */ - LC3_FLOAT fx_fs_scales[5] = { 1.0, 1.0, 1.5, 1.0, 1.5 }; /*NB,WB, sSWB, SWB, FB*/ - fft_fs_scale = fx_fs_scales[bw_idx]; - } - - - max_xfp_abs = (LC3_FLOAT) LC3_FABS( xfp[0] ); - for ( i = 1; i < xfp_len; i++ ) + + sens = (inp_high-inp_low)*(1-pfind_sens); + + if (inp_high > ((LC3_FLOAT) PEAK_LOCATOR_RES_FX)/2.0) + { + { + /* from ROM constants.c */ + LC3_FLOAT fx_fft_scales[5] = { 6, 7, 7, 8, 8 }; /*NB,WB, sSWB, SWB, FB*/ + fx_fft_scale = LC3_POW(2.0, fx_fft_scales[bw_idx]); /*% scaling due to up / dn pre shifts in fx FFT */ + } + { /* from ROM constants.c */ + LC3_FLOAT fx_fs_scales[5] = { 1.0, 1.0, 1.5, 1.0, 1.5 }; /*NB,WB, sSWB, SWB, FB*/ + fft_fs_scale = fx_fs_scales[bw_idx]; + } + + + max_xfp_abs = (LC3_FLOAT) LC3_FABS(xfp[0]); + for (i = 1; i < xfp_len; i++) { + max_xfp_abs = (LC3_FLOAT) MAX(max_xfp_abs, LC3_FABS(xfp[i])); + } + + if (max_xfp_abs >= 0.5) + { + PLC2_Q_flt = (LC3_FLOAT)LC3_FLOOR(LC3_LOGTWO(32768 / 2 / 2 / max_xfp_abs)); + Q_scale_flt = LC3_POW(2.0, PLC2_Q_flt) / fx_fft_scale / fft_fs_scale; /* basop way using xfp scale */ + + /* C-Float additional safety limit/verification of the integer xfp based scaling using the available C-float Xabs max value inp_high as well */ + { + LC3_FLOAT tmp_scale; + tmp_scale = LC3_POW(2.0, LC3_FLOOR(LC3_LOGTWO(32768 / 2 / 2 / inp_high))); + if (Q_scale_flt > tmp_scale) { + Q_scale_flt = tmp_scale; + } + } + /* Round sens, inp_high, inp_low according to BASOP fix-point scaling */ + + for (i = 0; i < peak_range_1; i++) { + Xabs_fx[i] = (LC3_INT16) LC3_ROUND(Xabs[i] * Q_scale_flt) ; + } + sens_fx = (LC3_INT16) LC3_ROUND(sens * Q_scale_flt) ; + inp_high_fx = (LC3_INT16) LC3_ROUND(inp_high * Q_scale_flt) ; + inp_low_fx = (LC3_INT16) LC3_ROUND(inp_low * Q_scale_flt) ; + plc_phEcu_peak_locator_fxlike(Xabs_fx, peak_range_1, plocs_fx, &n_plocs_fx, sens_fx, inp_high_fx, inp_low_fx); + + *n_plocs = (LC3_INT32)n_plocs_fx; + for (i = 0; i < *n_plocs; i++) { + plocs[i] = (LC3_INT32)plocs_fx[i]; /* short Word16 values now stored/saved as Word32 */ + } + } + else { - max_xfp_abs = (LC3_FLOAT) MAX( max_xfp_abs, LC3_FABS( xfp[i] ) ); - } - - if ( max_xfp_abs >= 0.5 ) - { - PLC2_Q_flt = (LC3_FLOAT) LC3_FLOOR( LC3_LOGTWO( 32768 / 2 / 2 / max_xfp_abs ) ); - Q_scale_flt = LC3_POW( 2.0, PLC2_Q_flt ) / fx_fft_scale / fft_fs_scale; /* basop way using xfp scale */ - - /* C-Float additional safety limit/verification of the integer xfp based scaling using the available C-float Xabs max value inp_high as well */ - { - LC3_FLOAT tmp_scale; - tmp_scale = LC3_POW( 2.0, LC3_FLOOR( LC3_LOGTWO( 32768 / 2 / 2 / inp_high ) ) ); - if ( Q_scale_flt > tmp_scale ) - { - Q_scale_flt = tmp_scale; - } - } - /* Round sens, inp_high, inp_low according to BASOP fix-point scaling */ - - for ( i = 0; i < peak_range_1; i++ ) - { - Xabs_fx[i] = (LC3_INT16) LC3_ROUND( Xabs[i] * Q_scale_flt ); - } - sens_fx = (LC3_INT16) LC3_ROUND( sens * Q_scale_flt ); - inp_high_fx = (LC3_INT16) LC3_ROUND( inp_high * Q_scale_flt ); - inp_low_fx = (LC3_INT16) LC3_ROUND( inp_low * Q_scale_flt ); - plc_phEcu_peak_locator_fxlike( Xabs_fx, peak_range_1, plocs_fx, &n_plocs_fx, sens_fx, inp_high_fx, inp_low_fx ); - - *n_plocs = (LC3_INT32) n_plocs_fx; - for ( i = 0; i < *n_plocs; i++ ) - { - plocs[i] = (LC3_INT32) plocs_fx[i]; /* short Word16 values now stored/saved as Word32 */ - } - } - else - { - *n_plocs = 0; /* time domain xfp level near zero */ + *n_plocs = 0; /* time domain xfp level near zero */ } } else { *n_plocs = 0; /* Freq domain Xabs max level near zero */ } - - for ( i = 0; i < *n_plocs; i++ ) - { - curr = plocs[i]; - if ( curr == 0 ) - { - interPos = plc_phEcu_interp_max( Xabs, 3 ); /* returns 0.0 ... 2.0 */ - if ( interPos == 2 ) - { - /* integer peak was at DC, restrict to one of coeffs at [DC or DC+1] */ - interPos = plc_phEcu_interp_max( Xabs, 2 ); /* returns 0.0 or 1.0 */ + + for (i = 0; i < *n_plocs; i++) { + curr = plocs[i]; + if (curr == 0) { + interPos = plc_phEcu_interp_max(Xabs, 3); /* returns 0.0 ... 2.0 */ + if (interPos == 2) { + /* integer peak was at DC, restrict to one of coeffs at [DC or DC+1] */ + interPos = plc_phEcu_interp_max(Xabs, 2); /* returns 0.0 or 1.0 */ } interPos += plocs[i]; - } - else if ( curr == 1 ) - { - interPos = plc_phEcu_interp_max( Xabs, 3 ); + } else if (curr == 1) { + interPos = plc_phEcu_interp_max(Xabs, 3); interPos += plocs[i] - 1; - } - else if ( curr == *x_len - 2 ) - { - interPos = plc_phEcu_interp_max( &Xabs[*x_len - 3], 3 ); + } else if (curr == *x_len - 2) { + interPos = plc_phEcu_interp_max(&Xabs[*x_len - 3], 3); interPos += plocs[i] - 1; - } - else if ( curr == *x_len - 1 ) - { - /* integer curr at Fs/2, a real coeff */ - interPos = plc_phEcu_interp_max( &Xabs[*x_len - 3], 3 ); /* returns 0.0 ... 2.0 */ - interPos += plocs[i] - 2; /* valid for range ]... 1.0 ... 2.0] , where 1 is fs/2-1 and 2.0 is Fs/2 */ - if ( interPos == 0 ) - { - /* restrict to one of coeffs at [fs/2-1, fs/2 ] */ - interPos = plc_phEcu_interp_max( &Xabs[*x_len - 2], 2 ); /* returns 0.0 or 1.0 */ + } else if (curr == *x_len - 1) { + /* integer curr at Fs/2, a real coeff */ + interPos = plc_phEcu_interp_max(&Xabs[*x_len - 3], 3); /* returns 0.0 ... 2.0 */ + interPos += plocs[i] - 2; /* valid for range ]... 1.0 ... 2.0] , where 1 is fs/2-1 and 2.0 is Fs/2 */ + if (interPos == 0) { + /* restrict to one of coeffs at [fs/2-1, fs/2 ] */ + interPos = plc_phEcu_interp_max(&Xabs[*x_len - 2], 2); /* returns 0.0 or 1.0 */ interPos += plocs[i] - 1; - } + } - if ( interPos > ( *x_len - 1 ) ) - { /* interPos only defined up to Fs/2 */ - interPos = (LC3_FLOAT) ( *x_len - 1 ); + if (interPos > (*x_len - 1) ) { /* interPos only defined up to Fs/2 */ + interPos = (LC3_FLOAT)(*x_len - 1); } - } - else - { - Xana_p[0] = x[plocs[i] - 1]; + } else { + Xana_p[0] = x[plocs[i]-1]; Xana_p[1] = x[plocs[i]]; - Xana_p[2] = x[plocs[i] + 1]; - phEcu_c_jacob[0] = (LC3_FLOAT) PHECU_C_JACOB; - interPos = plc_phEcu_imax2_jacobsen_mag( Xana_p, phEcu_c_jacob ); + Xana_p[2] = x[plocs[i]+1]; + phEcu_c_jacob[0] = (LC3_FLOAT)PHECU_C_JACOB; + interPos = plc_phEcu_imax2_jacobsen_mag(Xana_p, phEcu_c_jacob ); interPos += (LC3_FLOAT) plocs[i]; - } + } f0est[i] = interPos; } - - if ( *n_plocs >= 2 && plocs[0] == 0 && - f0est[0] > f0est[1] && plocs[1] <= 2 && Xabs[0] < Xabs[plocs[1] + 1] ) - { + + if (*n_plocs >= 2 && plocs[0] == 0 && + f0est[0] > f0est[1] && plocs[1] <= 2 && Xabs[0] < Xabs[plocs[1]+1]) + { f0est[0] = f0est[1]; } - - P_in_plocs = plc_phEcu_pitch_in_plocs( plocs, *n_plocs ); - - if ( f0hzLtpBin > 0.0 && P_in_plocs > 0 ) - { + + P_in_plocs = plc_phEcu_pitch_in_plocs(plocs, *n_plocs); + + if (f0hzLtpBin > 0.0 && P_in_plocs > 0) { nSubs = 2; n_plocs_in = *n_plocs; - plc_phEcu_LF_peak_analysis( plocs, n_plocs, f0est, Xabs, &f0hzLtpBin, &f0gainLtp, nSubs ); - - if ( n_plocs_in == *n_plocs ) - { + plc_phEcu_LF_peak_analysis(plocs, n_plocs, f0est, Xabs, &f0hzLtpBin, &f0gainLtp, nSubs); + + if (n_plocs_in == *n_plocs) { nSubs = 3; - plc_phEcu_F0_refine_first( plocs, *n_plocs, f0est, *x_len, &f0hzLtpBin, &f0gainLtp, nSubs ); + plc_phEcu_F0_refine_first(plocs, *n_plocs, f0est, *x_len, &f0hzLtpBin, &f0gainLtp, nSubs); } } - - if ( f0gainLtp > 0.0 && f0gainLtp < 0.5 && *n_plocs > 14 ) - { - if ( P_in_plocs > 0 ) - { + + if (f0gainLtp > 0.0 && f0gainLtp < 0.5 && *n_plocs > 14) { + if (P_in_plocs > 0) { *n_plocs = 0; } } - return; + return; } -#define sub( a, b ) ( a - b ) -#define add( a, b ) ( a + b ) -#define s_xor( a, b ) ( a ^ b ) +#define sub(a,b) (a - b) +#define add(a,b) (a + b) +#define s_xor(a,b) (a ^ b) /* in case a value (e.g max or min) is already known , find the first corresponding array index */ -static LC3_INT16 plc_phEcu_find_ind_fx( /* o : output maximum indx 0.. len-1 */ - const LC3_INT16 *inp, /* i : vector */ - const LC3_INT16 len, /* i : length */ - const LC3_INT16 val /* i : value to find */ +static LC3_INT16 plc_phEcu_find_ind_fx( /* o : output maximum indx 0.. len-1 */ + const LC3_INT16 *inp, /* i : vector */ + const LC3_INT16 len, /* i : length */ + const LC3_INT16 val /* i : value to find */ ) { - LC3_INT16 val_ind; + LC3_INT16 val_ind; LC3_INT16 pos; - val_ind = -1; + val_ind = -1; - for ( pos = 0; pos < len; pos++ ) + for(pos = 0; pos < len; pos++) { - if ( sub( inp[pos], val ) == 0 ) + if (sub(inp[pos], val) == 0) { val_ind = pos; } } - return val_ind; + return val_ind; } + /* BASOP function adapted to compile in float/integer environment */ /*----------------------------------------------------------------------------- * plc_phEcu_peak_locator_fxlike() *----------------------------------------------------------------------------*/ -static void plc_phEcu_peak_locator_fxlike( const LC3_INT16 *inp, /* i: vector with values >=0 ,Qx */ - const LC3_INT16 inp_len, /* i: length of inp */ - LC3_INT16 *int_plocs, /* o: array of filtered integer plocs Q0 */ - LC3_INT16 *n_fsc, /* o: total_ number of filtered located highs Q0 */ - const LC3_INT16 sens, /* i sensitivity, Qx */ - const LC3_INT16 inp_high, /* i global high , Qx */ - const LC3_INT16 inp_low /* i: global low, Qx */ +static void plc_phEcu_peak_locator_fxlike(const LC3_INT16 *inp, /* i: vector with values >=0 ,Qx */ + const LC3_INT16 inp_len, /* i: length of inp */ + LC3_INT16 * int_plocs, /* o: array of filtered integer plocs Q0 */ + LC3_INT16 * n_fsc, /* o: total_ number of filtered located highs Q0 */ + const LC3_INT16 sens, /* i sensitivity, Qx */ + const LC3_INT16 inp_high, /* i global high , Qx */ + const LC3_INT16 inp_low /* i: global low, Qx */ ) { - LC3_INT16 j, k, n, idx_high, idx_low; - LC3_INT16 inp_len_minus1; - LC3_INT16 pairs_start, pairs_end; - LC3_INT16 *p_tmp; - LC3_INT16 prev_delta, curr_delta; - LC3_INT16 delta_predc, delta_fin; - LC3_INT16 add_dc_flag, add_fin_flag; - LC3_INT16 low_val_cand_pairs, val_range; - LC3_INT16 num_pairs, n_tail_values; - LC3_INT16 cand_phase_start, cand_idx, prev_low_plus_sens, tmp; - LC3_INT16 cand_high, prev_low; - LC3_INT16 *cand_pairs; /* actually [DC ] + pairs + [FS/2] */ - - LC3_INT16 sc_idx[1 + 368 + 1]; - LC3_INT16 cand_pairs_buf[1 + 1 + 368 + 1]; - LC3_INT16 fsc_idx[1 + 368 / 2 + 1]; - - - inp_len_minus1 = sub( inp_len, 1 ); /* size of delta=derivative array ,and last index in inp */ - - cand_pairs = &cand_pairs_buf[1]; /* ptr init , make space for storing a lowest amplitude value in location -1 */ + LC3_INT16 j, k, n, idx_high, idx_low; + LC3_INT16 inp_len_minus1; + LC3_INT16 pairs_start, pairs_end; + LC3_INT16 *p_tmp; + LC3_INT16 prev_delta, curr_delta; + LC3_INT16 delta_predc, delta_fin; + LC3_INT16 add_dc_flag, add_fin_flag; + LC3_INT16 low_val_cand_pairs, val_range; + LC3_INT16 num_pairs, n_tail_values; + LC3_INT16 cand_phase_start, cand_idx, prev_low_plus_sens, tmp; + LC3_INT16 cand_high, prev_low; + LC3_INT16 *cand_pairs; /* actually [DC ] + pairs + [FS/2] */ + + LC3_INT16 sc_idx[1 + 368 + 1]; + LC3_INT16 cand_pairs_buf[1 + 1 + 368 + 1]; + LC3_INT16 fsc_idx[1 + 368 / 2 + 1]; + + + inp_len_minus1 = sub(inp_len, 1); /* size of delta=derivative array ,and last index in inp */ + + cand_pairs = &cand_pairs_buf[1]; /* ptr init , make space for storing a lowest amplitude value in location -1 */ pairs_start = 1; /* adjusted to zero or 1 or 2 when/if, DC is injected as sc_idx[0], or initial plateau skipped */ - p_tmp = &( sc_idx[pairs_start] ); /* ptr init */ + p_tmp = &(sc_idx[pairs_start]); /* ptr init */ /* xor high/low pairs of delta_inp and save sign changes */ - prev_delta = sub( inp[1], inp[0] ); /* precompute very first delta */ + prev_delta = sub(inp[1], inp[0]); /* precompute very first delta */ - for ( n = 1; n < inp_len_minus1; n++ ) - { /* sign change analysis */ - curr_delta = sub( inp[n + 1], inp[n] ); /* n+1 ,n , are loop ptrs */ - if ( s_xor( prev_delta, curr_delta ) < 0 ) /* a "0" delta treated as a positive sign */ + for(n = 1; n < inp_len_minus1; n++) + { /* sign change analysis */ + curr_delta = sub(inp[n + 1], inp[n]); /* n+1 ,n , are loop ptrs */ + if (s_xor(prev_delta, curr_delta) < 0) /* a "0" delta treated as a positive sign */ { - *p_tmp++ = n; /* store sign change bin locations , location n in the inp[] signal */ + *p_tmp++ = n; /* store sign change bin locations , location n in the inp[] signal */ } - prev_delta = curr_delta; + prev_delta = curr_delta; } - k = (LC3_INT16) ( p_tmp - &( sc_idx[pairs_start] ) ); + k = (LC3_INT16)(p_tmp - &(sc_idx[pairs_start])); /* copy sign change location values to a pairs array */ /* leave one initial sc_idx location open for a potential initial DC value */ - for ( j = 0; j < k; j++ ) - { - cand_pairs[j + pairs_start] = inp[sc_idx[j + pairs_start]]; + for(j = 0; j < k; j++){ + cand_pairs[j + pairs_start] = inp[sc_idx[j + pairs_start]]; } /* filter away a potential single initial/trailing plateau to enable correct analysis for adding DC or fs/2 bins */ - - if ( ( sub( k, 2 ) >= 0 ) && - ( sub( cand_pairs[pairs_start], cand_pairs[pairs_start + 1] ) == 0 ) ) - { - pairs_start = add( pairs_start, 1 ); - k = sub( k, 1 ); + + if((sub(k, 2) >= 0) && + (sub(cand_pairs[pairs_start], cand_pairs[pairs_start + 1]) == 0)){ + pairs_start = add(pairs_start, 1); + k = sub(k, 1); } /* filter away potential single trailing plateu */ - pairs_end = sub( add( pairs_start, k ), 1 ); /* point to last established sign change element */ - - if ( ( sub( k, 2 ) >= 0 ) && - ( sub( cand_pairs[sub( pairs_end, 1 )], cand_pairs[pairs_end] ) == 0 ) ) - { - k = sub( k, 1 ); + pairs_end = sub(add(pairs_start, k), 1); /* point to last established sign change element */ + + if ((sub(k, 2) >= 0) && + (sub(cand_pairs[sub(pairs_end, 1)], cand_pairs[pairs_end]) == 0)){ + k = sub(k, 1); } - pairs_end = sub( add( pairs_start, k ), 1 ); /* recalc ptr to last element */ + pairs_end = sub(add(pairs_start, k), 1); /* recalc ptr to last element */ /* conditionally add high/lows on both sides of input (pre_dc or fin) as candidates */ - add_dc_flag = 0; - add_fin_flag = 0; + add_dc_flag = 0; + add_fin_flag = 0; - if ( sub( k, 1 ) == 0 ) /* one single sign change found special case */ + if(sub(k, 1) == 0) /* one single sign change found special case */ { - if ( sub( inp[0], cand_pairs[pairs_start] ) != 0 ) + if (sub(inp[0], cand_pairs[pairs_start]) != 0) { - add_dc_flag = 1; /* not plateau */ + add_dc_flag = 1; /* not plateau */ } - if ( sub( cand_pairs[pairs_end], inp[inp_len_minus1] ) != 0 ) + if (sub(cand_pairs[pairs_end], inp[inp_len_minus1]) != 0) { - add_fin_flag = 1; /* not plateau */ + add_fin_flag = 1; /* not plateau */ } } - if ( sub( k, 2 ) >= 0 ) + if(sub(k, 2) >= 0) { - delta_predc = sub( cand_pairs[pairs_start + 1], cand_pairs[pairs_start] ); - delta_fin = sub( cand_pairs[pairs_end], cand_pairs[pairs_end - 1] ); + delta_predc = sub(cand_pairs[pairs_start + 1], cand_pairs[pairs_start]); + delta_fin = sub(cand_pairs[pairs_end], cand_pairs[pairs_end - 1]); /* plateaus are allowed to be detected by xor sign change, but still not allowed at the start nor at the end */ - add_dc_flag = 1; - if ( sub( inp[0], cand_pairs[pairs_start] ) == 0 ) + add_dc_flag = 1; + if (sub(inp[0], cand_pairs[pairs_start]) == 0) { - add_dc_flag = 0; /* plateau down or , plateaus up., --> do not add DC */ + add_dc_flag = 0; /* plateau down or , plateaus up., --> do not add DC */ } - - if ( ( sub( inp[0], cand_pairs[pairs_start] ) < 0 ) && ( delta_predc > 0 ) ) + + if ((sub(inp[0], cand_pairs[pairs_start]) < 0) && (delta_predc > 0)) { - add_dc_flag = -1; /*UP - up ... replace */ + add_dc_flag = -1; /*UP - up ... replace */ } - - if ( ( sub( inp[0], cand_pairs[pairs_start] ) > 0 ) && ( delta_predc < 0 ) ) + + if ((sub(inp[0], cand_pairs[pairs_start]) > 0) && (delta_predc < 0)) { - add_dc_flag = -1; /* DOWN - down ... % replace */ + add_dc_flag = -1; /* DOWN - down ... % replace */ } - add_fin_flag = 1; - if ( sub( cand_pairs[pairs_end], inp[inp_len_minus1] ) == 0 ) + add_fin_flag = 1; + if (sub(cand_pairs[pairs_end], inp[inp_len_minus1]) == 0) { - add_fin_flag = 0; /* up - plateau ... */ + add_fin_flag = 0; /* up - plateau ... */ } - - if ( ( delta_fin > 0 ) && ( sub( cand_pairs[pairs_end], inp[inp_len_minus1] ) < 0 ) ) + + if ((delta_fin > 0) && (sub(cand_pairs[pairs_end], inp[inp_len_minus1]) < 0)) { - add_fin_flag = -1; /* up - UP ... % replace , hard to hit */ + add_fin_flag = -1; /* up - UP ... % replace , hard to hit */ } - - if ( ( delta_fin < 0 ) && ( sub( cand_pairs[pairs_end], inp[inp_len_minus1] ) > 0 ) ) + + if ((delta_fin < 0) && (sub(cand_pairs[pairs_end], inp[inp_len_minus1]) > 0)) { - add_fin_flag = -1; /*down - DOWN ... % replace */ + add_fin_flag = -1; /*down - DOWN ... % replace */ } + } - if ( add_dc_flag > 0 ) - { /* add DC */ - pairs_start = sub( pairs_start, 1 ); - cand_pairs[pairs_start] = inp[0]; - sc_idx[pairs_start] = 0; - k = add( k, 1 ); + if(add_dc_flag > 0) + { /* add DC */ + pairs_start = sub(pairs_start, 1); + cand_pairs[pairs_start] = inp[0]; + sc_idx[pairs_start] = 0; + k = add(k, 1); } - if ( add_dc_flag < 0 ) + if(add_dc_flag < 0) { /* -1 --> replace with DC*/ - cand_pairs[pairs_start] = inp[0]; - sc_idx[pairs_start] = 0; + cand_pairs[pairs_start] = inp[0]; + sc_idx[pairs_start] = 0; } - if ( add_fin_flag > 0 ) - { /* add FS/2 */ - pairs_end = add( pairs_end, 1 ); - cand_pairs[pairs_end] = inp[inp_len_minus1]; - sc_idx[pairs_end] = inp_len_minus1; - k = add( k, 1 ); + if(add_fin_flag > 0) + { /* add FS/2 */ + pairs_end = add(pairs_end, 1); + cand_pairs[pairs_end] = inp[inp_len_minus1]; + sc_idx[pairs_end] = inp_len_minus1; + k = add(k, 1); } - if ( add_fin_flag < 0 ) - { /* -1, replace tail with FS/2*/ - cand_pairs[pairs_end] = inp[inp_len_minus1]; - sc_idx[pairs_end] = inp_len_minus1; + if(add_fin_flag < 0) + { /* -1, replace tail with FS/2*/ + cand_pairs[pairs_end] = inp[inp_len_minus1]; + sc_idx[pairs_end] = inp_len_minus1; } /* preliminary cand_pairs now only have highs , lows , no initial/trailing plateaus */ /* we allow the DC/FsBy2 lows to be used as the candidatelLow */ - low_val_cand_pairs = inp_low; - val_range = sub( inp_high, low_val_cand_pairs ); /* used to determine if search is useful at all */ - + low_val_cand_pairs = inp_low; + val_range = sub(inp_high, low_val_cand_pairs); /* used to determine if search is useful at all */ - if ( ( sub( val_range, PEAK_LOCATOR_RES_FX ) < 0 ) || - ( sub( inp_high, sens ) < 0 ) ) + + if ((sub(val_range, PEAK_LOCATOR_RES_FX) < 0) || + (sub(inp_high, sens) < 0)) { - k = 0; + k = 0; } - - if ( ( k == 0 ) && ( sub( val_range, sens ) >= 0 ) ) + + if ((k == 0) && (sub(val_range, sens) >= 0)) { - k = 1; + k = 1; } - if ( sub( k, 2 ) > 0 ) + if(sub(k, 2) > 0) { /* low, high, low, ... or high, low, high, ...*/ - cand_phase_start = pairs_start; /*assume first candidate is a high */ - if ( sub( cand_pairs[pairs_start], cand_pairs[pairs_start + 1] ) < 0 ) + cand_phase_start = pairs_start; /*assume first candidate is a high */ + if (sub(cand_pairs[pairs_start], cand_pairs[pairs_start + 1]) < 0) { - cand_phase_start = add( pairs_start, 1 ); /* first is a low, --> skip to next higher cand */ + cand_phase_start = add(pairs_start, 1); /* first is a low, --> skip to next higher cand */ } /* high, low, high, ... */ - tmp = k; - if ( sub( cand_phase_start, pairs_start ) != 0 ) + tmp = k; + if (sub(cand_phase_start, pairs_start) != 0) { - tmp = sub( tmp, 1 ); + tmp = sub(tmp, 1); } - num_pairs = tmp / 2; // shr(tmp, 1); - n_tail_values = sub( tmp, num_pairs * 2 ); // shl(num_pairs, 1)); + num_pairs = tmp / 2; // shr(tmp, 1); + n_tail_values = sub(tmp, num_pairs * 2); // shl(num_pairs, 1)); /* filter preliminary sign changes into sensitivity filtered sign changes */ - *n_fsc = 0; /* counter of filtered fsc_idx */ - cand_high = low_val_cand_pairs; - cand_idx = -1; /* sentinel location for no high cand found yet. */ - cand_pairs[-1] = low_val_cand_pairs; + *n_fsc = 0; /* counter of filtered fsc_idx */ + cand_high = low_val_cand_pairs; + cand_idx = -1; /* sentinel location for no high cand found yet. */ + cand_pairs[-1] = low_val_cand_pairs; - prev_low = low_val_cand_pairs; - prev_low_plus_sens = add( prev_low, sens ); + prev_low = low_val_cand_pairs; + prev_low_plus_sens = add(prev_low, sens); /* filter loop for high - low sign change pairs */ /* idx_high, idx_low are raw pointers into the cand_pairs and sc_idx arrays */ - for ( idx_high = cand_phase_start; idx_high < ( cand_phase_start + 2 * num_pairs ); idx_high += 2 ) + for(idx_high = cand_phase_start; idx_high < (cand_phase_start + 2 * num_pairs); idx_high += 2) { - idx_low = idx_high + 1; /* loop ptr increase */ + idx_low = idx_high + 1; /* loop ptr increase */ /* new high candidate larger than previous candidate and */ /* sensitivity still larger than the the previous low */ - tmp = MAX( cand_high, prev_low_plus_sens ); - if ( sub( cand_pairs[idx_high], tmp ) > 0 ) + tmp = MAX(cand_high, prev_low_plus_sens); + if (sub(cand_pairs[idx_high], tmp) > 0) { - cand_idx = idx_high; /* enable or shift candidate position fwd */ + cand_idx = idx_high; /* enable or shift candidate position fwd */ } - cand_high = cand_pairs[cand_idx]; /* NB, cand_pairs[-1] , has the low_val_cand_pairs value stored */ + cand_high = cand_pairs[cand_idx]; /* NB, cand_pairs[-1] , has the low_val_cand_pairs value stored */ /* now check the fwd idx_low of the current {high,low} pair */ - prev_low = MIN( cand_pairs[idx_low], prev_low ); + prev_low = MIN(cand_pairs[idx_low], prev_low); - tmp = sub( cand_high, sens ); - if ( sub( tmp, cand_pairs[idx_low] ) > 0 ) + tmp = sub(cand_high, sens); + if(sub(tmp, cand_pairs[idx_low]) > 0) { /* this low point is now low enough to fix a previous high candidate */ - fsc_idx[*n_fsc] = cand_idx; /*% add cand high idx -> output idx list*/ - *n_fsc = add( *n_fsc, 1 ); + fsc_idx[*n_fsc] = cand_idx; /*% add cand high idx -> output idx list*/ + *n_fsc = add(*n_fsc, 1); - prev_low = cand_pairs[idx_low]; /* use this value as new low estimate */ - cand_idx = -1; /* no candidate until next pair or tail bin, and pt to lowVal */ - cand_high = low_val_cand_pairs; /* enable next candidate to be selected immediately */ + prev_low = cand_pairs[idx_low]; /* use this value as new low estimate */ + cand_idx = -1; /* no candidate until next pair or tail bin, and pt to lowVal */ + cand_high = low_val_cand_pairs; /* enable next candidate to be selected immediately */ } - prev_low_plus_sens = add( prev_low, sens ); + prev_low_plus_sens = add(prev_low, sens); } /* { high, low} for loop */ - - if ( ( n_tail_values == 0 ) && ( cand_idx >= 0 ) ) + + if((n_tail_values == 0) && (cand_idx >= 0)) { /* no tail low or high value to analyze still may need to lock a non-locked but qualified candidate */ - fsc_idx[*n_fsc] = cand_idx; - *n_fsc = add( *n_fsc, 1 ); + fsc_idx[*n_fsc] = cand_idx; + *n_fsc = add(*n_fsc, 1); } /* cand_pairs vector may have a last orphan value */ - if ( n_tail_values > 0 ) + if(n_tail_values > 0) { /* cand_pairs vector may have a last orphan tail value */ /* @@ -570,49 +548,52 @@ static void plc_phEcu_peak_locator_fxlike( const LC3_INT16 *inp, /* i: vecto tmp=a||b */ - tmp = MAX( cand_high, prev_low_plus_sens ); - tmp = sub( cand_pairs[pairs_end], tmp ); - if ( tmp > 0 ) + tmp = MAX(cand_high, prev_low_plus_sens); + tmp = sub(cand_pairs[pairs_end], tmp); + if(tmp > 0) { - fsc_idx[*n_fsc] = pairs_end; - *n_fsc = add( *n_fsc, 1 ); + fsc_idx[*n_fsc] = pairs_end; + *n_fsc = add(*n_fsc, 1); } else { - if ( cand_idx >= 0 ) - { /* we have a previously established high candidate */ - fsc_idx[*n_fsc] = cand_idx; - *n_fsc = add( *n_fsc, 1 ); - } + if(cand_idx >= 0) + { /* we have a previously established high candidate */ + fsc_idx[*n_fsc] = cand_idx; + *n_fsc = add(*n_fsc, 1); + } + } } /* move high locations info from fsc_idx , to output */ - for ( j = 0; j < *n_fsc; j++ ) - { - int_plocs[j] = sc_idx[fsc_idx[j]]; + for(j = 0; j < *n_fsc; j++) + { + int_plocs[j] = sc_idx[fsc_idx[j]]; + } } /* end of pairs + [tail] section filtering */ else { /* constant/single rise or constant decay or very low overall values, cases */ - *n_fsc = 0; - - tmp = sub( inp_high, sens ); - if ( ( k != 0 ) && ( sub( tmp, low_val_cand_pairs ) > 0 ) ) + *n_fsc = 0; + + tmp = sub(inp_high, sens); + if((k != 0) && (sub(tmp, low_val_cand_pairs) > 0)) { /* low,high */ /* high,low */ - tmp = plc_phEcu_find_ind_fx( inp, inp_len, inp_high ); - int_plocs[0] = tmp; /* simply locate the high peak*/ - *n_fsc = 1; - if ( tmp < 0 ) - { /*safety in case max value index was not found */ - *n_fsc = 0; + tmp = plc_phEcu_find_ind_fx(inp, inp_len, inp_high); + int_plocs[0] = tmp; /* simply locate the high peak*/ + *n_fsc = 1; + if (tmp < 0) + { /*safety in case max value index was not found */ + *n_fsc = 0; } - } + } } return; } + diff --git a/lib_lc3plus/plc_phecu_subst_spec.c b/lib_lc3plus/plc_phecu_subst_spec.c index 4c838ab2ff..43f806339b 100644 --- a/lib_lc3plus/plc_phecu_subst_spec.c +++ b/lib_lc3plus/plc_phecu_subst_spec.c @@ -1,12 +1,12 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "defines.h" @@ -14,258 +14,234 @@ #include "constants.h" -static LC3_INT32 own_rand( LC3_INT32 seed ); -static Complex valley_magnitude_adj( Complex X_i_in, LC3_INT32 uni_seed, LC3_FLOAT cos_F ); -static LC3_INT32 rand_phase( LC3_INT32 seed_in, LC3_FLOAT *cos_F ); - -void plc_phEcu_subst_spec( LC3_INT32 *plocs, LC3_INT32 n_plocs, LC3_FLOAT *f0est, LC3_INT32 time_offs, Complex *X, LC3_INT32 X_len, LC3_FLOAT *mag_chg_gr, LC3_INT32 *seed, LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *Xavg, LC3_INT32 t_adv_in, LC3_INT32 Lprot, LC3_INT32 delta_corr, LC3_FLOAT *corr_phase_dbg, LC3_FLOAT *X_i_new_re_dbg, LC3_FLOAT *X_i_new_im_dbg ) -{ +static LC3_INT32 own_rand(LC3_INT32 seed); +static Complex valley_magnitude_adj(Complex X_i_in, LC3_INT32 uni_seed, LC3_FLOAT cos_F); +static LC3_INT32 rand_phase(LC3_INT32 seed_in, LC3_FLOAT* cos_F); +void plc_phEcu_subst_spec(LC3_INT32* plocs, LC3_INT32 n_plocs, LC3_FLOAT* f0est, LC3_INT32 time_offs, Complex* X, LC3_INT32 X_len, + LC3_FLOAT* mag_chg_gr, LC3_INT32 *seed, LC3_FLOAT* alpha, LC3_FLOAT* beta, LC3_FLOAT* Xavg, + LC3_INT32 t_adv_in, LC3_INT32 Lprot, LC3_INT32 delta_corr, LC3_FLOAT *corr_phase_dbg, + LC3_FLOAT *X_i_new_re_dbg, LC3_FLOAT *X_i_new_im_dbg) { + LC3_INT32 i, i2, lprotBy2Minus1, one_peak_flag_mask, noise_mag_scale; LC3_INT32 t_adv; - LC3_FLOAT corr_phase[MAX_PLC_NPLOCS] = { 0 }; - LC3_FLOAT cos_F, mag_chg_local, alpha_local, beta_local, tmp; + LC3_FLOAT corr_phase[MAX_PLC_NPLOCS] = {0}; + LC3_FLOAT cos_F, mag_chg_local, alpha_local, beta_local, tmp; Complex X_i, X_i_new; LC3_INT32 segmentLen, e; LC3_FLOAT Xph; LC3_FLOAT seed_local; LC3_INT32 binCounter, subInd; - - UNUSED( corr_phase_dbg ); - UNUSED( X_i_new_re_dbg ); - UNUSED( X_i_new_im_dbg ); + + UNUSED(corr_phase_dbg); + UNUSED(X_i_new_re_dbg); + UNUSED(X_i_new_im_dbg); seed_local = (LC3_FLOAT) *seed; - - - lprotBy2Minus1 = imin( 320, Lprot / 2 - 1 ); /* limit to 20 KHz */ - - + + + lprotBy2Minus1 = imin(320, Lprot/2 - 1); /* limit to 20 KHz */ + + t_adv = t_adv_in + time_offs; - - for ( i = 0; i < n_plocs; i++ ) - { - corr_phase[i] = (LC3_FLOAT) 2.0 * (LC3_FLOAT) M_PI * ( f0est[i] / Lprot ) * (LC3_FLOAT) t_adv; + + for (i = 0; i < n_plocs; i++) { + corr_phase[i] = (LC3_FLOAT)2.0 * (LC3_FLOAT)M_PI * (f0est[i]/Lprot)*(LC3_FLOAT)t_adv; } // EVOLVE PHASE ----------------- binCounter = 1; subInd = 0; - + one_peak_flag_mask = -1; - if ( n_plocs < 3 && n_plocs > 0 ) - { + if (n_plocs < 3 && n_plocs > 0) { one_peak_flag_mask = 0; } - + noise_mag_scale = 0; - if ( n_plocs == 0 || time_offs != 0 ) - { + if (n_plocs == 0 || time_offs != 0) { noise_mag_scale = 1; } - - if ( n_plocs == 0 ) - { - X[0] = realtoc( 0 ); - X[X_len - 1] = realtoc( 0 ); + + if (n_plocs == 0) { + X[0] = realtoc(0); + X[X_len-1] = realtoc(0); } - if ( n_plocs != 0 ) - { - for ( i = 0; i < n_plocs; i++ ) - { - LC3_INT32 delta_corr_dn = delta_corr; - LC3_INT32 delta_corr_up = delta_corr; + if (n_plocs != 0) { + for (i = 0; i < n_plocs; i++) { + LC3_INT32 delta_corr_dn = delta_corr; + LC3_INT32 delta_corr_up = delta_corr; - if ( i > 0 ) - { - delta_corr_dn = imin( ( ( plocs[i] - plocs[i - 1] - 1 ) / 2 ), delta_corr_dn ); - } + if (i > 0) { + delta_corr_dn = imin( ((plocs[i] - plocs[i - 1] - 1) / 2), delta_corr_dn); + } - if ( i < n_plocs - 1 ) - { - delta_corr_up = imin( ( ( plocs[i + 1] - plocs[i] - 1 ) / 2 ), delta_corr_up ); + if (i < n_plocs - 1) { + delta_corr_up = imin( ((plocs[i + 1] - plocs[i] - 1) / 2), delta_corr_up); + } + + segmentLen = (plocs[i] - delta_corr_dn) - binCounter; + + for (i2 = 0; i2 < segmentLen; i2++) { + seed_local = (LC3_FLOAT)rand_phase((LC3_INT32)seed_local, &cos_F); + + X_i = X[binCounter]; + X_i_new = cmul(X_i, cexpi((LC3_FLOAT)M_PI*seed_local / (LC3_FLOAT)32768.0)); + + + seed_local = (LC3_FLOAT)own_rand((LC3_INT32)seed_local); + + if (noise_mag_scale != 0) { + X_i = valley_magnitude_adj(X_i_new,(LC3_INT32) seed_local, cos_F); + X_i_new = X_i; } - segmentLen = ( plocs[i] - delta_corr_dn ) - binCounter; + mag_chg_local = mag_chg_gr[subInd]; + alpha_local = alpha[subInd]; - for ( i2 = 0; i2 < segmentLen; i2++ ) - { - seed_local = (LC3_FLOAT) rand_phase( (LC3_INT32) seed_local, &cos_F ); - - X_i = X[binCounter]; - X_i_new = cmul( X_i, cexpi( (LC3_FLOAT) M_PI * seed_local / (LC3_FLOAT) 32768.0 ) ); - - - seed_local = (LC3_FLOAT) own_rand( (LC3_INT32) seed_local ); - - if ( noise_mag_scale != 0 ) - { - X_i = valley_magnitude_adj( X_i_new, (LC3_INT32) seed_local, cos_F ); - X_i_new = X_i; - } - - mag_chg_local = mag_chg_gr[subInd]; - alpha_local = alpha[subInd]; - - if ( beta[subInd] != 0 ) - { - tmp = beta[subInd] * Xavg[subInd]; - if ( one_peak_flag_mask == 0 ) - { - tmp = 0; - X_i_new = realtoc( 0 ); - } - X[binCounter] = cadd( cmul( realtoc( alpha_local ), X_i_new ), cmul( realtoc( tmp ), cexpi( (LC3_FLOAT) M_PI * seed_local / (LC3_FLOAT) 32768.0 ) ) ); - } - else - { - if ( one_peak_flag_mask == 0 ) - { - X_i_new = realtoc( 0 ); - } - - X[binCounter] = cmul( realtoc( mag_chg_local ), X_i_new ); - } - - binCounter++; - - if ( binCounter >= gwlpr[subInd + 1] ) - { - subInd++; - } + if (beta[subInd] != 0) { + tmp = beta[subInd] * Xavg[subInd]; + if (one_peak_flag_mask == 0) { + tmp = 0; + X_i_new = realtoc(0); + } + X[binCounter] = cadd(cmul(realtoc(alpha_local), X_i_new), cmul(realtoc(tmp), cexpi((LC3_FLOAT)M_PI*seed_local / (LC3_FLOAT)32768.0))); + } + else { + if (one_peak_flag_mask == 0) { + X_i_new = realtoc(0); + } + + X[binCounter] = cmul(realtoc(mag_chg_local), X_i_new); } + binCounter++; + + if (binCounter >= gwlpr[subInd + 1]) { + subInd++; + } + } + e = plocs[i] + delta_corr_up; - if ( e > lprotBy2Minus1 ) - { + if (e > lprotBy2Minus1) { e = lprotBy2Minus1; } - + Xph = corr_phase[i]; + + segmentLen = e - (binCounter - 1); - segmentLen = e - ( binCounter - 1 ); + for (i2 = 0; i2 < segmentLen; i2++) + { + seed_local = (LC3_FLOAT)own_rand((LC3_INT32)seed_local); + X_i = X[binCounter]; - for ( i2 = 0; i2 < segmentLen; i2++ ) { - seed_local = (LC3_FLOAT) own_rand( (LC3_INT32) seed_local ); - X_i = X[binCounter]; - - { - LC3_INT32 nrep = (LC3_INT32) LC3_FLOOR( Xph / ( 2.0f * (LC3_FLOAT) M_PI ) ); + LC3_INT32 nrep =(LC3_INT32) LC3_FLOOR(Xph / (2.0f*(LC3_FLOAT)M_PI)); - X_i_new = cmul( X_i, cexpi( Xph - ( 2.0f * (LC3_FLOAT) M_PI * (LC3_FLOAT) nrep ) ) ); - } + X_i_new = cmul(X_i, cexpi(Xph - (2.0f*(LC3_FLOAT)M_PI*(LC3_FLOAT)nrep))); + } - seed_local = (LC3_FLOAT) own_rand( (LC3_INT32) seed_local ); + seed_local = (LC3_FLOAT)own_rand((LC3_INT32)seed_local); - mag_chg_local = mag_chg_gr[subInd]; - alpha_local = alpha[subInd]; - beta_local = beta[subInd]; - if ( beta_local != 0 ) - { + mag_chg_local = mag_chg_gr[subInd]; + alpha_local = alpha[subInd]; + beta_local = beta[subInd]; + if (beta_local != 0) { - assert( alpha_local == mag_chg_local ); - tmp = beta_local * Xavg[subInd]; + assert(alpha_local == mag_chg_local); + tmp = beta_local * Xavg[subInd]; - X[binCounter] = cadd( cmul( realtoc( alpha_local ), X_i_new ), cmul( realtoc( tmp ), cexpi( (LC3_FLOAT) M_PI * seed_local / (LC3_FLOAT) 32768.0 ) ) ); - } - else - { - X[binCounter] = cmul( realtoc( mag_chg_local ), X_i_new ); - } + X[binCounter] = cadd(cmul(realtoc(alpha_local), X_i_new), cmul(realtoc(tmp), cexpi((LC3_FLOAT)M_PI*seed_local / (LC3_FLOAT)32768.0))); + } + else + { + X[binCounter] = cmul(realtoc(mag_chg_local), X_i_new); + } - binCounter++; + binCounter++; - if ( binCounter >= gwlpr[subInd + 1] ) - { - subInd++; - } + if (binCounter >= gwlpr[subInd + 1]) { + subInd++; } - } - } + } + } + } - segmentLen = lprotBy2Minus1 - ( binCounter - 1 ); - - for ( i = 0; i < segmentLen; i++ ) - { - seed_local = (LC3_FLOAT) rand_phase( (LC3_INT32) seed_local, &cos_F ); + segmentLen = lprotBy2Minus1 - (binCounter - 1); + for (i = 0; i < segmentLen; i++) { + seed_local = (LC3_FLOAT)rand_phase((LC3_INT32)seed_local, &cos_F); + X_i = X[binCounter]; - X_i_new = cmul( X_i, cexpi( (LC3_FLOAT) M_PI * seed_local / (LC3_FLOAT) 32768.0 ) ); - - seed_local = (LC3_FLOAT) own_rand( (LC3_INT32) seed_local ); + X_i_new = cmul(X_i, cexpi((LC3_FLOAT)M_PI*seed_local/(LC3_FLOAT)32768.0)); - if ( noise_mag_scale != 0 ) - { - X_i = valley_magnitude_adj( X_i_new, (LC3_INT32) seed_local, cos_F ); + seed_local = (LC3_FLOAT)own_rand((LC3_INT32)seed_local); + + if (noise_mag_scale != 0) { + X_i = valley_magnitude_adj(X_i_new, (LC3_INT32)seed_local, cos_F); X_i_new = X_i; } - - if ( one_peak_flag_mask == 0 ) - { - X_i_new = realtoc( 0 ); + + if (one_peak_flag_mask == 0) { + X_i_new = realtoc(0); } - + alpha_local = alpha[subInd]; mag_chg_local = mag_chg_gr[subInd]; - - if ( beta[subInd] != 0 ) - { - assert( alpha_local == mag_chg_local ); - tmp = beta[subInd] * Xavg[subInd]; - - if ( one_peak_flag_mask == 0 ) - { + + if (beta[subInd] != 0) { + assert(alpha_local == mag_chg_local); + tmp = beta[subInd]*Xavg[subInd]; + + if (one_peak_flag_mask == 0) { tmp = 0; } - - X[binCounter] = cadd( cmul( realtoc( alpha_local ), X_i_new ), cmul( realtoc( tmp ), cexpi( (LC3_FLOAT) M_PI * seed_local / (LC3_FLOAT) 32768.0 ) ) ); - } - else - { - X[binCounter] = cmul( realtoc( mag_chg_local ), X_i_new ); + + X[binCounter] = cadd(cmul(realtoc(alpha_local), X_i_new), cmul(realtoc(tmp), cexpi((LC3_FLOAT)M_PI*seed_local/(LC3_FLOAT)32768.0))); + } + else + { + X[binCounter] = cmul(realtoc(mag_chg_local), X_i_new); } - + binCounter++; - - if ( binCounter >= gwlpr[subInd + 1] ) - { + + if (binCounter >= gwlpr[subInd + 1]) { subInd++; } } - - *seed = (LC3_INT32) seed_local; + + *seed = (LC3_INT32)seed_local; } -static LC3_INT32 own_rand( LC3_INT32 seed ) -{ - LC3_INT32 retSeed; - assert( seed <= 32767 && seed >= -32768 ); - retSeed = ( 13849 + ( seed + 32768 ) * 31821 ) & 65535; - retSeed -= 32768; - assert( retSeed <= 32767 && retSeed >= -32768 ); +static LC3_INT32 own_rand(LC3_INT32 seed) { + LC3_INT32 retSeed; + assert(seed <= 32767 && seed >= -32768); + retSeed = (13849 + (seed + 32768) * 31821) & 65535; + retSeed -= 32768; + assert(retSeed <= 32767 && retSeed >= -32768); return retSeed; } -static Complex valley_magnitude_adj( Complex X_i_in, LC3_INT32 uni_seed, LC3_FLOAT cos_F ) -{ - LC3_FLOAT scale = ( (LC3_FLOAT) 0.5 * (LC3_FLOAT) uni_seed / (LC3_FLOAT) 32768.0 ) + (LC3_FLOAT) 0.5 * cos_F; - scale = (LC3_FLOAT) 1.0 + (LC3_FLOAT) 0.25 * scale; - - assert( scale <= (LC3_FLOAT) 1.25 ); - assert( scale >= (LC3_FLOAT) 0.75 ); - - return cmul( X_i_in, realtoc( scale ) ); +static Complex valley_magnitude_adj(Complex X_i_in, LC3_INT32 uni_seed, LC3_FLOAT cos_F) { + LC3_FLOAT scale = ((LC3_FLOAT)0.5*(LC3_FLOAT)uni_seed/(LC3_FLOAT)32768.0) + (LC3_FLOAT)0.5*cos_F; + scale = (LC3_FLOAT)1.0 + (LC3_FLOAT)0.25*scale; + + assert(scale <= (LC3_FLOAT)1.25); + assert(scale >= (LC3_FLOAT)0.75); + + return cmul(X_i_in, realtoc(scale)); } -static LC3_INT32 rand_phase( LC3_INT32 seed_in, LC3_FLOAT *cos_F ) -{ - LC3_FLOAT seed = (LC3_FLOAT) own_rand( seed_in ); - *cos_F = LC3_COS( (LC3_FLOAT) M_PI * seed / (LC3_FLOAT) 32768.0 ); +static LC3_INT32 rand_phase(LC3_INT32 seed_in, LC3_FLOAT* cos_F) { + LC3_FLOAT seed = (LC3_FLOAT)own_rand(seed_in); + *cos_F = LC3_COS((LC3_FLOAT)M_PI*seed/(LC3_FLOAT)32768.0); return (LC3_INT32) seed; } + diff --git a/lib_lc3plus/plc_phecu_tba_per_band_gain.c b/lib_lc3plus/plc_phecu_tba_per_band_gain.c index fae3b227cf..9f585f28dd 100644 --- a/lib_lc3plus/plc_phecu_tba_per_band_gain.c +++ b/lib_lc3plus/plc_phecu_tba_per_band_gain.c @@ -1,11 +1,11 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ #include "options.h" @@ -13,31 +13,32 @@ #include "functions.h" -void plc_phEcu_tba_per_band_gain( LC3_INT32 n_grp, LC3_FLOAT *gr_pow_left, LC3_FLOAT *gr_pow_right, LC3_FLOAT *trans, LC3_FLOAT *grp_pow_change ) +void plc_phEcu_tba_per_band_gain(LC3_INT32 n_grp, LC3_FLOAT *gr_pow_left, LC3_FLOAT *gr_pow_right, LC3_FLOAT *trans, LC3_FLOAT *grp_pow_change) { LC3_INT32 i; /* per band gain */ - for ( i = 0; i < n_grp; i++ ) - { - if ( gr_pow_left[i] > 0 ) + for (i = 0; i < n_grp; i++) { + if (gr_pow_left[i] > 0) { trans[i] = gr_pow_right[i] / gr_pow_left[i]; } else { /* handle division by zero case */ - if ( gr_pow_right[i] > 0 ) + if (gr_pow_right[i] > 0) { - trans[i] = 10.0; /* positive/0 transient */ + trans[i] = 10.0; /* positive/0 transient */ } else { - trans[i] = 1.0; /* 0/0 no transient , no power change */ + trans[i] = 1.0; /* 0/0 no transient , no power change */ } } - grp_pow_change[i] = (LC3_FLOAT) 10.0 * LC3_LOGTEN( trans[i] ); + grp_pow_change[i] = (LC3_FLOAT) 10.0 * LC3_LOGTEN(trans[i]); + } return; } + diff --git a/lib_lc3plus/plc_phecu_tba_spect_Xavg.c b/lib_lc3plus/plc_phecu_tba_spect_Xavg.c index 3527caa991..600b9714e4 100644 --- a/lib_lc3plus/plc_phecu_tba_spect_Xavg.c +++ b/lib_lc3plus/plc_phecu_tba_spect_Xavg.c @@ -1,43 +1,45 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "defines.h" #include "functions.h" -void plc_phEcu_tba_spect_Xavg( LC3_INT32 fs_idx, LC3_INT32 n_grp, LC3_FLOAT *oold_spec_shape, LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_spec_shape, LC3_FLOAT *old_EwPtr, LC3_FLOAT *gr_pow_left, LC3_FLOAT *gr_pow_right, LC3_FLOAT *Xavg ) +void plc_phEcu_tba_spect_Xavg(LC3_INT32 fs_idx, LC3_INT32 n_grp, LC3_FLOAT *oold_spec_shape, + LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_spec_shape, + LC3_FLOAT *old_EwPtr, LC3_FLOAT *gr_pow_left, LC3_FLOAT *gr_pow_right, LC3_FLOAT *Xavg) { - LC3_INT32 i; - LC3_FLOAT XavgEn[MAX_LGW]; - LC3_FLOAT xfp_w_scale, oold_Escale, old_Escale; + LC3_INT32 i; + LC3_FLOAT XavgEn[MAX_LGW]; + LC3_FLOAT xfp_w_scale, oold_Escale, old_Escale; /* 8k 16k 24k 32k 48k */ LC3_FLOAT flt_xfp_wE_MDCT2FFT_target[5] = { (LC3_FLOAT) 1.9906, (LC3_FLOAT) 4.0445, (LC3_FLOAT) 6.0980, (LC3_FLOAT) 8.1533, (LC3_FLOAT) 12.2603 }; - LC3_INT32 gw_0[10] = { 1, 3, 5, 9, 17, 33, 49, 65, 81, 97 }; - + LC3_INT32 gw_0[10] = { 1, 3, 5, 9, 17, 33, 49, 65, 81, 97 }; + /* prepare scale factor */ - xfp_w_scale = LC3_ROUND( flt_xfp_wE_MDCT2FFT_target[fs_idx] / (LC3_FLOAT) 16.0 * (LC3_FLOAT) 32768.0 ) / (LC3_FLOAT) LC3_POW( 2, 11 ); + xfp_w_scale = LC3_ROUND(flt_xfp_wE_MDCT2FFT_target[fs_idx]/(LC3_FLOAT)16.0*(LC3_FLOAT) 32768.0) / (LC3_FLOAT) LC3_POW(2,11); /* prepare left and right subband energies */ - oold_Escale = ( *oold_EwPtr ) * xfp_w_scale; - old_Escale = ( *old_EwPtr ) * xfp_w_scale; - for ( i = 0; i < n_grp; i++ ) - { + oold_Escale = (*oold_EwPtr) * xfp_w_scale; + old_Escale = (*old_EwPtr) * xfp_w_scale; + for (i = 0;i < n_grp;i++) { gr_pow_left[i] = oold_spec_shape[i] * oold_Escale; gr_pow_right[i] = old_spec_shape[i] * old_Escale; - XavgEn[i] = ( (LC3_FLOAT) 0.5 ) * ( gr_pow_left[i] + gr_pow_right[i] ) / ( gw_0[i + 1] - gw_0[i] ); - Xavg[i] = LC3_SQRT( XavgEn[i] ); + XavgEn[i] = ((LC3_FLOAT) 0.5) * (gr_pow_left[i] + gr_pow_right[i]) / (gw_0[i + 1] - gw_0[i]); + Xavg[i] = LC3_SQRT(XavgEn[i]); } return; } + diff --git a/lib_lc3plus/plc_phecu_tba_trans_dect_gains.c b/lib_lc3plus/plc_phecu_tba_trans_dect_gains.c index d0f8d75935..e5f0d3caae 100644 --- a/lib_lc3plus/plc_phecu_tba_trans_dect_gains.c +++ b/lib_lc3plus/plc_phecu_tba_trans_dect_gains.c @@ -1,23 +1,24 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "defines.h" #include "functions.h" -#define BETA_MUTE_FAC 0.5 /* % attenuation factor per additional bad frame, FX uses 0.5 (shift right with 1 bit) */ +#define BETA_MUTE_FAC 0.5 /* % attenuation factor per additional bad frame, FX uses 0.5 (shift right with 1 bit) */ #define BETA_MUTE_FAC_INI 0.5 -#define OFF_FRAMES_LIMIT 30 /* 300 ms for LC3 10 ms */ +#define OFF_FRAMES_LIMIT 30 /* 300 ms for LC3 10 ms */ + #define LGW32k 7 @@ -28,127 +29,120 @@ /* Tables are in Q15 */ /* 0.3 dB attenuation per frame for 16 frames, then 6 dB attenuation per frame */ const LC3_INT32 POW_ATT_TABLE1[OFF_FRAMES_LIMIT + 1] = { 32767, 31656, 30581, 29543, 28540, 27571, 26635, 25731, 24857, 24013, - 23198, 22410, 21650, 20915, 20205, 19519, 9759, 4880, 2440, 1220, - 610, 305, 152, 76, 38, 19, 10, 5, 2, 1, - 0 }; + 23198, 22410, 21650, 20915, 20205, 19519, 9759, 4880, 2440, 1220, + 610, 305, 152, 76, 38, 19, 10, 5, 2, 1, + 0 }; /* % 0.4 dB attenuation per frame for 16 frames, then 6 dB attenuation per frame */ const LC3_INT32 POW_ATT_TABLE0[OFF_FRAMES_LIMIT + 1] = { 32767, 31293, 29885, 28540, 27255, 26029, 24857, 23738, 22670, 21650, - 20675, 19745, 18856, 18007, 17197, 16423, 8211, 4106, 2053, 1026, - 513, 257, 128, 64, 32, 16, 8, 4, 2, 1, - 0 }; + 20675, 19745, 18856, 18007, 17197, 16423, 8211, 4106, 2053, 1026, + 513, 257, 128, 64, 32, 16, 8, 4, 2, 1, + 0 }; -#ifdef PLC2_FADEOUT_IN_MS +#ifdef PLC2_FADEOUT_IN_MS #if PLC2_FADEOUT_IN_MS == 0 /* default setting only requieres two tables */ -const Word16 *const POW_ATT_TABLES[1 + 2] = { - NULL, - POW_ATT_TABLE1 /*1 0.3dB steps */, - POW_ATT_TABLE0 /*2 0.4 dB steps*/, +const Word16* const POW_ATT_TABLES[1 + 2] = +{ NULL, POW_ATT_TABLE1/*1 0.3dB steps */ , POW_ATT_TABLE0/*2 0.4 dB steps*/, }; -#else +#else const LC3_INT32 POW_ATT_TABLE_p3x8_6[] = { - 32767, 31656, 30581, 29543, 28540, 27571, 26635, 25731, 12865, 6433, - 3216, 1608, 804, 402, 201, 101, 50, 25, 13, 6, - 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0 -}; -const LC3_INT32 POW_ATT_TABLE_p4x8_6[OFF_FRAMES_LIMIT + 1] = { - 32767, 31293, 29885, 28540, 27255, 26029, 24857, 23738, 11869, 5935, - 2967, 1484, 742, 371, 185, 93, 46, 23, 12, 6, - 3, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -const LC3_INT32 POW_ATT_TABLE_p3x4_6[OFF_FRAMES_LIMIT + 1] = { - 32767, 31656, 30581, 29543, 14772, 7386, 3693, 1847, 923, 462, - 231, 115, 58, 29, 14, 7, 4, 2, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; -const LC3_INT32 POW_ATT_TABLE_p4x4_6[OFF_FRAMES_LIMIT + 1] = { - 32767, 31293, 29885, 28540, 14270, 7135, 3568, 1784, 892, 446, - 223, 111, 56, 28, 14, 7, 3, 2, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -const LC3_INT32 POW_ATT_TABLE_p3x2_6[OFF_FRAMES_LIMIT + 1] = { - 32767, 31656, 15828, 7914, 3957, 1979, 989, 495, 247, 124, - 62, 31, 15, 8, 4, 2, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; -const LC3_INT32 POW_ATT_TABLE_p4x2_6[OFF_FRAMES_LIMIT + 1] = { - 32767, 31293, 15647, 7823, 3912, 1956, 978, 489, 244, 122, - 61, 31, 15, 8, 4, 2, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -const LC3_INT32 POW_ATT_TABLE_p3x1_6[OFF_FRAMES_LIMIT + 1] = { - 32767, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, - 32, 16, 8, 4, 2, 1, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; -const LC3_INT32 POW_ATT_TABLE_p4x1_6[OFF_FRAMES_LIMIT + 1] = { - 32767, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, - 32, 16, 8, 4, 2, 1, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - - -const LC3_INT32 *const POW_ATT_TABLES[1 + 10] = { - NULL, - POW_ATT_TABLE1, POW_ATT_TABLE0, /* .3dB x16,16 6dB steps */ /* .4dB x16, 16 6dB steps */ /*original/default */ - POW_ATT_TABLE_p3x8_6, POW_ATT_TABLE_p4x8_6, /* .3dB x8, 24 6dB steps */ /* .4dB x8, 24 6dB steps */ - POW_ATT_TABLE_p3x4_6, POW_ATT_TABLE_p4x4_6, /* .3dB x4, 28 6dB steps */ /* .4dB x4, 28 6dB steps */ - POW_ATT_TABLE_p3x2_6, POW_ATT_TABLE_p4x2_6, /* .3dB x2, 30 6dB steps */ /* .4dB x2, 30 6dB steps */ - POW_ATT_TABLE_p3x1_6, POW_ATT_TABLE_p4x1_6 /* .3dB x1, 30 6dB steps */ /* .4dB x1, 30 6dB steps */ + 32767, 31656, 30581, 29543, 28540, 27571, 26635, 25731, 12865, 6433, + 3216, 1608, 804, 402, 201, 101, 50, 25, 13, 6, + 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0 }; +const LC3_INT32 POW_ATT_TABLE_p4x8_6[OFF_FRAMES_LIMIT + 1] = { + 32767, 31293, 29885, 28540, 27255, 26029, 24857, 23738, 11869, 5935, + 2967, 1484, 742, 371, 185, 93, 46, 23, 12, 6, + 3, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 }; + +const LC3_INT32 POW_ATT_TABLE_p3x4_6[OFF_FRAMES_LIMIT + 1] = { + 32767, 31656, 30581, 29543, 14772, 7386, 3693, 1847, 923, 462, + 231, 115, 58, 29, 14, 7, 4, 2, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +const LC3_INT32 POW_ATT_TABLE_p4x4_6[OFF_FRAMES_LIMIT + 1] = { + 32767, 31293, 29885, 28540, 14270, 7135, 3568, 1784, 892, 446, + 223, 111, 56, 28, 14, 7, 3, 2, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +const LC3_INT32 POW_ATT_TABLE_p3x2_6[OFF_FRAMES_LIMIT + 1] = { + 32767, 31656, 15828, 7914, 3957, 1979, 989, 495, 247, 124, + 62, 31, 15, 8, 4, 2, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +const LC3_INT32 POW_ATT_TABLE_p4x2_6[OFF_FRAMES_LIMIT + 1] = { + 32767, 31293, 15647, 7823, 3912, 1956, 978, 489, 244, 122, + 61, 31, 15, 8, 4, 2, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +const LC3_INT32 POW_ATT_TABLE_p3x1_6[OFF_FRAMES_LIMIT + 1] = { + 32767, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, + 32, 16, 8, 4, 2, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +const LC3_INT32 POW_ATT_TABLE_p4x1_6[OFF_FRAMES_LIMIT + 1] = { + 32767, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, + 32, 16, 8, 4, 2, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + + +const LC3_INT32* const POW_ATT_TABLES[1 + 10] = +{ NULL, + POW_ATT_TABLE1 , POW_ATT_TABLE0, /* .3dB x16,16 6dB steps */ /* .4dB x16, 16 6dB steps */ /*original/default */ + POW_ATT_TABLE_p3x8_6, POW_ATT_TABLE_p4x8_6, /* .3dB x8, 24 6dB steps */ /* .4dB x8, 24 6dB steps */ + POW_ATT_TABLE_p3x4_6, POW_ATT_TABLE_p4x4_6, /* .3dB x4, 28 6dB steps */ /* .4dB x4, 28 6dB steps */ + POW_ATT_TABLE_p3x2_6, POW_ATT_TABLE_p4x2_6, /* .3dB x2, 30 6dB steps */ /* .4dB x2, 30 6dB steps */ + POW_ATT_TABLE_p3x1_6, POW_ATT_TABLE_p4x1_6 /* .3dB x1, 30 6dB steps */ /* .4dB x1, 30 6dB steps */ }; #endif #endif -void plc_phEcu_tba_trans_dect_gains( LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FLOAT *grp_pow_change, LC3_FLOAT *stPhECU_beta_mute, LC3_FLOAT *stPhECU_mag_chg_1st, LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *mag_chg, LC3_FLOAT *ph_dith, LC3_INT32 *tr_dec, LC3_FLOAT *att_val, LC3_INT32 *attDegreeFrames_dbg, LC3_FLOAT *thresh_dbg ) +void plc_phEcu_tba_trans_dect_gains(LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FLOAT *grp_pow_change, + LC3_FLOAT *stPhECU_beta_mute, LC3_FLOAT *stPhECU_mag_chg_1st, + LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *mag_chg, LC3_FLOAT *ph_dith, LC3_INT32 *tr_dec, + LC3_FLOAT *att_val, LC3_INT32 *attDegreeFrames_dbg, LC3_FLOAT *thresh_dbg) { LC3_INT32 i; - LC3_FLOAT thresh_tr_dB, max_increase_grp_pow; + LC3_FLOAT thresh_tr_dB, max_increase_grp_pow; LC3_FLOAT max_increase_grp_pow_lin; LC3_FLOAT grp_pow_change_lin[MAX_LGW]; LC3_FLOAT XavgFadeinFactor; LC3_INT32 burst_att_thresh; LC3_INT32 att_per_frame_idx; - LC3_INT32 att_always, attDegreeFrames; + LC3_INT32 att_always, attDegreeFrames; LC3_INT32 FADEOUT_IN_MS, PLC_P800_SPEECH_FADEOUT_IN_FRAMES, PLC2_FADEOUT_IN_FRAMES, BURST_ATT_THRESH_PRE; const LC3_INT32 *TABLEQ15; - LC3_INT32 BURST_ATT_THRESH; /* start attenuate with losses in a row, also starts FADE2AVG actions */ - LC3_INT32 ATT_PER_FRAME; /* initial msuic attenuation table ptr, actually implemented in table lookup! */ - LC3_INT32 BETA_MUTE_THR; /* time threshold in 10 ms frames to start beta - noise attenuation */ - - UNUSED( attDegreeFrames_dbg ); + LC3_INT32 BURST_ATT_THRESH; /* start attenuate with losses in a row, also starts FADE2AVG actions */ + LC3_INT32 ATT_PER_FRAME; /* initial msuic attenuation table ptr, actually implemented in table lookup! */ + LC3_INT32 BETA_MUTE_THR; /* time threshold in 10 ms frames to start beta - noise attenuation */ + + UNUSED(attDegreeFrames_dbg); /* constants setup */ - att_always = 0; + att_always = 0; XavgFadeinFactor = -1.0; - if ( PLC2_FADEOUT_IN_MS != 0 ) + if (PLC2_FADEOUT_IN_MS != 0) { - if ( PLC2_FADEOUT_IN_MS < 0 ) + if (PLC2_FADEOUT_IN_MS < 0) { - FADEOUT_IN_MS = PLC_FADEOUT_IN_MS; /* % use TDC - SETTING as input */ + FADEOUT_IN_MS = PLC_FADEOUT_IN_MS; /* % use TDC - SETTING as input */ } else { FADEOUT_IN_MS = PLC2_FADEOUT_IN_MS; /* % use a PLC2 individual settinsg */ } - PLC_P800_SPEECH_FADEOUT_IN_FRAMES = (LC3_INT32) LC3_FLOOR( (LC3_FLOAT) FADEOUT_IN_MS / (LC3_FLOAT) 10.0 ); /* % nominal svaleu for speech */ + PLC_P800_SPEECH_FADEOUT_IN_FRAMES = (LC3_INT32) LC3_FLOOR((LC3_FLOAT)FADEOUT_IN_MS / (LC3_FLOAT)10.0); /* % nominal svaleu for speech */ - PLC2_FADEOUT_IN_FRAMES = MIN( OFF_FRAMES_LIMIT, MAX( 6, 3 * PLC_P800_SPEECH_FADEOUT_IN_FRAMES ) ); /* for PLC2 we typically maintain energy 3x longer */ + PLC2_FADEOUT_IN_FRAMES = MIN(OFF_FRAMES_LIMIT, MAX(6, 3 * PLC_P800_SPEECH_FADEOUT_IN_FRAMES)); /* for PLC2 we typically maintain energy 3x longer */ - BURST_ATT_THRESH_PRE = MIN( 5, MAX( 1, ( 1 * PLC2_FADEOUT_IN_FRAMES ) / 6 ) ); /* nominal 20-40 ms to start actual muting, will be thresh +1 fot assumed music */ + BURST_ATT_THRESH_PRE = MIN(5, MAX(1, (1 * PLC2_FADEOUT_IN_FRAMES) / 6)); /* nominal 20-40 ms to start actual muting, will be thresh +1 fot assumed music */ - ATT_PER_FRAME = MIN( 10, MAX( 2, 2 * ( 6 - BURST_ATT_THRESH_PRE ) ) ); /* % we let the BURST_ATT_thresh control the initial table selection */ - BURST_ATT_THRESH = MIN( BURST_ATT_THRESH_PRE, 4 ); - BETA_MUTE_THR = MIN( 4 + ( OFF_FRAMES_LIMIT / 2 ) + 1, MAX( 4, BURST_ATT_THRESH + 1 + (LC3_INT32) LC3_POW( (LC3_FLOAT) 2.0, BURST_ATT_THRESH_PRE - (LC3_FLOAT) 1 ) ) ); /* nominal time to start mandatory decrease of Xavg */ + ATT_PER_FRAME = MIN(10, MAX(2, 2 * (6 - BURST_ATT_THRESH_PRE))); /* % we let the BURST_ATT_thresh control the initial table selection */ + BURST_ATT_THRESH = MIN(BURST_ATT_THRESH_PRE, 4); + BETA_MUTE_THR = MIN(4 + (OFF_FRAMES_LIMIT / 2) + 1, MAX(4, BURST_ATT_THRESH + 1 + (LC3_INT32)LC3_POW((LC3_FLOAT)2.0,BURST_ATT_THRESH_PRE - (LC3_FLOAT)1))); /* nominal time to start mandatory decrease of Xavg */ } @@ -158,19 +152,19 @@ void plc_phEcu_tba_trans_dect_gains( LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_F /* 10ms constants */ - thresh_tr_dB = 10.0; /* dB threshold kept same as for 20ms, even though transient analysis frame size was shortened */ - max_increase_grp_pow = 0; /* maximum amplification(dB) in case of onset transients, offset always deacy */ + thresh_tr_dB = 10.0; /* dB threshold kept same as for 20ms, even though transient analysis frame size was shortened */ + max_increase_grp_pow = 0; /* maximum amplification(dB) in case of onset transients, offset always deacy */ - max_increase_grp_pow_lin = (LC3_FLOAT) 1.0 * LC3_POW( (LC3_FLOAT) 10.0, max_increase_grp_pow / (LC3_FLOAT) 10.0 ) * (LC3_FLOAT) ( 32767.0 / 32768.0 ); + max_increase_grp_pow_lin = (LC3_FLOAT)1.0*LC3_POW((LC3_FLOAT)10.0, max_increase_grp_pow / (LC3_FLOAT)10.0)*(LC3_FLOAT)(32767.0 / 32768.0); /* envelope setting */ burst_att_thresh = BURST_ATT_THRESH + 1; att_per_frame_idx = ATT_PER_FRAME - 1; - + attDegreeFrames = 0; - if ( burst_len > burst_att_thresh ) + if (burst_len > burst_att_thresh) { att_always = 1; @@ -178,92 +172,91 @@ void plc_phEcu_tba_trans_dect_gains( LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_F /* Limit attDegreeFrames to OFF_FRAMES_LIMIT */ attDegreeFrames = burst_len - burst_att_thresh; - if ( attDegreeFrames > OFF_FRAMES_LIMIT ) + if (attDegreeFrames > OFF_FRAMES_LIMIT) { attDegreeFrames = OFF_FRAMES_LIMIT; } } - set_vec( 1.0 * ( 32767.0 / 32768.0 ), mag_chg, n_grp ); - set_vec( 0.0, ph_dith, n_grp ); + set_vec(1.0 * (32767.0/32768.0), mag_chg, n_grp); + set_vec(0.0, ph_dith, n_grp); - set_vec( 1.0 * ( 32767.0 / 32768.0 ), alpha, n_grp ); - set_vec( 0.0, beta, n_grp ); - set_vec_int( 0, tr_dec, n_grp ); + set_vec(1.0 * (32767.0/32768.0), alpha, n_grp); + set_vec(0.0, beta, n_grp); + set_vec_int(0, tr_dec, n_grp); - set_vec( 1.0 * ( 32767.0 / 32768.0 ), att_val, n_grp ); + set_vec(1.0 * (32767.0/32768.0), att_val, n_grp); + /* transient detection per band */ - for ( i = 0; i < n_grp; i++ ) - { - if ( burst_len == 1 ) + for (i = 0;i < n_grp; i++) { + if(burst_len == 1) { /* first bad frame */ - grp_pow_change_lin[i] = LC3_POW( (LC3_FLOAT) 10.0, grp_pow_change[i] / (LC3_FLOAT) 10.0 ); + grp_pow_change_lin[i] = LC3_POW((LC3_FLOAT)10.0, grp_pow_change[i]/(LC3_FLOAT)10.0); *stPhECU_beta_mute = BETA_MUTE_FAC_INI; - *stPhECU_beta_mute = *stPhECU_beta_mute / (LC3_FLOAT) 2.0; - + *stPhECU_beta_mute = *stPhECU_beta_mute / (LC3_FLOAT)2.0; + /* transient processing */ /* transients may be both rise and decay transients !! */ - if ( LC3_FABS( grp_pow_change[i] ) >= thresh_tr_dB ) + if(LC3_FABS(grp_pow_change[i]) >= thresh_tr_dB) { - + tr_dec[i] = 1; } /* magnitude modification */ att_val[i] = 0.0f; - if ( tr_dec[i] || att_always ) - { + if(tr_dec[i] || att_always) { - att_val[i] = MIN( max_increase_grp_pow_lin, grp_pow_change_lin[i] ); /* % linear values !! */ - att_val[i] = LC3_SQRT( att_val[i] ); + att_val[i] = MIN(max_increase_grp_pow_lin, grp_pow_change_lin[i]); /* % linear values !! */ + att_val[i] = LC3_SQRT(att_val[i]); mag_chg[i] = att_val[i]; stPhECU_mag_chg_1st[i] = att_val[i]; } else { - mag_chg[i] = 1.0 * (LC3_FLOAT) ( 32767.0 / 32768.0 ); - stPhECU_mag_chg_1st[i] = (LC3_FLOAT) 1.0; + mag_chg[i] = 1.0 * (LC3_FLOAT)(32767.0/32768.0); + stPhECU_mag_chg_1st[i] = (LC3_FLOAT)1.0; } } else { /* burst handling based on states */ - assert( burst_len >= 2 ); /* states used here */ + assert(burst_len >= 2); /* states used here */ tr_dec[i] = 0; - if ( PLC_FADEOUT_IN_MS > 0 ) + if (PLC_FADEOUT_IN_MS > 0) { - assert( att_per_frame_idx >= 1 && att_per_frame_idx <= 10 ); - TABLEQ15 = POW_ATT_TABLES[att_per_frame_idx]; - att_val[i] = (LC3_FLOAT) 1.0 * ( (LC3_FLOAT) TABLEQ15[MIN( OFF_FRAMES_LIMIT, attDegreeFrames )] / (LC3_FLOAT) 32768.0 ); /* Table idx 0...N-1 therefore no + 1 */ + assert(att_per_frame_idx >= 1 && att_per_frame_idx <= 10); + TABLEQ15 = POW_ATT_TABLES[att_per_frame_idx]; + att_val[i] = (LC3_FLOAT)1.0 * ( (LC3_FLOAT) TABLEQ15[MIN(OFF_FRAMES_LIMIT, attDegreeFrames )] / (LC3_FLOAT)32768.0); /* Table idx 0...N-1 therefore no + 1 */ att_val[i] = att_val[i]; } else { - if ( att_per_frame_idx == ATT_PER_FRAME ) + if (att_per_frame_idx == ATT_PER_FRAME) { - att_val[i] = (LC3_FLOAT) 1.0 * ( (LC3_FLOAT) POW_ATT_TABLE0[MIN( OFF_FRAMES_LIMIT, attDegreeFrames )] / (LC3_FLOAT) 32768.0 ); + att_val[i] = (LC3_FLOAT)1.0 * ( (LC3_FLOAT)POW_ATT_TABLE0[MIN(OFF_FRAMES_LIMIT, attDegreeFrames)] / (LC3_FLOAT)32768.0); } else { - att_val[i] = (LC3_FLOAT) 1.0 * ( (LC3_FLOAT) POW_ATT_TABLE1[MIN( OFF_FRAMES_LIMIT, attDegreeFrames )] / (LC3_FLOAT) 32768.0 ); + att_val[i] = (LC3_FLOAT)1.0 * ( (LC3_FLOAT)POW_ATT_TABLE1[MIN(OFF_FRAMES_LIMIT, attDegreeFrames)] / (LC3_FLOAT)32768.0); } } - - - if ( ( att_val[i] != 0 ) && ( att_val[i] * (LC3_FLOAT) 32768.0 < (LC3_FLOAT) 0.5 ) ) + + + if ( (att_val[i] != 0) && (att_val[i] * (LC3_FLOAT)32768.0 < (LC3_FLOAT)0.5) ) { - att_val[i] = 0.0; /* for SNR measurments match in float lowest possible level to BASOP representation */ + att_val[i] = 0.0; /* for SNR measurments match in float lowest possible level to BASOP representation */ } /* Apply attenuation */ @@ -271,55 +264,57 @@ void plc_phEcu_tba_trans_dect_gains( LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_F mag_chg[i] = mag_chg[i] * att_val[i]; /* add additional attenuation from burst attenation logic */ - if ( ( mag_chg[i] != 0 ) && ( mag_chg[i] * (LC3_FLOAT) 32768.0 < (LC3_FLOAT) 0.5 ) ) + if ((mag_chg[i] != 0) && (mag_chg[i] * (LC3_FLOAT)32768.0 < (LC3_FLOAT)0.5)) { - mag_chg[i] = 0; /* for SNR measurments match in float lowest possible level to BASOP representation */ + mag_chg[i] = 0; /* for SNR measurments match in float lowest possible level to BASOP representation */ } - if ( burst_len > BETA_MUTE_THR ) + + if(burst_len > BETA_MUTE_THR) { - *stPhECU_beta_mute = *stPhECU_beta_mute * (LC3_FLOAT) BETA_MUTE_FAC; + *stPhECU_beta_mute = *stPhECU_beta_mute * (LC3_FLOAT)BETA_MUTE_FAC; } alpha[i] = mag_chg[i]; - if ( alpha[i] >= (LC3_FLOAT) ( 32766.0 / 32768.0 ) ) + if (alpha[i] >= (LC3_FLOAT)(32766.0 / 32768.0)) { - beta[i] = 0; /* align to BASOP more efficent use of beta */ + beta[i] = 0; /* align to BASOP more efficent use of beta */ } else { - beta[i] = LC3_SQRT( (LC3_FLOAT) 1.0 - alpha[i] * alpha[i] ) * *stPhECU_beta_mute; + beta[i] = LC3_SQRT((LC3_FLOAT)1.0 - alpha[i]* alpha[i]) * *stPhECU_beta_mute; } - if ( i >= LGW32k - 1 ) - { - beta[i] = beta[i] * (LC3_FLOAT) 0.1; + if ( i >= LGW32k-1) { + beta[i] = beta[i] * (LC3_FLOAT)0.1; } - else if ( i >= LGW16k - 1 ) + else if( i >= LGW16k-1) { - beta[i] = beta[i] * (LC3_FLOAT) 0.5; + beta[i] = beta[i] * (LC3_FLOAT)0.5; } /* limit Xavg noise contribution further in case of offset / tr_decay */ - if ( ( burst_len <= burst_att_thresh ) && ( stPhECU_mag_chg_1st[i] < (LC3_FLOAT) ( 32767.0 / 32768.0 ) ) ) + if ((burst_len <= burst_att_thresh) && (stPhECU_mag_chg_1st[i] < (LC3_FLOAT)(32767.0 / 32768.0))) { - XavgFadeinFactor = (LC3_FLOAT) ( burst_len - (LC3_FLOAT) 1.0 ) / burst_att_thresh; - - XavgFadeinFactor = MIN( (LC3_FLOAT) 1.0, XavgFadeinFactor ); + XavgFadeinFactor = (LC3_FLOAT)(burst_len - (LC3_FLOAT)1.0) / burst_att_thresh; + + XavgFadeinFactor = MIN((LC3_FLOAT)1.0, XavgFadeinFactor); - beta[i] = beta[i] * XavgFadeinFactor; + beta[i] = beta[i] * XavgFadeinFactor; + } } } - if ( thresh_dbg != NULL ) + if (thresh_dbg != NULL) { *thresh_dbg = XavgFadeinFactor; } - return; + return; } + diff --git a/lib_lc3plus/plc_phecu_trans_burst_ana_sub.c b/lib_lc3plus/plc_phecu_trans_burst_ana_sub.c index a6adff0dc8..c860cd6ce3 100644 --- a/lib_lc3plus/plc_phecu_trans_burst_ana_sub.c +++ b/lib_lc3plus/plc_phecu_trans_burst_ana_sub.c @@ -1,11 +1,11 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ #include "options.h" @@ -13,31 +13,36 @@ #include "functions.h" -void plc_phEcu_trans_burst_ana_sub( LC3_INT32 fs_idx, LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FLOAT *oold_spect_shape, LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_spect_shape, LC3_FLOAT *old_EwPtr, LC3_FLOAT *stPhECU_beta_mute, LC3_FLOAT *stPhECU_mag_chg_1st, LC3_FLOAT *stPhECU_Xavg, LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *mag_chg, LC3_INT32 *tr_dec_dbg, LC3_FLOAT *gpc_dbg ) +void plc_phEcu_trans_burst_ana_sub(LC3_INT32 fs_idx, LC3_INT32 burst_len, LC3_INT32 n_grp, LC3_FLOAT *oold_spect_shape, + LC3_FLOAT *oold_EwPtr, LC3_FLOAT *old_spect_shape, + LC3_FLOAT *old_EwPtr, LC3_FLOAT *stPhECU_beta_mute, + LC3_FLOAT *stPhECU_mag_chg_1st, LC3_FLOAT *stPhECU_Xavg, LC3_FLOAT *alpha, LC3_FLOAT *beta, LC3_FLOAT *mag_chg, LC3_INT32 *tr_dec_dbg, LC3_FLOAT *gpc_dbg) { - LC3_FLOAT gr_pow_left[MAX_LGW]; - LC3_FLOAT gr_pow_right[MAX_LGW]; - LC3_FLOAT trans[MAX_LGW]; - LC3_FLOAT grp_pow_change[MAX_LGW]; - LC3_FLOAT ph_dith[MAX_LGW]; - LC3_FLOAT att_val[MAX_LGW]; - LC3_INT32 tr_dec[MAX_LGW]; + LC3_FLOAT gr_pow_left[MAX_LGW]; + LC3_FLOAT gr_pow_right[MAX_LGW]; + LC3_FLOAT trans[MAX_LGW]; + LC3_FLOAT grp_pow_change[MAX_LGW]; + LC3_FLOAT ph_dith[MAX_LGW]; + LC3_FLOAT att_val[MAX_LGW]; + LC3_INT32 tr_dec[MAX_LGW]; - LC3_INT32 attDegreeFrames; - LC3_FLOAT thresh_dbg; + LC3_INT32 attDegreeFrames; + LC3_FLOAT thresh_dbg; - UNUSED( tr_dec_dbg ); - UNUSED( gpc_dbg ); + UNUSED(tr_dec_dbg); + UNUSED(gpc_dbg); - if ( burst_len <= 1 ) + if (burst_len <= 1) { - plc_phEcu_tba_spect_Xavg( fs_idx, n_grp, oold_spect_shape, oold_EwPtr, old_spect_shape, old_EwPtr, gr_pow_left, gr_pow_right, stPhECU_Xavg ); + plc_phEcu_tba_spect_Xavg(fs_idx, n_grp, oold_spect_shape, oold_EwPtr, old_spect_shape, old_EwPtr, gr_pow_left, gr_pow_right, stPhECU_Xavg); + + plc_phEcu_tba_per_band_gain(n_grp, gr_pow_left, gr_pow_right, trans, grp_pow_change); - plc_phEcu_tba_per_band_gain( n_grp, gr_pow_left, gr_pow_right, trans, grp_pow_change ); } - plc_phEcu_tba_trans_dect_gains( burst_len, n_grp, grp_pow_change, stPhECU_beta_mute, stPhECU_mag_chg_1st, alpha, beta, mag_chg, ph_dith, tr_dec, att_val, &attDegreeFrames, &thresh_dbg ); + plc_phEcu_tba_trans_dect_gains(burst_len, n_grp, grp_pow_change, stPhECU_beta_mute, stPhECU_mag_chg_1st, alpha, beta, mag_chg, ph_dith, tr_dec, att_val, &attDegreeFrames, &thresh_dbg); return; } + diff --git a/lib_lc3plus/plc_tdc.c b/lib_lc3plus/plc_tdc.c index ff7f84abbc..1a1a408f4d 100644 --- a/lib_lc3plus/plc_tdc.c +++ b/lib_lc3plus/plc_tdc.c @@ -1,12 +1,12 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" /***************************************************************************\ @@ -17,478 +17,461 @@ #include "functions.h" -static LC3_INT16 TDC_random_short( LC3_INT16 *seed ); -static LC3_FLOAT TDC_get_gainp( const LC3_FLOAT x[], const LC3_FLOAT y[], LC3_INT32 n ); -static LC3_FLOAT TDC_get_gainc( const LC3_FLOAT x[], const LC3_FLOAT y[], const LC3_FLOAT *gain_p, const LC3_INT32 n, const LC3_INT32 frame_dms ); -static void TDC_LPC_synthesis( const LC3_FLOAT a[], LC3_FLOAT x[], LC3_FLOAT y[], LC3_INT32 l, const LC3_FLOAT mem[], LC3_INT32 lpcorder, LC3_FLOAT *buf ); -static void TDC_LPC_residu( const LC3_FLOAT *a, LC3_FLOAT *x, LC3_FLOAT *y, LC3_INT32 l, LC3_INT32 lpcorder ); -static void TDC_highPassFiltering( const LC3_INT32 L_buffer, LC3_FLOAT exc2[], const LC3_FLOAT hp_filt[], const LC3_INT32 l_fir_fer ); -static void TDC_f_preemph( LC3_FLOAT *signal, const LC3_FLOAT *mu, LC3_INT32 L, LC3_FLOAT *mem ); -static void TDC_deemph( LC3_FLOAT *signal, const LC3_FLOAT *mu, LC3_INT32 L, const LC3_FLOAT *mem ); -const LC3_FLOAT TDC_high_16[TDC_L_FIR_HP] = { 0.f, -0.0205f, -0.0651f, -0.1256f, -0.1792f, 0.8028f, -0.1792f, -0.1256f, -0.0651f, -0.0205f, 0.f }; -const LC3_FLOAT TDC_high_32[TDC_L_FIR_HP] = { -0.0517f, -0.0587f, -0.0820f, -0.1024f, -0.1164f, 0.8786f, -0.1164f, -0.1024f, -0.0820f, -0.0587f, -0.0517f }; -const LC3_FLOAT TDC_high_16_harm[TDC_L_FIR_HP] = { 0.0053f, 0.0000f, -0.0440f, 0.0000f, 0.2637f, 0.5500f, 0.2637f, 0.0000f, -0.0440f, 0.0000f, 0.0053f }; -const LC3_FLOAT TDC_high_32_harm[TDC_L_FIR_HP] = { -0.0053f, -0.0037f, -0.0140f, 0.0180f, 0.2668f, 0.4991f, 0.2668f, 0.0180f, -0.0140f, -0.0037f, -0.0053f }; -static void TDC_levinson( LC3_FLOAT *acf, LC3_INT32 len, LC3_FLOAT *out ); -static void TDC_copyFLOAT( const LC3_FLOAT *X, LC3_FLOAT *Z, LC3_INT32 n ); -static LC3_FLOAT TDC_dotFLOAT( const LC3_FLOAT *X, const LC3_FLOAT *Y, LC3_INT32 n ); - -const LC3_INT32 beforeNextIncArray[4][4] = { { 0, 0, 0, 1 }, - { 0, 1, 0, 1 }, - { 0, 1, 1, 1 }, - { 1, 1, 1, 1 } }; -const LC3_INT32 nextIncArray[4][4] = { { 1, 0, 0, 0 }, - { 1, 0, 1, 0 }, - { 1, 0, 1, 1 }, - { 1, 1, 1, 1 } }; - -void processTdcApply_fl( const LC3_INT32 pitch_int, - const LC3_FLOAT *preemphFac, - const LC3_FLOAT *A, - const LC3_INT32 lpc_order, - const LC3_FLOAT *pcmbufHist, - const LC3_INT32 max_len_pcm_plc, - const LC3_INT32 N, - const LC3_INT32 frame_dms, - const LC3_INT32 SampRate, - const LC3_INT32 nbLostFramesInRow, - const LC3_INT32 overlap, - const LC3_FLOAT *stabFac, - LC3_FLOAT harmonicBuf[MAX_PITCH], - LC3_FLOAT synthHist[M], - LC3_INT32 *fract, - LC3_INT16 *seed, - LC3_FLOAT *gain_c, - LC3_FLOAT *alpha, - LC3_FLOAT *synth ) -{ - LC3_FLOAT step, step_n; - LC3_INT32 i, len, Tc, nbLostCmpt_loc, nextInc, beforeNextInc; - LC3_FLOAT gain_h, tmp, gain_p; - LC3_FLOAT *exc2, *exc_buf, *exc, *x_pre, *buf, *pt_exc, *pt1_exc, *synthMemPtr; - LC3_FLOAT *harmonicBufPtr; - LC3_FLOAT synth_mem[M]; - const LC3_FLOAT *hp_filt, *high_harm; - LC3_FLOAT gainInov; - LC3_FLOAT hpBlendFac; - char *scratchSpace1st, *scratchSpaceTmp; - char scratchSpace[( MAX_LEN_PCM_PLC + MDCT_MEM_LEN_MAX + MAX_LEN_PCM_PLC + 1 + M ) * sizeof( LC3_FLOAT )]; - LC3_FLOAT alphaPrev; - LC3_FLOAT throttle; - LC3_INT32 frame_dms_idx, nbLostFramesInRow_mod; - - memset( synth_mem, 0, M * sizeof( LC3_FLOAT ) ); - memset( scratchSpace, 0, ( MAX_LEN_PCM_PLC + MDCT_MEM_LEN_MAX + MAX_LEN_PCM_PLC + 1 + M ) * sizeof( LC3_FLOAT ) ); - - /* len of synthesized signal */ - len = N + overlap; - - nbLostCmpt_loc = floor( frame_dms / 100.0 * ( nbLostFramesInRow - 1 ) + 1 ); - frame_dms_idx = frame_dms / 25 - 1; /* 0,1,2,3 */ - nbLostFramesInRow_mod = ( nbLostFramesInRow - 1 ) % 4; - - beforeNextInc = beforeNextIncArray[frame_dms_idx][nbLostFramesInRow_mod]; - nextInc = nextIncArray[frame_dms_idx][nbLostFramesInRow_mod]; - - if ( nbLostCmpt_loc > PLC_FADEOUT_IN_MS / 10 ) - { - gain_p = 0; - *gain_c = 0; - *alpha = 0; - memset( synth, 0, len * sizeof( LC3_FLOAT ) ); - return; - } - - Tc = pitch_int; - if ( *fract > 0 ) - { - Tc++; - } - - /*---------------------------------------------------------------- - * Buffer Initialization for timeDomainConcealment_Apply - * - * 1st - * |--exc_buf--|--x_pre--| - * | |--exc2--| - * | |--buf (LPC Syn)--| - * - *---------------------------------------------------------------*/ - - scratchSpace1st = scratchSpace; - exc_buf = (LC3_FLOAT *) scratchSpace1st; - scratchSpace1st += (LC3_INT32) sizeof( LC3_FLOAT ) * ( Tc + N / 2 + len ); - exc = exc_buf + ( Tc + N / 2 ); - - scratchSpaceTmp = scratchSpace1st; - x_pre = (LC3_FLOAT *) scratchSpaceTmp; - scratchSpaceTmp += (LC3_INT32) sizeof( LC3_FLOAT ) * ( lpc_order + Tc + N / 2 + 1 ); - - /*---------------------------------------------------------------* - * LPC Residual * - *---------------------------------------------------------------*/ - if ( nbLostFramesInRow == 1 ) - { - /* copy buffer to pre-emphasis buffer */ - TDC_copyFLOAT( &( pcmbufHist[max_len_pcm_plc - ( lpc_order + Tc + N / 2 + 1 )] ), &( x_pre[0] ), lpc_order + Tc + N / 2 + 1 ); - - /* apply pre-emphasis to the signal */ - TDC_f_preemph( &( x_pre[1] ), preemphFac, lpc_order + Tc + N / 2, &x_pre[0] ); - - /* copy memory for LPC synth */ - TDC_copyFLOAT( &( x_pre[Tc + N / 2 + 1] ), synth_mem, lpc_order ); - - /* LPC Residual */ - TDC_LPC_residu( A, &( x_pre[lpc_order + 1] ), &( exc[-( Tc + N / 2 )] ), Tc + N / 2, lpc_order ); - } - - /*---------------------------------------------------------------* - * Calculate gains * - *---------------------------------------------------------------*/ - if ( nbLostFramesInRow == 1 ) - { - if ( pitch_int == Tc ) - { - gain_p = TDC_get_gainp( &( x_pre[lpc_order + Tc + 1] ), &( x_pre[lpc_order + 1] ), N / 2 ); - } - else - { - tmp = TDC_get_gainp( &( x_pre[lpc_order + Tc + 1] ), &( x_pre[lpc_order + 2] ), N / 2 ); - gain_p = TDC_get_gainp( &( x_pre[lpc_order + Tc + 1] ), &( x_pre[lpc_order + 1] ), N / 2 ); - - if ( tmp > gain_p ) - { - Tc = pitch_int; - gain_p = tmp; - *fract = 0; - } - } - - if ( gain_p < 0.0f ) - { - gain_p = 0.0f; - } - - if ( gain_p > 1.0f ) - { - gain_p = 1.0f; - } - - *gain_c = 0.0f; - - if ( pitch_int == Tc ) - { - *gain_c = TDC_get_gainc( &( exc[-1] ), &( exc[-1 - Tc] ), &gain_p, N / 2, frame_dms ); - } - else - { - tmp = TDC_get_gainc( &( exc[-1] ), &( exc[-1 - pitch_int] ), &gain_p, N / 2, frame_dms ); - *gain_c = TDC_get_gainc( &( exc[-1] ), &( exc[-1 - Tc] ), &gain_p, N / 2, frame_dms ); - *gain_c = MIN( *gain_c, tmp ); - } +static LC3_INT16 TDC_random_short(LC3_INT16 *seed); +static LC3_FLOAT TDC_get_gainp(const LC3_FLOAT x[], const LC3_FLOAT y[], LC3_INT32 n); +static LC3_FLOAT TDC_get_gainc(const LC3_FLOAT x[], const LC3_FLOAT y[], const LC3_FLOAT *gain_p, const LC3_INT32 n, const LC3_INT32 frame_dms); +static void TDC_LPC_synthesis(const LC3_FLOAT a[], LC3_FLOAT x[], LC3_FLOAT y[], LC3_INT32 l, const LC3_FLOAT mem[], LC3_INT32 lpcorder, LC3_FLOAT *buf); +static void TDC_LPC_residu(const LC3_FLOAT *a, LC3_FLOAT *x, LC3_FLOAT *y, LC3_INT32 l, LC3_INT32 lpcorder); +static void TDC_highPassFiltering(const LC3_INT32 L_buffer, LC3_FLOAT exc2[], const LC3_FLOAT hp_filt[], const LC3_INT32 l_fir_fer); +static void TDC_f_preemph(LC3_FLOAT *signal, const LC3_FLOAT *mu, LC3_INT32 L, LC3_FLOAT *mem); +static void TDC_deemph(LC3_FLOAT *signal, const LC3_FLOAT *mu, LC3_INT32 L, const LC3_FLOAT *mem); +const LC3_FLOAT TDC_high_16[TDC_L_FIR_HP] = { 0.f, -0.0205f, -0.0651f, -0.1256f, -0.1792f, 0.8028f, -0.1792f, -0.1256f, -0.0651f, -0.0205f, 0.f }; +const LC3_FLOAT TDC_high_32[TDC_L_FIR_HP] = {-0.0517f, -0.0587f, -0.0820f, -0.1024f, -0.1164f, 0.8786f, -0.1164f, -0.1024f, -0.0820f, -0.0587f, -0.0517f}; +const LC3_FLOAT TDC_high_16_harm[TDC_L_FIR_HP] = { 0.0053f, 0.0000f, -0.0440f, 0.0000f, 0.2637f, 0.5500f, 0.2637f, 0.0000f, -0.0440f, 0.0000f, 0.0053f}; +const LC3_FLOAT TDC_high_32_harm[TDC_L_FIR_HP] = {-0.0053f, -0.0037f, -0.0140f, 0.0180f, 0.2668f, 0.4991f, 0.2668f, 0.0180f, -0.0140f, -0.0037f, -0.0053f}; +static void TDC_levinson(LC3_FLOAT *acf, LC3_INT32 len, LC3_FLOAT *out); +static void TDC_copyFLOAT(const LC3_FLOAT * X, LC3_FLOAT * Z, LC3_INT32 n); +static LC3_FLOAT TDC_dotFLOAT(const LC3_FLOAT * X, const LC3_FLOAT * Y, LC3_INT32 n); + +const LC3_INT32 beforeNextIncArray[4][4] = {{0,0,0,1}, + {0,1,0,1}, + {0,1,1,1}, + {1,1,1,1}}; +const LC3_INT32 nextIncArray[4][4] = {{1,0,0,0}, + {1,0,1,0}, + {1,0,1,1}, + {1,1,1,1}}; + +void processTdcApply_fl(const LC3_INT32 pitch_int, + const LC3_FLOAT *preemphFac, + const LC3_FLOAT* A, + const LC3_INT32 lpc_order, + const LC3_FLOAT* pcmbufHist, + const LC3_INT32 max_len_pcm_plc, + const LC3_INT32 N, + const LC3_INT32 frame_dms, + const LC3_INT32 SampRate, + const LC3_INT32 nbLostFramesInRow, + const LC3_INT32 overlap, + const LC3_FLOAT *stabFac, + LC3_FLOAT harmonicBuf[MAX_PITCH], + LC3_FLOAT synthHist[M], + LC3_INT32* fract, + LC3_INT16* seed, + LC3_FLOAT* gain_c, + LC3_FLOAT* alpha, + LC3_FLOAT* synth + ) +{ + LC3_FLOAT step, step_n; + LC3_INT32 i, len, Tc, nbLostCmpt_loc, nextInc, beforeNextInc; + LC3_FLOAT gain_h, tmp, gain_p; + LC3_FLOAT *exc2, *exc_buf, *exc, *x_pre, *buf, *pt_exc, *pt1_exc, *synthMemPtr; + LC3_FLOAT *harmonicBufPtr; + LC3_FLOAT synth_mem[M]; + const LC3_FLOAT *hp_filt, *high_harm; + LC3_FLOAT gainInov; + LC3_FLOAT hpBlendFac; + char *scratchSpace1st, *scratchSpaceTmp; + char scratchSpace[(MAX_LEN_PCM_PLC + MDCT_MEM_LEN_MAX + MAX_LEN_PCM_PLC + 1 + M) * sizeof(LC3_FLOAT)]; + LC3_FLOAT alphaPrev; + LC3_FLOAT throttle; + LC3_INT32 frame_dms_idx, nbLostFramesInRow_mod; + + memset(synth_mem, 0, M * sizeof(LC3_FLOAT)); + memset(scratchSpace, 0, (MAX_LEN_PCM_PLC + MDCT_MEM_LEN_MAX + MAX_LEN_PCM_PLC + 1 + M) * sizeof(LC3_FLOAT)); + + /* len of synthesized signal */ + len = N + overlap; + + nbLostCmpt_loc = floor(frame_dms/100.0 * (nbLostFramesInRow - 1) + 1); + frame_dms_idx = frame_dms / 25 - 1; /* 0,1,2,3 */ + nbLostFramesInRow_mod = (nbLostFramesInRow - 1) % 4; + + beforeNextInc = beforeNextIncArray[frame_dms_idx][nbLostFramesInRow_mod]; + nextInc = nextIncArray [frame_dms_idx][nbLostFramesInRow_mod]; + + if (nbLostCmpt_loc > PLC_FADEOUT_IN_MS/10) + { + gain_p = 0; + *gain_c = 0; + *alpha = 0; + memset(synth, 0, len * sizeof(LC3_FLOAT)); + return; + } + + Tc = pitch_int; + if (*fract > 0) { + Tc++; + } + + /*---------------------------------------------------------------- + * Buffer Initialization for timeDomainConcealment_Apply + * + * 1st + * |--exc_buf--|--x_pre--| + * | |--exc2--| + * | |--buf (LPC Syn)--| + * + *---------------------------------------------------------------*/ + + scratchSpace1st = scratchSpace; + exc_buf = (LC3_FLOAT*)scratchSpace1st; scratchSpace1st += (LC3_INT32)sizeof(LC3_FLOAT) * (Tc + N/2 + len); + exc = exc_buf + (Tc + N/2); + + scratchSpaceTmp = scratchSpace1st; + x_pre = (LC3_FLOAT*)scratchSpaceTmp; scratchSpaceTmp += (LC3_INT32)sizeof(LC3_FLOAT) * (lpc_order + Tc + N/2 + 1); + + /*---------------------------------------------------------------* + * LPC Residual * + *---------------------------------------------------------------*/ + if (nbLostFramesInRow == 1) + { + /* copy buffer to pre-emphasis buffer */ + TDC_copyFLOAT(&(pcmbufHist[max_len_pcm_plc-(lpc_order+Tc+N/2+1)]), &(x_pre[0]), lpc_order+Tc+N/2+1); + + /* apply pre-emphasis to the signal */ + TDC_f_preemph(&(x_pre[1]), preemphFac, lpc_order+Tc+N/2, &x_pre[0]); + + /* copy memory for LPC synth */ + TDC_copyFLOAT(&(x_pre[Tc+N/2+1]), synth_mem, lpc_order); + + /* LPC Residual */ + TDC_LPC_residu(A, &(x_pre[lpc_order+1]), &(exc[-(Tc+N/2)]), Tc+N/2, lpc_order); + } + + /*---------------------------------------------------------------* + * Calculate gains * + *---------------------------------------------------------------*/ + if (nbLostFramesInRow == 1) + { + if (pitch_int == Tc) + { + gain_p = TDC_get_gainp( &(x_pre[lpc_order+Tc+1]), &(x_pre[lpc_order+1]), N/2 ); } else { - gain_p = *alpha; - } - - /*---------------------------------------------------------------* - * Damping factor * - *---------------------------------------------------------------*/ - - alphaPrev = 1; - if ( nbLostFramesInRow > 1 ) - { - alphaPrev = *alpha; - } - - if ( nextInc != 0 ) - { - switch ( nbLostCmpt_loc ) - { - case 1: - *alpha = (LC3_FLOAT) sqrt( gain_p ); - if ( *alpha > 0.98f ) - { - *alpha = 0.98f; - } - else if ( *alpha < 0.925f ) - { - *alpha = 0.925f; - } - break; - case 2: - *alpha = ( 0.63f + 0.35f * ( *stabFac ) ) * gain_p; - if ( *alpha < 0.919f ) - { - *alpha = 0.919f; - } - break; - default: - *alpha = ( 0.652f + 0.328f * ( *stabFac ) ) * gain_p; - } - } - - if ( nbLostCmpt_loc > 3 ) - { - switch ( frame_dms ) - { - case 25: - *alpha *= PLC34_ATTEN_FAC_025; - break; - case 50: - *alpha *= PLC34_ATTEN_FAC_050; - break; - case 100: - *alpha *= PLC34_ATTEN_FAC_100; - break; - } - } + tmp = TDC_get_gainp( &(x_pre[lpc_order+Tc+1]), &(x_pre[lpc_order+2]), N/2 ); + gain_p = TDC_get_gainp( &(x_pre[lpc_order+Tc+1]), &(x_pre[lpc_order+1]), N/2 ); - if ( nbLostCmpt_loc > 5 ) - { - gain_p = *alpha; + if (tmp > gain_p) { + Tc = pitch_int; + gain_p = tmp; + *fract = 0; + } } - /*---------------------------------------------------------------* - * Construct the harmonic part * - * Last pitch cycle of the previous frame is repeatedly copied. * - *---------------------------------------------------------------*/ - - pt_exc = harmonicBuf; - pt1_exc = exc - Tc; - - if ( nbLostFramesInRow == 1 ) + if(gain_p < 0.0f) { - if ( *stabFac >= 1 ) - { - TDC_copyFLOAT( pt1_exc, pt_exc, Tc ); - } - else - { - /* These values are necessary for the last five filtered samples */ - TDC_copyFLOAT( &exc[-Tc], exc, ( TDC_L_FIR_HP - 1 ) / 2 ); - - high_harm = TDC_high_32_harm; - if ( SampRate <= 16000 ) - { - high_harm = TDC_high_16_harm; - } - - for ( i = 0; i < Tc; i++ ) - { - pt_exc[i] = TDC_dotFLOAT( &pt1_exc[i - ( TDC_L_FIR_HP - 1 ) / 2], high_harm, TDC_L_FIR_HP ); - } - } + gain_p = 0.0f; } - /*---------------------------------------------------------------* - * Construct the random part of excitation * - *---------------------------------------------------------------*/ - scratchSpaceTmp = scratchSpace1st; - exc2 = (LC3_FLOAT *) scratchSpaceTmp; - scratchSpaceTmp += (LC3_INT32) sizeof( LC3_FLOAT ) * ( len + TDC_L_FIR_HP - 1 ); - - for ( i = 0; i < len + TDC_L_FIR_HP - 1; i++ ) + if(gain_p > 1.0f) { - exc2[i] = (LC3_FLOAT) TDC_random_short( seed ); + gain_p = 1.0f; } - /* high pass noise */ - if ( SampRate <= 16000 ) - { - hp_filt = TDC_high_16; - } - else - { - hp_filt = TDC_high_32; - } + *gain_c = 0.0f; - if ( nbLostFramesInRow == 1 ) + if (pitch_int == Tc) { - TDC_highPassFiltering( len, exc2, hp_filt, TDC_L_FIR_HP ); + *gain_c = TDC_get_gainc( &(exc[-1]), &(exc[-1-Tc]), &gain_p, N/2, frame_dms ); } else { - /* moves from 0 to 1, speed is defined by PLC3_HPBLENDTHROTTLE */ - throttle = (LC3_FLOAT) nbLostCmpt_loc / ( nbLostCmpt_loc + PLC3_HPBLENDTHROTTLE ); - hpBlendFac = ( 1 - *alpha ) * throttle; - - for ( i = 0; i < len; i++ ) - { - exc2[i] = hpBlendFac * exc2[i + TDC_L_FIR_HP / 2] + ( 1 - hpBlendFac ) * TDC_dotFLOAT( &exc2[i], hp_filt, TDC_L_FIR_HP ); - } - } - - /* normalize energy */ - gainInov = 1.0f / (LC3_FLOAT) sqrt( TDC_dotFLOAT( exc2, exc2, N ) / (LC3_FLOAT) N + 0.01f ); - gainInov *= ( 1.1f - 0.75 * gain_p ); - - /* gains */ - gain_h = alphaPrev; - tmp = *gain_c * *alpha / alphaPrev; - - /* update steps */ - step = ( 1.0f / (LC3_FLOAT) N ) * ( gain_h - *alpha ); - step_n = ( 1.0f / (LC3_FLOAT) N ) * ( *gain_c - tmp ); - - /*---------------------------------------------------------------* - * Construct the total excitation * - *---------------------------------------------------------------*/ - harmonicBufPtr = harmonicBuf + ( ( nbLostFramesInRow - 1 ) * N ) % Tc; - - for ( i = 0; i < len; i++ ) - { - /* harmonic */ - if ( harmonicBufPtr - harmonicBuf >= Tc ) - { - harmonicBufPtr = harmonicBuf; - } - exc[i] = *harmonicBufPtr++; - exc[i] *= gain_h; - - /* random */ - exc2[i] *= *gain_c * gainInov; - - /* total */ - exc[i] = exc[i] + exc2[i]; - - /* update */ + tmp = TDC_get_gainc( &(exc[-1]), &(exc[-1-pitch_int]), &gain_p, N/2, frame_dms ); + *gain_c = TDC_get_gainc( &(exc[-1]), &(exc[-1-Tc]) , &gain_p, N/2, frame_dms ); + *gain_c = MIN(*gain_c, tmp); + } + } + else + { + gain_p = *alpha; + } + + /*---------------------------------------------------------------* + * Damping factor * + *---------------------------------------------------------------*/ + + alphaPrev = 1; + if (nbLostFramesInRow > 1) + { + alphaPrev = *alpha; + } + + if (nextInc != 0) + { + switch (nbLostCmpt_loc) + { + case 1: + *alpha = (LC3_FLOAT)sqrt(gain_p); + if ( *alpha > 0.98f ) + { + *alpha = 0.98f; + } + else if ( *alpha < 0.925f ) + { + *alpha = 0.925f; + } + break; + case 2: + *alpha = (0.63f + 0.35f * (*stabFac)) * gain_p; + if ( *alpha < 0.919f ) + { + *alpha = 0.919f; + } + break; + default: + *alpha = (0.652f + 0.328f * (*stabFac)) * gain_p; + } + } + + if (nbLostCmpt_loc > 3) + { + switch (frame_dms) + { + case 25: *alpha *= PLC34_ATTEN_FAC_025; break; + case 50: *alpha *= PLC34_ATTEN_FAC_050; break; + case 100: *alpha *= PLC34_ATTEN_FAC_100; break; + } + } + + if (nbLostCmpt_loc > 5) + { + gain_p = *alpha; + } + + /*---------------------------------------------------------------* + * Construct the harmonic part * + * Last pitch cycle of the previous frame is repeatedly copied. * + *---------------------------------------------------------------*/ + + pt_exc = harmonicBuf; + pt1_exc = exc - Tc; + + if( nbLostFramesInRow == 1 ) + { + if (*stabFac >= 1) + { + TDC_copyFLOAT(pt1_exc, pt_exc, Tc); + } + else + { + /* These values are necessary for the last five filtered samples */ + TDC_copyFLOAT(&exc[-Tc], exc, (TDC_L_FIR_HP-1)/2); + + high_harm = TDC_high_32_harm; + if (SampRate <= 16000) + { + high_harm = TDC_high_16_harm; + } + + for( i = 0; i < Tc; i++ ) + { + pt_exc[i] = TDC_dotFLOAT(&pt1_exc[i-(TDC_L_FIR_HP-1)/2], high_harm, TDC_L_FIR_HP); + } + } + } + + /*---------------------------------------------------------------* + * Construct the random part of excitation * + *---------------------------------------------------------------*/ + scratchSpaceTmp = scratchSpace1st; + exc2 = (LC3_FLOAT*)scratchSpaceTmp; scratchSpaceTmp += (LC3_INT32)sizeof(LC3_FLOAT) * (len + TDC_L_FIR_HP - 1); + + for (i = 0; i < len + TDC_L_FIR_HP - 1; i++) { + exc2[i] = (LC3_FLOAT)TDC_random_short(seed); + } + + /* high pass noise */ + if (SampRate <= 16000 ) + { + hp_filt = TDC_high_16; + } else { + hp_filt = TDC_high_32; + } + + if ( nbLostFramesInRow == 1 ) + { + TDC_highPassFiltering(len, exc2, hp_filt, TDC_L_FIR_HP); + } + else + { + /* moves from 0 to 1, speed is defined by PLC3_HPBLENDTHROTTLE */ + throttle = (LC3_FLOAT)nbLostCmpt_loc / (nbLostCmpt_loc + PLC3_HPBLENDTHROTTLE); + hpBlendFac = (1 - *alpha) * throttle; + + for (i = 0; i < len; i++) + { + exc2[i] = hpBlendFac * exc2[i+TDC_L_FIR_HP/2] + (1 - hpBlendFac) * TDC_dotFLOAT(&exc2[i], hp_filt, TDC_L_FIR_HP ); + } + } + + /* normalize energy */ + gainInov = 1.0f / (LC3_FLOAT)sqrt(TDC_dotFLOAT( exc2, exc2, N ) / (LC3_FLOAT)N + 0.01f ); + gainInov *= (1.1f - 0.75* gain_p); + + /* gains */ + gain_h = alphaPrev; + tmp = *gain_c * *alpha / alphaPrev; + + /* update steps */ + step = (1.0f/(LC3_FLOAT)N) * (gain_h - *alpha); + step_n = (1.0f/(LC3_FLOAT)N) * (*gain_c - tmp); + + /*---------------------------------------------------------------* + * Construct the total excitation * + *---------------------------------------------------------------*/ + harmonicBufPtr = harmonicBuf + ((nbLostFramesInRow - 1) * N) % Tc; + + for ( i = 0; i < len; i++ ) { + /* harmonic */ + if (harmonicBufPtr - harmonicBuf >= Tc) { + harmonicBufPtr = harmonicBuf; + } + exc[i] = *harmonicBufPtr++; + exc[i] *= gain_h; + + /* random */ + exc2[i] *= *gain_c * gainInov; + + /* total */ + exc[i] = exc[i] + exc2[i]; + + /* update */ + gain_h -= step; + gain_h = MAX(gain_h, 0); + *gain_c -= step_n; + *gain_c = MAX(*gain_c, 0); + } + + *gain_c = tmp; + + /*----------------------------------------------------------* + * Compute the synthesis speech * + *----------------------------------------------------------*/ + buf = (LC3_FLOAT*)scratchSpace1st; scratchSpace1st += (LC3_INT32)sizeof(LC3_FLOAT) * (len + lpc_order); + synthMemPtr = synth_mem; + if (nbLostFramesInRow != 1) + { + synthMemPtr = synthHist; + } + + TDC_LPC_synthesis(A, + &exc[0], + synth, + len, + synthMemPtr, + lpc_order, + buf); + + TDC_copyFLOAT(&synth[N-lpc_order], synthHist, lpc_order); + + /*----------------------------------------------------------* + * Deemphasis * + *----------------------------------------------------------*/ + TDC_deemph( synth, preemphFac, len, &pcmbufHist[max_len_pcm_plc-1] ); + + /*----------------------------------------------------------* + * Fade to zero * + *----------------------------------------------------------*/ + if (beforeNextInc != 0) + { + if (nbLostCmpt_loc == PLC_FADEOUT_IN_MS/10) + { + gain_h = 1; + step = 1.0f/(LC3_FLOAT)N; + for ( i = 0; i < N; i++ ) { + synth[i] *= gain_h; gain_h -= step; - gain_h = MAX( gain_h, 0 ); - *gain_c -= step_n; - *gain_c = MAX( *gain_c, 0 ); - } - - *gain_c = tmp; - - /*----------------------------------------------------------* - * Compute the synthesis speech * - *----------------------------------------------------------*/ - buf = (LC3_FLOAT *) scratchSpace1st; - scratchSpace1st += (LC3_INT32) sizeof( LC3_FLOAT ) * ( len + lpc_order ); - synthMemPtr = synth_mem; - if ( nbLostFramesInRow != 1 ) - { - synthMemPtr = synthHist; - } - - TDC_LPC_synthesis( A, - &exc[0], - synth, - len, - synthMemPtr, - lpc_order, - buf ); - - TDC_copyFLOAT( &synth[N - lpc_order], synthHist, lpc_order ); - - /*----------------------------------------------------------* - * Deemphasis * - *----------------------------------------------------------*/ - TDC_deemph( synth, preemphFac, len, &pcmbufHist[max_len_pcm_plc - 1] ); - - /*----------------------------------------------------------* - * Fade to zero * - *----------------------------------------------------------*/ - if ( beforeNextInc != 0 ) - { - if ( nbLostCmpt_loc == PLC_FADEOUT_IN_MS / 10 ) - { - gain_h = 1; - step = 1.0f / (LC3_FLOAT) N; - for ( i = 0; i < N; i++ ) - { - synth[i] *= gain_h; - gain_h -= step; - } - memset( &synth[N], 0, overlap * sizeof( LC3_FLOAT ) ); - } + } + memset(&synth[N], 0, overlap * sizeof(LC3_FLOAT)); } + } } /* Take only real part */ -void processTdcInverseOdft_fl( LC3_FLOAT *in, LC3_INT32 n_bands, LC3_FLOAT *out, LC3_INT32 lpc_order ) +void processTdcInverseOdft_fl(LC3_FLOAT *in, LC3_INT32 n_bands, LC3_FLOAT *out, LC3_INT32 lpc_order) { - LC3_INT32 i, j, k; - LC3_FLOAT buf[2 * MAX_BANDS_NUMBER_PLC]; - Complex sum; - Complex res; + LC3_INT32 i, j, k; + LC3_FLOAT buf[2*MAX_BANDS_NUMBER_PLC]; + Complex sum; + Complex res; /* Buffer for ifft */ j = 0; - for ( i = 0; i < n_bands - 1; i += 2 ) + for (i = 0; i < n_bands - 1; i += 2) { buf[j] = in[i]; j++; } - for ( i = n_bands - 1; i > 0; i -= 2 ) + for (i = n_bands - 1; i > 0; i -= 2) { buf[j] = in[i]; j++; } - for ( i = 0; i < n_bands; i++ ) + for (i = 0; i < n_bands; i++) { buf[j] = in[i]; j++; } /* ifft */ - for ( j = 0; j < n_bands; j++ ) + for (j = 0; j < n_bands; j++) { sum.r = 0, sum.i = 0; res.r = 0, res.i = 0; - for ( k = 0; k < n_bands; k++ ) + for (k = 0; k < n_bands; k++) { - res = cexpi( ( 2 * M_PI * (LC3_FLOAT) ( j * k ) ) / (LC3_FLOAT) n_bands ); + res = cexpi((2 * M_PI * (LC3_FLOAT) (j * k)) / (LC3_FLOAT) n_bands); res.r = res.r * buf[k]; res.i = res.i * buf[k]; - sum = cadd( sum, res ); + sum = cadd(sum, res); } - res = cexpi( (LC3_FLOAT) j * M_PI / ( 2.0 * (LC3_FLOAT) n_bands ) ); - out[j] = ( sum.r * res.r - sum.i * res.i ); + res = cexpi((LC3_FLOAT) j * M_PI / (2.0 * (LC3_FLOAT) n_bands)); + out[j] = (sum.r * res.r - sum.i * res.i); } out[0] = out[0] * 1.0001; - if ( out[0] == 0 ) + if (out[0] == 0) { out[0] = 1; - zero_float( &out[1], lpc_order ); + zero_float(&out[1], lpc_order); } } -void processTdcPreemphasis_fl( LC3_FLOAT *in, LC3_FLOAT *pre_emph_factor, LC3_INT32 n_bands ) +void processTdcPreemphasis_fl(LC3_FLOAT *in, LC3_FLOAT *pre_emph_factor, LC3_INT32 n_bands) { - LC3_INT32 i; + LC3_INT32 i; - for ( i = 0; i < n_bands; i++ ) + for (i = 0; i < n_bands; i++) { - in[i] = in[i] * ( 1.0 - 2.0 * ( *pre_emph_factor ) * LC3_COS( 2.0 * M_PI * ( 0.5 + (LC3_FLOAT) i ) / ( 2.0 * (LC3_FLOAT) n_bands ) ) + ( *pre_emph_factor ) * ( *pre_emph_factor ) ); + in[i] = in[i] * (1.0 - 2.0 * (*pre_emph_factor) * LC3_COS(2.0 * M_PI * (0.5 + (LC3_FLOAT) i) / (2.0 * (LC3_FLOAT) n_bands)) + (*pre_emph_factor) * (*pre_emph_factor)); } } -void processTdcLpcEstimation_fl( LC3_FLOAT *r, LC3_INT32 fs_idx, LC3_INT32 len, LC3_FLOAT *A, LC3_INT32 frame_dms ) +void processTdcLpcEstimation_fl(LC3_FLOAT *r, LC3_INT32 fs_idx, LC3_INT32 len, LC3_FLOAT *A, LC3_INT32 frame_dms) { - LC3_INT32 i; - const LC3_FLOAT *lpc_array; - + LC3_INT32 i; + const LC3_FLOAT *lpc_array; + lpc_array = plc_tdc_lpc_all[fs_idx]; - - if ( fs_idx == 0 && frame_dms == 25 ) + + if (fs_idx == 0 && frame_dms == 25) { lpc_array = plc_tdc_lpc_8_25ms; } - + /* r[0] = r[0] * 1 */ - for ( i = 1; i < len; i++ ) + for (i = 1; i < len; i++) { r[i] = r[i] * lpc_array[i]; } - TDC_levinson( r, len - 1, A ); + TDC_levinson(r, len - 1, A); } /** random @@ -502,111 +485,109 @@ void processTdcLpcEstimation_fl( LC3_FLOAT *r, LC3_INT32 fs_idx, LC3_INT32 len, * Returns: * random number */ -static LC3_INT16 TDC_random_short( LC3_INT16 *seed ) +static LC3_INT16 TDC_random_short(LC3_INT16 *seed) { - *seed = (LC3_INT16) ( *seed * 12821L + 16831L ); - return ( *seed ); + *seed = (LC3_INT16) (*seed * 12821L + 16831L); + return(*seed); } -static LC3_FLOAT TDC_get_gainp( /* output: gain of pitch */ - const LC3_FLOAT x[], /* input : input signal */ - const LC3_FLOAT y[], /* input : shifted input signal */ - LC3_INT32 n /* input : vector length */ +static LC3_FLOAT TDC_get_gainp( /* output: gain of pitch */ + const LC3_FLOAT x[], /* input : input signal */ + const LC3_FLOAT y[], /* input : shifted input signal */ + LC3_INT32 n /* input : vector length */ ) { - LC3_FLOAT corr, ener; - LC3_INT16 i; + LC3_FLOAT corr, ener; + LC3_INT16 i; + + corr = 0; ener = 1e-6f; - corr = 0; - ener = 1e-6f; - - for ( i = 0; i < n; i++ ) + for (i = 0; i < n; i++) { - corr += x[i] * y[i]; - ener += y[i] * y[i]; + corr += x[i]*y[i]; + ener += y[i]*y[i]; } - return ( corr / ener ); + return(corr/ener); } -static LC3_FLOAT TDC_get_gainc( /* output: gain of code */ - const LC3_FLOAT x[], /* input : input signal */ - const LC3_FLOAT y[], /* input : shifted input signal */ - const LC3_FLOAT *gain_p, /* input : gain of pitch */ - const LC3_INT32 n, /* input : vector length */ - const LC3_INT32 frame_dms /* input : frame length in dms */ +static LC3_FLOAT TDC_get_gainc( /* output: gain of code */ + const LC3_FLOAT x[], /* input : input signal */ + const LC3_FLOAT y[], /* input : shifted input signal */ + const LC3_FLOAT *gain_p, /* input : gain of pitch */ + const LC3_INT32 n, /* input : vector length */ + const LC3_INT32 frame_dms /* input : frame length in dms */ ) { - LC3_FLOAT gain_c; - LC3_FLOAT gain_c_max; - LC3_INT16 i; - - gain_c = 0; - gain_c_max = 0; + LC3_FLOAT gain_c; + LC3_FLOAT gain_c_max; + LC3_INT16 i; + + gain_c = 0; gain_c_max = 0; - for ( i = 0; i < n; i++ ) + for (i = 0; i < n; i++) { - gain_c += ( x[-i] - *gain_p * y[-i] ) * ( x[-i] - *gain_p * y[-i] ); + gain_c += ( x[-i] - *gain_p * y[-i] ) * ( x[-i] - *gain_p * y[-i] ); } - if ( frame_dms < 100 ) + if (frame_dms < 100) { - for ( i = 0; i < n; i++ ) + for (i = 0; i < n; i++) { - gain_c_max += ( x[-i] * x[-i] ); + gain_c_max += (x[-i] * x[-i]); } - gain_c = MIN( gain_c, gain_c_max ); + gain_c = MIN(gain_c, gain_c_max); } - gain_c = (LC3_FLOAT) sqrt( gain_c / n ); + gain_c = (LC3_FLOAT)sqrt(gain_c / n ); return gain_c; } -static void TDC_highPassFiltering( const LC3_INT32 L_buffer, /* i: buffer length */ - LC3_FLOAT exc2[], /* i/o: unvoiced excitation before the high pass filtering */ - const LC3_FLOAT hp_filt[], /* i: high pass filter coefficients */ - const LC3_INT32 l_fir_fer ) /* i: high pass filter length */ +static void TDC_highPassFiltering(const LC3_INT32 L_buffer, /* i: buffer length */ + LC3_FLOAT exc2[], /* i/o: unvoiced excitation before the high pass filtering */ + const LC3_FLOAT hp_filt[], /* i: high pass filter coefficients */ + const LC3_INT32 l_fir_fer) /* i: high pass filter length */ { - LC3_INT32 i; - - for ( i = 0; i < L_buffer; i++ ) - { - exc2[i] = TDC_dotFLOAT( &exc2[i], hp_filt, l_fir_fer ); - } + LC3_INT32 i; + + for( i=0 ; i< L_buffer; i++ ) { + exc2[i] = TDC_dotFLOAT(&exc2[i], hp_filt, l_fir_fer); + } } static void TDC_LPC_synthesis( - const LC3_FLOAT a[], - LC3_FLOAT x[], - LC3_FLOAT y[], - LC3_INT32 l, - const LC3_FLOAT mem[], - LC3_INT32 lpcorder, - LC3_FLOAT *buf ) + const LC3_FLOAT a[], + LC3_FLOAT x[], + LC3_FLOAT y[], + LC3_INT32 l, + const LC3_FLOAT mem[], + LC3_INT32 lpcorder, + LC3_FLOAT *buf + ) { - LC3_FLOAT s, *yy; - LC3_INT32 i, j; - - /* copy initial filter states into synthesis buffer */ - for ( i = 0; i < lpcorder; i++ ) - { - buf[i] = mem[i]; - } - yy = &buf[i]; - - for ( i = 0; i < l; i++ ) - { - s = x[i]; - for ( j = 1; j <= lpcorder; j++ ) - { - s -= a[j] * yy[i - j]; - } - y[i] = s; - yy[i] = y[i]; - } - - return; + LC3_FLOAT s, *yy; + LC3_INT32 i, j; + + /* copy initial filter states into synthesis buffer */ + for (i=0; i < lpcorder; i++) + { + buf[i] = mem[i]; + } + yy = &buf[i]; + + for (i = 0; i < l; i++) + { + s = x[i]; + for (j = 1; j <= lpcorder; j++) + { + s -= a[j] * yy[i- j]; + } + y[i] = s; + yy[i] = y[i]; + } + + return; } @@ -625,22 +606,22 @@ static void TDC_LPC_synthesis( * Returns: * void */ -static void TDC_LPC_residu( const LC3_FLOAT *a, LC3_FLOAT *x, LC3_FLOAT *y, LC3_INT32 l, LC3_INT32 lpcorder ) +static void TDC_LPC_residu(const LC3_FLOAT *a, LC3_FLOAT *x, LC3_FLOAT *y, LC3_INT32 l, LC3_INT32 lpcorder) { - LC3_FLOAT s; - LC3_INT32 i, j; - - for ( i = 0; i < l; i++ ) - { - s = x[i]; - for ( j = 1; j <= lpcorder; j++ ) - { - s += a[j] * x[i - j]; - } - y[i] = s; - } - - return; + LC3_FLOAT s; + LC3_INT32 i, j; + + for (i = 0; i < l; i++) + { + s = x[i]; + for (j = 1; j <= lpcorder; j++) + { + s += a[j] * x[i - j]; + } + y[i] = s; + } + + return; } @@ -660,18 +641,18 @@ static void TDC_LPC_residu( const LC3_FLOAT *a, LC3_FLOAT *x, LC3_FLOAT *y, LC3_ * void */ -static void TDC_f_preemph( LC3_FLOAT *signal, const LC3_FLOAT *mu, LC3_INT32 L, LC3_FLOAT *mem ) +static void TDC_f_preemph(LC3_FLOAT *signal, const LC3_FLOAT *mu, LC3_INT32 L, LC3_FLOAT *mem) { - LC3_INT32 i; + LC3_INT32 i; - for ( i = L - 1; i > 0; i-- ) - { - signal[i] = signal[i] - *mu * signal[i - 1]; - } + for (i = L - 1; i > 0; i--) + { + signal[i] = signal[i] - *mu * signal[i - 1]; + } - signal[0] -= *mu * ( *mem ); + signal[0] -= *mu * (*mem); - return; + return; } /* @@ -690,99 +671,93 @@ static void TDC_f_preemph( LC3_FLOAT *signal, const LC3_FLOAT *mu, LC3_INT32 L, * Returns: * void */ -static void TDC_deemph( LC3_FLOAT *signal, const LC3_FLOAT *mu, LC3_INT32 L, const LC3_FLOAT *mem ) +static void TDC_deemph(LC3_FLOAT *signal, const LC3_FLOAT *mu, LC3_INT32 L, const LC3_FLOAT *mem) { - LC3_INT32 i; + LC3_INT32 i; - signal[0] = signal[0] + *mu * ( *mem ); + signal[0] = signal[0] + *mu * (*mem); - for ( i = 1; i < L; i++ ) - { - signal[i] = signal[i] + *mu * signal[i - 1]; - } + for (i = 1; i < L; i++) + { + signal[i] = signal[i] + *mu * signal[i - 1]; + } - return; + return; } -static void TDC_copyFLOAT( const LC3_FLOAT *X, LC3_FLOAT *Z, LC3_INT32 n ) +static void TDC_copyFLOAT(const LC3_FLOAT * X, LC3_FLOAT * Z, LC3_INT32 n) { - /* no values to copy */ - if ( ( n < 1 ) || ( X == Z ) ) - { - return; - } - /* If overlapping */ - if ( ( ( Z > X ) && ( Z < X + n ) ) || ( ( Z < X ) && ( X < Z + n ) ) ) - { - memmove( Z, X, sizeof( LC3_FLOAT ) * n ); - } - else - { - memcpy( Z, X, sizeof( LC3_FLOAT ) * n ); - } + /* no values to copy */ + if ( (n < 1) || (X == Z) ){ + return; + } + /* If overlapping */ + if ( ( (Z > X) && (Z < X+n) ) || ( (Z < X) && (X < Z+n) ) ) { + memmove(Z, X, sizeof(LC3_FLOAT)*n); + } + else{ + memcpy(Z, X, sizeof(LC3_FLOAT)*n); + } } -static LC3_FLOAT TDC_dotFLOAT( const LC3_FLOAT *X, const LC3_FLOAT *Y, LC3_INT32 n ) +static LC3_FLOAT TDC_dotFLOAT(const LC3_FLOAT * X, const LC3_FLOAT * Y, LC3_INT32 n) { - LC3_FLOAT acc; - LC3_INT32 i; - - acc = 0; - if ( n ) - { - acc = X[0] * Y[0]; - } + LC3_FLOAT acc; + LC3_INT32 i; - for ( i = 1; i < n; i++ ) - acc += X[i] * Y[i]; + acc = 0; + if (n) { + acc = X[0]*Y[0]; + } - return acc; + for (i=1; i= 0; i-- ) + for (i = t - 1; i >= 0; i--) { out[j] = buf[k] - g * buf2[i]; - j++; - k++; + j++; k++; } - v = v * ( 1.0 - g * g ); + v = v * (1.0 - g * g); } - move_float( buf, out, len ); + move_float(buf, out, len); out[0] = 1; j = 1; - for ( i = len - 1; i >= 0; i-- ) + for (i = len - 1; i >= 0; i--) { out[j] = -buf[i]; j++; } } + diff --git a/lib_lc3plus/plc_tdc_tdac.c b/lib_lc3plus/plc_tdc_tdac.c index 6d66eb6513..329361b14c 100644 --- a/lib_lc3plus/plc_tdc_tdac.c +++ b/lib_lc3plus/plc_tdc_tdac.c @@ -1,31 +1,31 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -void processTdcTdac_fl( const LC3_FLOAT *synth_inp, const LC3_FLOAT *win, LC3_INT32 frame_length, LC3_INT32 la_zeroes, LC3_FLOAT *ola_mem ) +void processTdcTdac_fl(const LC3_FLOAT *synth_inp, const LC3_FLOAT *win, LC3_INT32 frame_length, LC3_INT32 la_zeroes, LC3_FLOAT *ola_mem) { - LC3_INT32 i, L, LD2, NZ, synth_len; - LC3_FLOAT synth[( MAX_LEN + MDCT_MEM_LEN_MAX )], *synth1, *synth2, *ola_mem1, *ola_mem2, sz; - const LC3_FLOAT *win1, *win2, *win3, *win4; + LC3_INT32 i, L, LD2, NZ, synth_len; + LC3_FLOAT synth[(MAX_LEN + MDCT_MEM_LEN_MAX)], *synth1, *synth2, *ola_mem1, *ola_mem2, sz; + const LC3_FLOAT *win1, *win2, *win3, *win4; - assert( la_zeroes <= frame_length / 2 ); + assert(la_zeroes <= frame_length / 2); - L = frame_length; - LD2 = L / 2; - NZ = LD2 - la_zeroes; - synth_len = 2 * L - la_zeroes; + L = frame_length; + LD2 = L/2; + NZ = LD2 - la_zeroes; + synth_len = 2*L - la_zeroes; - move_float( synth, synth_inp, synth_len ); + move_float(synth, synth_inp, synth_len); /* calculate x_ov[L+la_zeroes] ... x_ov[2*L-1] */ win1 = &win[L + LD2 - 1]; @@ -40,7 +40,7 @@ void processTdcTdac_fl( const LC3_FLOAT *synth_inp, const LC3_FLOAT *win, LC3_IN ola_mem1 = &ola_mem[LD2 - la_zeroes]; ola_mem2 = &ola_mem[LD2 - la_zeroes - 1]; - for ( i = 0; i < NZ; i++ ) + for (i = 0; i < NZ; i++) { /* analysis windowing + 2N -> N */ sz = *synth1 * *win1 + *synth2 * *win2; @@ -60,7 +60,7 @@ void processTdcTdac_fl( const LC3_FLOAT *synth_inp, const LC3_FLOAT *win, LC3_IN ola_mem2--; } - for ( ; i < LD2; i++ ) + for (; i < LD2; i++) { /* analysis windowing + 2N -> N */ sz = *synth1 * *win1; @@ -77,3 +77,4 @@ void processTdcTdac_fl( const LC3_FLOAT *synth_inp, const LC3_FLOAT *win, LC3_IN ola_mem1++; } } + diff --git a/lib_lc3plus/plc_update.c b/lib_lc3plus/plc_update.c index ed24a1f3a0..a151420eb7 100644 --- a/lib_lc3plus/plc_update.c +++ b/lib_lc3plus/plc_update.c @@ -1,129 +1,125 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ #include "functions.h" #include "options.h" -void processPlcUpdate_fl( PlcAdvSetup *PlcAdvSetup, LC3_INT32 frame_length, LC3_FLOAT *syntM, LC3_FLOAT *scf_q, LC3_INT32 *nbLostCmpt, LC3_FLOAT *cum_alpha, LC3_INT32 bfi, LC3_INT32 *prevBfi, LC3_INT32 *prevprevBfi ) +void processPlcUpdate_fl(PlcAdvSetup *PlcAdvSetup, LC3_INT32 frame_length, LC3_FLOAT *syntM, LC3_FLOAT *scf_q, + LC3_INT32 *nbLostCmpt, LC3_FLOAT *cum_alpha, LC3_INT32 bfi, LC3_INT32 *prevBfi, LC3_INT32 *prevprevBfi) { LC3_FLOAT tmp[MAX_LEN_PCM_PLC]; - - move_float( tmp, &PlcAdvSetup->pcmbufHist[frame_length], PlcAdvSetup->max_len_pcm_plc - frame_length ); - move_float( &PlcAdvSetup->pcmbufHist[0], tmp, PlcAdvSetup->max_len_pcm_plc - frame_length ); - move_float( &PlcAdvSetup->pcmbufHist[PlcAdvSetup->max_len_pcm_plc - frame_length], syntM, frame_length ); - - if ( bfi != 1 ) - { + + move_float(tmp, &PlcAdvSetup->pcmbufHist[frame_length], PlcAdvSetup->max_len_pcm_plc - frame_length); + move_float(&PlcAdvSetup->pcmbufHist[0], tmp, PlcAdvSetup->max_len_pcm_plc - frame_length); + move_float(&PlcAdvSetup->pcmbufHist[PlcAdvSetup->max_len_pcm_plc - frame_length], syntM, frame_length); + + if (bfi != 1) + { *nbLostCmpt = 0; *cum_alpha = 1; - - if ( PlcAdvSetup ) + + if (PlcAdvSetup) { - move_float( PlcAdvSetup->scf_q_old_old, PlcAdvSetup->scf_q_old, M ); - move_float( PlcAdvSetup->scf_q_old, scf_q, M ); - /* PLC fullband transient detector setting for non-bfi frames */ - PlcAdvSetup->PlcPhEcuSetup.PhECU_short_flag_prev = 0; /* fullband transient not active */ + move_float(PlcAdvSetup->scf_q_old_old, PlcAdvSetup->scf_q_old, M); + move_float(PlcAdvSetup->scf_q_old, scf_q, M); + /* PLC fullband transient detector setting for non-bfi frames */ + PlcAdvSetup->PlcPhEcuSetup.PhECU_short_flag_prev = 0; /* fullband transient not active */ } } - + *prevprevBfi = *prevBfi; *prevBfi = bfi; } -void plc_phEcu_processPLCspec2shape( LC3_INT16 prev_bfi, LC3_INT16 bfi, LC3_FLOAT q_d[], LC3_INT32 yLen, LC3_FLOAT *stPhECU_oold_grp_shape, LC3_FLOAT *stPhECU_old_grp_shape ) +void plc_phEcu_processPLCspec2shape(LC3_INT16 prev_bfi, LC3_INT16 bfi, LC3_FLOAT q_d[], LC3_INT32 yLen, + LC3_FLOAT *stPhECU_oold_grp_shape, LC3_FLOAT *stPhECU_old_grp_shape) { - LC3_INT32 i, j, N_grp; - LC3_INT32 local_prev_bfi; - LC3_INT32 fs_idx; - LC3_FLOAT E_tot = 0.0; - LC3_INT32 l_grp; - LC3_FLOAT *pX; - - if ( bfi != 1 ) /* compute only for bfi== 0 or 2 */ - { - fs_idx = (LC3_INT32) floor( yLen / 100 ); - assert( fs_idx < 5 ); - N_grp = xavg_N_grp[fs_idx]; - - local_prev_bfi = prev_bfi; - if ( local_prev_bfi == 2 ) - { - local_prev_bfi = 0; - } - - - /* Copy old to oold grp shape */ - for ( i = 0; i < MAX_LGW; i++ ) - { - stPhECU_oold_grp_shape[i] = stPhECU_old_grp_shape[i]; - } - - /* Accumulate DC-coupled bins to total */ - E_tot = 0; - pX = q_d; /* ptr setup */ - for ( i = 0; i < mdct_grp_bins[0]; i++ ) - { - E_tot += sqrf( *pX ); + LC3_INT32 i, j, N_grp; + LC3_INT32 local_prev_bfi; + LC3_INT32 fs_idx; + LC3_FLOAT E_tot = 0.0; + LC3_INT32 l_grp; + LC3_FLOAT *pX; + + if (bfi != 1) /* compute only for bfi== 0 or 2 */ + { + fs_idx = (LC3_INT32)floor(yLen / 100); + assert(fs_idx < 5); + N_grp = xavg_N_grp[fs_idx]; + + local_prev_bfi = prev_bfi; + if (local_prev_bfi == 2) { + local_prev_bfi = 0; + } + + + /* Copy old to oold grp shape */ + for (i = 0; i < MAX_LGW; i++) + { + stPhECU_oold_grp_shape[i] = stPhECU_old_grp_shape[i]; + } + + /* Accumulate DC-coupled bins to total */ + E_tot = 0; + pX = q_d; /* ptr setup */ + for (i = 0; i < mdct_grp_bins[0]; i++) + { + E_tot += sqrf( *pX ); + pX++; + } + + /* Accumulate middle grps and add to total */ + for (i = 0; i < (N_grp - 1); i++) + { + l_grp = mdct_grp_bins[i + 1] - mdct_grp_bins[i]; ; + stPhECU_old_grp_shape[i] = 0.0; + for (j = 0; j < l_grp; j++) { + stPhECU_old_grp_shape[i] += sqrf( *pX ); pX++; - } - - /* Accumulate middle grps and add to total */ - for ( i = 0; i < ( N_grp - 1 ); i++ ) - { - l_grp = mdct_grp_bins[i + 1] - mdct_grp_bins[i]; - ; + } + E_tot += stPhECU_old_grp_shape[i]; + } + + /* Accumulate last subbband and add to total */ + stPhECU_old_grp_shape[(N_grp - 1)] = 0.0; + l_grp = mdct_grp_bins[N_grp] - mdct_grp_bins[N_grp - 1] - mdct_grp_bins[0]; + assert( (mdct_grp_bins[N_grp] - mdct_grp_bins[0]) <= yLen); + for (j = 0; j < l_grp; j++) + { + stPhECU_old_grp_shape[(N_grp - 1)] += sqrf( *pX ); + pX++; + } + E_tot += stPhECU_old_grp_shape[(N_grp - 1)]; + + + /* Normalize shape */ + for (i = 0; i < (N_grp); i++) { + if (E_tot > 0.0) { + stPhECU_old_grp_shape[i] /= E_tot; + } + else + { stPhECU_old_grp_shape[i] = 0.0; - for ( j = 0; j < l_grp; j++ ) - { - stPhECU_old_grp_shape[i] += sqrf( *pX ); - pX++; - } - E_tot += stPhECU_old_grp_shape[i]; - } - - /* Accumulate last subbband and add to total */ - stPhECU_old_grp_shape[( N_grp - 1 )] = 0.0; - l_grp = mdct_grp_bins[N_grp] - mdct_grp_bins[N_grp - 1] - mdct_grp_bins[0]; - assert( ( mdct_grp_bins[N_grp] - mdct_grp_bins[0] ) <= yLen ); - for ( j = 0; j < l_grp; j++ ) - { - stPhECU_old_grp_shape[( N_grp - 1 )] += sqrf( *pX ); - pX++; - } - E_tot += stPhECU_old_grp_shape[( N_grp - 1 )]; - - - /* Normalize shape */ - for ( i = 0; i < ( N_grp ); i++ ) - { - if ( E_tot > 0.0 ) - { - stPhECU_old_grp_shape[i] /= E_tot; - } - else - { - stPhECU_old_grp_shape[i] = 0.0; - } - } - if ( local_prev_bfi == 1 ) - { - for ( i = 0; i < MAX_LGW; i++ ) - { - stPhECU_oold_grp_shape[i] = stPhECU_old_grp_shape[i]; - } - } - } /*bfi*/ - return; + } + } + if (local_prev_bfi == 1) { + for (i = 0; i < MAX_LGW; i++) { + stPhECU_oold_grp_shape[i] = stPhECU_old_grp_shape[i]; + } + } + }/*bfi*/ + return; } -void processPlcUpdateSpec_fl( LC3_FLOAT *q_d_prev, LC3_FLOAT *q_d_fl_c, LC3_INT32 yLen ) +void processPlcUpdateSpec_fl(LC3_FLOAT *q_d_prev, LC3_FLOAT *q_d_fl_c, LC3_INT32 yLen) { - move_float( q_d_prev, q_d_fl_c, yLen ); + move_float(q_d_prev, q_d_fl_c, yLen); } + diff --git a/lib_lc3plus/quantize_spec.c b/lib_lc3plus/quantize_spec.c index 3a7b051cb4..7886b4586d 100644 --- a/lib_lc3plus/quantize_spec.c +++ b/lib_lc3plus/quantize_spec.c @@ -1,228 +1,194 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -static LC3_INT sign( LC3_FLOAT x ); +static LC3_INT sign(LC3_FLOAT x); -LC3_INT sign( LC3_FLOAT x ) +LC3_INT sign(LC3_FLOAT x) { - if ( x > 0 ) + if (x > 0) return 1; - if ( x < 0 ) + if (x < 0) return -1; return 0; } -void processQuantizeSpec_fl( LC3_FLOAT x[], LC3_FLOAT gain, LC3_INT xq[], LC3_INT nt, LC3_INT totalBits, LC3_INT *nbits, LC3_INT *nbits2, LC3_INT fs, LC3_INT *lastnzout, LC3_INT *codingdata, LC3_INT *lsbMode, LC3_INT mode, LC3_INT target, LC3_INT hrmode ) +void processQuantizeSpec_fl(LC3_FLOAT x[], LC3_FLOAT gain, LC3_INT xq[], LC3_INT nt, LC3_INT totalBits, LC3_INT* nbits, LC3_INT* nbits2, LC3_INT fs, + LC3_INT* lastnzout, LC3_INT* codingdata, LC3_INT* lsbMode, LC3_INT mode, LC3_INT target, LC3_INT hrmode) { LC3_INT rateFlag = 0, i = 0, lastnz2 = 0, m = 0, maxlev = 0, k = 0; LC3_INT nbits_lsb = 0; - LC3_INT c = 0; + LC3_INT c = 0; LC3_INT a = 0, b = 0, lev1 = 0, sym = 0, t = 0, pki = 0; LC3_INT a1_msb = 0, b1_msb = 0; LC3_INT lastnz = 1; LC3_FLOAT offset = 0.375; - if ( hrmode ) + if (hrmode) { offset = 0.5; } /* Quantization */ - for ( i = 0; i < nt; i++ ) - { - xq[i] = trunc( x[i] / gain + offset * sign( x[i] ) ); - if ( hrmode == 0 ) - { - assert( xq[i] <= 32767 && xq[i] >= -32768 ); + for (i = 0; i < nt; i++) { + xq[i] = trunc(x[i] / gain + offset * sign(x[i])); + if (hrmode == 0) { + assert(xq[i] <= 32767 && xq[i] >= -32768); } } /* Rate flag */ - if ( ( fs < 48000 && totalBits > 320 + ( fs / 8000 - 2 ) * 160 ) || ( fs == 48000 && totalBits > 800 ) ) - { + if ((fs < 48000 && totalBits > 320 + (fs / 8000 - 2) * 160) || (fs == 48000 && totalBits > 800)) { rateFlag = 512; } /* Init */ - if ( mode == 0 && ( ( fs < 48000 && totalBits >= 640 + ( fs / 8000 - 2 ) * 160 ) || ( fs == 48000 && totalBits >= 1120 ) ) ) - { + if (mode == 0 && ((fs < 48000 && totalBits >= 640 + (fs / 8000 - 2) * 160) || (fs == 48000 && totalBits >= 1120))) { mode = 1; } /* Last non-zero 2-tuple */ - for ( i = nt - 2; i >= 2; i = i - 2 ) - { - if ( xq[i + 1] != 0 || xq[i] != 0 ) - { + for (i = nt - 2; i >= 2; i = i - 2) { + if (xq[i + 1] != 0 || xq[i] != 0) { lastnz = i + 1; break; } } - if ( mode < 0 ) - { + if (mode < 0) { lastnz2 = lastnz + 1; - } - else - { + } else { lastnz2 = 2; } - *nbits = 0; + *nbits = 0; *nbits2 = 0; /* Calculate number of estimated bits */ - for ( k = 0; k < lastnz; k = k + 2 ) - { + for (k = 0; k < lastnz; k = k + 2) { t = c + rateFlag; - if ( k > nt / 2 ) - { + if (k > nt / 2) { t += 256; } codingdata[0] = t; - a = abs( xq[k] ); - b = abs( xq[k + 1] ); - m = MAX( a, b ); + a = abs(xq[k]); + b = abs(xq[k + 1]); + m = MAX(a, b); - if ( m == 0 ) - { + if (m == 0) { maxlev = -1; - } - else - { - maxlev = 29 - ( clz_func( MAX( m, 3 ) ) - 1 ); + } else { + maxlev = 29 - (clz_func(MAX(m, 3)) - 1); } codingdata[1] = maxlev; - if ( mode <= 0 ) - { - *nbits = *nbits + MIN( a, 1 ) * 2048; - *nbits = *nbits + MIN( b, 1 ) * 2048; + if (mode <= 0) { + *nbits = *nbits + MIN(a, 1) * 2048; + *nbits = *nbits + MIN(b, 1) * 2048; } lev1 = 0; - while ( MAX( a, b ) >= 4 ) - { - pki = ari_spec_lookup_fl[t + lev1 * 1024]; + while (MAX(a, b) >= 4) { + pki = ari_spec_lookup_fl[t + lev1 * 1024]; *nbits = *nbits + ari_spec_bits_fl[pki][16]; - if ( lev1 == 0 && mode > 0 ) - { + if (lev1 == 0 && mode > 0) { nbits_lsb += 2; - } - else - { + } else { *nbits = *nbits + 2 * 2048; } - a = a >> 1; - b = b >> 1; - lev1 = MIN( lev1 + 1, 3 ); + a = a >> 1; + b = b >> 1; + lev1 = MIN(lev1 + 1, 3); } - pki = ari_spec_lookup_fl[t + lev1 * 1024]; - sym = a + 4 * b; + pki = ari_spec_lookup_fl[t + lev1 * 1024]; + sym = a + 4 * b; codingdata[2] = sym; codingdata += 3; *nbits = *nbits + ari_spec_bits_fl[pki][sym]; - if ( mode > 0 ) - { - a1_msb = abs( xq[k] ); - b1_msb = abs( xq[k + 1] ); + if (mode > 0) { + a1_msb = abs(xq[k]); + b1_msb = abs(xq[k + 1]); - if ( lev1 > 0 ) - { + if (lev1 > 0) { a1_msb = a1_msb >> 1; b1_msb = b1_msb >> 1; - if ( a1_msb == 0 && xq[k] != 0 ) - { + if (a1_msb == 0 && xq[k] != 0) { nbits_lsb++; } - if ( b1_msb == 0 && xq[k + 1] != 0 ) - { + if (b1_msb == 0 && xq[k + 1] != 0) { nbits_lsb++; } } - *nbits = *nbits + MIN( a1_msb, 1 ) * 2048; - *nbits = *nbits + MIN( b1_msb, 1 ) * 2048; + *nbits = *nbits + MIN(a1_msb, 1) * 2048; + *nbits = *nbits + MIN(b1_msb, 1) * 2048; } - if ( mode >= 0 && ( abs( xq[k] ) != 0 || abs( xq[k + 1] ) != 0 ) && *nbits <= target * 2048 ) - { + if (mode >= 0 && (abs(xq[k]) != 0 || abs(xq[k + 1]) != 0) && *nbits <= target * 2048) { lastnz2 = k + 2; *nbits2 = *nbits; } lev1 = lev1 - 1; - if ( lev1 <= 0 ) - { - t = 1 + ( a + b ) * ( lev1 + 2 ); - } - else - { + if (lev1 <= 0) { + t = 1 + (a + b) * (lev1 + 2); + } else { t = 13 + lev1; } - c = ( c & 15 ) * 16 + t; + c = (c & 15) * 16 + t; } /* Number of bits */ - *nbits = ceil( (LC3_FLOAT) *nbits / 2048.0 ); + *nbits = ceil((LC3_FLOAT)*nbits / 2048.0); - if ( mode >= 0 ) - { - *nbits2 = ceil( (LC3_FLOAT) *nbits2 / 2048.0 ); - } - else - { + if (mode >= 0) { + *nbits2 = ceil((LC3_FLOAT)*nbits2 / 2048.0); + } else { *nbits2 = *nbits; } - if ( mode > 0 ) - { + if (mode > 0) { *nbits += nbits_lsb; *nbits2 += nbits_lsb; } /* Truncation of high-frequency coefficients */ - for ( i = lastnz2; i <= lastnz; i++ ) - { + for (i = lastnz2; i <= lastnz; i++) { xq[i] = 0; } /* Truncation of LSBs */ - if ( mode > 0 && *nbits > target ) - { + if (mode > 0 && *nbits > target) { *lsbMode = 1; - } - else - { + } else { *lsbMode = 0; } diff --git a/lib_lc3plus/reorder_bitstream.c b/lib_lc3plus/reorder_bitstream.c index a5f3205ff3..77b50d7a13 100644 --- a/lib_lc3plus/reorder_bitstream.c +++ b/lib_lc3plus/reorder_bitstream.c @@ -1,40 +1,41 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -void processReorderBitstream_fl( LC3_UINT8 *bytes, LC3_INT32 n_pccw, LC3_INT32 n_pc, LC3_INT32 b_left, LC3_INT32 len ) +void processReorderBitstream_fl(LC3_UINT8* bytes, LC3_INT32 n_pccw, LC3_INT32 n_pc, LC3_INT32 b_left, LC3_INT32 len) { LC3_UINT8 bytes_local[MAX_NBYTES2]; LC3_INT32 i, block_bytes; - - assert( b_left > 0 ); - - memcpy( bytes_local, bytes, len * sizeof( LC3_UINT8 ) ); - - if ( n_pccw == 0 ) + + assert(b_left > 0); + + memcpy(bytes_local, bytes, len * sizeof(LC3_UINT8)); + + if (n_pccw == 0) { return; } - - block_bytes = ceil( (LC3_FLOAT) n_pc / 2.0 ); - - for ( i = 0; i < block_bytes; i++ ) + + block_bytes = ceil((LC3_FLOAT) n_pc / 2.0); + + for (i = 0; i < block_bytes; i++) { bytes[i] = bytes_local[b_left + i]; } - - for ( i = 0; i < b_left; i++ ) + + for (i = 0; i < b_left; i++) { bytes[block_bytes + i] = bytes_local[i]; } } + diff --git a/lib_lc3plus/resamp12k8.c b/lib_lc3plus/resamp12k8.c index 3c40b20082..0cab5daae9 100644 --- a/lib_lc3plus/resamp12k8.c +++ b/lib_lc3plus/resamp12k8.c @@ -1,22 +1,23 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -void process_resamp12k8_fl( LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC3_INT mem_in_len, LC3_FLOAT mem_50[], LC3_FLOAT mem_out[], LC3_INT mem_out_len, LC3_FLOAT y[], LC3_INT *y_len, LC3_INT fs_idx, LC3_INT frame_dms, LC3_INT fs ) +void process_resamp12k8_fl(LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC3_INT mem_in_len, LC3_FLOAT mem_50[], LC3_FLOAT mem_out[], + LC3_INT mem_out_len, LC3_FLOAT y[], LC3_INT* y_len, LC3_INT fs_idx, LC3_INT frame_dms, LC3_INT fs) { + - - LC3_INT len_12k8 = 0, N12k8 = 0, i = 0, k = 0; - LC3_FLOAT mac = 0, buf_out[120 + MAX_LEN] = { 0 }, bufdown[128] = { 0 }, buf[120 + MAX_LEN] = { 0 }; + LC3_INT len_12k8 = 0, N12k8 = 0, i = 0, k = 0; + LC3_FLOAT mac = 0, buf_out[120 + MAX_LEN] = {0}, bufdown[128] = {0}, buf[120 + MAX_LEN] = {0}; LC3_INT32 index_int, index_frac, resamp_upfac, resamp_delay, resamp_off_int, resamp_off_frac; LC3_FLOAT u_11, u_21, u_1, u_2; @@ -24,7 +25,7 @@ void process_resamp12k8_fl( LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC const LC3_FLOAT *filt_input, *filt_coeff; - switch ( frame_dms ) + switch (frame_dms) { case 25: len_12k8 = LEN_12K8 / 4; @@ -38,42 +39,42 @@ void process_resamp12k8_fl( LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC } *y_len = len_12k8; - N12k8 = x_len * 12800 / fs; + N12k8 = x_len * 12800 / fs; /* Init Input Buffer */ - memmove( buf, mem_in, mem_in_len * sizeof( LC3_FLOAT ) ); - memmove( &buf[mem_in_len], x, x_len * sizeof( LC3_FLOAT ) ); - memmove( mem_in, &buf[x_len], mem_in_len * sizeof( LC3_FLOAT ) ); + memmove(buf, mem_in, mem_in_len * sizeof(LC3_FLOAT)); + memmove(&buf[mem_in_len], x, x_len * sizeof(LC3_FLOAT)); + memmove(mem_in, &buf[x_len], mem_in_len * sizeof(LC3_FLOAT)); + filter = lp_filter[fs_idx]; /* Upsampling & Low-pass Filtering & Downsampling */ - index_int = 1; + index_int = 1; index_frac = 0; - resamp_upfac = resamp_params[fs_idx][0]; - resamp_delay = resamp_params[fs_idx][1]; - resamp_off_int = resamp_params[fs_idx][2]; + resamp_upfac = resamp_params[fs_idx][0]; + resamp_delay = resamp_params[fs_idx][1]; + resamp_off_int = resamp_params[fs_idx][2]; resamp_off_frac = resamp_params[fs_idx][3]; k = 0; - for ( i = 0; i < N12k8; i++ ) - { + for (i = 0; i < N12k8; i++) { filt_input = &buf[index_int]; filt_coeff = &filter[index_frac * resamp_delay * 2]; - mac = mac_loop( filt_input, filt_coeff, ( 2 * resamp_delay ) ); - + mac = mac_loop(filt_input, filt_coeff, (2 * resamp_delay)); + bufdown[k++] = mac; - - index_int = index_int + resamp_off_int; + + index_int = index_int + resamp_off_int; index_frac = index_frac + resamp_off_frac; - - if ( ( resamp_upfac - index_frac ) <= 0 ) + + if ((resamp_upfac - index_frac) <= 0) { - index_int = index_int + 1; + index_int = index_int + 1; index_frac = index_frac - resamp_upfac; } } @@ -83,25 +84,24 @@ void process_resamp12k8_fl( LC3_FLOAT x[], LC3_INT x_len, LC3_FLOAT mem_in[], LC u_11 = mem_50[0]; u_21 = mem_50[1]; - for ( i = 0; i < len_12k8; i++ ) - { - LC3_FLOAT y1 = ( highpass50_filt_b[0] * bufdown[i] + u_11 ); - u_1 = ( highpass50_filt_b[1] * bufdown[i] + u_21 ) - highpass50_filt_a[1] * y1; - u_2 = highpass50_filt_b[2] * bufdown[i] - highpass50_filt_a[2] * y1; - u_11 = u_1; - u_21 = u_2; - bufdown[i] = (LC3_FLOAT) y1; + for (i = 0; i < len_12k8; i++) { + LC3_FLOAT y1 = (highpass50_filt_b[0] * bufdown[i] + u_11); + u_1 = (highpass50_filt_b[1] * bufdown[i] + u_21) - highpass50_filt_a[1] * y1; + u_2 = highpass50_filt_b[2] * bufdown[i] - highpass50_filt_a[2] * y1; + u_11 = u_1; + u_21 = u_2; + bufdown[i] = (LC3_FLOAT)y1; } - mem_50[0] = (LC3_FLOAT) u_11; - mem_50[1] = (LC3_FLOAT) u_21; + mem_50[0] = (LC3_FLOAT)u_11; + mem_50[1] = (LC3_FLOAT)u_21; /* Output Buffer */ - memmove( buf_out, mem_out, mem_out_len * sizeof( LC3_FLOAT ) ); + memmove(buf_out, mem_out, mem_out_len * sizeof(LC3_FLOAT)); - memmove( &buf_out[mem_out_len], bufdown, len_12k8 * sizeof( LC3_FLOAT ) ); + memmove(&buf_out[mem_out_len], bufdown, len_12k8 * sizeof(LC3_FLOAT)); - memmove( y, buf_out, ( *y_len + 1 ) * sizeof( LC3_FLOAT ) ); + memmove(y, buf_out, (*y_len + 1) * sizeof(LC3_FLOAT)); - memmove( mem_out, &buf_out[N12k8], mem_out_len * sizeof( LC3_FLOAT ) ); + memmove(mem_out, &buf_out[N12k8], mem_out_len * sizeof(LC3_FLOAT)); } diff --git a/lib_lc3plus/residual_coding.c b/lib_lc3plus/residual_coding.c index 844057cf8f..42094d275f 100644 --- a/lib_lc3plus/residual_coding.c +++ b/lib_lc3plus/residual_coding.c @@ -1,71 +1,74 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -void processResidualCoding_fl( LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gain, LC3_INT L_spec, LC3_INT targetBits, LC3_INT nBits, uint8_t *resBits, LC3_INT *numResBits, LC3_INT hrmode ) +void processResidualCoding_fl(LC3_FLOAT x[], LC3_INT xq[], LC3_FLOAT gain, LC3_INT L_spec, LC3_INT targetBits, LC3_INT nBits, uint8_t* resBits, LC3_INT* numResBits + , LC3_INT hrmode +) { LC3_INT n = 0, m = 0, k = 0; - LC3_INT iter = 0; + LC3_INT iter=0; LC3_FLOAT offset; LC3_INT iter_max = 1; - LC3_INT nz_idx[MAX_LEN] = { 0 }; + LC3_INT nz_idx[MAX_LEN] = {0}; LC3_INT N_nz = 0, idx = 0; - memset( resBits, 0, MAX_RESBITS_LEN ); + memset(resBits, 0, MAX_RESBITS_LEN); m = targetBits - nBits + 4; - if ( hrmode ) + if (hrmode) { m += 10; } - assert( m <= MAX_RESBITS ); + assert(m <= MAX_RESBITS); offset = .25; - if ( hrmode ) + if (hrmode) { iter_max = EXT_RES_ITER_MAX; + } - for ( k = 0; k < L_spec; k++ ) + for (k = 0; k < L_spec; k ++) { - if ( xq[k] ) + if (xq[k]) { - nz_idx[N_nz++] = k; + nz_idx[N_nz ++] = k; } } - while ( iter < iter_max && n < m ) + while (iter < iter_max && n < m) { k = 0; - while ( k < N_nz && n < m ) + while (k < N_nz && n < m) { idx = nz_idx[k]; - - if ( x[idx] >= (LC3_FLOAT) xq[idx] * gain ) + + if (x[idx] >= (LC3_FLOAT)xq[idx] * gain) { - resBits[n >> 3] |= 1 << ( n & 7 ); + resBits[n >> 3] |= 1 << (n & 7); x[idx] -= gain * offset; } else { - resBits[n >> 3] &= ~( 1 << ( n & 7 ) ); + resBits[n >> 3] &= ~(1 << (n & 7)); x[idx] += gain * offset; } - + n++; - + k++; } - iter++; + iter ++; offset *= .5; } diff --git a/lib_lc3plus/residual_decoding.c b/lib_lc3plus/residual_decoding.c index 05f257e645..97fd94afc3 100644 --- a/lib_lc3plus/residual_decoding.c +++ b/lib_lc3plus/residual_decoding.c @@ -1,27 +1,29 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -void processResidualDecoding_fl( LC3_INT *bitsRead, LC3_FLOAT x[], LC3_INT L_spec, uint8_t prm[], LC3_INT resQBits, LC3_INT hrmode ) +void processResidualDecoding_fl(LC3_INT* bitsRead, LC3_FLOAT x[], LC3_INT L_spec, uint8_t prm[], LC3_INT resQBits + , LC3_INT hrmode +) { LC3_INT k = 0, n = 0; LC3_FLOAT offset1 = 0, offset2 = 0; LC3_FLOAT offset = 0; - LC3_INT nz_idx[MAX_LEN] = { 0 }; + LC3_INT nz_idx[MAX_LEN] = {0}; LC3_INT N_nz = 0, idx = 0; LC3_INT iter = 0, iter_max = 1; - if ( hrmode ) + if (hrmode) { iter_max = EXT_RES_ITER_MAX; offset = offset1 = offset2 = 0.25; @@ -32,72 +34,62 @@ void processResidualDecoding_fl( LC3_INT *bitsRead, LC3_FLOAT x[], LC3_INT L_spe offset2 = 0.3125; } - if ( hrmode ) + if (hrmode) { /* enumerat non-zero coefficients */ - for ( k = 0; k < L_spec; k++ ) + for (k = 0; k < L_spec; k ++) { - if ( x[k] ) + if (x[k]) { - nz_idx[N_nz++] = k; + nz_idx[N_nz ++] = k; } } /* apply residual corrections */ - while ( n < resQBits && iter < iter_max ) + while (n < resQBits && iter < iter_max) { - for ( k = 0; k < N_nz; k++ ) + for (k = 0; k < N_nz; k ++) { idx = nz_idx[k]; - - if ( ( prm[n >> 3] & 1 << ( n & 7 ) ) == 0 ) + + if ((prm[n >> 3] & 1 << (n & 7)) == 0) { x[idx] -= offset; } else { - + x[idx] += offset; } - if ( ++n >= resQBits ) + if (++n >= resQBits) { break; } } offset /= 2; - iter++; + iter ++; } } else { - while ( k < L_spec && n < resQBits ) - { - if ( x[k] != 0 ) - { - if ( ( prm[n >> 3] & 1 << ( n & 7 ) ) == 0 ) + while (k < L_spec && n < resQBits) { + if (x[k] != 0) { + if ((prm[n >> 3] & 1 << (n & 7)) == 0) { - if ( x[k] > 0 ) - { + if (x[k] > 0) { x[k] -= offset1; - } - else - { + } else { x[k] -= offset2; } - } - else - { - if ( x[k] > 0 ) - { + } else { + if (x[k] > 0) { x[k] += offset2; - } - else - { + } else { x[k] += offset1; } } n++; } - + k++; } } diff --git a/lib_lc3plus/setup_com_lc3.c b/lib_lc3plus/setup_com_lc3.c index 95c6271dcf..17054d1ffc 100644 --- a/lib_lc3plus/setup_com_lc3.c +++ b/lib_lc3plus/setup_com_lc3.c @@ -1,29 +1,30 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "functions.h" #include "options.h" -LC3_FLOAT array_max_abs( LC3_FLOAT *in, LC3_INT32 len ) +LC3_FLOAT array_max_abs(LC3_FLOAT *in, LC3_INT32 len) { - LC3_FLOAT max; - LC3_INT32 i; - - max = LC3_FABS( in[0] ); - - for ( i = 0; i < len; i++ ) + LC3_FLOAT max; + LC3_INT32 i; + + max = LC3_FABS(in[0]); + + for (i = 0; i < len; i++) { - if ( LC3_FABS( in[i] ) > LC3_FABS( max ) ) + if (LC3_FABS(in[i]) > LC3_FABS(max)) { - max = LC3_FABS( in[i] ); + max = LC3_FABS(in[i]); } } - + return max; } + diff --git a/lib_lc3plus/setup_dec_lc3.c b/lib_lc3plus/setup_dec_lc3.c index 310e8f530d..c14309720e 100644 --- a/lib_lc3plus/setup_dec_lc3.c +++ b/lib_lc3plus/setup_dec_lc3.c @@ -1,12 +1,12 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "setup_dec_lc3.h" @@ -15,54 +15,52 @@ #include /* if decoder is null only size is reported */ -#include "fft/iis_fft.h" +# include "fft/iis_fft.h" -int alloc_decoder( LC3PLUS_Dec *decoder, int samplerate, int channels ) +int alloc_decoder(LC3PLUS_Dec* decoder, int samplerate, int channels) { - int ch = 0; - size_t size = sizeof( LC3PLUS_Dec ); - size_t frame_len = DYN_MAX_LEN_EXT( samplerate ); - - void *PlcAdvSetup = NULL; - LC3_FLOAT *pcmbufHist, *harmonicBuf; - LC3_FLOAT *PhECU_oold_grp_shape, *PhECU_old_grp_shape; - LC3_FLOAT *PhECU_xfp; - Complex *PhECU_X_sav_m; - LC3_INT32 *PhECU_plocs; - LC3_FLOAT *PhECU_f0est, *PhECU_mag_chg_1st, *PhECU_Xavg; - LC3_FLOAT *sine_table1_phecu, *sine_table2_phecu; - HANDLE_IIS_FFT handle_fft_phaseecu; - HANDLE_IIS_FFT handle_ifft_phaseecu; - LC3_FLOAT *q_old_res; - - for ( ch = 0; ch < channels; ch++ ) - { - DecSetup *setup = balloc( decoder, &size, sizeof( DecSetup ) ); - - size_t max_pitch = ceilf( 228.0 * CODEC_FS( samplerate ) / 12800.0 ); - size_t pcm_plc_len = max_pitch + frame_len; - pcmbufHist = balloc( decoder, &size, sizeof( LC3_FLOAT ) * pcm_plc_len ); - harmonicBuf = balloc( decoder, &size, sizeof( LC3_FLOAT ) * max_pitch ); - PlcAdvSetup = balloc( decoder, &size, sizeof( *setup->PlcAdvSetup ) ); - PhECU_oold_grp_shape = balloc( decoder, &size, sizeof( LC3_FLOAT ) * MAX_LGW ); /* BASOP Word16 PhECU_oold_grp_shape_fx[MAX_LGW]; */ - PhECU_old_grp_shape = balloc( decoder, &size, sizeof( LC3_FLOAT ) * MAX_LGW ); /* BASOP Word16 PhECU_old_grp_shape_fx[MAX_LGW] ; */ - PhECU_xfp = balloc( decoder, &size, sizeof( LC3_FLOAT ) * ( frame_len * 16 / 10 ) ); - PhECU_X_sav_m = balloc( decoder, &size, sizeof( Complex ) * ( ( ( frame_len * 16 / 10 ) / 2 ) + 1 ) ); /*MAX_PLC_LMSPEC*/ - PhECU_plocs = balloc( decoder, &size, sizeof( LC3_INT32 ) * ( ( ( frame_len * 16 / 10 ) / 4 ) + 1 + 1 ) ); /* BASOP Word16 *PhECU_plocs; */ - - handle_fft_phaseecu = balloc( decoder, &size, sizeof( IIS_FFT ) * 1 ); - handle_ifft_phaseecu = balloc( decoder, &size, sizeof( IIS_FFT ) * 1 ); - PhECU_f0est = balloc( decoder, &size, sizeof( LC3_FLOAT ) * ( ( ( frame_len * 16 / 10 ) / 4 ) + 1 ) ); /*BASOP Word32 *PhECU_f0est;*/ - PhECU_mag_chg_1st = balloc( decoder, &size, sizeof( LC3_FLOAT ) * MAX_LGW ); /* BASOP Word16 PhECU_mag_chg_1st[MAX_LGW];*/ - PhECU_Xavg = balloc( decoder, &size, sizeof( LC3_FLOAT ) * MAX_LGW ); /* BASOP Word16 PhECU_Xavg[MAX_LGW] ; */ - - sine_table1_phecu = balloc( decoder, &size, sizeof( LC3_FLOAT ) * ( ( ( CODEC_FS( samplerate ) * 16 ) / 1000 ) / 2 + 1 ) ); - sine_table2_phecu = balloc( decoder, &size, sizeof( LC3_FLOAT ) * ( ( ( CODEC_FS( samplerate ) * 16 ) / 1000 ) / 2 + 1 ) ); - - q_old_res = balloc( decoder, &size, sizeof( LC3_FLOAT ) * frame_len ); - - if ( decoder ) - { + int ch = 0; + size_t size = sizeof(LC3PLUS_Dec); + size_t frame_len = DYN_MAX_LEN_EXT(samplerate); + + void *PlcAdvSetup = NULL; + LC3_FLOAT *pcmbufHist, *harmonicBuf; + LC3_FLOAT *PhECU_oold_grp_shape, *PhECU_old_grp_shape; + LC3_FLOAT *PhECU_xfp; + Complex *PhECU_X_sav_m; + LC3_INT32 *PhECU_plocs; + LC3_FLOAT *PhECU_f0est, *PhECU_mag_chg_1st, *PhECU_Xavg; + LC3_FLOAT *sine_table1_phecu, *sine_table2_phecu; + HANDLE_IIS_FFT handle_fft_phaseecu; + HANDLE_IIS_FFT handle_ifft_phaseecu; + LC3_FLOAT *q_old_res; + + for (ch = 0; ch < channels; ch++) { + DecSetup* setup = balloc(decoder, &size, sizeof(DecSetup)); + + size_t max_pitch = ceilf(228.0 * CODEC_FS(samplerate) / 12800.0); + size_t pcm_plc_len = max_pitch + frame_len; + pcmbufHist = balloc(decoder, &size, sizeof(LC3_FLOAT) * pcm_plc_len); + harmonicBuf = balloc(decoder, &size, sizeof(LC3_FLOAT) * max_pitch); + PlcAdvSetup = balloc(decoder, &size, sizeof(*setup->PlcAdvSetup)); + PhECU_oold_grp_shape = balloc(decoder, &size, sizeof(LC3_FLOAT) *MAX_LGW); /* BASOP Word16 PhECU_oold_grp_shape_fx[MAX_LGW]; */ + PhECU_old_grp_shape = balloc(decoder, &size, sizeof(LC3_FLOAT) *MAX_LGW); /* BASOP Word16 PhECU_old_grp_shape_fx[MAX_LGW] ; */ + PhECU_xfp = balloc(decoder, &size, sizeof(LC3_FLOAT) *(frame_len * 16 / 10)); + PhECU_X_sav_m = balloc(decoder, &size, sizeof(Complex) *(((frame_len * 16 / 10) / 2) + 1));/*MAX_PLC_LMSPEC*/ + PhECU_plocs = balloc(decoder, &size, sizeof(LC3_INT32) * (((frame_len * 16 / 10) / 4) + 1 + 1)); /* BASOP Word16 *PhECU_plocs; */ + + handle_fft_phaseecu = balloc(decoder, &size, sizeof(IIS_FFT) * 1); + handle_ifft_phaseecu = balloc(decoder, &size, sizeof(IIS_FFT) * 1); + PhECU_f0est = balloc(decoder, &size, sizeof(LC3_FLOAT) * (((frame_len * 16 / 10) / 4) + 1)); /*BASOP Word32 *PhECU_f0est;*/ + PhECU_mag_chg_1st = balloc(decoder, &size, sizeof(LC3_FLOAT) *MAX_LGW); /* BASOP Word16 PhECU_mag_chg_1st[MAX_LGW];*/ + PhECU_Xavg = balloc(decoder, &size, sizeof(LC3_FLOAT) * MAX_LGW); /* BASOP Word16 PhECU_Xavg[MAX_LGW] ; */ + + sine_table1_phecu = balloc(decoder, &size, sizeof(LC3_FLOAT) * (((CODEC_FS(samplerate) * 16) / 1000) / 2 + 1)); + sine_table2_phecu = balloc(decoder, &size, sizeof(LC3_FLOAT) * (((CODEC_FS(samplerate) * 16) / 1000) / 2 + 1)); + + q_old_res = balloc(decoder, &size, sizeof(LC3_FLOAT) * frame_len); + + if (decoder) { decoder->channel_setup[ch] = setup; setup->PlcAdvSetup = PlcAdvSetup; @@ -79,126 +77,117 @@ int alloc_decoder( LC3PLUS_Dec *decoder, int samplerate, int channels ) setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Xavg = PhECU_Xavg; setup->PlcAdvSetup->PlcPhEcuSetup.handle_fft_phaseecu = handle_fft_phaseecu; setup->PlcAdvSetup->PlcPhEcuSetup.handle_ifft_phaseecu = handle_ifft_phaseecu; - + setup->PlcAdvSetup->PlcPhEcuSetup.handle_fft_phaseecu->sine_table = sine_table1_phecu; setup->PlcAdvSetup->PlcPhEcuSetup.handle_ifft_phaseecu->sine_table = sine_table2_phecu; - - setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot = ( CODEC_FS( samplerate ) * 16 ) / 1000; - real_fft_init( &( setup->PlcAdvSetup->PlcPhEcuSetup.PhEcu_Fft ), setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot, &( setup->PlcAdvSetup->PlcPhEcuSetup.handle_fft_phaseecu ) ); - real_ifft_init( &( setup->PlcAdvSetup->PlcPhEcuSetup.PhEcu_Ifft ), setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot, &( setup->PlcAdvSetup->PlcPhEcuSetup.handle_ifft_phaseecu ) ); + + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot = (CODEC_FS(samplerate) * 16) / 1000; + real_fft_init(&(setup->PlcAdvSetup->PlcPhEcuSetup.PhEcu_Fft), setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot, &(setup->PlcAdvSetup->PlcPhEcuSetup.handle_fft_phaseecu)); + real_ifft_init(&(setup->PlcAdvSetup->PlcPhEcuSetup.PhEcu_Ifft), setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot, &(setup->PlcAdvSetup->PlcPhEcuSetup.handle_ifft_phaseecu)); setup->statePC.q_old_res = q_old_res; } } - return (int) size; + return (int)size; } -LC3PLUS_Error FillDecSetup( LC3PLUS_Dec *decoder, int samplerate, int channels, LC3PLUS_PlcMode plc_mode, int hrmode ) +LC3PLUS_Error FillDecSetup(LC3PLUS_Dec* decoder, int samplerate, int channels, LC3PLUS_PlcMode plc_mode + , int hrmode +) { - memset( decoder, 0, lc3plus_dec_get_size( samplerate, channels ) ); - alloc_decoder( decoder, samplerate, channels ); + memset(decoder, 0, lc3plus_dec_get_size(samplerate, channels)); + alloc_decoder(decoder, samplerate, channels); - decoder->fs = CODEC_FS( samplerate ); + decoder->fs = CODEC_FS(samplerate); decoder->fs_out = samplerate; - decoder->fs_idx = FS2FS_IDX( decoder->fs ); + decoder->fs_idx = FS2FS_IDX(decoder->fs); decoder->plcMeth = plc_mode; - + decoder->hrmode = hrmode != 0; - - if ( decoder->fs_idx > 4 ) - { + + if (decoder->fs_idx > 4) { decoder->fs_idx = 5; } - decoder->channels = channels; - decoder->frame_ms = 10; - decoder->frame_dms = 100; + decoder->channels = channels; + decoder->frame_ms = 10; + decoder->frame_dms = 100; decoder->BW_cutoff_bits = BW_cutoff_bits_all[decoder->fs_idx]; - - if ( decoder->fs == 8000 ) - { + + if (decoder->fs == 8000) { decoder->tilt = 14; - } - else if ( decoder->fs == 16000 ) - { + } else if (decoder->fs == 16000) { decoder->tilt = 18; - } - else if ( decoder->fs == 24000 ) - { + } else if (decoder->fs == 24000) { decoder->tilt = 22; - } - else if ( decoder->fs == 32000 ) - { + } else if (decoder->fs == 32000) { decoder->tilt = 26; - } - else if ( decoder->fs == 48000 ) - { + } else if (decoder->fs == 48000) { decoder->tilt = 30; } - else if ( decoder->fs == 96000 ) - { + else if (decoder->fs == 96000) { decoder->tilt = 34; } - set_dec_frame_params( decoder ); - - lc3plus_dec_set_ep_enabled( decoder, 0 ); + set_dec_frame_params(decoder); + lc3plus_dec_set_ep_enabled(decoder, 0); + return LC3PLUS_OK; } /* set frame config params */ -void set_dec_frame_params( LC3PLUS_Dec *decoder ) +void set_dec_frame_params(LC3PLUS_Dec* decoder) { int ch = 0; - - if ( decoder->fs_idx == 5 ) + + if (decoder->fs_idx == 5) { decoder->hrmode = 1; } - decoder->frame_length = ceil( decoder->fs * 10 / 1000 ); /* fs * 0.01*2^6 */ - if ( decoder->hrmode == 1 ) + decoder->frame_length = ceil(decoder->fs * 10 / 1000); /* fs * 0.01*2^6 */ + if (decoder->hrmode == 1) { decoder->yLen = decoder->frame_length; } else { - decoder->yLen = MIN( MAX_BW, decoder->frame_length ); + decoder->yLen = MIN(MAX_BW, decoder->frame_length); } decoder->bands_number = 64; - if ( decoder->frame_ms == 2.5 ) + if (decoder->frame_ms == 2.5) { decoder->frame_length = decoder->frame_length >> 2; decoder->yLen /= 4; - if ( decoder->hrmode ) + if (decoder->hrmode) { decoder->bands_number = bands_number_2_5ms_HR[decoder->fs_idx]; - } + } else { decoder->bands_number = bands_number_2_5ms[decoder->fs_idx]; } } - if ( decoder->frame_ms == 5 ) + if (decoder->frame_ms == 5) { decoder->frame_length = decoder->frame_length >> 1; decoder->yLen /= 2; decoder->bands_number = bands_number_5ms[decoder->fs_idx]; } - if ( decoder->hrmode ) + if (decoder->hrmode) { - decoder->BW_cutoff_bits = 0; + decoder->BW_cutoff_bits = 0; } else { - decoder->BW_cutoff_bits = BW_cutoff_bits_all[decoder->fs_idx]; + decoder->BW_cutoff_bits = BW_cutoff_bits_all[decoder->fs_idx]; } - if ( decoder->frame_ms == 10 ) + if (decoder->frame_ms == 10) { - if ( decoder->hrmode ) + if (decoder->hrmode) { decoder->bands_offset = ACC_COEFF_PER_BAND_HR[decoder->fs_idx]; } @@ -206,11 +195,11 @@ void set_dec_frame_params( LC3PLUS_Dec *decoder ) { decoder->bands_offset = ACC_COEFF_PER_BAND[decoder->fs_idx]; } - decoder->cutoffBins = BW_cutoff_bin_all; + decoder->cutoffBins = BW_cutoff_bin_all; } - else if ( decoder->frame_ms == 2.5 ) + else if (decoder->frame_ms == 2.5) { - if ( decoder->hrmode ) + if (decoder->hrmode) { decoder->bands_offset = ACC_COEFF_PER_BAND_2_5ms_HR[decoder->fs_idx]; } @@ -218,11 +207,11 @@ void set_dec_frame_params( LC3PLUS_Dec *decoder ) { decoder->bands_offset = ACC_COEFF_PER_BAND_2_5ms[decoder->fs_idx]; } - decoder->cutoffBins = BW_cutoff_bin_all_2_5ms; + decoder->cutoffBins = BW_cutoff_bin_all_2_5ms; } - else if ( decoder->frame_ms == 5 ) + else if (decoder->frame_ms == 5) { - if ( decoder->hrmode ) + if (decoder->hrmode) { decoder->bands_offset = ACC_COEFF_PER_BAND_5ms_HR[decoder->fs_idx]; } @@ -230,94 +219,86 @@ void set_dec_frame_params( LC3PLUS_Dec *decoder ) { decoder->bands_offset = ACC_COEFF_PER_BAND_5ms[decoder->fs_idx]; } - decoder->cutoffBins = BW_cutoff_bin_all_5ms; + decoder->cutoffBins = BW_cutoff_bin_all_5ms; } - - decoder->n_bandsPLC = MIN( decoder->frame_length, 80 ); - - if ( decoder->frame_ms == 10 ) + + decoder->n_bandsPLC = MIN(decoder->frame_length, 80); + + if (decoder->frame_ms == 10) { decoder->bands_offsetPLC = ACC_COEFF_PER_BAND_PLC[decoder->fs_idx]; } - else if ( decoder->frame_ms == 5 ) + else if (decoder->frame_ms == 5) { decoder->bands_offsetPLC = ACC_COEFF_PER_BAND_PLC_5ms[decoder->fs_idx]; - if ( decoder->fs == 24000 ) + if (decoder->fs == 24000) { decoder->n_bandsPLC = 40; } } - else if ( decoder->frame_ms == 2.5 ) + else if (decoder->frame_ms == 2.5) { decoder->bands_offsetPLC = ACC_COEFF_PER_BAND_PLC_2_5ms[decoder->fs_idx]; - if ( decoder->fs == 48000 ) + if (decoder->fs == 48000) { decoder->n_bandsPLC = 60; } } - assert( decoder->bands_offsetPLC ); + assert(decoder->bands_offsetPLC); - if ( decoder->frame_ms == 10 ) - { - decoder->imdct_win = MDCT_WINS_10ms[decoder->hrmode][decoder->fs_idx]; + if (decoder->frame_ms == 10) { + decoder->imdct_win = MDCT_WINS_10ms[decoder->hrmode][decoder->fs_idx]; decoder->imdct_laZeros = MDCT_la_zeroes[decoder->fs_idx]; - decoder->imdct_winLen = MDCT_WINDOWS_LENGTHS_10ms[decoder->fs_idx]; + decoder->imdct_winLen = MDCT_WINDOWS_LENGTHS_10ms[decoder->fs_idx]; } - else if ( decoder->frame_ms == 2.5 ) - { - decoder->imdct_win = MDCT_WINS_2_5ms[decoder->hrmode][decoder->fs_idx]; + else if (decoder->frame_ms == 2.5) { + decoder->imdct_win = MDCT_WINS_2_5ms[decoder->hrmode][decoder->fs_idx]; decoder->imdct_laZeros = MDCT_la_zeroes_2_5ms[decoder->fs_idx]; - decoder->imdct_winLen = MDCT_WINDOWS_LENGTHS_2_5ms[decoder->fs_idx]; + decoder->imdct_winLen = MDCT_WINDOWS_LENGTHS_2_5ms[decoder->fs_idx]; } - else if ( decoder->frame_ms == 5 ) - { - decoder->imdct_win = MDCT_WINS_5ms[decoder->hrmode][decoder->fs_idx]; + else if (decoder->frame_ms == 5) { + decoder->imdct_win = MDCT_WINS_5ms[decoder->hrmode][decoder->fs_idx]; decoder->imdct_laZeros = MDCT_la_zeroes_5ms[decoder->fs_idx]; - decoder->imdct_winLen = MDCT_WINDOWS_LENGTHS_5ms[decoder->fs_idx]; + decoder->imdct_winLen = MDCT_WINDOWS_LENGTHS_5ms[decoder->fs_idx]; } decoder->la_zeroes = decoder->imdct_laZeros; decoder->imdct_memLen = decoder->frame_length - decoder->imdct_laZeros; - for ( ch = 0; ch < decoder->channels; ch++ ) - { - DecSetup *setup = decoder->channel_setup[ch]; - + for (ch = 0; ch < decoder->channels; ch++) { + DecSetup* setup = decoder->channel_setup[ch]; + setup->ltpf_mem_beta_idx = -1; - + setup->statePC.seed = 24607; - if ( decoder ) - { + if (decoder) { /* Init DCT4 structs */ - if ( setup->dct4structImdct.length != 0 ) - { - dct4_free( &setup->dct4structImdct ); - dct4_init( &setup->dct4structImdct, decoder->frame_length ); - } - else - { - dct4_init( &setup->dct4structImdct, decoder->frame_length ); + if (setup->dct4structImdct.length != 0) { + dct4_free(&setup->dct4structImdct); + dct4_init(&setup->dct4structImdct, decoder->frame_length); + } else { + dct4_init(&setup->dct4structImdct, decoder->frame_length); } - + setup->PlcNsSetup.cum_alpha = 1; setup->PlcNsSetup.seed = 24607; setup->alpha = 1; - if ( setup->PlcAdvSetup ) + if (setup->PlcAdvSetup) { - LC3_INT32 pitch_max = 0, pitch_ana_len = 0, tdc_synt_len = 0; - pitch_max = ceil( 228.0 * (LC3_FLOAT) decoder->fs / 12800.0 ); + LC3_INT32 pitch_max = 0, pitch_ana_len = 0, tdc_synt_len = 0; + pitch_max = ceil(228.0 * (LC3_FLOAT) decoder->fs / 12800.0); pitch_ana_len = pitch_max + decoder->frame_length * (LC3_FLOAT) 100 / decoder->frame_dms; - tdc_synt_len = 16 + 1 + pitch_max + ceil( decoder->frame_length / 2 ); - setup->PlcAdvSetup->max_len_pcm_plc = MAX( pitch_ana_len, tdc_synt_len ); + tdc_synt_len = 16 + 1 + pitch_max + ceil(decoder->frame_length / 2); + setup->PlcAdvSetup->max_len_pcm_plc = MAX(pitch_ana_len, tdc_synt_len); setup->PlcAdvSetup->PlcTdcSetup.preemphFac = plc_preemph_fac[decoder->fs_idx]; setup->PlcAdvSetup->PlcTdcSetup.seed = 24607; setup->PlcAdvSetup->PlcTdcSetup.lpcorder = 16; - if ( decoder->fs_idx == 0 && decoder->frame_dms == 25 ) + if (decoder->fs_idx == 0 && decoder->frame_dms == 25) { setup->PlcAdvSetup->PlcTdcSetup.lpcorder = 8; } @@ -327,63 +308,66 @@ void set_dec_frame_params( LC3PLUS_Dec *decoder ) setup->PlcAdvSetup->cum_fading_slow = 1; setup->PlcAdvSetup->cum_fflcAtten = 1; - if ( decoder->fs_idx <= 4 && decoder->frame_dms == 100 ) + if (decoder->fs_idx <= 4 && decoder->frame_dms == 100) { - setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot = ( decoder->fs * 16 ) / 1000; /* 16 ms of samples at fs*/ + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot = (decoder->fs * 16) / 1000; /* 16 ms of samples at fs*/ - setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_f0hzLtpBin = 0; - setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_norm_corr = 0; + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_f0hzLtpBin = 0; + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_norm_corr = 0; - set_vec( PHECU_GRP_SHAPE_INIT, setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_oold_grp_shape, MAX_LGW ); - set_vec( PHECU_GRP_SHAPE_INIT, setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_old_grp_shape, MAX_LGW ); + set_vec(PHECU_GRP_SHAPE_INIT, setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_oold_grp_shape, MAX_LGW); + set_vec(PHECU_GRP_SHAPE_INIT, setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_old_grp_shape, MAX_LGW); - setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_L_oold_xfp_w_E = (LC3_FLOAT) PHECU_LTOT_MIN_MAN * LC3_POW( 2.0, PHECU_LTOT_MIN_EXP - 31 ); - setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_L_old_xfp_w_E = (LC3_FLOAT) PHECU_LTOT_MIN_MAN * LC3_POW( 2.0, PHECU_LTOT_MIN_EXP - 31 ); + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_L_oold_xfp_w_E = (LC3_FLOAT)PHECU_LTOT_MIN_MAN * LC3_POW(2.0, PHECU_LTOT_MIN_EXP - 31); + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_L_old_xfp_w_E = (LC3_FLOAT)PHECU_LTOT_MIN_MAN * LC3_POW(2.0, PHECU_LTOT_MIN_EXP - 31); - /* CFL uses separate buffers for pcmHist, xfp and Xsav and q_d , BASOP uses an optimized joint buffer*/ - zero_float( setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_xfp, setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot ); - zero_cmplx( setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_X_sav_m, ( setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot / 2 + 1 ) ); + /* CFL uses separate buffers for pcmHist, xfp and Xsav and q_d , BASOP uses an optimized joint buffer*/ + zero_float(setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_xfp, setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot); + zero_cmplx(setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_X_sav_m, (setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot/2 + 1)); - set_vec( POS_ONE_Q15, setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_mag_chg_1st, MAX_LGW ); + set_vec(POS_ONE_Q15, setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_mag_chg_1st, MAX_LGW); - setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_beta_mute = ( 16384.0 / 32768.0 ); - setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_seed = 21845; + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_beta_mute = (16384.0/32768.0); + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_seed = 21845; - assert( decoder->frame_dms == 100 ); - setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_LDWIN_OLAP = ( decoder->frame_length / 4 ); /* 2.5 ms for regular 10 ms MDCT */ + assert(decoder->frame_dms == 100); + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_LDWIN_OLAP = (decoder->frame_length / 4 ); /* 2.5 ms for regular 10 ms MDCT */ - setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_t_adv = ( decoder->frame_length + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_LDWIN_OLAP ) / 2; + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_t_adv = ( + decoder->frame_length + + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_Lprot + + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_LDWIN_OLAP )/ 2; } - setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_short_flag_prev = 0; /* fullband transient */ + setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_short_flag_prev = 0; /* fullband transient */ setup->PlcAdvSetup->PlcPhEcuSetup.PhECU_num_plocs = 0; } } } } -LC3PLUS_Error update_dec_bitrate( LC3PLUS_Dec *decoder, int ch, int nBytes ) +LC3PLUS_Error update_dec_bitrate(LC3PLUS_Dec* decoder, int ch, int nBytes) { int totalBits = 0, bitsTmp = 0, channel_bytes = 0, maxBytes = 0, minBytes = 0; - DecSetup *setup; + DecSetup* setup; - if ( decoder->hrmode ) + if (decoder->hrmode) { - switch ( decoder->frame_dms ) + switch (decoder->frame_dms) { - case 25: - maxBytes = 210; - minBytes = MIN_NBYTES; - break; - case 50: - maxBytes = 375; - minBytes = MIN_NBYTES; - break; - case 100: - maxBytes = 625; - minBytes = MIN_NBYTES; - break; - default: - return LC3PLUS_HRMODE_ERROR; + case 25: + maxBytes = 210; + minBytes = MIN_NBYTES; + break; + case 50: + maxBytes = 375; + minBytes = MIN_NBYTES; + break; + case 100: + maxBytes = 625; + minBytes = MIN_NBYTES; + break; + default: + return LC3PLUS_HRMODE_ERROR; } } else @@ -394,82 +378,67 @@ LC3PLUS_Error update_dec_bitrate( LC3PLUS_Dec *decoder, int ch, int nBytes ) channel_bytes = nBytes; - setup = decoder->channel_setup[ch]; - - if ( channel_bytes < minBytes || channel_bytes > maxBytes ) - { - return LC3PLUS_NUMBYTES_ERROR; - } + setup = decoder->channel_setup[ch]; - setup->targetBytes = channel_bytes; - setup->total_bits = setup->targetBytes << 3; - setup->enable_lpc_weighting = ( setup->total_bits < 480 ); - setup->quantizedGainOff = - -( MIN( 115, setup->total_bits / ( 10 * ( decoder->fs_idx + 1 ) ) ) + 105 + 5 * ( decoder->fs_idx + 1 ) ); - - if ( decoder->hrmode && decoder->fs_idx == 5 ) - { - setup->quantizedGainOff = MAX( setup->quantizedGainOff, -181 ); - } - - totalBits = setup->total_bits; - - if ( decoder->frame_ms == 2.5 ) - { - setup->enable_lpc_weighting = setup->total_bits < 120; - totalBits = setup->total_bits * 4.0 * ( 1.0 - 0.4 ); - } - if ( decoder->frame_ms == 5 ) - { - setup->enable_lpc_weighting = ( setup->total_bits < 240 ); - totalBits = setup->total_bits * 2 - 160; - } - - if ( decoder->frame_length > 40 * ( (LC3_FLOAT) ( decoder->frame_dms ) / 10.0 ) ) - { - setup->N_red_tns = 40 * ( (LC3_FLOAT) ( decoder->frame_dms ) / 10.0 ); - setup->fs_red_tns = 40000; - } - else - { - setup->N_red_tns = decoder->frame_length; - setup->fs_red_tns = decoder->fs; - } - - bitsTmp = totalBits; + if (channel_bytes < minBytes || channel_bytes > maxBytes) + { + return LC3PLUS_NUMBYTES_ERROR; + } + + setup->targetBytes = channel_bytes; + setup->total_bits = setup->targetBytes << 3; + setup->enable_lpc_weighting = (setup->total_bits < 480); + setup->quantizedGainOff = + -(MIN(115, setup->total_bits / (10 * (decoder->fs_idx + 1))) + 105 + 5 * (decoder->fs_idx + 1)); + + if (decoder->hrmode && decoder->fs_idx == 5) + { + setup->quantizedGainOff = MAX(setup->quantizedGainOff, -181); + } - if ( bitsTmp < 400 + ( decoder->fs_idx - 1 ) * 80 ) - { - setup->ltpf_conf_beta = 0.4; - setup->ltpf_conf_beta_idx = 0; - } - else if ( bitsTmp < 480 + ( decoder->fs_idx - 1 ) * 80 ) - { - setup->ltpf_conf_beta = 0.35; - setup->ltpf_conf_beta_idx = 1; - } - else if ( bitsTmp < 560 + ( decoder->fs_idx - 1 ) * 80 ) - { - setup->ltpf_conf_beta = 0.3; - setup->ltpf_conf_beta_idx = 2; - } - else if ( bitsTmp < 640 + ( decoder->fs_idx - 1 ) * 80 ) - { - setup->ltpf_conf_beta = 0.25; - setup->ltpf_conf_beta_idx = 3; - } - else - { - setup->ltpf_conf_beta = 0; - setup->ltpf_conf_beta_idx = -1; - } + totalBits = setup->total_bits; + + if (decoder->frame_ms == 2.5) { + setup->enable_lpc_weighting = setup->total_bits < 120; + totalBits = setup->total_bits * 4.0 * (1.0 - 0.4); + } + if (decoder->frame_ms == 5) { + setup->enable_lpc_weighting = (setup->total_bits < 240); + totalBits = setup->total_bits * 2 - 160; + } + + if (decoder->frame_length > 40 * ((LC3_FLOAT) (decoder->frame_dms) / 10.0)) { + setup->N_red_tns = 40 * ((LC3_FLOAT) (decoder->frame_dms) / 10.0); + setup->fs_red_tns = 40000; + } else { + setup->N_red_tns = decoder->frame_length; + setup->fs_red_tns = decoder->fs; + } - /* No LTPF in hrmode */ - if ( decoder->hrmode == 1 ) - { - setup->ltpf_conf_beta = 0; - setup->ltpf_conf_beta_idx = -1; - } + bitsTmp = totalBits; + + if (bitsTmp < 400 + (decoder->fs_idx - 1) * 80) { + setup->ltpf_conf_beta = 0.4; + setup->ltpf_conf_beta_idx = 0; + } else if (bitsTmp < 480 + (decoder->fs_idx - 1) * 80) { + setup->ltpf_conf_beta = 0.35; + setup->ltpf_conf_beta_idx = 1; + } else if (bitsTmp < 560 + (decoder->fs_idx - 1) * 80) { + setup->ltpf_conf_beta = 0.3; + setup->ltpf_conf_beta_idx = 2; + } else if (bitsTmp < 640 + (decoder->fs_idx - 1) * 80) { + setup->ltpf_conf_beta = 0.25; + setup->ltpf_conf_beta_idx = 3; + } else { + setup->ltpf_conf_beta = 0; + setup->ltpf_conf_beta_idx = -1; + } + /* No LTPF in hrmode */ + if (decoder->hrmode == 1) { + setup->ltpf_conf_beta = 0; + setup->ltpf_conf_beta_idx = -1; + } + return LC3PLUS_OK; } diff --git a/lib_lc3plus/setup_dec_lc3.h b/lib_lc3plus/setup_dec_lc3.h index 8052e38987..6ed0f438ea 100644 --- a/lib_lc3plus/setup_dec_lc3.h +++ b/lib_lc3plus/setup_dec_lc3.h @@ -1,12 +1,12 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #ifndef SETUP_DEC_LC3_FL_H #define SETUP_DEC_LC3_FL_H @@ -14,30 +14,29 @@ #include "constants.h" /* Channel state and bitrate-derived values go in this struct */ -typedef struct -{ - LC3_INT *stDec_ola_mem_fx; /* MDCT_MEM_LEN_MAX */ - LC3_INT total_bits; - LC3_INT enable_lpc_weighting; - LC3_INT targetBytes; - LC3_INT quantizedGainOff; - LC3_INT ltpf_param[3]; - LC3_INT ltpf_param_mem[3]; - LC3_INT ltpf_mem_pitch; - LC3_INT ltpf_mem_active; - LC3_INT ltpf_mem_pitch_fr; - LC3_INT ltpf_mem_beta_idx; - LC3_INT ltpf_conf_beta_idx; - LC3_INT spec_inv_idx; - LC3_INT concealMethod; - LC3_INT last_size; - LC3_INT BW_cutoff_idx_nf; - LC3_INT prev_BW_cutoff_idx_nf; - LC3_INT fs_red_tns; - LC3_INT N_red_tns; - LC3_INT scf_idx[SCF_MAX_PARAM]; - uint8_t resBits[MAX_RESBITS_LEN]; - LC3_INT tns_idx[TNS_NUMFILTERS_MAX * MAXLAG]; +typedef struct { + LC3_INT* stDec_ola_mem_fx; /* MDCT_MEM_LEN_MAX */ + LC3_INT total_bits; + LC3_INT enable_lpc_weighting; + LC3_INT targetBytes; + LC3_INT quantizedGainOff; + LC3_INT ltpf_param[3]; + LC3_INT ltpf_param_mem[3]; + LC3_INT ltpf_mem_pitch; + LC3_INT ltpf_mem_active; + LC3_INT ltpf_mem_pitch_fr; + LC3_INT ltpf_mem_beta_idx; + LC3_INT ltpf_conf_beta_idx; + LC3_INT spec_inv_idx; + LC3_INT concealMethod; + LC3_INT last_size; + LC3_INT BW_cutoff_idx_nf; + LC3_INT prev_BW_cutoff_idx_nf; + LC3_INT fs_red_tns; + LC3_INT N_red_tns; + LC3_INT scf_idx[SCF_MAX_PARAM]; + uint8_t resBits[MAX_RESBITS_LEN]; + LC3_INT tns_idx[TNS_NUMFILTERS_MAX * MAXLAG]; LC3_FLOAT prev_fac_ns; LC3_FLOAT ltpf_mem_x[3 * MAX_LEN]; @@ -52,21 +51,20 @@ typedef struct LC3_FLOAT alpha; Dct4 dct4structImdct; - - PlcSetup PlcSetup; - PlcNsSetup PlcNsSetup; - + + PlcSetup PlcSetup; + PlcNsSetup PlcNsSetup; + pcState statePC; - PlcAdvSetup *PlcAdvSetup; + PlcAdvSetup* PlcAdvSetup; } DecSetup; /* Constants and sampling rate derived values go in this struct */ -struct LC3PLUS_Dec -{ - DecSetup *channel_setup[MAX_CHANNELS]; - const LC3_INT *W_fx; - const LC3_INT *bands_offset; - const LC3_INT *cutoffBins; +struct LC3PLUS_Dec { + DecSetup* channel_setup[MAX_CHANNELS]; + const LC3_INT* W_fx; + const LC3_INT* bands_offset; + const LC3_INT* cutoffBins; LC3_INT fs; /* sampling rate, 44.1 maps to 48 */ LC3_INT fs_out; /* output sampling rate */ @@ -79,10 +77,10 @@ struct LC3PLUS_Dec LC3_INT ep_enabled; /* error protection enabled */ LC3_INT error_report; /* corrected errors in last frame or -1 on error */ - LC3_INT imdct_memLen; - LC3_INT imdct_winLen; - LC3_INT imdct_laZeros; - const LC3_FLOAT *imdct_win; + LC3_INT imdct_memLen; + LC3_INT imdct_winLen; + LC3_INT imdct_laZeros; + const LC3_FLOAT* imdct_win; LC3_INT yLen; LC3_INT W_size; @@ -92,23 +90,23 @@ struct LC3PLUS_Dec LC3_INT ltpf_mem_y_len; LC3_INT BW_cutoff_bits; LC3_INT tilt; - + LC3_INT hrmode; LC3_INT specflip; - - const LC3_INT *bands_offsetPLC; + + const LC3_INT* bands_offsetPLC; LC3_INT n_bandsPLC; - - LC3_INT32 rframe; - int plcMeth; /* PLC method for all channels */ + + LC3_INT32 rframe; + int plcMeth; /* PLC method for all channels */ LC3_INT16 n_pccw; LC3_INT16 be_bp_left; LC3_INT16 be_bp_right; LC3_INT16 n_pc; LC3_INT16 m_fec; - int epmr; - LC3_INT16 combined_channel_coding; - int last_error; + int epmr; + LC3_INT16 combined_channel_coding; + int last_error; }; #endif diff --git a/lib_lc3plus/setup_enc_lc3.c b/lib_lc3plus/setup_enc_lc3.c index 85baa05741..986b43d608 100644 --- a/lib_lc3plus/setup_enc_lc3.c +++ b/lib_lc3plus/setup_enc_lc3.c @@ -1,12 +1,12 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "setup_enc_lc3.h" @@ -14,118 +14,108 @@ #include /* if encoder is null only size is reported */ -int alloc_encoder( LC3PLUS_Enc *encoder, int channels ) +int alloc_encoder(LC3PLUS_Enc* encoder, int channels) { - int ch = 0; - size_t size = sizeof( LC3PLUS_Enc ); + int ch = 0; + size_t size = sizeof(LC3PLUS_Enc); - for ( ch = 0; ch < channels; ch++ ) - { - EncSetup *setup = balloc( encoder, &size, sizeof( EncSetup ) ); - if ( encoder ) - { + for (ch = 0; ch < channels; ch++) { + EncSetup* setup = balloc(encoder, &size, sizeof(EncSetup)); + if (encoder) { encoder->channel_setup[ch] = setup; } } - return (int) size; + return (int)size; } -LC3PLUS_Error FillEncSetup( LC3PLUS_Enc *encoder, int samplerate, int channels, int hrmode, int32_t lfe_channel_array[] ) +LC3PLUS_Error FillEncSetup(LC3PLUS_Enc* encoder, int samplerate, int channels + , int hrmode + , int32_t lfe_channel_array[] +) { int ch = 0; - memset( encoder, 0, lc3plus_enc_get_size( samplerate, channels ) ); - alloc_encoder( encoder, channels ); + memset(encoder, 0, lc3plus_enc_get_size(samplerate, channels)); + alloc_encoder(encoder, channels); - encoder->fs = CODEC_FS( samplerate ); - encoder->fs_in = samplerate; - encoder->fs_idx = FS2FS_IDX( encoder->fs ); + encoder->fs = CODEC_FS(samplerate); + encoder->fs_in = samplerate; + encoder->fs_idx = FS2FS_IDX(encoder->fs); encoder->frame_dms = 100; - if ( encoder->fs_idx > 4 ) - { + if (encoder->fs_idx > 4) { encoder->fs_idx = 5; } encoder->hrmode = hrmode != 0; - encoder->channels = channels; - encoder->frame_ms = 10; - encoder->envelope_bits = 38; - encoder->global_gain_bits = 8; - encoder->noise_fac_bits = 3; - encoder->BW_cutoff_bits = BW_cutoff_bits_all[encoder->fs_idx]; + encoder->channels = channels; + encoder->frame_ms = 10; + encoder->envelope_bits = 38; + encoder->global_gain_bits = 8; + encoder->noise_fac_bits = 3; + encoder->BW_cutoff_bits = BW_cutoff_bits_all[encoder->fs_idx]; - encoder->r12k8_mem_in_len = 2 * 8 * encoder->fs / 12800; + encoder->r12k8_mem_in_len = 2 * 8 * encoder->fs / 12800; encoder->r12k8_mem_out_len = 24; - for ( ch = 0; ch < encoder->channels; ch++ ) + for (ch = 0; ch < encoder->channels; ch++) { encoder->channel_setup[ch]->lfe = lfe_channel_array[ch] != 0; } - encoder->bw_ctrl_active = 0; - encoder->bandwidth = encoder->fs / 2; + encoder->bw_ctrl_active = 0; + encoder->bandwidth = encoder->fs / 2; encoder->bandwidth_preset = encoder->fs / 2; - if ( encoder->fs == 8000 ) - { + if (encoder->fs == 8000) { encoder->tilt = 14; - } - else if ( encoder->fs == 16000 ) - { + } else if (encoder->fs == 16000) { encoder->tilt = 18; - } - else if ( encoder->fs == 24000 ) - { + } else if (encoder->fs == 24000) { encoder->tilt = 22; - } - else if ( encoder->fs == 32000 ) - { + } else if (encoder->fs == 32000) { encoder->tilt = 26; - } - else if ( encoder->fs == 48000 ) - { + } else if (encoder->fs == 48000) { encoder->tilt = 30; } - else if ( encoder->fs == 96000 ) - { + else if (encoder->fs == 96000) { encoder->tilt = 34; } - set_enc_frame_params( encoder ); + set_enc_frame_params(encoder); return LC3PLUS_OK; } /* set frame config params */ -void set_enc_frame_params( LC3PLUS_Enc *encoder ) +void set_enc_frame_params(LC3PLUS_Enc* encoder) { - int ch = 0; - EncSetup *setup; + int ch = 0; + EncSetup* setup; - encoder->frame_length = ceil( encoder->fs * 10 / 1000 ); /* fs * 0.01*2^6 */ - if ( encoder->hrmode == 1 ) + encoder->frame_length = ceil(encoder->fs * 10 / 1000); /* fs * 0.01*2^6 */ + if (encoder->hrmode == 1) { encoder->yLen = encoder->frame_length; } else { - encoder->yLen = MIN( MAX_BW, encoder->frame_length ); + encoder->yLen = MIN(MAX_BW, encoder->frame_length); encoder->sns_damping = 0.85; } encoder->stEnc_mdct_mem_len = encoder->frame_length - encoder->la_zeroes; - encoder->bands_number = 64; - encoder->nSubdivisions = 3; + encoder->bands_number = 64; + encoder->nSubdivisions = 3; encoder->near_nyquist_index = encoder->bands_number - 2; - encoder->near_nyquist_flag = 0; - encoder->ltpf_mem_in_len = LTPF_MEMIN_LEN; - - if ( encoder->fs_idx == 5 ) + encoder->near_nyquist_flag = 0; + encoder->ltpf_mem_in_len = LTPF_MEMIN_LEN; + + if (encoder->fs_idx == 5) { encoder->hrmode = 1; } - if ( encoder->hrmode ) + if (encoder->hrmode) { encoder->BW_cutoff_bits = 0; } @@ -134,10 +124,9 @@ void set_enc_frame_params( LC3PLUS_Enc *encoder ) encoder->BW_cutoff_bits = BW_cutoff_bits_all[encoder->fs_idx]; } - if ( encoder->frame_ms == 10 ) - { + if (encoder->frame_ms == 10) { encoder->la_zeroes = MDCT_la_zeroes[encoder->fs_idx]; - if ( encoder->hrmode ) + if (encoder->hrmode) { encoder->bands_offset = ACC_COEFF_PER_BAND_HR[encoder->fs_idx]; } @@ -145,16 +134,15 @@ void set_enc_frame_params( LC3PLUS_Enc *encoder ) { encoder->bands_offset = ACC_COEFF_PER_BAND[encoder->fs_idx]; } - encoder->cutoffBins = BW_cutoff_bin_all; - - encoder->attdec_nblocks = 4; - encoder->attdec_damping = 0.5; + encoder->cutoffBins = BW_cutoff_bin_all; + + encoder->attdec_nblocks = 4; + encoder->attdec_damping = 0.5; encoder->attdec_hangover_thresh = 2; } - else if ( encoder->frame_ms == 2.5 ) - { + else if (encoder->frame_ms == 2.5) { encoder->la_zeroes = MDCT_la_zeroes_2_5ms[encoder->fs_idx]; - if ( encoder->hrmode ) + if (encoder->hrmode) { encoder->bands_offset = ACC_COEFF_PER_BAND_2_5ms_HR[encoder->fs_idx]; } @@ -162,12 +150,11 @@ void set_enc_frame_params( LC3PLUS_Enc *encoder ) { encoder->bands_offset = ACC_COEFF_PER_BAND_2_5ms[encoder->fs_idx]; } - encoder->cutoffBins = BW_cutoff_bin_all_2_5ms; + encoder->cutoffBins = BW_cutoff_bin_all_2_5ms; } - else if ( encoder->frame_ms == 5 ) - { + else if (encoder->frame_ms == 5) { encoder->la_zeroes = MDCT_la_zeroes_5ms[encoder->fs_idx]; - if ( encoder->hrmode ) + if (encoder->hrmode) { encoder->bands_offset = ACC_COEFF_PER_BAND_5ms_HR[encoder->fs_idx]; } @@ -175,250 +162,203 @@ void set_enc_frame_params( LC3PLUS_Enc *encoder ) { encoder->bands_offset = ACC_COEFF_PER_BAND_5ms[encoder->fs_idx]; } - encoder->cutoffBins = BW_cutoff_bin_all_5ms; + encoder->cutoffBins = BW_cutoff_bin_all_5ms; } - if ( encoder->frame_ms == 2.5 ) - { + if (encoder->frame_ms == 2.5) { encoder->frame_length = encoder->frame_length >> 2; encoder->yLen /= 4; encoder->stEnc_mdct_mem_len = encoder->frame_length - encoder->la_zeroes; - if ( encoder->hrmode ) + if (encoder->hrmode) { - encoder->bands_number = bands_number_2_5ms_HR[encoder->fs_idx]; + encoder->bands_number = bands_number_2_5ms_HR[encoder->fs_idx]; } else { - encoder->bands_number = bands_number_2_5ms[encoder->fs_idx]; + encoder->bands_number = bands_number_2_5ms[encoder->fs_idx]; } - encoder->nSubdivisions = 2; + encoder->nSubdivisions = 2; encoder->near_nyquist_index = encoder->bands_number - 2; - encoder->ltpf_mem_in_len = LTPF_MEMIN_LEN + ( LEN_12K8 >> 2 ); + encoder->ltpf_mem_in_len = LTPF_MEMIN_LEN + (LEN_12K8 >> 2); } - - - if ( encoder->frame_ms == 5 ) - { + + + if (encoder->frame_ms == 5) { encoder->frame_length = encoder->frame_length >> 1; encoder->yLen /= 2; encoder->stEnc_mdct_mem_len = encoder->frame_length - encoder->la_zeroes; - encoder->bands_number = bands_number_5ms[encoder->fs_idx]; - encoder->nSubdivisions = 2; + encoder->bands_number = bands_number_5ms[encoder->fs_idx]; + encoder->nSubdivisions = 2; encoder->near_nyquist_index = encoder->bands_number - 3; } - for ( ch = 0; ch < encoder->channels; ch++ ) - { + for (ch = 0; ch < encoder->channels; ch++) { setup = encoder->channel_setup[ch]; setup->olpa_mem_pitch = 17; + + if (setup->mdctStruct.mem != NULL) { + mdct_free(&setup->mdctStruct); + mdct_init(&setup->mdctStruct, encoder->frame_length, encoder->frame_dms, encoder->fs_idx, encoder->hrmode); - if ( setup->mdctStruct.mem != NULL ) - { - mdct_free( &setup->mdctStruct ); - mdct_init( &setup->mdctStruct, encoder->frame_length, encoder->frame_dms, encoder->fs_idx, encoder->hrmode ); - - dct2_free( &setup->dct2StructSNS ); - dct2_init( &setup->dct2StructSNS, M ); + dct2_free(&setup->dct2StructSNS); + dct2_init(&setup->dct2StructSNS, M); } else { - mdct_init( &setup->mdctStruct, encoder->frame_length, encoder->frame_dms, encoder->fs_idx, encoder->hrmode ); - dct2_init( &setup->dct2StructSNS, M ); + mdct_init(&setup->mdctStruct, encoder->frame_length, encoder->frame_dms, encoder->fs_idx, encoder->hrmode); + dct2_init(&setup->dct2StructSNS, M); } } } /* change encoder bitrate */ -LC3PLUS_Error update_enc_bitrate( LC3PLUS_Enc *encoder, int bitrate ) +LC3PLUS_Error update_enc_bitrate(LC3PLUS_Enc* encoder, int bitrate) { int ch = 0, bitsTmp = 0, minBR = 0, maxBR = 0, totalBytes = 0; LC3_INT channel_bytes = 0, max_bytes = 0; - if ( encoder->hrmode ) + if (encoder->hrmode) { #ifdef ENABLE_HR_MODE_FL - switch ( encoder->frame_dms ) - { - case 25: - maxBR = 672000; - if ( encoder->fs == 48000 ) - { - minBR = MIN_BR_25MS_48KHZ_HR; - } - else if ( encoder->fs == 96000 ) - { - minBR = MIN_BR_25MS_96KHZ_HR; - } - else - { - return LC3PLUS_HRMODE_ERROR; - } - break; - case 50: - maxBR = 600000; - if ( encoder->fs == 48000 ) - { - minBR = MIN_BR_50MS_48KHZ_HR; - } - else if ( encoder->fs == 96000 ) - { - minBR = MIN_BR_50MS_96KHZ_HR; - } - else - { - return LC3PLUS_HRMODE_ERROR; - } - break; - case 100: - maxBR = 500000; - if ( encoder->fs == 48000 ) - { - minBR = MIN_BR_100MS_48KHZ_HR; - } - else if ( encoder->fs == 96000 ) - { - minBR = MIN_BR_100MS_96KHZ_HR; - } - else - { - return LC3PLUS_HRMODE_ERROR; - } - break; - default: - return LC3PLUS_HRMODE_ERROR; + switch (encoder->frame_dms) + { + case 25: + maxBR = 672000; + if (encoder->fs == 48000) {minBR = MIN_BR_25MS_48KHZ_HR;} + else if (encoder->fs == 96000) {minBR = MIN_BR_25MS_96KHZ_HR;} + else { return LC3PLUS_HRMODE_ERROR;} + break; + case 50: + maxBR = 600000; + if (encoder->fs == 48000) {minBR = MIN_BR_50MS_48KHZ_HR;} + else if (encoder->fs == 96000) {minBR = MIN_BR_50MS_96KHZ_HR;} + else { return LC3PLUS_HRMODE_ERROR;} + break; + case 100: + maxBR = 500000; + if (encoder->fs == 48000) {minBR = MIN_BR_100MS_48KHZ_HR;} + else if (encoder->fs == 96000) {minBR = MIN_BR_100MS_96KHZ_HR;} + else { return LC3PLUS_HRMODE_ERROR;} + break; + default: + return LC3PLUS_HRMODE_ERROR; } #endif } else { - minBR = ( MIN_NBYTES << 3 ); + minBR = (MIN_NBYTES << 3); maxBR = MAX_BR; - switch ( encoder->frame_dms ) - { - case 25: - minBR = MIN_BR_025DMS; - maxBR = MAX_BR; - break; - case 50: - minBR = MIN_BR_050DMS; - maxBR = MAX_BR; - /* have additional limitations for 5.0ms */ - switch ( encoder->fs_in ) - { - case 8000: - maxBR = MAX_BR_050DMS_NB; - break; - default: - break; - } - break; - case 100: - /* have additional limitations for 10ms */ - minBR = MIN_BR_100DMS; - maxBR = MAX_BR; - switch ( encoder->fs_in ) - { - case 8000: - maxBR = MAX_BR_100DMS_NB; - break; - case 16000: - maxBR = MAX_BR_100DMS_WB; - break; - case 24000: - maxBR = MAX_BR_100DMS_SSWB; - break; - default: - maxBR = MAX_BR; - break; - } - break; - default: - return LC3PLUS_FRAMEMS_ERROR; + switch (encoder->frame_dms) + { + case 25: + minBR = MIN_BR_025DMS; + maxBR = MAX_BR; + break; + case 50: + minBR = MIN_BR_050DMS; + maxBR = MAX_BR; + /* have additional limitations for 5.0ms */ + switch (encoder->fs_in) + { + case 8000: maxBR = MAX_BR_050DMS_NB; break; + default: break; + } + break; + case 100: + /* have additional limitations for 10ms */ + minBR = MIN_BR_100DMS; + maxBR = MAX_BR; + switch (encoder->fs_in) + { + case 8000: maxBR = MAX_BR_100DMS_NB ; break; + case 16000: maxBR = MAX_BR_100DMS_WB ; break; + case 24000: maxBR = MAX_BR_100DMS_SSWB; break; + default: maxBR = MAX_BR; break; + } + break; + default: return LC3PLUS_FRAMEMS_ERROR; } - maxBR *= ( encoder->fs_in == 44100 ? 441. / 480 : 1 ); + maxBR *= (encoder->fs_in == 44100 ? 441. / 480 : 1); } minBR *= encoder->channels; maxBR *= encoder->channels; - + encoder->combined_channel_coding = 0; - - if ( encoder->channels > 1 && encoder->epmode ) + + if (encoder->channels > 1 && encoder->epmode) { - if ( encoder->bitrate * encoder->frame_length / ( 8 * encoder->fs_in ) <= 160 ) + if (encoder->bitrate * encoder->frame_length / (8 * encoder->fs_in) <= 160) { encoder->combined_channel_coding = 1; } } - if ( encoder->epmode > 0 ) + if (encoder->epmode > 0) { - max_bytes = bitrate * encoder->frame_length / ( 8 * encoder->fs_in * encoder->channels ); - if ( max_bytes < FEC_SLOT_BYTES_MIN || max_bytes > FEC_SLOT_BYTES_MAX ) + max_bytes = bitrate * encoder->frame_length / (8 * encoder->fs_in * encoder->channels); + if (max_bytes < FEC_SLOT_BYTES_MIN || max_bytes > FEC_SLOT_BYTES_MAX) { encoder->lc3_br_set = 0; return LC3PLUS_BITRATE_ERROR; } } - if ( encoder->combined_channel_coding ) + if (encoder->combined_channel_coding) { - totalBytes = fec_get_data_size( encoder->epmode, encoder->combined_channel_coding, - bitrate * encoder->frame_length / ( 8 * encoder->fs_in ) ); + totalBytes = fec_get_data_size(encoder->epmode, encoder->combined_channel_coding, + bitrate * encoder->frame_length / (8 * encoder->fs_in)); encoder->channel_setup[0]->n_pccw = - fec_get_n_pccw( bitrate * encoder->frame_length / ( 8 * encoder->fs_in ), encoder->epmode, - encoder->combined_channel_coding ); + fec_get_n_pccw(bitrate * encoder->frame_length / (8 * encoder->fs_in), encoder->epmode, + encoder->combined_channel_coding); - encoder->channel_setup[0]->n_pc = fec_get_n_pc( encoder->epmode, encoder->channel_setup[0]->n_pccw, - bitrate * encoder->frame_length / ( 8 * encoder->fs_in ) ); + encoder->channel_setup[0]->n_pc = fec_get_n_pc(encoder->epmode, encoder->channel_setup[0]->n_pccw, + bitrate * encoder->frame_length / (8 * encoder->fs_in)); } else { - totalBytes = bitrate * encoder->frame_length / ( 8 * encoder->fs_in ); + totalBytes = bitrate * encoder->frame_length / (8 * encoder->fs_in); } - - if ( encoder->frame_dms <= 50 ) + + if (encoder->frame_dms <= 50) { encoder->tnsMaxOrder = 4; - } - else - { + } else { encoder->tnsMaxOrder = 8; } - if ( bitrate < minBR || bitrate > maxBR ) - { + if (bitrate < minBR || bitrate > maxBR) { return LC3PLUS_BITRATE_ERROR; } - + encoder->lc3_br_set = 1; - for ( ch = 0; ch < encoder->channels; ch++ ) - { + for (ch = 0; ch < encoder->channels; ch++) { - EncSetup *setup = encoder->channel_setup[ch]; + EncSetup* setup = encoder->channel_setup[ch]; + + setup->targetBytes = totalBytes / encoder->channels + (ch < (totalBytes % encoder->channels)); + channel_bytes = totalBytes / encoder->channels + (ch < (totalBytes % encoder->channels)); - setup->targetBytes = totalBytes / encoder->channels + ( ch < ( totalBytes % encoder->channels ) ); - channel_bytes = totalBytes / encoder->channels + ( ch < ( totalBytes % encoder->channels ) ); - - if ( encoder->combined_channel_coding ) + if (encoder->combined_channel_coding) { setup->targetBytes = channel_bytes; } else { - setup->targetBytes = fec_get_data_size( encoder->epmode, encoder->combined_channel_coding, channel_bytes ); - setup->n_pccw = fec_get_n_pccw( channel_bytes, encoder->epmode, encoder->combined_channel_coding ); - setup->n_pc = fec_get_n_pc( encoder->epmode, setup->n_pccw, channel_bytes ); + setup->targetBytes = fec_get_data_size(encoder->epmode, encoder->combined_channel_coding, channel_bytes); + setup->n_pccw = fec_get_n_pccw(channel_bytes, encoder->epmode, encoder->combined_channel_coding); + setup->n_pc = fec_get_n_pc(encoder->epmode, setup->n_pccw, channel_bytes); } // reduce bandwith to 12kHz if bitrate is low - if ( encoder->frame_dms == 100 && - ( ( setup->targetBytes < 40 && encoder->fs == 48000 ) || - ( setup->targetBytes < 36 && encoder->fs == 32000 ) ) ) + if (encoder->frame_dms == 100 && + ((setup->targetBytes < 40 && encoder->fs == 48000) || + (setup->targetBytes < 36 && encoder->fs == 32000))) { - encoder->bandwidth = MIN( 12000, encoder->bandwidth_preset ); + encoder->bandwidth = MIN(12000, encoder->bandwidth_preset); } else { @@ -427,51 +367,49 @@ LC3PLUS_Error update_enc_bitrate( LC3PLUS_Enc *encoder, int bitrate ) encoder->bandwidth = encoder->bandwidth_preset; } encoder->bw_ctrl_cutoff_bin = encoder->bandwidth * encoder->frame_dms / 5000; - encoder->bw_index = ( encoder->bandwidth / 4000 ) - 1; - setup->total_bits = setup->targetBytes << 3; + encoder->bw_index = (encoder->bandwidth / 4000) - 1; + setup->total_bits = setup->targetBytes << 3; setup->targetBitsInit = setup->total_bits - encoder->envelope_bits - encoder->global_gain_bits - encoder->noise_fac_bits - encoder->BW_cutoff_bits - - ceil( LC3_LOGTWO( encoder->frame_length / 2 ) ) - 2 - 1; + ceil(LC3_LOGTWO(encoder->frame_length / 2)) - 2 - 1; - if ( setup->total_bits > 1280 ) - { + if (setup->total_bits > 1280) { setup->targetBitsInit = setup->targetBitsInit - 1; } - if ( setup->total_bits > 2560 ) - { + if (setup->total_bits > 2560) { setup->targetBitsInit = setup->targetBitsInit - 1; } - if ( encoder->hrmode ) + if (encoder->hrmode) { setup->targetBitsInit -= 1; } - setup->targetBitsAri = setup->total_bits; + setup->targetBitsAri = setup->total_bits; setup->enable_lpc_weighting = setup->total_bits < 480; - if ( encoder->frame_ms == 5 ) - { + if (encoder->frame_ms == 5) { setup->enable_lpc_weighting = setup->total_bits < 240; } - if ( encoder->frame_ms == 2.5 ) - { + if (encoder->frame_ms == 2.5) { setup->enable_lpc_weighting = setup->total_bits < 120; } setup->quantizedGainOff = - -( MIN( 115, setup->total_bits / ( 10 * ( encoder->fs_idx + 1 ) ) ) + 105 + 5 * ( encoder->fs_idx + 1 ) ); + -(MIN(115, setup->total_bits / (10 * (encoder->fs_idx + 1))) + 105 + 5 * (encoder->fs_idx + 1)); - if ( encoder->hrmode && encoder->fs_idx == 5 ) + if (encoder->hrmode && encoder->fs_idx == 5) { - setup->quantizedGainOff = MAX( setup->quantizedGainOff, -181 ); + setup->quantizedGainOff = MAX(setup->quantizedGainOff, -181); } - if ( encoder->frame_ms == 10 && ( ( encoder->fs_in >= 44100 && setup->targetBytes >= 100 ) || ( encoder->fs_in == 32000 && setup->targetBytes >= 81 ) ) && setup->targetBytes < 340 && encoder->hrmode == 0 ) - { + if (encoder->frame_ms == 10 && ((encoder->fs_in >= 44100 && setup->targetBytes >= 100) || + (encoder->fs_in == 32000 && setup->targetBytes >= 81)) && setup->targetBytes < 340 && encoder->hrmode == 0) { setup->attack_handling = 1; - } - else if ( encoder->frame_dms == 75 && ( ( encoder->fs_in >= 44100 && setup->targetBytes >= 75 ) || ( encoder->fs_in == 32000 && setup->targetBytes >= 61 ) ) && setup->targetBytes < 150 && encoder->hrmode == 0 ) + + } + else if (encoder->frame_dms == 75 && ((encoder->fs_in >= 44100 && setup->targetBytes >= 75) || + (encoder->fs_in == 32000 && setup->targetBytes >= 61)) && setup->targetBytes < 150 && encoder->hrmode == 0) { setup->attack_handling = 1; } @@ -483,116 +421,97 @@ LC3PLUS_Error update_enc_bitrate( LC3PLUS_Enc *encoder, int bitrate ) setup->attdec_filter_mem[0] = 0; setup->attdec_filter_mem[1] = 0; - setup->attdec_detected = 0; - setup->attdec_position = 0; + setup->attdec_detected = 0; + setup->attdec_position = 0; setup->attdec_acc_energy = 0; } bitsTmp = setup->total_bits; - if ( encoder->frame_ms == 2.5 ) - { - bitsTmp = bitsTmp * 4.0 * ( 1.0 - 0.4 ); + if (encoder->frame_ms == 2.5) { + bitsTmp = bitsTmp * 4.0 * (1.0 - 0.4); } - if ( encoder->frame_ms == 5 ) - { + if (encoder->frame_ms == 5) { bitsTmp = bitsTmp * 2 - 160; } - if ( bitsTmp < 400 + ( encoder->fs_idx - 1 ) * 80 ) - { + if (bitsTmp < 400 + (encoder->fs_idx - 1) * 80) { setup->ltpf_enable = 1; - } - else if ( bitsTmp < 480 + ( encoder->fs_idx - 1 ) * 80 ) - { + } else if (bitsTmp < 480 + (encoder->fs_idx - 1) * 80) { setup->ltpf_enable = 1; - } - else if ( bitsTmp < 560 + ( encoder->fs_idx - 1 ) * 80 ) - { + } else if (bitsTmp < 560 + (encoder->fs_idx - 1) * 80) { setup->ltpf_enable = 1; - } - else if ( bitsTmp < 640 + ( encoder->fs_idx - 1 ) * 80 ) - { + } else if (bitsTmp < 640 + (encoder->fs_idx - 1) * 80) { setup->ltpf_enable = 1; - } - else - { + } else { setup->ltpf_enable = 0; } - if ( encoder->hrmode ) - { + if (encoder->hrmode) { setup->ltpf_enable = 0; } /* turn down SNS shaping for higher rates */ - if ( encoder->hrmode == 0 ) - { + if (encoder->hrmode == 0) { encoder->sns_damping = 0.85; - } - else - { + } else { encoder->sns_damping = 0.6; - if ( encoder->fs_idx >= 4 ) - { - if ( encoder->frame_ms == 10 ) + if (encoder->fs_idx >= 4) { + if (encoder->frame_ms == 10) { - if ( setup->total_bits > 4400 ) - { - encoder->sns_damping = 6881.0 / 32768.0; + if (setup->total_bits > 4400) { + encoder->sns_damping = 6881.0/32768.0; } } - if ( encoder->frame_ms == 5 ) + if (encoder->frame_ms == 5) { - if ( setup->total_bits > 4600 / 2 ) - { - encoder->sns_damping = 4915.0 / 32768.0; + if (setup->total_bits > 4600/2) { + encoder->sns_damping = 4915.0/32768.0; } } - if ( encoder->frame_ms == 2.5 ) + if (encoder->frame_ms == 2.5) { - if ( setup->total_bits > 4600 / 4 ) - { - encoder->sns_damping = 4915.0 / 32768.0; + if (setup->total_bits > 4600/4) { + encoder->sns_damping = 4915.0/32768.0; } } } } - if ( encoder->hrmode && encoder->fs_idx >= 4 ) + if (encoder->hrmode && encoder->fs_idx >= 4) { int real_rate = setup->targetBytes * 8000 / encoder->frame_ms; setup->regBits = real_rate / 12500; - if ( encoder->fs_idx == 5 ) + if (encoder->fs_idx == 5) { - if ( encoder->frame_ms == 10 ) + if (encoder->frame_ms == 10) { - setup->regBits += 2; + setup->regBits +=2; } - if ( encoder->frame_ms == 2.5 ) + if (encoder->frame_ms == 2.5) { setup->regBits -= 6; } } else { - if ( encoder->frame_ms == 2.5 ) + if (encoder->frame_ms == 2.5) { setup->regBits -= 6; } - else if ( encoder->frame_ms == 5 ) + else if (encoder->frame_ms == 5) { setup->regBits += 0; } - if ( encoder->frame_ms == 10 ) + if (encoder->frame_ms == 10) { setup->regBits += 5; } } - if ( setup->regBits < 6 ) + if (setup->regBits < 6) { setup->regBits = 6; } - if ( setup->regBits > 23 ) + if (setup->regBits > 23) { setup->regBits = 23; } @@ -608,20 +527,18 @@ LC3PLUS_Error update_enc_bitrate( LC3PLUS_Enc *encoder, int bitrate ) return LC3PLUS_OK; } -void update_enc_bandwidth( LC3PLUS_Enc *encoder, int bandwidth ) +void update_enc_bandwidth(LC3PLUS_Enc* encoder, int bandwidth) { int index = 0; - if ( bandwidth >= encoder->fs_in ) - { + if (bandwidth >= encoder->fs_in) { encoder->bandwidth = 0; } else { encoder->bandwidth = bandwidth; - index = FS2FS_IDX( bandwidth ); - if ( index > 4 ) - { + index = FS2FS_IDX(bandwidth); + if (index > 4) { index = 5; } encoder->bw_ctrl_cutoff_bin = encoder->cutoffBins[index]; diff --git a/lib_lc3plus/setup_enc_lc3.h b/lib_lc3plus/setup_enc_lc3.h index c5570c4636..31f0cbeb50 100644 --- a/lib_lc3plus/setup_enc_lc3.h +++ b/lib_lc3plus/setup_enc_lc3.h @@ -1,12 +1,12 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #ifndef SETUP_ENC_LC3_FL_H #define SETUP_ENC_LC3_FL_H @@ -14,8 +14,7 @@ #include "constants.h" /* Channel state and bitrate-derived values go in this struct */ -typedef struct -{ +typedef struct { LC3_FLOAT targetBitsOff; LC3_FLOAT ltpf_mem_normcorr; LC3_FLOAT ltpf_mem_mem_normcorr; @@ -56,7 +55,7 @@ typedef struct LC3_INT codingdata[3 * MAX_LEN]; uint8_t resBits[MAX_RESBITS_LEN]; LC3_INT regBits; - + LC3_INT16 n_pc; LC3_INT16 n_pccw; LC3_INT16 be_bp_left; @@ -69,12 +68,11 @@ typedef struct } EncSetup; /* Constants and sampling rate derived values go in this struct */ -struct LC3PLUS_Enc -{ - EncSetup *channel_setup[MAX_CHANNELS]; - const LC3_INT *W_fx; - const LC3_INT *bands_offset; - const LC3_INT *cutoffBins; +struct LC3PLUS_Enc { + EncSetup* channel_setup[MAX_CHANNELS]; + const LC3_INT* W_fx; + const LC3_INT* bands_offset; + const LC3_INT* cutoffBins; LC3_INT fs; /* encoder sampling rate 44.1 -> 48 */ LC3_INT fs_in; /* input sampling rate */ @@ -105,15 +103,15 @@ struct LC3PLUS_Enc LC3_INT tnsMaxOrder; LC3_INT hrmode; LC3_INT bandwidth; - LC3_INT bandwidth_preset; - LC3_INT bw_ctrl_active; + LC3_INT bandwidth_preset; + LC3_INT bw_ctrl_active; LC3_INT bw_ctrl_cutoff_bin; LC3_INT bw_index; LC3_FLOAT sns_damping; LC3_INT attdec_nblocks; LC3_FLOAT attdec_damping; LC3_INT attdec_hangover_thresh; - + LC3_INT16 combined_channel_coding; LC3_INT16 epmr; }; diff --git a/lib_lc3plus/sns_compute_scf.c b/lib_lc3plus/sns_compute_scf.c index 78a4089a16..5cb041925b 100644 --- a/lib_lc3plus/sns_compute_scf.c +++ b/lib_lc3plus/sns_compute_scf.c @@ -1,50 +1,47 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -void processSnsComputeScf_fl( LC3_FLOAT *x, LC3_INT tilt, LC3_INT xLen, LC3_FLOAT *gains, LC3_INT smooth, LC3_FLOAT sns_damping, LC3_FLOAT attdec_damping_factor ) +void processSnsComputeScf_fl(LC3_FLOAT* x, LC3_INT tilt, LC3_INT xLen, LC3_FLOAT* gains, LC3_INT smooth, LC3_FLOAT sns_damping, LC3_FLOAT attdec_damping_factor) { - LC3_INT bands_number = 0, d = 0, i = 0, j = 0, n = 0, n2 = 0, n4 = 0, mapping[64] = { 0 }; - LC3_FLOAT tmp[64] = { 0 }, x_tmp1[MAX_LEN] = { 0 }, x_tmp2[MAX_LEN] = { 0 }, sum = 0, mean = 0, xl4[16] = { 0 }, nf = 0, xl[64] = { 0 }, gains_smooth[M] = { 0 }, ratio = 0; - LC3_FLOAT W[6] = { 1.0 / 12.0, 2.0 / 12.0, 3.0 / 12.0, 3.0 / 12.0, 2.0 / 12.0, 1.0 / 12.0 }; + LC3_INT bands_number = 0, d = 0, i = 0, j = 0, n = 0, n2 = 0, n4 = 0, mapping[64] = {0}; + LC3_FLOAT tmp[64] = {0}, x_tmp1[MAX_LEN] = {0}, x_tmp2[MAX_LEN] = {0}, sum = 0, mean = 0, xl4[16] = {0}, nf = 0, xl[64] = {0}, gains_smooth[M] = {0}, ratio = 0; + LC3_FLOAT W[6] = {1.0 / 12.0, 2.0 / 12.0, 3.0 / 12.0, 3.0 / 12.0, 2.0 / 12.0, 1.0 / 12.0}; bands_number = xLen; - assert( bands_number <= 64 ); + assert(bands_number <= 64); /* 5 ms */ - if ( bands_number < 64 ) - { + if (bands_number < 64) { d = 64 - bands_number; - if ( d < xLen ) + if (d < xLen) { j = 0; - for ( i = 0; i < 2 * d; i = i + 2 ) - { - tmp[i] = x[j]; + for (i = 0; i < 2 * d; i = i + 2) { + tmp[i] = x[j]; tmp[i + 1] = x[j]; j++; } - move_float( &tmp[2 * d], &x[d], 64 - 2 * d ); - } - else if ( ceil( 64.0 / (LC3_FLOAT) xLen ) == 4 ) + move_float(&tmp[2 * d], &x[d], 64 - 2 * d); + } else if (ceil(64.0 / (LC3_FLOAT) xLen) == 4) { - ratio = LC3_FABS( (LC3_FLOAT) ( 1.0 - 32.0 / (LC3_FLOAT) xLen ) ); - n4 = round( ratio * xLen ); + ratio = LC3_FABS((LC3_FLOAT) (1.0 - 32.0 / (LC3_FLOAT) xLen)); + n4 = round(ratio * xLen); n2 = xLen - n4; - + j = 0; - for ( i = 1; i <= n4; i++ ) + for(i = 1; i <= n4; i++) { mapping[j] = i; mapping[j + 1] = i; @@ -52,29 +49,27 @@ void processSnsComputeScf_fl( LC3_FLOAT *x, LC3_INT tilt, LC3_INT xLen, LC3_FLOA mapping[j + 3] = i; j += 4; } - - for ( i = n4 + 1; i <= n4 + n2; i++ ) + + for (i = n4 + 1; i <= n4 + n2; i++) { mapping[j] = i; mapping[j + 1] = i; j += 2; } - - - for ( i = 0; i < 64; i++ ) + + + for (i = 0; i < 64; i++) { tmp[i] = x[mapping[i] - 1]; } - } - else - { - assert( 0 && "Unsupported number of bands!" ); + } else { + assert(0 && "Unsupported number of bands!"); } - move_float( x, tmp, 64 ); + move_float(x, tmp, 64); bands_number = 64; - xLen = bands_number; + xLen = bands_number; } @@ -82,71 +77,60 @@ void processSnsComputeScf_fl( LC3_FLOAT *x, LC3_INT tilt, LC3_INT xLen, LC3_FLOA x_tmp1[0] = x[0]; - move_float( &x_tmp1[1], &x[0], xLen - 1 ); + move_float(&x_tmp1[1], &x[0], xLen - 1); - move_float( &x_tmp2[0], &x[1], xLen - 1 ); + move_float(&x_tmp2[0], &x[1], xLen - 1); x_tmp2[xLen - 1] = x[xLen - 1]; - for ( i = 0; i < xLen; i++ ) - { - x[i] = 0.5 * x[i] + 0.25 * ( x_tmp1[i] + x_tmp2[i] ); + for (i = 0; i < xLen; i++) { + x[i] = 0.5 * x[i] + 0.25 * (x_tmp1[i] + x_tmp2[i]); } /* Pre-emphasis */ - for ( i = 0; i < xLen; i++ ) - { - x[i] = x[i] * LC3_POW( 10.0, (LC3_FLOAT) i * (LC3_FLOAT) tilt / ( (LC3_FLOAT) bands_number - 1.0 ) / 10.0 ); + for (i = 0; i < xLen; i++) { + x[i] = x[i] * LC3_POW(10.0, (LC3_FLOAT)i * (LC3_FLOAT)tilt / ((LC3_FLOAT)bands_number - 1.0) / 10.0); } /* Noise floor at -40dB */ - for ( i = 0; i < 64; i++ ) - { + for (i = 0; i < 64; i++) { sum += x[i]; } - mean = sum / (LC3_FLOAT) xLen; + mean = sum / (LC3_FLOAT)xLen; - nf = mean * LC3_POW( 10.0, -40.0 / 10.0 ); - nf = MAX( nf, LC3_POW( 2.0, -32.0 ) ); + nf = mean * LC3_POW(10.0, -40.0 / 10.0); + nf = MAX(nf, LC3_POW(2.0, -32.0)); - for ( i = 0; i < 64; i++ ) - { - if ( x[i] < nf ) - { + for (i = 0; i < 64; i++) { + if (x[i] < nf) { x[i] = nf; } } /* Log-domain */ - for ( i = 0; i < 64; i++ ) - { - xl[i] = LC3_LOGTWO( x[i] ) / 2.0; + for (i = 0; i < 64; i++) { + xl[i] = LC3_LOGTWO(x[i]) / 2.0; } /* Downsampling */ - for ( n = 0; n < bands_number / 4; n++ ) - { - if ( n == 0 ) - { + for (n = 0; n < bands_number / 4; n++) { + if (n == 0) { tmp[0] = xl[0]; - move_float( &tmp[1], &xl[0], 5 ); - } - else if ( n == ( bands_number / 4 - 1 ) ) - { - move_float( tmp, &xl[59], 5 ); + move_float(&tmp[1], &xl[0], 5); + + } else if (n == (bands_number / 4 - 1)) { + move_float(tmp, &xl[59], 5); tmp[5] = xl[63]; - } - else - { - move_float( tmp, &xl[n * 4 - 1], ( ( n * 4 + 5 - 1 ) - ( n * 4 - 1 ) + 1 ) ); + + } else { + move_float(tmp, &xl[n * 4 - 1], ((n * 4 + 5 - 1) - (n * 4 - 1) + 1)); } sum = 0; - for ( i = 0; i < 6; i++ ) - { + for (i = 0; i < 6; i++) { sum += tmp[i] * W[i]; } @@ -157,43 +141,37 @@ void processSnsComputeScf_fl( LC3_FLOAT *x, LC3_INT tilt, LC3_INT xLen, LC3_FLOA /* Remove mean and scaling */ sum = 0; - for ( i = 0; i < bands_number / 4; i++ ) - { + for (i = 0; i < bands_number / 4; i++) { sum += xl4[i]; } - mean = sum / ( (LC3_FLOAT) bands_number / 4.0 ); + mean = sum / ((LC3_FLOAT)bands_number / 4.0); - for ( i = 0; i < bands_number / 4; i++ ) - { - gains[i] = sns_damping * ( xl4[i] - mean ); + for (i = 0; i < bands_number / 4; i++) { + gains[i] = sns_damping * (xl4[i] - mean); } /* Smoothing */ - if ( smooth ) - { - gains_smooth[0] = ( gains[0] + gains[1] + gains[2] ) / 3.0; - gains_smooth[1] = ( gains[0] + gains[1] + gains[2] + gains[3] ) / 4.0; + if (smooth) { + gains_smooth[0] = (gains[0] + gains[1] + gains[2]) / 3.0; + gains_smooth[1] = (gains[0] + gains[1] + gains[2] + gains[3]) / 4.0; - for ( i = 2; i < 14; i++ ) - { - gains_smooth[i] = ( gains[i - 2] + gains[i - 1] + gains[i] + gains[i + 1] + gains[i + 2] ) / 5.0; + for (i = 2; i < 14; i++) { + gains_smooth[i] = (gains[i - 2] + gains[i - 1] + gains[i] + gains[i + 1] + gains[i + 2]) / 5.0; } - gains_smooth[M - 2] = ( gains[M - 4] + gains[M - 3] + gains[M - 2] + gains[M - 1] ) / 4.0; - gains_smooth[M - 1] = ( gains[M - 3] + gains[M - 2] + gains[M - 1] ) / 3.0; + gains_smooth[M - 2] = (gains[M - 4] + gains[M - 3] + gains[M - 2] + gains[M - 1]) / 4.0; + gains_smooth[M - 1] = (gains[M - 3] + gains[M - 2] + gains[M - 1]) / 3.0; sum = 0; - for ( i = 0; i < M; i++ ) - { + for (i = 0; i < M; i++) { sum += gains_smooth[i]; } - mean = sum / (LC3_FLOAT) M; + mean = sum / (LC3_FLOAT)M; - for ( i = 0; i < M; i++ ) - { - gains[i] = attdec_damping_factor * ( gains_smooth[i] - mean ); + for (i = 0; i < M; i++) { + gains[i] = attdec_damping_factor * (gains_smooth[i] - mean); } } } diff --git a/lib_lc3plus/sns_interpolate_scf.c b/lib_lc3plus/sns_interpolate_scf.c index 4518393003..4419397890 100644 --- a/lib_lc3plus/sns_interpolate_scf.c +++ b/lib_lc3plus/sns_interpolate_scf.c @@ -1,101 +1,90 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -void processSnsInterpolateScf_fl( LC3_FLOAT *gains, LC3_INT encoder_side, LC3_INT bands_number, LC3_FLOAT *gains_int ) +void processSnsInterpolateScf_fl(LC3_FLOAT* gains, LC3_INT encoder_side, LC3_INT bands_number, LC3_FLOAT* gains_int) { - LC3_INT i = 0, n = 0, d = 0, n4 = 0; - LC3_FLOAT tmp[MAX_BANDS_NUMBER_PLC] = { 0 }, ratio = 0; + LC3_INT i = 0, n = 0, d = 0, n4 = 0; + LC3_FLOAT tmp[MAX_BANDS_NUMBER_PLC] = {0}, ratio = 0; /* Interpolation */ gains_int[0] = gains[0]; gains_int[1] = gains[0]; - for ( n = 0; n <= 14; n++ ) - { - gains_int[n * 4 + 2] = gains[n] + ( gains[n + 1] - gains[n] ) / 8.0; - gains_int[n * 4 + 3] = gains[n] + 3.0 * ( gains[n + 1] - gains[n] ) / 8.0; - gains_int[n * 4 + 4] = gains[n] + 5.0 * ( gains[n + 1] - gains[n] ) / 8.0; - gains_int[n * 4 + 5] = gains[n] + 7.0 * ( gains[n + 1] - gains[n] ) / 8.0; + for (n = 0; n <= 14; n++) { + gains_int[n * 4 + 2] = gains[n] + (gains[n + 1] - gains[n]) / 8.0; + gains_int[n * 4 + 3] = gains[n] + 3.0 * (gains[n + 1] - gains[n]) / 8.0; + gains_int[n * 4 + 4] = gains[n] + 5.0 * (gains[n + 1] - gains[n]) / 8.0; + gains_int[n * 4 + 5] = gains[n] + 7.0 * (gains[n + 1] - gains[n]) / 8.0; } - gains_int[62] = gains[15] + ( gains[15] - gains[14] ) / 8.0; - gains_int[63] = gains[15] + 3.0 * ( gains[15] - gains[14] ) / 8.0; + gains_int[62] = gains[15] + (gains[15] - gains[14]) / 8.0; + gains_int[63] = gains[15] + 3.0 * (gains[15] - gains[14]) / 8.0; /* For 5ms */ - if ( bands_number < 64 ) - { + if (bands_number < 64) { d = 64 - bands_number; - if ( d < 32 ) + if (d < 32) { i = 0; - for ( n = 0; n < 2 * d; n = n + 2 ) - { - tmp[i] = ( gains_int[n] + gains_int[n + 1] ) / (LC3_FLOAT) 2.0; + for (n = 0; n < 2 * d; n = n + 2) { + tmp[i] = (gains_int[n] + gains_int[n + 1]) / (LC3_FLOAT)2.0; i++; } - for ( n = 1; n < d; n++ ) - { + for (n = 1; n < d; n++) { gains_int[n] = gains_int[2 * n]; } - for ( n = 2 * d; n < 64; n++ ) - { + for (n = 2 * d; n < 64; n++) { gains_int[n - d] = gains_int[n]; } - move_float( gains_int, tmp, d ); - } - else if ( ceil( 64.0 / (LC3_FLOAT) bands_number ) == 4 ) + move_float(gains_int, tmp, d); + } else if (ceil(64.0 / (LC3_FLOAT) bands_number) == 4) { - ratio = LC3_FABS( (LC3_FLOAT) ( (LC3_FLOAT) 1.0 - (LC3_FLOAT) 32.0 / (LC3_FLOAT) bands_number ) ); - n4 = LC3_ROUND( ratio * (LC3_FLOAT) bands_number ); - - for ( i = 0; i < n4; i++ ) + ratio = LC3_FABS((LC3_FLOAT) ((LC3_FLOAT)1.0 - (LC3_FLOAT)32.0 / (LC3_FLOAT) bands_number)); + n4 = LC3_ROUND(ratio * (LC3_FLOAT)bands_number); + + for (i = 0; i < n4; i++) { - tmp[i] = ( gains_int[4 * i] + gains_int[4 * i + 1] + gains_int[4 * i + 2] + gains_int[4 * i + 3] ) / 4.0; + tmp[i] = (gains_int[4 * i] + gains_int[4 * i + 1] + gains_int[4 * i + 2] + gains_int[4 * i + 3]) / 4.0; } - - for ( i = 0; i < bands_number - n4; i++ ) + + for (i = 0; i < bands_number - n4; i++) { - tmp[n4 + i] = ( gains_int[4 * n4 + 2 * i] + gains_int[4 * n4 + 2 * i + 1] ) / 2.0; + tmp[n4 + i] = (gains_int[4 * n4 + 2 * i] + gains_int[4 * n4 + 2 * i + 1]) / 2.0; } - - move_float( gains_int, tmp, bands_number ); - } - else - { - assert( 0 && "Unsupported number of bands!" ); + + move_float(gains_int, tmp, bands_number); + } else { + assert(0 && "Unsupported number of bands!"); } } /* Inversion at encoder-side */ - if ( encoder_side == 1 ) - { - for ( n = 0; n < bands_number; n++ ) - { + if (encoder_side == 1) { + for (n = 0; n < bands_number; n++) { gains_int[n] = -gains_int[n]; } } /* Linear domain */ - for ( n = 0; n < bands_number; n++ ) - { - gains_int[n] = LC3_POW( 2, gains_int[n] ); + for (n = 0; n < bands_number; n++) { + gains_int[n] = LC3_POW(2, gains_int[n]); } } diff --git a/lib_lc3plus/sns_quantize_scf.c b/lib_lc3plus/sns_quantize_scf.c index 05bc62f186..704127cce7 100644 --- a/lib_lc3plus/sns_quantize_scf.c +++ b/lib_lc3plus/sns_quantize_scf.c @@ -1,35 +1,34 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -static void pvq_dec( LC3_INT k, LC3_INT m, LC3_INT LS_ind, LC3_INT MPVQ_ind, LC3_INT *pulses ); -static LC3_INT find_last_indice_le( LC3_INT compare, const LC3_INT *array, LC3_INT len ); -static void idct_II( LC3_FLOAT *in, LC3_FLOAT *out, LC3_INT len ); +static void pvq_dec(LC3_INT k, LC3_INT m, LC3_INT LS_ind, LC3_INT MPVQ_ind, LC3_INT* pulses); +static LC3_INT find_last_indice_le(LC3_INT compare, const LC3_INT* array, LC3_INT len); +static void idct_II(LC3_FLOAT* in, LC3_FLOAT* out, LC3_INT len); -void idct_II( LC3_FLOAT *in, LC3_FLOAT *out, LC3_INT len ) +void idct_II(LC3_FLOAT* in, LC3_FLOAT* out, LC3_INT len) { LC3_INT i; LC3_FLOAT norm1, sum; norm1 = 0.353553390593274; /* sqrt(2 / 16) */ - - for ( i = 0; i < len; i++ ) - { - sum = mac_loop( in, idct_lookup[i], len ); + + for (i = 0; i < len; i++) { + sum = mac_loop(in, idct_lookup[i], len); out[i] = norm1 * sum; } } -static LC3_INT pvq_pulse_search( LC3_FLOAT *xabs, LC3_FLOAT *ener, LC3_FLOAT *corr, LC3_INT *y, LC3_INT start, LC3_INT end ) +static LC3_INT pvq_pulse_search(LC3_FLOAT *xabs, LC3_FLOAT *ener, LC3_FLOAT *corr, LC3_INT *y, LC3_INT start, LC3_INT end) { LC3_INT i; LC3_INT nBest; @@ -45,7 +44,7 @@ static LC3_INT pvq_pulse_search( LC3_FLOAT *xabs, LC3_FLOAT *ener, LC3_FLOAT *co i = start; currCorr = *corr + xabs[i]; - currEn = *ener + ( 2 * y[i] ); + currEn = *ener + (2 * y[i]); corrSq = currCorr * currCorr; @@ -54,14 +53,14 @@ static LC3_INT pvq_pulse_search( LC3_FLOAT *xabs, LC3_FLOAT *ener, LC3_FLOAT *co nBest = i; /* Iterative max search as recommended in the spec */ - for ( ; i < end; i++ ) + for (; i < end; i++) { currCorr = *corr + xabs[i]; - currEn = *ener + ( 2 * y[i] ); + currEn = *ener + (2 * y[i]); corrSq = currCorr * currCorr; - if ( ( corrSq * bestEn ) > ( bestCorrSq * currEn ) ) + if ((corrSq * bestEn) > (bestCorrSq * currEn)) { bestEn = currEn; bestCorrSq = corrSq; @@ -70,26 +69,26 @@ static LC3_INT pvq_pulse_search( LC3_FLOAT *xabs, LC3_FLOAT *ener, LC3_FLOAT *co } *corr += xabs[nBest]; - *ener += ( 2 * y[nBest] ); + *ener += (2 * y[nBest]); y[nBest] += 1; /* Add the selected unit pulse */ return nBest; } -static void pvq_enc_vec_normalize( LC3_FLOAT *vec, LC3_INT N ) +static void pvq_enc_vec_normalize(LC3_FLOAT *vec, LC3_INT N) { LC3_FLOAT mag = 0.0, norm_fac; LC3_INT i; - for ( i = 0; i < N; i++ ) + for (i = 0; i < N; i++) { - mag += ( vec[i] * vec[i] ); + mag += (vec[i] * vec[i]); } - norm_fac = 1.0 / LC3_SQRT( mag ); + norm_fac = 1.0 / LC3_SQRT(mag); - for ( i = 0; i < N; i++ ) + for (i = 0; i < N; i++) { vec[i] = vec[i] * norm_fac; } @@ -97,7 +96,7 @@ static void pvq_enc_vec_normalize( LC3_FLOAT *vec, LC3_INT N ) return; } -static void pvq_enc_search( LC3_FLOAT *x_in, LC3_INT y[4][M] ) +static void pvq_enc_search(LC3_FLOAT* x_in, LC3_INT y[4][M]) { LC3_INT i, N, K, pulse_total, N_setA; LC3_FLOAT abs_sum, projfac; @@ -114,43 +113,43 @@ static void pvq_enc_search( LC3_FLOAT *x_in, LC3_INT y[4][M] ) yy = xy = 0.0f; - for ( i = 0; i < N; i++ ) + for (i = 0; i < N; i++) { - xabs[i] = LC3_FABS( x_in[i] ); + xabs[i] = LC3_FABS(x_in[i]); abs_sum += xabs[i]; } - projfac = ( K - 1 ) / abs_sum; + projfac = (K - 1) / abs_sum; - for ( i = 0; i < N; i++ ) + for (i = 0; i < N; i++) { - y[3][i] = floor( xabs[i] * projfac ); + y[3][i] = floor(xabs[i] * projfac); pulse_total += y[3][i]; - yy += ( y[3][i] * y[3][i] ); - xy += ( xabs[i] * y[3][i] ); + yy += (y[3][i] * y[3][i]); + xy += (xabs[i] * y[3][i]); } /* Step 2: Adding unit pulses up to K = 6 */ - for ( ; pulse_total < K; pulse_total++ ) + for (; pulse_total < K; pulse_total++) { - pvq_pulse_search( xabs, &yy, &xy, y[3], 0, N ); + pvq_pulse_search(xabs, &yy, &xy, y[3], 0, N); } /* Step 3: Adding unit pulses up to K = 8 */ - memcpy( y[2], y[3], sizeof( LC3_INT ) * N ); + memcpy(y[2], y[3], sizeof(LC3_INT)*N); K = 8; - for ( ; pulse_total < K; pulse_total++ ) + for (; pulse_total < K; pulse_total++) { - pvq_pulse_search( xabs, &yy, &xy, y[2], 0, N ); + pvq_pulse_search(xabs, &yy, &xy, y[2], 0, N); } - memcpy( y[1], y[2], sizeof( LC3_INT ) * N_setA ); + memcpy(y[1], y[2], sizeof(LC3_INT)*N_setA); /* Step 4: Remove unit pulses not belonging to set A */ - for ( i = N_setA; i < N; i++ ) + for (i = N_setA; i < N; i++) { y[1][i] = 0; } @@ -160,30 +159,30 @@ static void pvq_enc_search( LC3_FLOAT *x_in, LC3_INT y[4][M] ) xy = 0; pulse_total = 0; - for ( i = 0; i < N_setA; i++ ) + for (i = 0; i < N_setA; i++) { - yy += ( y[1][i] * y[1][i] ); - xy += ( xabs[i] * y[1][i] ); + yy += (y[1][i] * y[1][i]); + xy += (xabs[i] * y[1][i]); pulse_total += y[1][i]; } /* Step 6: Add unit pulses until K = 10 over N = 10 */ K = 10; - for ( ; pulse_total < K; pulse_total++ ) + for (; pulse_total < K; pulse_total++) { - pvq_pulse_search( xabs, &yy, &xy, y[1], 0, N_setA ); + pvq_pulse_search(xabs, &yy, &xy, y[1], 0, N_setA); } - memcpy( y[0], y[1], sizeof( LC3_INT ) * N ); + memcpy(y[0], y[1], sizeof(LC3_INT)*N); /* Step 7: Add unit pulses until K = 1 over N = 6 in set B*/ - pvq_pulse_search( xabs, &yy, &xy, y[0], N_setA, N ); + pvq_pulse_search(xabs, &yy, &xy, y[0], N_setA, N); /* Step 8: Add signs to each of the 4 vectors from x */ - for ( i = 0; i < N; i++ ) + for (i = 0; i < N; i++) { - if ( x_in[i] < 0 ) + if (x_in[i] < 0) { y[0][i] = -y[0][i]; y[1][i] = -y[1][i]; @@ -195,23 +194,24 @@ static void pvq_enc_search( LC3_FLOAT *x_in, LC3_INT y[4][M] ) return; } -static inline LC3_FLOAT calc_mse( LC3_FLOAT *t2rot, LC3_FLOAT *y, LC3_FLOAT gain, LC3_INT N ) +static inline LC3_FLOAT calc_mse(LC3_FLOAT *t2rot, LC3_FLOAT *y, LC3_FLOAT gain, LC3_INT N) { LC3_FLOAT mse; LC3_INT i; mse = 0.0; - for ( i = 0; i < N; i++ ) + for (i = 0; i < N; i++) { - LC3_FLOAT err = ( t2rot[i] - gain * y[i] ); - mse += ( err * err ); + LC3_FLOAT err = (t2rot[i] - gain * y[i]); + mse += (err * err); } return mse; } -static void sns_quant_adj_gain_shape_search( LC3_FLOAT *t2rot, LC3_INT y[4][M], LC3_INT *gain_idx, LC3_INT *shape_idx, LC3_FLOAT *y_norm, LC3_FLOAT *scq_gain ) +static void sns_quant_adj_gain_shape_search(LC3_FLOAT *t2rot, LC3_INT y[4][M] , + LC3_INT *gain_idx, LC3_INT *shape_idx, LC3_FLOAT *y_norm, LC3_FLOAT *scq_gain) { LC3_INT gidx, sidx; LC3_FLOAT min_mse, mse; @@ -220,8 +220,8 @@ static void sns_quant_adj_gain_shape_search( LC3_FLOAT *t2rot, LC3_INT y[4][M], LC3_INT i; const LC3_INT gain_levels[4] = { 2, 4, 4, 8 }; - const LC3_FLOAT *sns_vq_gains[4] = { sns_vq_reg_adj_gains_fl, sns_vq_reg_lf_adj_gains_fl, - sns_vq_near_adj_gains_fl, sns_vq_far_adj_gains_fl }; + const LC3_FLOAT *sns_vq_gains[4] = { sns_vq_reg_adj_gains_fl , sns_vq_reg_lf_adj_gains_fl , + sns_vq_near_adj_gains_fl , sns_vq_far_adj_gains_fl }; min_mse = -1.0; N = 16; @@ -229,21 +229,21 @@ static void sns_quant_adj_gain_shape_search( LC3_FLOAT *t2rot, LC3_INT y[4][M], *gain_idx = *shape_idx = 0; - for ( sidx = 0; sidx < 4; sidx++ ) + for (sidx = 0; sidx < 4; sidx++) { - for ( i = 0; i < N; i++ ) + for (i = 0; i < N; i++) { - yCur[sidx][i] = (LC3_FLOAT) y[sidx][i]; + yCur[sidx][i] = (LC3_FLOAT)y[sidx][i]; } /* Step 9: Normalize the vectors */ - pvq_enc_vec_normalize( yCur[sidx], N ); + pvq_enc_vec_normalize(yCur[sidx], N); - for ( gidx = 0; gidx < gain_levels[sidx]; gidx++ ) + for (gidx = 0; gidx < gain_levels[sidx]; gidx++) { - mse = calc_mse( t2rot, yCur[sidx], sns_vq_gains[sidx][gidx], N ); + mse = calc_mse(t2rot, yCur[sidx], sns_vq_gains[sidx][gidx], N); - if ( ( mse < min_mse ) || ( min_mse < 0 ) ) + if ((mse < min_mse) || (min_mse < 0)) { *gain_idx = gidx; *shape_idx = sidx; @@ -252,7 +252,7 @@ static void sns_quant_adj_gain_shape_search( LC3_FLOAT *t2rot, LC3_INT y[4][M], } } - for ( i = 0; i < N; i++ ) + for (i = 0; i < N; i++) { y_norm[i] = yCur[*shape_idx][i]; } @@ -262,25 +262,22 @@ static void sns_quant_adj_gain_shape_search( LC3_FLOAT *t2rot, LC3_INT y[4][M], return; } -static void enc_push_sign( LC3_FLOAT val, LC3_UINT32 *next_sign_ind, LC3_INT *index ) +static void enc_push_sign(LC3_FLOAT val, LC3_UINT32 *next_sign_ind, LC3_INT *index) { - if ( ( ( *next_sign_ind & 0x80000000U ) == 0 ) && ( val != 0 ) ) - { - *index = 2 * ( *index ) + *next_sign_ind; + if (((*next_sign_ind & 0x80000000U) == 0) && (val != 0)) { + *index = 2 * (*index) + *next_sign_ind; } - if ( val < 0 ) - { + if (val < 0) { *next_sign_ind = 1; } - if ( val > 0 ) - { + if (val > 0) { *next_sign_ind = 0; } return; } -static void MPVQ_enum( LC3_INT dim, LC3_INT *sns_vec, LC3_INT *index_val, LC3_INT *lead_sign_ind ) +static void MPVQ_enum(LC3_INT dim, LC3_INT *sns_vec, LC3_INT *index_val, LC3_INT *lead_sign_ind) { LC3_UINT32 next_sign_ind; LC3_INT k_val_acc; @@ -298,21 +295,20 @@ static void MPVQ_enum( LC3_INT dim, LC3_INT *sns_vec, LC3_INT *index_val, LC3_IN index = 0; n = 0; - row_ptr = (LC3_INT const *) &( pvq_enc_A[n] ); + row_ptr = (LC3_INT const *)&(pvq_enc_A[n]); tmp_h_row = row_ptr[0]; - for ( pos--; pos >= 0; pos-- ) + for (pos--; pos >= 0; pos--) { tmp_val = sns_vec[pos]; - enc_push_sign( tmp_val, &next_sign_ind, &index ); + enc_push_sign(tmp_val, &next_sign_ind, &index); index += tmp_h_row; - k_val_acc += abs( tmp_val ); - if ( pos != 0 ) - { + k_val_acc += abs(tmp_val); + if (pos != 0) { n += 1; /* switch row in offset table MPVQ_offsets(n, k) */ } - row_ptr = (LC3_INT const *) &( pvq_enc_A[n] ); + row_ptr = (LC3_INT const *)&(pvq_enc_A[n]); tmp_h_row = row_ptr[k_val_acc]; } @@ -323,7 +319,7 @@ static void MPVQ_enum( LC3_INT dim, LC3_INT *sns_vec, LC3_INT *index_val, LC3_IN return; } -static LC3_INT MSEsearch( LC3_FLOAT *scf, const LC3_FLOAT sns_CB[8][32] ) +static LC3_INT MSEsearch (LC3_FLOAT *scf, const LC3_FLOAT sns_CB[8][32]) { LC3_FLOAT distance, mse; LC3_INT i, n, ind; @@ -331,24 +327,21 @@ static LC3_INT MSEsearch( LC3_FLOAT *scf, const LC3_FLOAT sns_CB[8][32] ) ind = 0; distance = (LC3_FLOAT) LC3_CONST_POW_2_100; - for ( i = 0; i < 32; i++ ) - { + for (i = 0; i < 32; i++) { mse = 0; - for ( n = 0; n < 8; n++ ) - { - mse += ( scf[n] - sns_CB[n][i] ) * ( scf[n] - sns_CB[n][i] ); + for (n = 0; n < 8; n++) { + mse += (scf[n] - sns_CB[n][i]) * (scf[n] - sns_CB[n][i]); } - if ( mse < distance ) - { + if (mse < distance) { distance = mse; - ind = i; + ind = i; } } return ind; } -void process_snsQuantizesScf_Enc( LC3_FLOAT *env, LC3_INT *index, LC3_FLOAT *envq, Dct2 dct2structSNS ) +void process_snsQuantizesScf_Enc(LC3_FLOAT* env, LC3_INT* index, LC3_FLOAT* envq, Dct2 dct2structSNS) { LC3_FLOAT stage2_en1_norm_sub[M]; LC3_INT i, j; @@ -361,83 +354,72 @@ void process_snsQuantizesScf_Enc( LC3_FLOAT *env, LC3_INT *index, LC3_FLOAT *env LC3_INT y[4][M]; /* Stage 1 split VQ */ - index[0] = MSEsearch( &env[0], sns_LFCB ); /* ind_LF */ - index[1] = MSEsearch( &env[8], sns_HFCB ); /* ind_HF */ + index[0] = MSEsearch(&env[0], sns_LFCB); /* ind_LF */ + index[1] = MSEsearch(&env[8], sns_HFCB); /* ind_HF */ j = 8; - for ( i = 0; i < 8; i++, j++ ) - { + for (i = 0; i < 8; i++, j++) { st1_vector[i] = sns_LFCB[i][index[0]]; st1_vector[j] = sns_HFCB[i][index[1]]; } /* STAGE 2 */ - for ( i = 0; i < 16; i++ ) - { + for (i = 0; i < 16; i++) { pvq_target_pre[i] = env[i] - st1_vector[i]; } - dct2_apply( &dct2structSNS, pvq_target_pre, pvq_target ); - pvq_enc_search( pvq_target, y ); - sns_quant_adj_gain_shape_search( pvq_target, y, &gain, &shape, stage2_en1_norm_pre_sub, &scfq_gain ); + dct2_apply(&dct2structSNS, pvq_target_pre, pvq_target); + pvq_enc_search(pvq_target, y); + sns_quant_adj_gain_shape_search(pvq_target, y, &gain, &shape, stage2_en1_norm_pre_sub, &scfq_gain); /* Inverse transform */ - idct_II( stage2_en1_norm_pre_sub, stage2_en1_norm_sub, M ); + idct_II(stage2_en1_norm_pre_sub, stage2_en1_norm_sub, M); index[2] = shape; index[3] = gain; - if ( shape < 2 ) - { - MPVQ_enum( 10, y[shape], &index[5], &index[4] ); + if (shape < 2) { + MPVQ_enum(10, y[shape], &index[5], &index[4]); } - else - { - MPVQ_enum( M, y[shape], &index[5], &index[4] ); + else { + MPVQ_enum(M, y[shape], &index[5], &index[4]); } - if ( shape == 0 ) - { + if (shape == 0) { LC3_INT ls_ind, ind; - MPVQ_enum( 6, &y[shape][10], &ind, &ls_ind ); + MPVQ_enum(6, &y[shape][10], &ind, &ls_ind); index[6] = ind * 2 + ls_ind; } - else if ( shape == 2 ) - { + else if (shape == 2) { index[6] = -1; } - else - { + else { index[6] = -2; } - for ( i = 0; i < M; i++ ) - { - envq[i] = st1_vector[i] + ( stage2_en1_norm_sub[i] * scfq_gain ); + for (i = 0; i < M; i++) { + envq[i] = st1_vector[i] + (stage2_en1_norm_sub[i] * scfq_gain); } } -LC3_INT find_last_indice_le( LC3_INT compare, const LC3_INT *array, LC3_INT len ) +LC3_INT find_last_indice_le(LC3_INT compare, const LC3_INT* array, LC3_INT len) { LC3_INT idx = 0, i = 0; - for ( i = 0; i < len; i++ ) - { - if ( compare >= array[i] ) - { + for (i = 0; i < len; i++) { + if (compare >= array[i]) { idx++; } } - if ( idx > 0 ) - { + if (idx > 0) { idx--; } return idx; } -void pvq_dec( LC3_INT k, LC3_INT m, LC3_INT LS_ind, LC3_INT MPVQ_ind, LC3_INT *pulses ) +void pvq_dec(LC3_INT k, LC3_INT m, LC3_INT LS_ind, LC3_INT MPVQ_ind, LC3_INT* pulses) { LC3_INT leading_sign = 0, idx = 0, k_delta = 0, pos = 0; @@ -445,50 +427,41 @@ void pvq_dec( LC3_INT k, LC3_INT m, LC3_INT LS_ind, LC3_INT MPVQ_ind, LC3_INT *p /* Decoding loop */ - for ( pos = 0; pos < m; pos++ ) - { - if ( MPVQ_ind != 0 ) - { + for (pos = 0; pos < m; pos++) { + if (MPVQ_ind != 0) { /* Find last indice */ - idx = find_last_indice_le( MPVQ_ind, &pvq_enc_A[m - pos - 1][0], k + 1 ); + idx = find_last_indice_le(MPVQ_ind, &pvq_enc_A[m - pos - 1][0], k + 1); MPVQ_ind = MPVQ_ind - pvq_enc_A[m - pos - 1][idx]; - k_delta = k - idx; - } - else - { + k_delta = k - idx; + } else { pulses[pos] = leading_sign * k; break; } - if ( k_delta != 0 ) - { + if (k_delta != 0) { pulses[pos] = leading_sign * k_delta; - if ( ( MPVQ_ind % 2 ) != 0 ) - { + if ((MPVQ_ind % 2) != 0) { leading_sign = -1; - } - else - { + } else { leading_sign = 1; } - MPVQ_ind = floor( MPVQ_ind / 2 ); - k = k - k_delta; + MPVQ_ind = floor(MPVQ_ind / 2); + k = k - k_delta; } } } -void process_snsQuantizesScf_Dec( LC3_INT *scf_idx, LC3_FLOAT *scf_q ) +void process_snsQuantizesScf_Dec(LC3_INT* scf_idx, LC3_FLOAT* scf_q) { - LC3_INT i = 0, submode = 0; - LC3_INT pulses2[6] = { 0 }, pulses[M] = { 0 }; - LC3_FLOAT st2_vector[M] = { 0 }, st2_vector_idct[M] = { 0 }, sum = 0; + LC3_INT i = 0, submode = 0; + LC3_INT pulses2[6] = {0}, pulses[M] = {0}; + LC3_FLOAT st2_vector[M] = {0}, st2_vector_idct[M] = {0}, sum = 0; /* Decode first stage */ - for ( i = 0; i < 8; i++ ) - { - scf_q[i] = sns_LFCB[i][scf_idx[0]]; + for (i = 0; i < 8; i++) { + scf_q[i] = sns_LFCB[i][scf_idx[0]]; scf_q[i + 8] = sns_HFCB[i][scf_idx[1]]; } @@ -499,57 +472,46 @@ void process_snsQuantizesScf_Dec( LC3_INT *scf_idx, LC3_FLOAT *scf_q ) /* Decode pulses */ - if ( submode < 2 ) - { - pvq_dec( 10, 10, scf_idx[4], scf_idx[5], pulses ); + if (submode < 2) { + pvq_dec(10, 10, scf_idx[4], scf_idx[5], pulses); - if ( submode == 0 ) - { - pvq_dec( 1, 6, ( scf_idx[6] % 2 ), floor( scf_idx[6] / 2 ), pulses2 ); + if (submode == 0) { + pvq_dec(1, 6, (scf_idx[6] % 2), floor(scf_idx[6] / 2), pulses2); - move_int( &pulses[10], pulses2, 6 ); - } - else - { + move_int(&pulses[10], pulses2, 6); + + } else { pulses[15] = 0; } - } - else if ( submode == 2 ) - { - pvq_dec( 8, 16, scf_idx[4], scf_idx[5], pulses ); - } - else - { - pvq_dec( 6, 16, scf_idx[4], scf_idx[5], pulses ); + } else if (submode == 2) { + pvq_dec(8, 16, scf_idx[4], scf_idx[5], pulses); + } else { + pvq_dec(6, 16, scf_idx[4], scf_idx[5], pulses); } /* Normalization */ - for ( i = 0; i < M; i++ ) - { + for (i = 0; i < M; i++) { sum += pulses[i] * pulses[i]; } - sum = 1.0 / LC3_SQRT( sum ); + sum = 1.0 / LC3_SQRT(sum); - for ( i = 0; i < M; i++ ) - { - st2_vector[i] = pulses[i] * sum; + for (i = 0; i < M; i++) { + st2_vector[i] = pulses[i] * sum; } /* Inverse transform */ - idct_II( st2_vector, st2_vector_idct, M ); + idct_II(st2_vector, st2_vector_idct, M); /* Gain */ - for ( i = 0; i < M; i++ ) - { + for (i = 0; i < M; i++) { st2_vector_idct[i] = st2_vector_idct[i] * sns_dec_gains[submode][scf_idx[3]]; } /* Add stage 1 and stage 2 */ - for ( i = 0; i < M; i++ ) - { + for (i = 0; i < M; i++) { scf_q[i] = scf_q[i] + st2_vector_idct[i]; } } diff --git a/lib_lc3plus/structs.h b/lib_lc3plus/structs.h index fe00d569bc..fea377da41 100644 --- a/lib_lc3plus/structs.h +++ b/lib_lc3plus/structs.h @@ -1,12 +1,12 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #ifndef STRUCTS_H #define STRUCTS_H @@ -14,180 +14,164 @@ #include "defines.h" #include "fft/iisfft.h" -typedef struct -{ - LC3_FLOAT r; /* real part */ - LC3_FLOAT i; /* imaginary part */ +typedef struct { + LC3_FLOAT r; /* real part */ + LC3_FLOAT i; /* imaginary part */ } Complex; -typedef struct -{ - LC3_INT length; - void *handle; +typedef struct { + LC3_INT length; + void *handle; } Fft; -typedef struct -{ - LC3_INT length; - Fft fft; +typedef struct { + LC3_INT length; + Fft fft; } Dct2; -typedef struct -{ - LC3_INT length; - Fft fft; +typedef struct { + LC3_INT length; + Fft fft; } Dct3; -typedef struct -{ - LC3_INT length; - Complex *twid1; - Complex *twid2; - Fft fft; +typedef struct { + LC3_INT length; + Complex *twid1; + Complex *twid2; + Fft fft; } Dct4; -typedef struct -{ - LC3_INT length; - LC3_INT leading_zeros; - LC3_INT mem_length; - const LC3_FLOAT *window; - LC3_FLOAT *mem; - Dct4 dct; +typedef struct { + LC3_INT length; + LC3_INT leading_zeros; + LC3_INT mem_length; + const LC3_FLOAT *window; + LC3_FLOAT *mem; + Dct4 dct; } Mdct; -typedef struct -{ - uint32_t ac_low_fl; - uint32_t ac_range_fl; - int BER_detect; - - LC3_INT32 pc_c_bp; - LC3_INT32 pc_c_bp_side; - LC3_INT32 pc_bytes; - LC3_INT32 pc_b_left; - LC3_INT32 pc_b_right; - LC3_INT32 pc_enc; - LC3_INT32 pc_bfi; - LC3_INT32 pc_bbi; - LC3_INT32 pc_be_bp_left; - LC3_INT32 pc_be_bp_right; - LC3_INT32 pc_return; +typedef struct { + uint32_t ac_low_fl; + uint32_t ac_range_fl; + int BER_detect; + + LC3_INT32 pc_c_bp; + LC3_INT32 pc_c_bp_side; + LC3_INT32 pc_bytes; + LC3_INT32 pc_b_left; + LC3_INT32 pc_b_right; + LC3_INT32 pc_enc; + LC3_INT32 pc_bfi; + LC3_INT32 pc_bbi; + LC3_INT32 pc_be_bp_left; + LC3_INT32 pc_be_bp_right; + LC3_INT32 pc_return; } Decoder_State_fl; -typedef struct -{ - LC3_INT bp; - LC3_INT low; - LC3_INT range; - LC3_INT cache; - LC3_INT carry; - LC3_INT carry_count; - uint8_t *ptr; - LC3_INT *bp_side; - LC3_INT *mask_side; +typedef struct { + LC3_INT bp; + LC3_INT low; + LC3_INT range; + LC3_INT cache; + LC3_INT carry; + LC3_INT carry_count; + uint8_t *ptr; + LC3_INT *bp_side; + LC3_INT *mask_side; } Encoder_State_fl; -typedef struct -{ - LC3_INT nbLostCmpt; - LC3_INT prevBfi; - LC3_INT prevprevBfi; +typedef struct { + LC3_INT nbLostCmpt; + LC3_INT prevBfi; + LC3_INT prevprevBfi; LC3_FLOAT q_d[MAX_LEN]; LC3_FLOAT q_d_prev[MAX_LEN]; } PlcSetup; -typedef struct -{ +typedef struct { LC3_FLOAT cum_alpha; - LC3_INT seed; + LC3_INT seed; } PlcNsSetup; -typedef struct -{ +typedef struct { LC3_INT32 seed; LC3_INT32 ns_nbLostCmpt_pc; LC3_FLOAT *q_old_res; LC3_FLOAT prev_gg; } pcState; -typedef struct -{ - LC3_INT len; - LC3_INT sign; - LC3_FLOAT *table; +typedef struct { + LC3_INT len; + LC3_INT sign; + LC3_FLOAT* table; } Cfft; -typedef struct T_IIS_FFT -{ +typedef struct T_IIS_FFT { IIS_FFT_DIR sign; - LC3_INT32 len; - LC3_FLOAT *buffer; - LC3_FLOAT *sine_table; - Iisfft iisfft; - Cfft cfft; + LC3_INT32 len; + LC3_FLOAT* buffer; + LC3_FLOAT* sine_table; + Iisfft iisfft; + Cfft cfft; } IIS_FFT; -typedef struct T_IIS_FFT *HANDLE_IIS_FFT; - -typedef struct -{ - Fft PhEcu_Fft; /*no counterpart in BASOP */ - Fft PhEcu_Ifft; /*no counterpart in BASOP */ - - - LC3_FLOAT PhECU_f0hzLtpBin; /* BASOP Word16 PhECU_f0hzLtpBinQ7 */ - LC3_FLOAT PhECU_norm_corr; /* BASOP Word16 norm_corrQ15 */ - - LC3_FLOAT *PhECU_oold_grp_shape; /* BASOP Word16 PhECU_oold_grp_shape_fx[MAX_LGW]; */ - LC3_FLOAT *PhECU_old_grp_shape; /* BASOP Word16 PhECU_old_grp_shape_fx[MAX_LGW] ; */ +typedef struct T_IIS_FFT* HANDLE_IIS_FFT; - LC3_FLOAT PhECU_L_oold_xfp_w_E; /* BASOP Word32 PhECU_L_oold_xfp_w_E_fx;*/ - LC3_FLOAT PhECU_L_old_xfp_w_E; /* BASOP Word32 PhECU_L_old_xfp_w_E_fx; */ +typedef struct { + Fft PhEcu_Fft; /*no counterpart in BASOP */ + Fft PhEcu_Ifft; /*no counterpart in BASOP */ - LC3_INT32 PhECU_Lprot; /* BASOP Word16 PhECU_Lprot_fx;*/ + + LC3_FLOAT PhECU_f0hzLtpBin; /* BASOP Word16 PhECU_f0hzLtpBinQ7 */ + LC3_FLOAT PhECU_norm_corr; /* BASOP Word16 norm_corrQ15 */ - LC3_FLOAT *PhECU_xfp; - Complex *PhECU_X_sav_m; - LC3_INT32 *PhECU_plocs; /* BASOP Word16 *PhECU_plocs; */ /* MAX_PLOCS */ - LC3_FLOAT *PhECU_f0est; /*BASOP Word32 *PhECU_f0est;*/ + LC3_FLOAT *PhECU_oold_grp_shape; /* BASOP Word16 PhECU_oold_grp_shape_fx[MAX_LGW]; */ + LC3_FLOAT *PhECU_old_grp_shape; /* BASOP Word16 PhECU_old_grp_shape_fx[MAX_LGW] ; */ - LC3_FLOAT *PhECU_mag_chg_1st; /* BASOP Word16 PhECU_mag_chg_1st[MAX_LGW];*/ - LC3_FLOAT *PhECU_Xavg; /* BASOP Word16 PhECU_Xavg[MAX_LGW] ; */ + LC3_FLOAT PhECU_L_oold_xfp_w_E; /* BASOP Word32 PhECU_L_oold_xfp_w_E_fx;*/ + LC3_FLOAT PhECU_L_old_xfp_w_E; /* BASOP Word32 PhECU_L_old_xfp_w_E_fx; */ + + LC3_INT32 PhECU_Lprot ; /* BASOP Word16 PhECU_Lprot_fx;*/ - LC3_FLOAT PhECU_beta_mute; /* BASOP Word16 PhECU_beta_mute*/ + LC3_FLOAT *PhECU_xfp; + Complex *PhECU_X_sav_m; + LC3_INT32 *PhECU_plocs; /* BASOP Word16 *PhECU_plocs; */ /* MAX_PLOCS */ + LC3_FLOAT *PhECU_f0est; /*BASOP Word32 *PhECU_f0est;*/ - LC3_INT16 PhECU_seed; /* BASOP Word16 PhECU_seed_fx;*/ + LC3_FLOAT *PhECU_mag_chg_1st; /* BASOP Word16 PhECU_mag_chg_1st[MAX_LGW];*/ + LC3_FLOAT *PhECU_Xavg; /* BASOP Word16 PhECU_Xavg[MAX_LGW] ; */ - LC3_INT32 PhECU_LDWIN_OLAP; /* BASOP Word16 PhECU_LDWIN_OLAP; */ - LC3_INT32 PhECU_t_adv; /* BASOP Word16 t_adv; */ + LC3_FLOAT PhECU_beta_mute; /* BASOP Word16 PhECU_beta_mute*/ - LC3_INT32 PhECU_short_flag_prev; - LC3_INT32 PhECU_time_offs; - LC3_INT32 PhECU_num_plocs; - HANDLE_IIS_FFT handle_fft_phaseecu; - HANDLE_IIS_FFT handle_ifft_phaseecu; + LC3_INT16 PhECU_seed; /* BASOP Word16 PhECU_seed_fx;*/ + LC3_INT32 PhECU_LDWIN_OLAP; /* BASOP Word16 PhECU_LDWIN_OLAP; */ + LC3_INT32 PhECU_t_adv; /* BASOP Word16 t_adv; */ + + LC3_INT32 PhECU_short_flag_prev; + LC3_INT32 PhECU_time_offs; + LC3_INT32 PhECU_num_plocs; + HANDLE_IIS_FFT handle_fft_phaseecu; + HANDLE_IIS_FFT handle_ifft_phaseecu; + } PlcPhEcuSetup; -typedef struct -{ +typedef struct { LC3_INT16 seed; LC3_FLOAT gain_c; - LC3_INT32 lpcorder; - LC3_FLOAT A[M + 1]; - LC3_INT32 fract; - LC3_INT32 lagw_bw; + LC3_INT32 lpcorder; + LC3_FLOAT A[M+1]; + LC3_INT32 fract; + LC3_INT32 lagw_bw; LC3_FLOAT preemphFac; LC3_FLOAT *harmonicBuf; LC3_FLOAT synthHist[M]; } PlcTdcSetup; -typedef struct -{ +typedef struct { LC3_FLOAT *pcmbufHist; - LC3_INT32 max_len_pcm_plc; + LC3_INT32 max_len_pcm_plc; PlcTdcSetup PlcTdcSetup; LC3_FLOAT stabFac; LC3_FLOAT cum_fading_slow; @@ -195,7 +179,7 @@ typedef struct LC3_FLOAT cum_fflcAtten; LC3_FLOAT scf_q_old[M]; LC3_FLOAT scf_q_old_old[M]; - PlcPhEcuSetup PlcPhEcuSetup; + PlcPhEcuSetup PlcPhEcuSetup; } PlcAdvSetup; diff --git a/lib_lc3plus/tns_coder.c b/lib_lc3plus/tns_coder.c index 3c76a50d34..ff3883d2b5 100644 --- a/lib_lc3plus/tns_coder.c +++ b/lib_lc3plus/tns_coder.c @@ -1,39 +1,37 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -static void xcorr( LC3_FLOAT *in, LC3_FLOAT *out, LC3_INT lag, LC3_INT inLen ); -static void levdown( LC3_FLOAT *anxt, LC3_FLOAT *out_a, LC3_INT *len ); -static void poly2rc( LC3_FLOAT *a, LC3_FLOAT *out, LC3_INT len ); -static LC3_INT findRC_idx( const LC3_FLOAT *in1, const LC3_FLOAT *in2, LC3_FLOAT checkValue ); +static void xcorr(LC3_FLOAT* in, LC3_FLOAT* out, LC3_INT lag, LC3_INT inLen); +static void levdown(LC3_FLOAT* anxt, LC3_FLOAT* out_a, LC3_INT* len); +static void poly2rc(LC3_FLOAT* a, LC3_FLOAT* out, LC3_INT len); +static LC3_INT findRC_idx(const LC3_FLOAT* in1, const LC3_FLOAT* in2, LC3_FLOAT checkValue); -void xcorr( LC3_FLOAT *in, LC3_FLOAT *out, LC3_INT lag, LC3_INT inLen ) +void xcorr(LC3_FLOAT* in, LC3_FLOAT* out, LC3_INT lag, LC3_INT inLen) { - LC3_INT i = 0, m = 0; - LC3_FLOAT sum = 0, tmp_buf[MAX_LEN] = { 0 }; + LC3_INT i = 0, m = 0; + LC3_FLOAT sum = 0, tmp_buf[MAX_LEN] = {0}; - for ( m = -lag; m <= lag; m++ ) - { + for (m = -lag; m <= lag; m++) { /* Append zeros and input vector */ - zero_float( tmp_buf, abs( m ) ); + zero_float(tmp_buf, abs(m)); - move_float( &tmp_buf[abs( m )], in, inLen - abs( m ) ); + move_float(&tmp_buf[abs(m)], in, inLen - abs(m)); /* Calculate sum */ sum = 0; - for ( i = 0; i < inLen; i++ ) - { + for (i = 0; i < inLen; i++) { sum += in[i] * tmp_buf[i]; } @@ -41,70 +39,66 @@ void xcorr( LC3_FLOAT *in, LC3_FLOAT *out, LC3_INT lag, LC3_INT inLen ) } } -void levinsonDurbin( LC3_FLOAT *r, LC3_FLOAT *out_lev, LC3_FLOAT *rc_unq, LC3_FLOAT *error, LC3_INT len ) +void levinsonDurbin(LC3_FLOAT* r, LC3_FLOAT* out_lev, LC3_FLOAT* rc_unq, LC3_FLOAT* error, LC3_INT len) { - LC3_INT t = 0, i = 0, j = 0; - LC3_FLOAT g = 0, v = 0, sum = 0, buf_tmp[MAX_LEN] = { 0 }; + LC3_INT t = 0, i = 0, j = 0; + LC3_FLOAT g = 0, v = 0, sum = 0, buf_tmp[MAX_LEN] = {0}; - g = r[1] / r[0]; + g = r[1] / r[0]; out_lev[0] = g; - v = ( 1.0 - g * g ) * r[0]; + v = (1.0 - g * g) * r[0]; rc_unq[0] = -g; - for ( t = 1; t < len; t++ ) - { - zero_float( buf_tmp, len + 1 ); + for (t = 1; t < len; t++) { + zero_float(buf_tmp, len + 1); sum = 0; - for ( i = 1; i <= t; i++ ) - { + for (i = 1; i <= t; i++) { sum += out_lev[i - 1] * r[i]; } - g = ( r[t + 1] - sum ) / v; + g = (r[t + 1] - sum) / v; j = 1; - for ( i = t - 1; i >= 0; i-- ) - { + for (i = t - 1; i >= 0; i--) { buf_tmp[j] = out_lev[j - 1] - g * out_lev[i]; j++; } - move_float( &out_lev[1], &buf_tmp[1], len ); + move_float(&out_lev[1], &buf_tmp[1], len); out_lev[0] = g; - v = v * ( 1 - g * g ); + v = v * (1 - g * g); rc_unq[t] = -g; } /* Reorder out_lev */ out_lev[0] = 1; - j = 1; - for ( i = len - 1; i >= 0; i-- ) - { + j = 1; + for (i = len - 1; i >= 0; i--) { buf_tmp[j] = -out_lev[i]; j++; } - move_float( &out_lev[1], &buf_tmp[1], ( len - 1 ) ); + move_float(&out_lev[1], &buf_tmp[1], (len - 1)); out_lev[len] = rc_unq[len - 1]; *error = v; } -void levdown( LC3_FLOAT *anxt, LC3_FLOAT *out_a, LC3_INT *len ) +void levdown(LC3_FLOAT* anxt, LC3_FLOAT* out_a, LC3_INT* len) { - LC3_INT i = 0, j = 0; - LC3_FLOAT tmp_buf[8] = { 0 }, tmp_buf1[8] = { 0 }, tmp_buf2[8] = { 0 }, knxt = 0; + LC3_INT i = 0, j = 0; + LC3_FLOAT tmp_buf[8] = {0}, tmp_buf1[8] = {0}, tmp_buf2[8] = {0}, knxt = 0; /* Initial length = 9 */ /* Drop the leading 1 */ - move_float( &tmp_buf[0], &anxt[1], ( *len - 1 ) ); + move_float(&tmp_buf[0], &anxt[1], (*len - 1)); *len = *len - 1; /* Lenght = 8 */ @@ -113,67 +107,60 @@ void levdown( LC3_FLOAT *anxt, LC3_FLOAT *out_a, LC3_INT *len ) *len = *len - 1; /* Lenght = 7 */ - move_float( tmp_buf1, tmp_buf, *len ); + move_float(tmp_buf1, tmp_buf, *len); j = 0; - for ( i = *len - 1; i >= 0; i-- ) - { + for (i = *len - 1; i >= 0; i--) { tmp_buf2[j] = knxt * tmp_buf[i]; j++; } out_a[0] = 1; - for ( i = 0; i < *len; i++ ) - { - out_a[i + 1] = ( tmp_buf1[i] - tmp_buf2[i] ) / ( 1.0 - ( LC3_FABS( knxt ) ) * ( LC3_FABS( knxt ) ) ); + for (i = 0; i < *len; i++) { + out_a[i + 1] = (tmp_buf1[i] - tmp_buf2[i]) / (1.0 - (LC3_FABS(knxt)) * (LC3_FABS(knxt))); } *len = *len + 1; /* Length = 8 */ } -void poly2rc( LC3_FLOAT *a, LC3_FLOAT *out, LC3_INT len ) +void poly2rc(LC3_FLOAT* a, LC3_FLOAT* out, LC3_INT len) { - LC3_INT k = 0, i = 0, len_old = 0; - LC3_FLOAT buf[9] = { 0 }; + LC3_INT k = 0, i = 0, len_old = 0; + LC3_FLOAT buf[9] = {0}; len_old = len; - zero_float( out, len - 1 ); + zero_float(out, len - 1); /* Length = 9 */ /* Normalize */ - for ( i = 0; i < len; i++ ) - { + for (i = 0; i < len; i++) { a[i] = a[i] / a[0]; } out[len - 1] = a[len - 1]; /* Process */ - for ( k = len - 2; k >= 0; k-- ) - { - levdown( a, buf, &len ); + for (k = len - 2; k >= 0; k--) { + levdown(a, buf, &len); out[k] = buf[len - 1]; /* Store last value */ - move_float( a, buf, len ); + move_float(a, buf, len); } /* Shift output array by one to the left to lose leading 1 */ - for ( i = 0; i < len_old - 1; i++ ) - { + for (i = 0; i < len_old - 1; i++) { out[i] = out[i + 1]; } } -LC3_INT findRC_idx( const LC3_FLOAT *in1, const LC3_FLOAT *in2, LC3_FLOAT checkValue ) +LC3_INT findRC_idx(const LC3_FLOAT* in1, const LC3_FLOAT* in2, LC3_FLOAT checkValue) { LC3_INT i = 0, ret = 0; - for ( i = 0; i < 17; i++ ) - { - if ( checkValue <= in1[i] && checkValue > in2[i] ) - { + for (i = 0; i < 17; i++) { + if (checkValue <= in1[i] && checkValue > in2[i]) { ret = i; } } @@ -181,180 +168,155 @@ LC3_INT findRC_idx( const LC3_FLOAT *in1, const LC3_FLOAT *in2, LC3_FLOAT checkV return ret; } -void processTnsCoder_fl( LC3_FLOAT *x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, LC3_INT fs, LC3_INT N, LC3_INT frame_dms, LC3_INT nBits, LC3_INT *order_out, LC3_INT *rc_idx, LC3_INT *tns_numfilters, LC3_INT *bits_out, LC3_INT16 near_nyquist_flag ) +void processTnsCoder_fl(LC3_FLOAT* x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, LC3_INT fs, LC3_INT N, LC3_INT frame_dms, LC3_INT nBits, + LC3_INT* order_out, LC3_INT* rc_idx, LC3_INT* tns_numfilters, LC3_INT* bits_out + , LC3_INT16 near_nyquist_flag +) { - LC3_INT i = 0, stopfreq[2] = { 0 }, startfreq[2] = { 0 }, f = 0, numfilters = 0, maxOrder = 0, bits = 0, sub = 0, - subdiv_startfreq = 0, subdiv_stopfreq = 0, j = 0, rc_idx_tmp[8] = { 0 }, order_tmp[8] = { 0 }, tmp = 0, tns = 0; - LC3_FLOAT minPGfac = 0, minPredictionGain = 0, maxPG = 0, xcorr_out[MAX_LEN] = { 0 }, buf_tmp[MAX_LEN] = { 0 }, sum = 0, - subdiv_len = 0, nSubdivisions = 0, r[9] = { 0 }, out_lev[9] = { 0 }, rc_unq[9] = { 0 }, error_lev = 0, predGain = 0, - alpha = 0, rc[8] = { 0 }, st[9] = { 0 }, s = 0, tmpSave = 0, tmp_fl = 0; - const LC3_INT *order; + LC3_INT i = 0, stopfreq[2] = {0}, startfreq[2] = {0}, f = 0, numfilters = 0, maxOrder = 0, bits = 0, sub = 0, + subdiv_startfreq = 0, subdiv_stopfreq = 0, j = 0, rc_idx_tmp[8] = {0}, order_tmp[8] = {0}, tmp = 0, tns = 0; + LC3_FLOAT minPGfac = 0, minPredictionGain = 0, maxPG = 0, xcorr_out[MAX_LEN] = {0}, buf_tmp[MAX_LEN] = {0}, sum = 0, + subdiv_len = 0, nSubdivisions = 0, r[9] = {0}, out_lev[9] = {0}, rc_unq[9] = {0}, error_lev = 0, predGain = 0, + alpha = 0, rc[8] = {0}, st[9] = {0}, s = 0, tmpSave = 0, tmp_fl = 0; + const LC3_INT* order; /* Init */ - if ( fs >= 32000 && frame_dms >= 50 ) - { + if (fs >= 32000 && frame_dms >= 50) { numfilters = 2; - } - else - { + } else { numfilters = 1; } - if ( N > 40 * ( (LC3_FLOAT) ( frame_dms ) / 10.0 ) ) - { - N = 40 * ( (LC3_FLOAT) ( frame_dms ) / 10.0 ); + if (N > 40 * ((LC3_FLOAT) (frame_dms) / 10.0)) { + N = 40 * ((LC3_FLOAT) (frame_dms) / 10.0); fs = 40000; } - if ( numfilters == 1 ) - { - startfreq[0] = floor( 600 * N * 2 / fs ) + 1; - stopfreq[0] = N; - } - else - { - startfreq[0] = floor( 600 * N * 2 / fs ) + 1; + if (numfilters == 1) { + startfreq[0] = floor(600 * N * 2 / fs) + 1; + stopfreq[0] = N; + } else { + startfreq[0] = floor(600 * N * 2 / fs) + 1; startfreq[1] = N / 2 + 1; - stopfreq[0] = N / 2; - stopfreq[1] = N; + stopfreq[0] = N / 2; + stopfreq[1] = N; } - - switch ( frame_dms ) + + switch (frame_dms) { case 25: - maxOrder = 4; + maxOrder = 4; nSubdivisions = 2.0; break; case 50: - maxOrder = 4; + maxOrder = 4; nSubdivisions = 2.0; break; case 100: - maxOrder = 8; + maxOrder = 8; nSubdivisions = 3.0; break; } - minPGfac = 0.85; - maxPG = 2; + minPGfac = 0.85; + maxPG = 2; minPredictionGain = 1.5; - if ( ( frame_dms >= 50 && nBits >= 48 * ( (LC3_FLOAT) frame_dms / 10.0 ) ) || frame_dms == 25 ) - { + if ((frame_dms >= 50 && nBits >= 48 * ((LC3_FLOAT) frame_dms / 10.0)) || frame_dms == 25) { maxPG = minPredictionGain; } - if ( ( frame_dms >= 50 && nBits >= 48 * ( (LC3_FLOAT) frame_dms / 10.0 ) ) || frame_dms == 25 ) - { + if ((frame_dms >= 50 && nBits >= 48 * ((LC3_FLOAT) frame_dms / 10.0)) || frame_dms == 25) { order = order1_tns; - } - else - { + } else { order = order2_tns; } - + /* Processing */ - if ( bw_cutoff_idx >= 3 && numfilters == 2 ) - { - numfilters = 2; + if (bw_cutoff_idx >= 3 && numfilters == 2) { + numfilters = 2; startfreq[1] = bw_fcbin / 2 + 1; - stopfreq[0] = bw_fcbin / 2; - stopfreq[1] = bw_fcbin; - } - else - { - numfilters = 1; + stopfreq[0] = bw_fcbin / 2; + stopfreq[1] = bw_fcbin; + } else { + numfilters = 1; stopfreq[0] = bw_fcbin; } bits = 0; - for ( f = 0; f < numfilters; f++ ) - { - subdiv_len = ( (LC3_FLOAT) stopfreq[f] + 1.0 - (LC3_FLOAT) startfreq[f] ) / nSubdivisions; + for (f = 0; f < numfilters; f++) { + subdiv_len = ((LC3_FLOAT)stopfreq[f] + 1.0 - (LC3_FLOAT)startfreq[f]) / nSubdivisions; - zero_float( r, 9 ); + zero_float(r, 9); - for ( sub = 1; sub <= nSubdivisions; sub++ ) - { - subdiv_startfreq = floor( subdiv_len * ( sub - 1 ) ) + startfreq[f] - 1; - subdiv_stopfreq = floor( subdiv_len * sub ) + startfreq[f] - 1; + for (sub = 1; sub <= nSubdivisions; sub++) { + subdiv_startfreq = floor(subdiv_len * (sub - 1)) + startfreq[f] - 1; + subdiv_stopfreq = floor(subdiv_len * sub) + startfreq[f] - 1; sum = 0; - for ( i = subdiv_startfreq; i < subdiv_stopfreq; i++ ) - { + for (i = subdiv_startfreq; i < subdiv_stopfreq; i++) { sum += x[i] * x[i]; } - if ( sum < LC3_EPS ) + if (sum < LC3_EPS) { - zero_float( r, 9 ); + zero_float(r, 9); r[0] = 1; break; } - move_float( buf_tmp, &x[subdiv_startfreq], subdiv_stopfreq - subdiv_startfreq ); + move_float(buf_tmp, &x[subdiv_startfreq], subdiv_stopfreq - subdiv_startfreq); - xcorr( buf_tmp, xcorr_out, maxOrder, subdiv_stopfreq - subdiv_startfreq ); + xcorr(buf_tmp, xcorr_out, maxOrder, subdiv_stopfreq - subdiv_startfreq); j = 0; - for ( i = maxOrder; i >= 0; i-- ) - { + for (i = maxOrder; i >= 0; i--) { r[j] = r[j] + xcorr_out[i] / sum; j++; } } - for ( i = 0; i <= maxOrder; i++ ) - { + for (i = 0; i <= maxOrder; i++) { r[i] = r[i] * lagw_tns[i]; } - levinsonDurbin( r, out_lev, rc_unq, &error_lev, maxOrder ); + levinsonDurbin(r, out_lev, rc_unq, &error_lev, maxOrder); predGain = r[0] / error_lev; - if ( predGain > minPredictionGain && near_nyquist_flag == 0 ) - { + if (predGain > minPredictionGain && near_nyquist_flag == 0) { tns = 1; - } - else - { + } else { tns = 0; } bits++; - if ( tns == 1 ) - { + if (tns == 1) { /* LPC weighting */ - if ( predGain < maxPG ) - { - alpha = ( maxPG - predGain ) * ( minPGfac - 1.0 ) / ( maxPG - minPredictionGain ) + 1.0; + if (predGain < maxPG) { + alpha = (maxPG - predGain) * (minPGfac - 1.0) / (maxPG - minPredictionGain) + 1.0; - for ( i = 0; i <= maxOrder; i++ ) - { - out_lev[i] = out_lev[i] * LC3_POW( alpha, i ); + for (i = 0; i <= maxOrder; i++) { + out_lev[i] = out_lev[i] * LC3_POW(alpha, i); } - poly2rc( out_lev, rc_unq, maxOrder + 1 ); + poly2rc(out_lev, rc_unq, maxOrder + 1); } /* PARCOR Quantization */ - for ( i = 0; i < maxOrder; i++ ) - { - rc_idx_tmp[i] = findRC_idx( &quants_thr_tns[1], &quants_thr_tns[0], rc_unq[i] ); + for (i = 0; i < maxOrder; i++) { + rc_idx_tmp[i] = findRC_idx(&quants_thr_tns[1], &quants_thr_tns[0], rc_unq[i]); } - + /* Filter Order */ j = 0; - for ( i = 0; i < maxOrder; i++ ) - { + for (i = 0; i < maxOrder; i++) { rc[i] = quants_pts_tns[rc_idx_tmp[i]]; - if ( rc[i] != 0 ) - { + if (rc[i] != 0) { order_tmp[j] = i + 1; j++; } @@ -362,8 +324,7 @@ void processTnsCoder_fl( LC3_FLOAT *x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, order_out[f] = order_tmp[j - 1]; // Disable TNS if order is 0: - if ( order_out[f] == 0 ) - { + if (order_out[f] == 0) { tns = 0; // Jump to else statement @@ -372,47 +333,42 @@ void processTnsCoder_fl( LC3_FLOAT *x, LC3_INT bw_cutoff_idx, LC3_INT bw_fcbin, tmp = order[order_out[f] - 1]; /* Huffman Coding of PARCOR coefficients */ - for ( i = 0; i <= order_out[f] - 1; i++ ) - { + for (i = 0; i <= order_out[f] - 1; i++) { tmp += huff_bits_tns[i][rc_idx_tmp[i]]; } - bits = bits + ceil( (LC3_FLOAT) tmp / 2048.0 ); + bits = bits + ceil((LC3_FLOAT)tmp / 2048.0); j = 0; - for ( i = f * 8; i <= f * 8 + order_out[f] - 1; i++ ) - { + for (i = f * 8; i <= f * 8 + order_out[f] - 1; i++) { rc_idx[i] = rc_idx_tmp[j]; j++; } } /* Filtering */ - if ( tns == 1 ) - { - for ( i = startfreq[f]; i <= stopfreq[f]; i++ ) - { - s = x[i - 1]; + if (tns == 1) { + for (i = startfreq[f]; i <= stopfreq[f]; i++) { + s = x[i - 1]; tmpSave = s; - for ( j = 0; j < order_out[f] - 1; j++ ) - { + for (j = 0; j < order_out[f] - 1; j++) { tmp_fl = rc[j] * s + st[j]; s += rc[j] * st[j]; - st[j] = tmpSave; + st[j] = tmpSave; tmpSave = tmp_fl; } s += rc[order_out[f] - 1] * st[order_out[f] - 1]; st[order_out[f] - 1] = tmpSave; - x[i - 1] = s; + x[i - 1] = s; } } } tns_disabled: *tns_numfilters = numfilters; - *bits_out = bits; + *bits_out = bits; } diff --git a/lib_lc3plus/tns_decoder.c b/lib_lc3plus/tns_decoder.c index 0df5f33086..d3aeefc3a3 100644 --- a/lib_lc3plus/tns_decoder.c +++ b/lib_lc3plus/tns_decoder.c @@ -1,58 +1,50 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #include "options.h" #include "functions.h" -void processTnsDecoder_fl( LC3_FLOAT *x, LC3_INT *rc_idx, LC3_INT *order, LC3_INT numfilters, LC3_INT bw_fcbin, LC3_INT N, LC3_INT fs ) +void processTnsDecoder_fl(LC3_FLOAT* x, LC3_INT* rc_idx, LC3_INT* order, LC3_INT numfilters, LC3_INT bw_fcbin, LC3_INT N, LC3_INT fs) { - LC3_INT startfreq[2] = { 0 }, stopfreq[2] = { 0 }, f = 0, i = 0, j = 0, m = 0, l = 0, rc_idx_f[9] = { 0 }; - LC3_FLOAT rc[9] = { 0 }, s = 0, st[9] = { 0 }; + LC3_INT startfreq[2] = {0}, stopfreq[2] = {0}, f = 0, i = 0, j = 0, m = 0, l = 0, rc_idx_f[9] = {0}; + LC3_FLOAT rc[9] = {0}, s = 0, st[9] = {0}; - if ( numfilters == 2 ) - { - startfreq[0] = floor( 600 * N * 2 / fs ) + 1; - stopfreq[0] = bw_fcbin / 2; + if (numfilters == 2) { + startfreq[0] = floor(600 * N * 2 / fs) + 1; + stopfreq[0] = bw_fcbin / 2; startfreq[1] = bw_fcbin / 2 + 1; - stopfreq[1] = bw_fcbin; - } - else - { - startfreq[0] = floor( 600 * N * 2 / fs ) + 1; - stopfreq[0] = bw_fcbin; + stopfreq[1] = bw_fcbin; + } else { + startfreq[0] = floor(600 * N * 2 / fs) + 1; + stopfreq[0] = bw_fcbin; } - for ( f = 0; f < numfilters; f++ ) - { - if ( order[f] > 0 ) - { + for (f = 0; f < numfilters; f++) { + if (order[f] > 0) { j = 0; - for ( i = f * 8; i < f * 8 + 8; i++ ) - { + for (i = f * 8; i < f * 8 + 8; i++) { rc_idx_f[j] = rc_idx[i]; - rc[j] = quants_pts_tns[rc_idx_f[j]]; + rc[j] = quants_pts_tns[rc_idx_f[j]]; j++; } - for ( m = startfreq[f]; m <= stopfreq[f]; m++ ) - { + for (m = startfreq[f]; m <= stopfreq[f]; m++) { s = x[m - 1] - rc[order[f] - 1] * st[order[f] - 1]; - for ( l = order[f] - 2; l >= 0; l-- ) - { - s = s - rc[l] * st[l]; + for (l = order[f] - 2; l >= 0; l--) { + s = s - rc[l] * st[l]; st[l + 1] = rc[l] * s + st[l]; } - st[0] = s; + st[0] = s; x[m - 1] = s; } } diff --git a/lib_lc3plus/util.h b/lib_lc3plus/util.h index 6a00e69454..7ef6dedef7 100644 --- a/lib_lc3plus/util.h +++ b/lib_lc3plus/util.h @@ -1,12 +1,12 @@ /****************************************************************************** - * ETSI TS 103 634 V1.4.1 * - * Low Complexity Communication Codec Plus (LC3plus) * - * * - * Copyright licence is solely granted through ETSI Intellectual Property * - * Rights Policy, 3rd April 2019. No patent licence is granted by implication, * - * estoppel or otherwise. * - ******************************************************************************/ - +* ETSI TS 103 634 V1.4.1 * +* Low Complexity Communication Codec Plus (LC3plus) * +* * +* Copyright licence is solely granted through ETSI Intellectual Property * +* Rights Policy, 3rd April 2019. No patent licence is granted by implication, * +* estoppel or otherwise. * +******************************************************************************/ + #ifndef UTIL_H #define UTIL_H @@ -16,9 +16,8 @@ #ifdef _MSC_VER /* strcasecmp is not available on visual studio */ -static LC3_INT strcasecmp( const char *a, const char *b ) -{ - return _stricmp( a, b ); +static LC3_INT strcasecmp(const char* a, const char* b) { + return _stricmp(a,b); } #endif @@ -30,214 +29,186 @@ static LC3_INT strcasecmp( const char *a, const char *b ) #endif /* number of elements in array */ -#define ARRAY_SIZE( x ) ( sizeof( x ) / sizeof( ( x )[0] ) ) +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) /* min max with no side effects */ -static inline LC3_INT imin( LC3_INT a, LC3_INT b ) { return a < b ? a : b; } -static inline LC3_INT imax( LC3_INT a, LC3_INT b ) { return a > b ? a : b; } +static inline LC3_INT imin(LC3_INT a, LC3_INT b) { return a < b ? a : b; } +static inline LC3_INT imax(LC3_INT a, LC3_INT b) { return a > b ? a : b; } /* restrict x to range [min, max] */ -static inline LC3_INT iclamp( LC3_INT min, LC3_INT x, LC3_INT max ) -{ - return x < min ? min : x > max ? max - : x; +static inline LC3_INT iclamp(LC3_INT min, LC3_INT x, LC3_INT max) { + return x < min ? min : x > max ? max : x; } -static inline double fcmamp( double min, double x, double max ) -{ - return x < min ? min : x > max ? max - : x; +static inline double fcmamp(double min, double x, double max) { + return x < min ? min : x > max ? max : x; } -static inline LC3_FLOAT fclampf( LC3_FLOAT min, LC3_FLOAT x, LC3_FLOAT max ) -{ - return x < min ? min : x > max ? max - : x; +static inline LC3_FLOAT fclampf(LC3_FLOAT min, LC3_FLOAT x, LC3_FLOAT max) { + return x < min ? min : x > max ? max : x; } /* x² */ -static inline LC3_FLOAT sqrf( LC3_FLOAT x ) { return x * x; } +static inline LC3_FLOAT sqrf(LC3_FLOAT x) { return x * x; } /* convenience wrappers around memmove */ -static inline void move_float( LC3_FLOAT *dst, const LC3_FLOAT *src, LC3_INT len ) -{ - memmove( dst, src, len * sizeof( LC3_FLOAT ) ); +static inline void move_float(LC3_FLOAT *dst, const LC3_FLOAT *src, LC3_INT len) { + memmove(dst, src, len * sizeof(LC3_FLOAT)); } -static inline void move_int( LC3_INT *dst, const LC3_INT *src, LC3_INT len ) -{ - memmove( dst, src, len * sizeof( LC3_INT ) ); +static inline void move_int(LC3_INT *dst, const LC3_INT *src, LC3_INT len) { + memmove(dst, src, len * sizeof(LC3_INT)); } /* convenience wrappers around memset */ -static inline void zero_float( LC3_FLOAT *x, LC3_INT len ) -{ - memset( x, 0, len * sizeof( LC3_FLOAT ) ); +static inline void zero_float(LC3_FLOAT *x, LC3_INT len) { + memset(x, 0, len * sizeof(LC3_FLOAT)); } -static inline void zero_int( LC3_INT *x, LC3_INT len ) -{ - memset( x, 0, len * sizeof( LC3_INT ) ); +static inline void zero_int(LC3_INT *x, LC3_INT len) { + memset(x, 0, len * sizeof(LC3_INT)); } /* multiply float vectors element by element, in-place */ -static inline void mult_vec( LC3_FLOAT *a, const LC3_FLOAT *b, LC3_INT len ) -{ - LC3_INT i = 0; - for ( i = 0; i < len; i++ ) - { - a[i] *= b[i]; - } +static inline void mult_vec(LC3_FLOAT *a, const LC3_FLOAT *b, + LC3_INT len) { + LC3_INT i = 0; + for (i = 0; i < len; i++) { + a[i] *= b[i]; + } } /* multiply float vector with constant, in-place */ -static inline void mult_const( LC3_FLOAT *a, LC3_FLOAT b, LC3_INT len ) -{ - LC3_INT i = 0; - for ( i = 0; i < len; i++ ) - { - a[i] *= b; - } +static inline void mult_const(LC3_FLOAT *a, LC3_FLOAT b, LC3_INT len) { + LC3_INT i = 0; + for (i = 0; i < len; i++) { + a[i] *= b; + } } /* sum of vector */ -static inline LC3_FLOAT sum_vec( const LC3_FLOAT *x, LC3_INT len ) -{ - LC3_FLOAT sum = 0; - LC3_INT i = 0; - for ( i = 0; i < len; i++ ) - { - sum += x[i]; - } - return sum; +static inline LC3_FLOAT sum_vec(const LC3_FLOAT *x, LC3_INT len) { + LC3_FLOAT sum = 0; + LC3_INT i = 0; + for (i = 0; i < len; i++) { + sum += x[i]; + } + return sum; } /* complex constructor */ -static inline Complex cmplx( LC3_FLOAT r, LC3_FLOAT i ) { return ( Complex ){ r, i }; } +static inline Complex cmplx(LC3_FLOAT r, LC3_FLOAT i) { return (Complex){r, i}; } /* complex a + b */ -static inline Complex cadd( Complex a, Complex b ) -{ - return cmplx( a.r + b.r, a.i + b.i ); +static inline Complex cadd(Complex a, Complex b) { + return cmplx(a.r + b.r, a.i + b.i); } /* complex a * b */ -static inline Complex cmul( Complex a, Complex b ) -{ - return cmplx( a.r * b.r - a.i * b.i, a.i * b.r + a.r * b.i ); +static inline Complex cmul(Complex a, Complex b) { + return cmplx(a.r * b.r - a.i * b.i, a.i * b.r + a.r * b.i); } /* mac operator */ -static inline LC3_FLOAT mac_loop( const LC3_FLOAT *array1, const LC3_FLOAT *array2, LC3_INT len ) +static inline LC3_FLOAT mac_loop(const LC3_FLOAT *array1, const LC3_FLOAT *array2, LC3_INT len) { LC3_INT i; LC3_FLOAT sum = 0.0; - for ( i = 0; i < len; i++ ) + for (i = 0; i < len; i++) { - sum += ( *array1++ ) * ( *array2++ ); + sum += (*array1++) * (*array2++); } return sum; } /* complex eᶦˣ */ -static inline Complex cexpi( LC3_FLOAT x ) { return cmplx( LC3_COS( x ), LC3_SIN( x ) ); } +static inline Complex cexpi(LC3_FLOAT x) { return cmplx(LC3_COS(x), LC3_SIN(x)); } /* complex -x */ -static inline Complex cneg( Complex x ) { return cmplx( -x.r, -x.i ); } +static inline Complex cneg(Complex x) { return cmplx(-x.r, -x.i); } /* convert string to number. return true on success */ -static inline bool str_to_int( const char *str, LC3_INT *value ) -{ - char *end = NULL; - long v = str ? strtol( str, &end, 0 ) : 0; - *value = (LC3_INT) v; - return str && *end == 0 && v >= INT_MIN && v <= INT_MAX; +static inline bool str_to_int(const char *str, LC3_INT *value) { + char *end = NULL; + long v = str ? strtol(str, &end, 0) : 0; + *value = (LC3_INT)v; + return str && *end == 0 && v >= INT_MIN && v <= INT_MAX; } /* returns true if str ends with str ends with suffix. ignoring case. str may be * NULL */ -static inline bool str_ends_with( const char *str, const char *suffix ) -{ - char *tmp = str ? strrchr( str, suffix[0] ) : NULL; - return tmp && !strcasecmp( tmp, suffix ); +static inline bool str_ends_with(const char *str, const char *suffix) { + char *tmp = str ? strrchr(str, suffix[0]) : NULL; + return tmp && !strcasecmp(tmp, suffix); } /* complex a - b */ -static inline Complex csub( Complex a, Complex b ) -{ - return cmplx( a.r - b.r, a.i - b.i ); +static inline Complex csub(Complex a, Complex b) { + return cmplx(a.r - b.r, a.i - b.i); } -static inline void move_cmplx( Complex *dst, const Complex *src, LC3_INT32 len ) -{ - if ( len > 0 ) - { - memmove( dst, src, len * sizeof( Complex ) ); - assert( src[len - 1].r == dst[len - 1].r && src[len - 1].i == dst[len - 1].i ); /*check that Cmplx is stored contiguously*/ - assert( src[0].r == dst[0].r && src[0].i == dst[0].i ); /*check that Cmplx is stored contiguously*/ - } +static inline void move_cmplx(Complex *dst, const Complex *src, LC3_INT32 len) { + if (len > 0) { + memmove(dst, src, len * sizeof(Complex)); + assert(src[len - 1].r == dst[len - 1].r && src[len - 1].i == dst[len - 1].i); /*check that Cmplx is stored contiguously*/ + assert(src[0].r == dst[0].r && src[0].i == dst[0].i); /*check that Cmplx is stored contiguously*/ + } } -static inline void zero_cmplx( Complex *x, LC3_INT32 len ) -{ - if ( len > 0 ) - { - memset( x, 0, len * sizeof( Complex ) ); - assert( x[0].r == 0 && x[0].i == 0 && x[len - 1].r == 0 && x[len - 1].i == 0 ); - } +static inline void zero_cmplx(Complex *x, LC3_INT32 len) { + if(len > 0) { + memset(x, 0, len * sizeof(Complex)); + assert(x[0].r == 0 && x[0].i == 0 && x[len-1].r == 0 && x[len-1].i == 0); + } } -static inline Complex realtoc( LC3_FLOAT r ) { return cmplx( r, 0 ); } +static inline Complex realtoc(LC3_FLOAT r) { return cmplx(r, 0); } /* set float vector to constant */ -static inline void set_vec( const LC3_FLOAT c, LC3_FLOAT *x, LC3_INT32 len ) -{ +static inline void set_vec(const LC3_FLOAT c, LC3_FLOAT *x, LC3_INT32 len) { LC3_INT32 i = 0; - for ( i = 0; i < len; i++ ) - { + for (i = 0; i < len; i++) { x[i] = c; } } /* set float vector to constant */ -static inline void set_vec_int( const LC3_INT32 c, LC3_INT32 *x, LC3_INT32 len ) -{ +static inline void set_vec_int(const LC3_INT32 c, LC3_INT32 *x, LC3_INT32 len) { LC3_INT32 i = 0; - for ( i = 0; i < len; i++ ) - { + for (i = 0; i < len; i++) { x[i] = c; } } -static inline LC3_INT32 clz_func( LC3_INT32 inp ) +static inline LC3_INT32 clz_func(LC3_INT32 inp) { -#if defined( __clang__ ) || defined( __GNUC__ ) - if ( inp == 0 ) +#if defined(__clang__) || defined(__GNUC__) + if (inp == 0) { return 0; } - return __builtin_clz( inp ); + return __builtin_clz(inp); -#elif defined( _WIN32 ) || defined( _WIN64 ) +#elif defined(_WIN32) || defined(_WIN64) LC3_INT32 leading_zero = 0; - - if ( _BitScanReverse( &leading_zero, inp ) ) + + if (_BitScanReverse(&leading_zero, inp)) { return 31 - leading_zero; } else return 0; - + #else LC3_INT32 i = 0; int64_t x = inp; - - if ( inp == 0 ) + + if (inp == 0) { return 0; } + + inp = (inp < 0) ? ~inp : inp; - inp = ( inp < 0 ) ? ~inp : inp; - - while ( x < (int64_t) 0x80000000L ) + while (x < (int64_t)0x80000000L) { inp <<= 1; i += 1; -- GitLab From a1b815b2abe933023027432c80fc37c8bb7672d6 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 16 Aug 2023 12:39:23 +0200 Subject: [PATCH 06/12] exclude lib_lc3pus from clang-format --- scripts/check-format.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check-format.sh b/scripts/check-format.sh index 8ec2991cda..5d8336defe 100755 --- a/scripts/check-format.sh +++ b/scripts/check-format.sh @@ -160,7 +160,7 @@ fi if [ -z "$FILES" ]; then if [ $ALL ]; then - FILES=$(ls lib*/*.[c,h] apps/*.[c,h]) + FILES=$(ls lib_com/*.[c,h] lib_dec/*.[c,h] lib_enc/*.[c,h] lib_rend/*.[c,h] lib_util/*.[c,h] apps/*.[c,h]) elif [ -d ".svn" ]; then if [ ! -x "$(command -v svn)" ]; then echo "Subversion doesn't seem to be installed. Please ensure svn is in your PATH" -- GitLab From 0e19aca64b0975118f58c7d01b12d030f5374bcd Mon Sep 17 00:00:00 2001 From: Stefan Doehla Date: Thu, 17 Aug 2023 14:05:02 +0200 Subject: [PATCH 07/12] [add] .clang-format for lc3plus folder to disable clang-format there --- lib_lc3plus/.clang-format | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 lib_lc3plus/.clang-format diff --git a/lib_lc3plus/.clang-format b/lib_lc3plus/.clang-format new file mode 100644 index 0000000000..47a38a93f2 --- /dev/null +++ b/lib_lc3plus/.clang-format @@ -0,0 +1,2 @@ +DisableFormat: true +SortIncludes: Never -- GitLab From ae2d0c9074ff538f67b150eedc36c683b6297069 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Mon, 21 Aug 2023 16:22:20 +0200 Subject: [PATCH 08/12] Fix failing CI job: lc3plus-ensure-no-code-changes --- scripts/lc3plus_lib_setup/get_lc3plus.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/lc3plus_lib_setup/get_lc3plus.sh b/scripts/lc3plus_lib_setup/get_lc3plus.sh index 01ad362b71..ae24ad2ed9 100755 --- a/scripts/lc3plus_lib_setup/get_lc3plus.sh +++ b/scripts/lc3plus_lib_setup/get_lc3plus.sh @@ -26,9 +26,9 @@ rm -r ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/msv find ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point -type f -exec chmod -x {} \; # Move to output dir -rm -rf ../../lc3plus -mkdir ../../lc3plus -mv ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/* ../../lc3plus +rm -rf ../../lib_lc3plus +mkdir ../../lib_lc3plus +mv ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/* ../../lib_lc3plus # Clean up rm -rf lc3plus_sources.zip ETSI_Release -- GitLab From 755785ba15fd45197cb5452682d51a7625cce261 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Mon, 21 Aug 2023 17:08:40 +0200 Subject: [PATCH 09/12] Include .clang-format file in check of lc3plus codebase modifications --- scripts/lc3plus_lib_setup/get_lc3plus.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/lc3plus_lib_setup/get_lc3plus.sh b/scripts/lc3plus_lib_setup/get_lc3plus.sh index ae24ad2ed9..71b2a722ba 100755 --- a/scripts/lc3plus_lib_setup/get_lc3plus.sh +++ b/scripts/lc3plus_lib_setup/get_lc3plus.sh @@ -30,6 +30,9 @@ rm -rf ../../lib_lc3plus mkdir ../../lib_lc3plus mv ETSI_Release/LC3plus_ETSI_src_va15eb59632b_20230228/src/floating_point/* ../../lib_lc3plus +# Create additional files +printf "DisableFormat: true\nSortIncludes: Never\n" > ../../lib_lc3plus/.clang-format + # Clean up rm -rf lc3plus_sources.zip ETSI_Release -- GitLab From bf63fe813f267ec03d36cf31d5a5ee6d07e11457 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 14 Sep 2023 17:09:58 +0200 Subject: [PATCH 10/12] correct folder name --- scripts/prepare_delivery.sh | 10 +++++----- scripts/strip_split_rendering.sh | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/prepare_delivery.sh b/scripts/prepare_delivery.sh index 1d1aabca1a..5ff0d796a8 100755 --- a/scripts/prepare_delivery.sh +++ b/scripts/prepare_delivery.sh @@ -141,8 +141,8 @@ if [ $STRIP_SPLITREND -ne 0 ]; then echo "Stripping Split Rendering" - # remove complete lc3plus folder - rm -R $OUTDIR/lc3plus + # remove complete lib_lc3plus folder + rm -R $OUTDIR/lib_lc3plus # remove other split rendering files declare -a sr_files_rend=( @@ -221,12 +221,12 @@ if [ $STRIP_SPLITREND -ne 0 ]; then patch ${OUTDIR}/Makefile < ${ROOT}/scripts/makefile_noSR.patch # delete project file - rm ${OUTDIR}/Workspace_msvc/lib_LC3plus.vcxproj + rm ${OUTDIR}/Workspace_msvc/lib_lc3plus.vcxproj # patch project/solution files - sed -i.bak "/lib_LC3plus.vcxproj/,+1d" ${OUTDIR}/Workspace_msvc/Workspace_msvc.sln + sed -i.bak "/lib_lc3plus.vcxproj/,+1d" ${OUTDIR}/Workspace_msvc/Workspace_msvc.sln find ${OUTDIR}/Workspace_msvc -name "*.vcxproj" -exec sed -i.bak -e "s/..\\lib_lc3plus\;//g" \{\} \; - sed -i.bak "/lib_LC3plus.vcxproj/,+3d" ${OUTDIR}/Workspace_msvc/lib_rend.vcxproj # patch dependency + sed -i.bak "/lib_lc3plus.vcxproj/,+3d" ${OUTDIR}/Workspace_msvc/lib_rend.vcxproj # patch dependency # delete readme_split_rendering rm ${OUTDIR}/readme_split_rendering.txt diff --git a/scripts/strip_split_rendering.sh b/scripts/strip_split_rendering.sh index 12d1d6b3a1..37a9b07b8c 100755 --- a/scripts/strip_split_rendering.sh +++ b/scripts/strip_split_rendering.sh @@ -34,7 +34,7 @@ OUTDIR=$1 # remove complete lc3plus folder -rm -R $OUTDIR/lc3plus +rm -R $OUTDIR/lib_lc3plus # remove other split rendering files declare -a sr_files_rend=( @@ -81,4 +81,4 @@ for file in ${sr_files_util[@]}; do rm $OUTDIR/$file file_windows=${file//\//'\\'} sed -i.bak -e "/${file_windows}/d" ${OUTDIR}/Workspace_msvc/lib_util.vcxproj -done \ No newline at end of file +done -- GitLab From de5c265d8653f6e0593ba1d50f733ab5d169035e Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 15 Sep 2023 09:38:42 +0200 Subject: [PATCH 11/12] Fix strip_split_rendering.sh and update prepare_delivery.sh to use it. --- scripts/prepare_delivery.sh | 59 +------------------------------- scripts/strip_split_rendering.sh | 8 +++++ 2 files changed, 9 insertions(+), 58 deletions(-) diff --git a/scripts/prepare_delivery.sh b/scripts/prepare_delivery.sh index 5ff0d796a8..dd9634a0fb 100755 --- a/scripts/prepare_delivery.sh +++ b/scripts/prepare_delivery.sh @@ -140,57 +140,8 @@ sed -i.bak -e "s/\/\*\ *\(#define\ *SPLIT_REND_WITH_HEAD_ROT\ *\)\*\//\1/g" ${OU if [ $STRIP_SPLITREND -ne 0 ]; then echo "Stripping Split Rendering" - - # remove complete lib_lc3plus folder - rm -R $OUTDIR/lib_lc3plus - # remove other split rendering files - declare -a sr_files_rend=( - "lib_rend/ivas_lcld_decoder.c" - "lib_rend/ivas_lcld_encoder.c" - "lib_rend/ivas_MSPred.c" - "lib_rend/ivas_NoiseGen.c" - "lib_rend/ivas_PerceptualModel.c" - "lib_rend/ivas_PredDecoder.c" - "lib_rend/ivas_PredEncoder.c" - "lib_rend/ivas_RMSEnvGrouping.c" - "lib_rend/ivas_cldfb_codec_bitstream.c" - "lib_rend/ivas_cldfb_codec_bitstream.h" - "lib_rend/ivas_lc3plus_common.c" - "lib_rend/ivas_lc3plus_common.h" - "lib_rend/ivas_lc3plus_dec.c" - "lib_rend/ivas_lc3plus_dec.h" - "lib_rend/ivas_lc3plus_enc.c" - "lib_rend/ivas_lc3plus_enc.h" - "lib_rend/ivas_lcld_rom_tables.c" - "lib_rend/ivas_lcld_rom_tables.h" - "lib_rend/ivas_splitRend_lcld_dec.c" - "lib_rend/ivas_splitRend_lcld_enc.c" - "lib_rend/ivas_splitRendererPLC.c" - "lib_rend/ivas_splitRendererPost.c" - "lib_rend/ivas_splitRendererPre.c" - "lib_rend/ivas_splitRenderer_utils.c" - ) - - for file in ${sr_files_rend[@]}; do - rm $OUTDIR/$file - file_windows=${file//\//'\\'} - sed -i.bak -e "/${file_windows}/d" ${OUTDIR}/Workspace_msvc/lib_rend.vcxproj - done - - declare -a sr_files_util=( - "lib_util/split_rend_bfi_file_reader.c" - "lib_util/split_rend_bfi_file_reader.h" - "lib_util/split_render_file_read_write.c" - "lib_util/split_render_file_read_write.h" - ) - - for file in ${sr_files_util[@]}; do - rm $OUTDIR/$file - file_windows=${file//\//'\\'} - sed -i.bak -e "/${file_windows}/d" ${OUTDIR}/Workspace_msvc/lib_util.vcxproj - done - + ${ROOT}/scripts/strip_split_rendering.sh ${OUTDIR} # strip macros declare -a sr_macros=( @@ -220,14 +171,6 @@ if [ $STRIP_SPLITREND -ne 0 ]; then # patch Makefile patch ${OUTDIR}/Makefile < ${ROOT}/scripts/makefile_noSR.patch - # delete project file - rm ${OUTDIR}/Workspace_msvc/lib_lc3plus.vcxproj - - # patch project/solution files - sed -i.bak "/lib_lc3plus.vcxproj/,+1d" ${OUTDIR}/Workspace_msvc/Workspace_msvc.sln - find ${OUTDIR}/Workspace_msvc -name "*.vcxproj" -exec sed -i.bak -e "s/..\\lib_lc3plus\;//g" \{\} \; - sed -i.bak "/lib_lc3plus.vcxproj/,+3d" ${OUTDIR}/Workspace_msvc/lib_rend.vcxproj # patch dependency - # delete readme_split_rendering rm ${OUTDIR}/readme_split_rendering.txt diff --git a/scripts/strip_split_rendering.sh b/scripts/strip_split_rendering.sh index 37a9b07b8c..fb645c912f 100755 --- a/scripts/strip_split_rendering.sh +++ b/scripts/strip_split_rendering.sh @@ -82,3 +82,11 @@ for file in ${sr_files_util[@]}; do file_windows=${file//\//'\\'} sed -i.bak -e "/${file_windows}/d" ${OUTDIR}/Workspace_msvc/lib_util.vcxproj done + +# delete project file +rm ${OUTDIR}/Workspace_msvc/lib_lc3plus.vcxproj + +# patch project/solution files +sed -i.bak "/lib_lc3plus.vcxproj/,+1d" ${OUTDIR}/Workspace_msvc/Workspace_msvc.sln +find ${OUTDIR}/Workspace_msvc -name "*.vcxproj" -exec sed -i.bak -e "s/..\\lib_lc3plus\;//g" \{\} \; +sed -i.bak "/lib_lc3plus.vcxproj/,+3d" ${OUTDIR}/Workspace_msvc/lib_rend.vcxproj # patch dependency \ No newline at end of file -- GitLab From 1e37b632354ccb93d3c5bc0847fdce4595046481 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 15 Sep 2023 15:33:12 +0200 Subject: [PATCH 12/12] Fix for scripts/strip_split_rendering.py --- scripts/strip_split_rendering.py | 48 ++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/scripts/strip_split_rendering.py b/scripts/strip_split_rendering.py index 3f98db2419..556e955315 100644 --- a/scripts/strip_split_rendering.py +++ b/scripts/strip_split_rendering.py @@ -30,6 +30,9 @@ # the United Nations Convention on Contracts on the International Sales of Goods. # +import os +import glob + # remove other split rendering files sr_files_rend=[ "lib_rend\\ivas_lcld_decoder.c", @@ -48,8 +51,8 @@ sr_files_rend=[ "lib_rend\\ivas_lc3plus_dec.h", "lib_rend\\ivas_lc3plus_enc.c", "lib_rend\\ivas_lc3plus_enc.h", - "lib_rend/ivas_lcld_rom_tables.c" - "lib_rend/ivas_lcld_rom_tables.h" + "lib_rend\\ivas_lcld_rom_tables.c" + "lib_rend\\ivas_lcld_rom_tables.h" "lib_rend\\ivas_splitRend_lcld_dec.c", "lib_rend\\ivas_splitRend_lcld_enc.c", "lib_rend\\ivas_splitRendererPLC.c", @@ -67,20 +70,55 @@ sr_files_util=[ if __name__ == "__main__": + wsfile = '.\Workspace_msvc\Workspace_msvc.sln' rendproj = '.\Workspace_msvc\lib_rend.vcxproj' utilproj = '.\Workspace_msvc\lib_util.vcxproj' + lc3proj = '.\Workspace_msvc\lib_lc3plus.vcxproj' + + # Remove lc3plus project + os.remove(lc3proj) + + # Patch Workspace_msvc.sln + with open(wsfile,'r') as f: + lines = f.readlines() + with open(wsfile,'w') as f: + skip = 0 + for line in lines: + if 'lib_lc3plus.vcxproj' in line: + skip = 1 + else: + if skip == 0: + f.write(line) + else: + skip = skip - 1 + # Patch lib_rend.vcxproj with open(rendproj,'r') as f: lines = f.readlines() with open(rendproj,'w') as f: + skip = 0 for line in lines: - if not any([x in line for x in sr_files_rend]): + if any([x in line for x in sr_files_rend]): + skip = 1 + if 'lib_lc3plus.vcxproj' in line: + skip = 4 + if skip == 0: f.write(line) - + else: + skip = skip - 1 + + # Patch lib_util.vcxproj with open(utilproj,'r') as f: lines = f.readlines() with open(utilproj,'w') as f: for line in lines: if not any([x in line for x in sr_files_util]): f.write(line) - \ No newline at end of file + + # Remove include libraries + for proj in glob.glob('.\Workspace_msvc\*.vcxproj'): + with open(proj,'r') as f: + lines = f.readlines() + with open(proj,'w') as f: + for line in lines: + f.write(line.replace("..\lib_lc3plus;","")) -- GitLab